| px | top | add code | search | signup | login | help |
<?php
/*
http://www.china-on-site.com/flexphpdir/
FlexPHPDirectory is a simple, free and open source link directory system.You can add multi-level sub-categories.Users can submit site information.Users can search links by keyword or rate the link. New listings and cool listings are available.You can set a website as a sponsored link and list it before others. This program is easy to be internationalized. Low price customization service is provided.
*/
require("./DbSql.inc.php");
Class LinkSQL extends DBSQL
{
// the constructor
function LinkSQL($DBName = "")
{
$this->DBSQL($DBName);
}
function getchildcatalog($catid)
{
$sql = "select * from linkexcatalog where parentid='$catid' order by catalogid";
$result = $this->select($sql);
return $result;
}
function getcoolcatalog()
{
$sql = "select * from linkexcatalog where coolnum>0 order by catalogid";
$result = $this->select($sql);
return $result;
}
function getkeywordcatalog($keyword)
{
$sql = "select * from linkexcatalog where catalogname like '%$keyword%' order by catalogid";
$result = $this->select($sql);
return $result;
}
function getlinks($page,$record,$catid)
{
$start = $page*$record;
$sql = "select * from linkex where catalogid='$catid' and isdisplay=1 and isponsor=0 order by linkexid DESC LIMIT $start,$record";
$result = $this->select($sql);
return $result;
}
function getkeywordlinks($page,$record,$keyword)
{
$start = $page*$record;
$sql = "select * from linkex where ((title like '%$keyword%') or (description like '%$keyword%')) and isdisplay=1 order by linkexid DESC LIMIT $start,$record";
$result = $this->select($sql);
return $result;
}
function getsponsorlinks($catid)
{
$sql = "select * from linkex where catalogid='$catid' and isdisplay=1 and isponsor=1 order by linkexid DESC";
$result = $this->select($sql);
return $result;
}
function getnewlinks($forwardtimestamp)
{
$sql = "select * from linkex where adddate>$forwardtimestamp and isdisplay=1 order by linkexid DESC";
$result = $this->select($sql);
return $result;
}
function getcoollinks($catid)
{
$sql = "select * from linkex where iscool=1 and isdisplay=1 and catalogid='$catid' order by linkexid DESC";
$result = $this->select($sql);
return $result;
}
function getlinkbyid($linkexid)
{
$sql = "select * from linkex where linkexid='$linkexid'";
$result = $this->select($sql);
return $result;
}
function addlink($catalogid,$title,$url,$linkbackurl,$description,$email,$isdisplay)
{
global $admin_linkalreadyexist;
$sql = "select * from linkex where url='$url'";
$result = $this->select($sql);
if (!empty($result)){
print "$admin_linkalreadyexist";
return;
}
$adddate = time();
$sql = "insert into linkex (catalogid,title,url,linkbackurl,description,email,adddate,isdisplay) values ('$catalogid','$title','$url','$linkbackurl','$description','$email','$adddate','$isdisplay')";
$results = $this->insert($sql);
return $results;
}
function add_Picture($linkexid,$userfile_name,$PicturePath)
{
$sql = "select picture from linkex where linkexid='$linkexid'";
$result = $this->select($sql);
$picture = $result[0]["picture"];
if (!empty($picture)){
$file = $PicturePath.$picture;
unlink($file);
}
$sql = "UPDATE linkex SET picture=\"$userfile_name\" WHERE linkexid='$linkexid'";
$result = $this->update($sql);
return $result;
}
function getcatalognamebyid($catalogid)
{
$sql = "select catalogname from linkexcatalog where catalogid='$catalogid'";
$result = $this->select($sql);
$parentname = $result[0]["catalogname"];
return $parentname;
}
function addhit($hits,$linkexid)
{
$sql = "update linkex set hits=$hits+1 where linkexid='$linkexid'";
$result = $this->update($sql);
return $result;
}
function set_Rating($linkexid,$Rating)
{
$sql = "select rating,ratenum from linkex where linkexid='$linkexid'";
$result = $this->select($sql);
$OldR = $result[0]["rating"];
$OldN = $result[0]["ratenum"];
$NewN = $OldN+1;
$NewR = ($OldR*$OldN+$Rating)/$NewN;
$sql = "update linkex set rating=$NewR,ratenum=$NewN where linkexid='$linkexid'";
$result = $this->update($sql);
return $result;
}
}
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.