$maxhits){ $numpage = ($count % $maxhits == 0) ? ($count/$maxhits) : floor($count / $maxhits) + 1; for($i = 1;$i<= $numpage;$i++){ if($i<$numpage){ $toolbar .= "$i |"; } else{ $toolbar .= "$i"; } } } else{ $numpage = 1; } $result = mysql_db_query($DBName, $query, $db); if ($result) { while ($rows = mysql_fetch_array($result)) { $return[] = $rows; } return $return; } else { return false; } } function get_list_picture_by_cate($featured,$p,& $toolbar,$class = "bread",& $numpage,$cateid) { global $db, $DBName,$maxhits; if (!$db) { return false; } $count = "SELECT count(*) FROM pictures"; $query = "SELECT * FROM pictures"; if (($featured == 1) || ($featured == 0)) { $query .= " WHERE cateid = $cateid and Enabled=$featured"; $count .= " WHERE cateid = $cateid and Enabled=$featured"; } $result_count = mysql_db_query($DBName, $count, $db); $counts = mysql_fetch_array($result_count); $count = $counts[0]; if($p == 1 || !$p ){ $p = 0; } else{ $p = ($p - 1) * $maxhits; } $query .= " ORDER BY Title limit $p, $maxhits"; $numpage = 0; if($count> $maxhits){ $numpage = ($count % $maxhits == 0) ? ($count/$maxhits) : floor($count / $maxhits) + 1; for($i = 1;$i<= $numpage;$i++){ if($i<$numpage){ $toolbar .= "$i |"; } else{ $toolbar .= "$i"; } } } else{ $numpage = 1; } $result = mysql_db_query($DBName, $query, $db); if ($result) { while ($rows = mysql_fetch_array($result)) { $return[] = $rows; } return $return; } else { return false; } } function add_picture($Title,$ShortDesc,$Desc,$Enabled,$cateid) { global $db, $DBName; if (!$db) { return false; } $query = "INSERT INTO pictures(Title, ShortDesc, Description, Enabled,cateid) values('$Title','$ShortDesc','$Desc','$Enabled','$cateid')"; $result = mysql_db_query($DBName, $query, $db); if (!$result) { return false; } return true; } function update_picture($PictureID,$Title,$ShortDesc,$Desc,$Enabled,$cateid) { global $db, $DBName; if (!$db) { return false; } if(!$Enabled) { $Enabled = 0; } $query = "UPDATE pictures SET Title = '$Title', ShortDesc = '$ShortDesc', Description = '$Desc', Enabled = $Enabled, cateid = $cateid WHERE PictureID = '$PictureID'"; $result= mysql_db_query($DBName, $query, $db); if (!$result) { return false; } return true; } function update_picture_image($PictureID,$SmallPicture, $SmallPicture_name,$LargePicture, $LargePicture_name) { global $db, $DBName,$image_path_small,$image_path_large; if (!$db) { return false; } if ($SmallPicture_name != "") { $filename = $image_path_small . "/" . $SmallPicture_name; copy($SmallPicture,$filename); $query = "UPDATE pictures SET Small='$SmallPicture_name' WHERE PictureID=$PictureID"; $result = mysql_db_query($DBName,$query,$db); } if ($LargePicture_name != "") { $filename = $image_path_large . "/" . $LargePicture_name; copy($LargePicture,$filename); $query = "UPDATE pictures SET Large='$LargePicture_name' WHERE PictureID=$PictureID"; $result = mysql_db_query($DBName,$query,$db); } if (!$result) { return false; } return true; } function purge_picture_list($list) { global $db, $DBName; if (!$db) { return false; } $whereclause = ""; if (is_array($list)&&(count($list) > 0)) { for($i=0;$i $maxhits){ $numpage = ($count % $maxhits == 0) ? ($count/$maxhits) : floor($count / $maxhits) + 1; for($i = 1;$i<= $numpage;$i++){ if($i<$numpage){ $toolbar .= "$i |"; } else{ $toolbar .= "$i"; } } } else{ $numpage = 1; } $result = mysql_db_query($DBName, $query, $db); if ($result) { while ($rows = mysql_fetch_array($result)) { $return[] = $rows; } return $return; } else { return false; } } function get_list_category_in_cate($cateid) { global $db, $DBName,$maxhits; if (!$db) { return false; } $query = "SELECT * FROM category where parentid=$cateid"; $result = mysql_db_query($DBName, $query, $db); if ($result) { while ($rows = mysql_fetch_array($result)) { $return[] = $rows; } return $return; } else { return false; } } function add_category($catename,$parentid,$content) { global $db, $DBName; if (!$db) { return false; } $query = "INSERT INTO category(catename, parentid, content) values('$catename','$parentid','$content')"; $result = mysql_db_query($DBName, $query, $db); if (!$result) { return false; } return true; } function update_category($cateid,$catename,$parentid,$content) { global $db, $DBName; if (!$db) { return false; } if(!$Enabled) { $Enabled = 0; } $query = "UPDATE category SET catename = '$catename', parentid = '$parentid', content = '$content' WHERE cateid = '$cateid'"; $result= mysql_db_query($DBName, $query, $db); if (!$result) { return false; } return true; } function purge_category_list($list) { global $db, $DBName; if (!$db) { return false; } $whereclause = ""; if (is_array($list)&&(count($list) > 0)) { for($i=0;$i0){ $cats = get_category($rows['parentid']); $name = $cats["catename"] . "/" . $name; } $selected = ($id == $cateid) ? "selected" : ""; $select .= ""; } $select .= ""; return $select; } ################## End Category ###################### ?>