<?php

/**
 *
 * INDEXU
 * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
 *
 * INDEXU(tm) is protected by Indonesia and International copyright laws.
 * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
 * violators will be prosecuted. To obtain a license for using INDEXU(tm),
 * please register at Nicecoder home page at http://www.nicecoder.com
 *
 * Author:
 *    Dody Rachmat Wicaksono (dody@nicecoder.com)
 *    M. Zuber (zubby@nicecoder.com)
 *
 */

  /*===================================================
    DeleteBadLink()
  ===================================================*/

  function DeleteBadLink() {

    // vars global configuration
    global $dbConn, $admin_template_path;

    // vars url & form
    global $num_rows, $pflag;

    // vars messages
    global $msg;

    // vars template
    global $message;

    $tpl = new Template();

    $links_obj = new clsLink;
    $links_obj->table_name = "idx_link";
    $links_obj->bad_link_table_name = "idx_bad_link";

    $i=1;
    while($i<=$num_rows){
      $var = "chkbox_$i";
      $id = $GLOBALS["$var"];
      if(!empty($id)) {
        // get link id
        $query = "select link_id from idx_bad_link where bad_link_id = '$id'";
        $result = $dbConn->Execute($query);
        $lid = $result->Fields("link_id");

        $title = $links_obj->GetLinkTitle($lid);

        $delete_result = $links_obj->DeleteBadLinkReport($pflag, $id);

        if($delete_result==0) $message .= $msg["20261"];

        $tpl->assign('title', $title);
        $message = $tpl->fetch('var:' . $message);
      }
      $i++;
    }

    if(empty($message)) $message = $msg["20262"];

    DisplayTemplate($admin_template_path . "message.html", "\$message");
  }


  /*===================================================
    main
  ===================================================*/

  include "../application.php";
  
  RunPreFilter(__FILE__);

  DisplayTemplate($admin_template_path . "header.html");
  DeleteBadLink();
  DisplayTemplate($admin_template_path . "footer.html");

  RunPostFilter(__FILE__);

?>