Location: PHPKode > projects > PhpProjectMaster > www/inc/demo.lib.php
<?php
/* 
 demo related functions
 (c) 2005-2007 by Oleg Savchuk
 SITE: COMMON OSA LIBRARY
*/

 require_once "sitelib.php";
 require_once "form_utils.php";
 require_once "upload_utils.php";

//preset module variables

 $demo_vars=array(
   'table_name'   => 'demo',
   'table_key_id' => 'demo_id',
   'upload_url'   => "/demo_upload",
   'upload_path'  => "$site_root/demo_upload",
 );


//get item fields from database
function get_demo($item_id){
 global $demo_vars;

 $sql="select * from $demo_vars[table_name] where $demo_vars[table_key_id]=$item_id";
 return db_row($sql);
}

//mark item as removed
function delete_demo($item_id){
 global $demo_vars;

 db_query("update $demo_vars[table_name] set status=127 where $demo_vars[table_key_id]=$item_id");
}

//********************* for uploads
function get_upload_url_demo($item_id, $is_preview=''){
 global $demo_vars;

 $nameadd='';
 if ($is_preview) $nameadd='_s';

 return get_upload_url($item_id, $demo_vars['upload_path'], $demo_vars['upload_url'], $nameadd);
}

function get_upload_path_demo($item_id, $is_preview='', $ext='', $nocheck=''){
 global $demo_vars;

 $nameadd='';
 if ($is_preview) $nameadd='_s';

 return get_upload_path($item_id, $demo_vars['upload_path'], $nameadd, $ext, $nocheck);
}

//******************* insert related record
function insert_demo_link($iname){

 $item_id=db_value("select demo_link_id from demo_link where iname=".dbq($iname)." and status=0");
 
 if (!$item_id){
    db_query("insert into demo_link (iname, add_time, add_u_id) VALUES (".dbq($iname).", now(), ".($_SESSION['u_id']+0).")");
    $item_id=get_identity();
 }

 return $item_id;
}

?>
Return current item: PhpProjectMaster