<?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)
 *
 */
 
  /*===================================================
    DeleteLink()
  ===================================================*/

  function DeleteLink() {

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

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

    // vars messages
    global $msg;

    // vars template
    global $title;

    // check link owner
    
    $query  = "select username from idx_link_user where link_id = '$id'";
    $result = $dbConn->Execute($query);
    $un     = $result->Fields('username');
    
    $links_obj = new clsLink;
    $links_obj->table_name = "idx_link";
    $title                 = $links_obj->GetLinkTitle($id);
      
    if ($un == $_COOKIE['COOKIE_USERNAME']) {
      $delete_result = $links_obj->Delete($id);

      $query  = "delete from idx_link_user where link_id = '$id'";
      $result = $dbConn->Execute($query);

      DisplayTemplate($theme_path . "cp/link_delete_ok.html", "\$title");
    }
    else {
      DisplayTemplate($theme_path . "cp/link_delete_error.html", "\$title");
    }
  }


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

  include "../application.php";

  RunPreFilter(__FILE__);

  DeleteLink();

  RunPostFilter(__FILE__);

?>