"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/lib_admin.php3" between
mythreads-links_1.2.0.tar.gz and mythreads-links_1.2.1.tar.gz

About: MyThreads-Links is a web based links manager (using PHP and MySQL).

lib_admin.php3  (mythreads-links_1.2.0):lib_admin.php3  (mythreads-links_1.2.1)
<?php <?php
#-----------------------------------------------------------------> #----------------------------------------------------------------->
# $Id: lib_admin.php3,v 1.75 2015/05/30 11:48:11 ldrolez Exp $ # $Id: lib_admin.php3,v 1.74 2010/05/04 18:29:59 ldrolez Exp $
# #
# Website: http://mythreads.sourceforge.net # Website: http://mythreads.sourceforge.net
# #
# Desc: lib_admin.php3. Amin functions # Desc: lib_admin.php3. Amin functions
# #
# License: This code is released under the terms of the GNU GPL # License: This code is released under the terms of the GNU GPL
# version 2 or later. Please refer to www.gnu.org for a copy # version 2 or later. Please refer to www.gnu.org for a copy
# of this license. # of this license.
# #
#-----------------------------------------------------------------> #----------------------------------------------------------------->
######################### #########################
# Admin Functions Below # # Admin Functions Below #
######################### #########################
################################################# #################################################
# Admin : show categories in a 'select' menu # Admin : show categories in a 'select' menu
################################################# #################################################
function Admin_showCategories($select) function Admin_showCategories($select)
{ {
global $config; global $config, $mylink;
static $cache = array(); static $cache = array();
$content = ""; $content = "";
if (count($cache) == 0) if (count($cache) == 0)
{ {
$category = mysql_query("SELECT pathto,cat,title FROM ".$config[" $category = mysqli_query($mylink, "SELECT pathto,cat,title FROM "
pre"]."category order by pathto"); .$config["pre"]."category order by pathto");
while ($info_c = mysql_fetch_array($category)) while ($info_c = mysqli_fetch_array($category))
{ {
$cache[$info_c["cat"]] = $info_c; $cache[$info_c["cat"]] = $info_c;
$patharray = explode(":",$info_c['pathto']); $patharray = explode(":",$info_c['pathto']);
$sub_title = ""; $sub_title = "";
while (list($key, $val)=each($patharray)) while (list($key, $val)=each($patharray))
{ {
if ($val != ""){ if ($val != ""){
if (isset($cache[$val]["title"])) { if (isset($cache[$val]["title"])) {
$sub_title .= "/".$cache[$val]["title"]; $sub_title .= "/".$cache[$val]["title"];
} else { } else {
$result_sub = mysql_query("SELECT title F $result_sub = mysqli_query($mylink, "SELE
ROM ".$config["pre"]."category WHERE cat='$val' ORDER BY cat ASC"); CT title FROM ".$config["pre"]."category WHERE cat='$val' ORDER BY cat ASC");
$sub_title_new = mysql_fetch_array($resul $sub_title_new = mysqli_fetch_array($resu
t_sub); lt_sub);
$cache[$val]["title"] = $sub_title_new["t itle"]; $cache[$val]["title"] = $sub_title_new["t itle"];
$sub_title .= "/".$sub_title_new["title"] ; $sub_title .= "/".$sub_title_new["title"] ;
} }
} }
} }
$cache[$info_c["cat"]]["full"] = $sub_title; $cache[$info_c["cat"]]["full"] = $sub_title;
} }
} }
reset($cache); reset($cache);
skipping to change at line 104 skipping to change at line 104
return $content; return $content;
} }
################################################# #################################################
# Show main adminstrator's page # Show main adminstrator's page
################################################# #################################################
function Admin_showMain() function Admin_showMain()
{ {
global $start_script, $start_script_t, $_POST, $tpl; global $start_script, $start_script_t, $_POST, $tpl;
global $config; global $config, $mylink;
$total_delete_waiting = $total_waiting = 0; $total_delete_waiting = $total_waiting = 0;
$total_waiting_ref = mysql_query("SELECT COUNT(*) FROM ".$config["pre"]." $total_waiting_ref = mysqli_query($mylink, "SELECT COUNT(*) FROM ".$confi
links where status=1"); g["pre"]."links where status=1");
$total_waiting = mysql_fetch_array($total_waiting_ref); $total_waiting = mysqli_fetch_array($total_waiting_ref);
if ($total_waiting[0] < 1 ) if ($total_waiting[0] < 1 )
{ {
$total_waiting[0] = "0"; $total_waiting[0] = "0";
} }
$total_delete_waiting_ref = mysql_query("SELECT COUNT(*) FROM ".$config[" pre"]."links where status=2"); $total_delete_waiting_ref = mysqli_query($mylink, "SELECT COUNT(*) FROM " .$config["pre"]."links where status=2");
$total_delete_waiting = mysql_fetch_array($total_delete_waiting_ref); $total_delete_waiting = mysqli_fetch_array($total_delete_waiting_ref);
if ($total_delete_waiting[0] < 1 ) if ($total_delete_waiting[0] < 1 )
{ {
$total_delete_waiting[0] = "0"; $total_delete_waiting[0] = "0";
} }
$total_cat_waiting_ref = mysql_query("SELECT COUNT(*) FROM ".$config["pre $total_cat_waiting_ref = mysqli_query($mylink, "SELECT COUNT(*) FROM ".$c
"]."waitcat"); onfig["pre"]."waitcat");
$total_cat_waiting = mysql_fetch_array($total_cat_waiting_ref); $total_cat_waiting = mysqli_fetch_array($total_cat_waiting_ref);
if ($total_cat_waiting[0] < 1 ) if ($total_cat_waiting[0] < 1 )
{ {
$total_cat_waiting[0] = "0"; $total_cat_waiting[0] = "0";
} }
$tpl->set_file("adminmain", "form_admin_main.tpl"); $tpl->set_file("adminmain", "form_admin_main.tpl");
$tpl->set_var( array( $tpl->set_var( array(
"TOTAL_WAITING" => $total_waiting[0], "TOTAL_WAITING" => $total_waiting[0],
"TOTAL_DELETE_WAITING" => $total_delete_waiting[0], "TOTAL_DELETE_WAITING" => $total_delete_waiting[0],
skipping to change at line 182 skipping to change at line 182
return $content; return $content;
} }
################################################# #################################################
# Admin : Edit Sub Category form # Admin : Edit Sub Category form
################################################# #################################################
function Admin_showEditsub($category) function Admin_showEditsub($category)
{ {
global $start_script, $start_script_t, $tpl; global $start_script, $start_script_t, $tpl;
global $config; global $config, $mylink;
$result_ref = mysql_query("SELECT title,info FROM ".$config["pre"]."categ $result_ref = mysqli_query($mylink, "SELECT title,info FROM ".$config["pr
ory WHERE cat='$category'"); e"]."category WHERE cat='$category'");
$result = mysql_fetch_array($result_ref); $result = mysqli_fetch_array($result_ref);
$path = Admin_display_category($category); $path = Admin_display_category($category);
$tpl->set_file("editsub", "form_admin_edit_sub.tpl"); $tpl->set_file("editsub", "form_admin_edit_sub.tpl");
$tpl->set_var( array( $tpl->set_var( array(
"CATEGORY" => "$category", "CATEGORY" => "$category",
"RESULT_TITLE" => "$result[title]", "RESULT_TITLE" => "$result[title]",
"RESULT_MESSAGE" => "$result[info]", "RESULT_MESSAGE" => "$result[info]",
"PATH" => "$path" "PATH" => "$path"
)); ));
$content = $tpl->subst("editsub"); $content = $tpl->subst("editsub");
return $content; return $content;
} }
################################################# #################################################
# Admin : print Main page with just main category's # Admin : print Main page with just main category's
################################################# #################################################
function Admin_mainPage() function Admin_mainPage()
{ {
global $config, $start_script, $start_script_t; global $config, $start_script, $start_script_t, $mylink;
$result = mysql_query("SELECT cat,title,ttlinks FROM ".$config["pre"]."ca tegory WHERE under='0' ORDER BY title"); $result = mysqli_query($mylink, "SELECT cat,title,ttlinks FROM ".$config[ "pre"]."category WHERE under='0' ORDER BY title");
$links = "<table width=\"100%\"><tr>"; $links = "<table width=\"100%\"><tr>";
while ($info = mysql_fetch_array($result)) while ($info = mysqli_fetch_array($result))
{ {
$a++; $a++;
$links .= Message ("admin_cat", array( $links .= Message ("admin_cat", array(
"INFO_CAT" => $info[cat], "INFO_CAT" => $info[cat],
"INFO_TITLE" => $info[title], "INFO_TITLE" => $info[title],
"INFO_TT" => $info[ttlinks] "INFO_TT" => $info[ttlinks]
)); ));
if ($a == $config["across"]) if ($a == $config["across"])
{ {
skipping to change at line 240 skipping to change at line 240
################################################# #################################################
# #
################################################# #################################################
# #
# View links page # View links page
function Admin_viewPage($category) function Admin_viewPage($category)
{ {
######### #########
# global variables # global variables
global $config, $start_script, $start_script_t; global $config, $start_script, $start_script_t, $mylink;
$content .= "<table width=\"100%\" border=0 cellpadding=3><tr>"; $content .= "<table width=\"100%\" border=0 cellpadding=3><tr>";
$result_t = mysql_query("SELECT cat,title,ttlinks FROM ".$config["pre"]." category where under='$category' ORDER BY 'title'"); $result_t = mysqli_query($mylink, "SELECT cat,title,ttlinks FROM ".$confi g["pre"]."category where under='$category' ORDER BY 'title'");
while ($info = mysql_fetch_array($result_t)) while ($info = mysqli_fetch_array($result_t))
{ {
$a++; $a++;
$content .= Message ("admin_cat", array( $content .= Message ("admin_cat", array(
"INFO_CAT" => $info[cat], "INFO_CAT" => $info[cat],
"INFO_TITLE" => $info[title], "INFO_TITLE" => $info[title],
"INFO_TT" => $info[ttlinks] "INFO_TT" => $info[ttlinks]
)); ));
if ($a == $config["across"]) { $content .= "</tr>\n<tr>"; $a=0;} if ($a == $config["across"]) { $content .= "</tr>\n<tr>"; $a=0;}
skipping to change at line 272 skipping to change at line 272
} }
################################################# #################################################
# This function displays the different categories of links there are. # This function displays the different categories of links there are.
################################################# #################################################
# #
function Admin_display_category($category) function Admin_display_category($category)
{ {
global $start_script, $start_script_t; global $start_script, $start_script_t;
global $config; global $config, $mylink;
$result_sub = mysql_query("SELECT * FROM ".$config["pre"]."category WHERE $result_sub = mysqli_query($mylink, "SELECT * FROM ".$config["pre"]."cate
pathto LIKE '%:$category:'"); gory WHERE pathto LIKE '%:$category:'");
$sub_title = mysql_fetch_array($result_sub); $sub_title = mysqli_fetch_array($result_sub);
$patharray = explode(":",$sub_title[pathto]); $patharray = explode(":",$sub_title[pathto]);
$top_bt = Message("top_bt"); $top_bt = Message("top_bt");
$content .= "<a href=\"".$start_script_t."mode=admin&showAddsub=true\">$t op_bt</a>"; $content .= "<a href=\"".$start_script_t."mode=admin&showAddsub=true\">$t op_bt</a>";
while (list($key, $val)=each($patharray)) while (list($key, $val)=each($patharray))
{ {
if ($val != ""){ if ($val != ""){
$result_sub = mysql_query("SELECT * FROM ".$config["pre"] $result_sub = mysqli_query($mylink, "SELECT * FROM ".$con
."category WHERE cat='$val' ORDER BY cat ASC"); fig["pre"]."category WHERE cat='$val' ORDER BY cat ASC");
$sub_title_new = mysql_fetch_array($result_sub); $sub_title_new = mysqli_fetch_array($result_sub);
$content.= "/<a href=\"".$start_script_t."mode=admin&cate gory=$sub_title_new[cat]&showAddsub=true\">$sub_title_new[title]</a>"; $content.= "/<a href=\"".$start_script_t."mode=admin&cate gory=$sub_title_new[cat]&showAddsub=true\">$sub_title_new[title]</a>";
} }
} }
return $content; return $content;
} }
################################################# #################################################
# Admin : add a sub-category directly in the database # Admin : add a sub-category directly in the database
################################################# #################################################
function Admin_doAddsub($main,$title,$message) function Admin_doAddsub($main,$title,$message)
{ {
global $config; global $config, $mylink;
if ($title != "" ) if ($title != "" )
{ {
$max_ref = mysql_query("select MAX(cat)+1 from ".$config["pre"]." $max_ref = mysqli_query($mylink, "select MAX(cat)+1 from ".$confi
category"); g["pre"]."category");
$number = mysql_fetch_array($max_ref); $number = mysqli_fetch_array($max_ref);
$pathto_ref = mysql_query("select pathto from ".$config["pre"]."c $pathto_ref = mysqli_query($mylink, "select pathto from ".$config
ategory where cat='$main'"); ["pre"]."category where cat='$main'");
$pathto = mysql_fetch_array($pathto_ref); $pathto = mysqli_fetch_array($pathto_ref);
$su = mysql_query("insert into ".$config["pre"]."category (cat,un der,title,info,pathto) $su = mysqli_query($mylink, "insert into ".$config["pre"]."catego ry (cat,under,title,info,pathto)
values ('$number[0]','$main','$title','$message','$pathto[pat hto]$number[0]:' )"); values ('$number[0]','$main','$title','$message','$pathto[pat hto]$number[0]:' )");
$content = Message ("subcat_added", array("TITLE" => "$title")); $content = Message ("subcat_added", array("TITLE" => "$title"));
} else { } else {
$content = Message("did_not_fill_title"); $content = Message("did_not_fill_title");
} }
return $content; return $content;
} }
################################################# #################################################
# Admin : add a main category directly in the database # Admin : add a main category directly in the database
################################################# #################################################
function Admin_doAddmain($title,$message) function Admin_doAddmain($title,$message)
{ {
global $config; global $config, $mylink;
if ($title != ""){ if ($title != ""){
$max_ref = mysql_query("select MAX(cat)+1 from ".$config["pre"]." $max_ref = mysqli_query($mylink, "select MAX(cat)+1 from ".$confi
category"); g["pre"]."category");
$number = mysql_fetch_array($max_ref); $number = mysqli_fetch_array($max_ref);
if ($number[0] == "") $number[0] = 1; if ($number[0] == "") $number[0] = 1;
$su = mysql_query("insert into ".$config["pre"]."category (cat,un der,title,info,pathto) $su = mysqli_query($mylink, "insert into ".$config["pre"]."catego ry (cat,under,title,info,pathto)
values ('$number[0]','0','$title','$message',':$number[0] :' )"); values ('$number[0]','0','$title','$message',':$number[0] :' )");
$content = Message ("maincat_added", array("TITLE" => "$title")); $content = Message ("maincat_added", array("TITLE" => "$title"));
} else { } else {
$content = Message ("did_not_fill_cat_title"); $content = Message ("did_not_fill_cat_title");
} }
return $content; return $content;
} }
skipping to change at line 359 skipping to change at line 359
$content = $tpl->subst("askdel"); $content = $tpl->subst("askdel");
return $content; return $content;
} }
################################################# #################################################
# #
################################################# #################################################
function Admin_showdeletelink($_unused) function Admin_showdeletelink($_unused)
{ {
global $start_script, $start_script_t, $tpl, $config, $_POST; global $start_script, $start_script_t, $tpl, $config, $_POST, $mylink;
$content = ""; $content = "";
$result = mysql_query( "SELECT * FROM ".$config["pre"]."links where link= '$_POST[url]' and status=0"); $result = mysqli_query( $mylink, "SELECT * FROM ".$config["pre"]."links w here link='$_POST[url]' and status=0");
if (mysql_numrows($result)) if (mysqli_num_rows($result))
{ {
while ($info = mysql_fetch_array($result)) { while ($info = mysqli_fetch_array($result)) {
$category = mysql_query("SELECT * FROM ".$config["pre"]."category whe re pathto LIKE '%:$info[cat]:'"); $category = mysqli_query($mylink, "SELECT * FROM ".$config["pre"]."ca tegory where pathto LIKE '%:$info[cat]:'");
$cat = ""; $cat = "";
while ($info_c = mysql_fetch_array($category) ) while ($info_c = mysqli_fetch_array($category) )
{ {
$patharray = explode(":",$info_c[pathto]); $patharray = explode(":",$info_c[pathto]);
while (list($key, $val)=each($patharray)) while (list($key, $val)=each($patharray))
{ {
if ($val != ""){ if ($val != ""){
$result_sub = mysql_query("SELECT * FROM ".$confi $result_sub = mysqli_query($mylink, "SELECT * FRO
g["pre"]."category WHERE cat='$val' ORDER BY cat ASC"); M ".$config["pre"]."category WHERE cat='$val' ORDER BY cat ASC");
$sub_title_new = mysql_fetch_array($result_sub); $sub_title_new = mysqli_fetch_array($result_sub);
$cat .= "/$sub_title_new[title]"; $cat .= "/$sub_title_new[title]";
} }
} }
} }
$tpl->set_file("showdelete", "form_admin_show_delete.tpl"); $tpl->set_file("showdelete", "form_admin_show_delete.tpl");
$tpl->set_var( array( $tpl->set_var( array(
"CATEGORY" => "$cat", "CATEGORY" => "$cat",
"INFO_TITLE" => "$info[title]", "INFO_TITLE" => "$info[title]",
"INFO_MESSAGE" => "$info[message]", "INFO_MESSAGE" => "$info[message]",
skipping to change at line 409 skipping to change at line 409
return $content; return $content;
} }
################################################# #################################################
# #
################################################# #################################################
# #
function Admin_dodeletelink($_unused) function Admin_dodeletelink($_unused)
{ {
global $config, $_POST; global $config, $_POST, $mylink;
if ($_POST[idx] != "" && $_POST[cat] != ""){ if ($_POST[idx] != "" && $_POST[cat] != ""){
$minus_totals = mysql_query("UPDATE ".$config["pre"]."category SE T ttlinks=ttlinks-1 WHERE pathto like '%:".intval($_POST[cat]).":%'"); $minus_totals = mysqli_query($mylink, "UPDATE ".$config["pre"]."c ategory SET ttlinks=ttlinks-1 WHERE pathto like '%:".intval($_POST[cat]).":%'");
$result = mysql_query("DELETE FROM ".$config["pre"]."links where idx='".intval($_POST[idx])."' and status=0"); $result = mysqli_query($mylink, "DELETE FROM ".$config["pre"]."li nks where idx='".intval($_POST[idx])."' and status=0");
$content = Message ("link_deleted", array ( $content = Message ("link_deleted", array (
"TEXT" => htmlentities($_POST[link]))); "TEXT" => htmlentities($_POST[link])));
} else { } else {
$content = Message ("no_link_for", array ("TEXT" => htmlentities( $_POST[link]))); $content = Message ("no_link_for", array ("TEXT" => htmlentities( $_POST[link])));
} }
updateRSS(); updateRSS();
return $content; return $content;
} }
################################################# #################################################
# #
################################################# #################################################
# #
function Admin_dodeletecat($_unused) function Admin_dodeletecat($_unused)
{ {
global $config, $_POST; global $config, $_POST, $mylink;
if (isset($_POST[delete])){ if (isset($_POST[delete])){
$result_cat = mysql_query("DELETE FROM ".$config["pre"]."category $result_cat = mysqli_query($mylink, "DELETE FROM ".$config["pre"]
where pathto LIKE '%:".intval($_POST[category]).":%'"); ."category where pathto LIKE '%:".intval($_POST[category]).":%'");
$howmany_cat = mysql_affected_rows(); $howmany_cat = mysqli_affected_rows($mylink);
$result_links = mysql_query("DELETE FROM ".$config["pre"]."links $result_links = mysqli_query($mylink, "DELETE FROM ".$config["pre
where cat='".intval($_POST[category])."' "); "]."links where cat='".intval($_POST[category])."' ");
$howmany_links = mysql_affected_rows(); $howmany_links = mysqli_affected_rows($mylink);
$content = Message ("cat_links_deleted", array ( $content = Message ("cat_links_deleted", array (
"CAT" => $howmany_cat, "CAT" => $howmany_cat,
"LINKS" => $howmany_links)); "LINKS" => $howmany_links));
} }
elseif(! isset($_POST[delete]) and isset($_POST[title])) elseif(! isset($_POST[delete]) and isset($_POST[title]))
{ {
$update = mysql_query("UPDATE ".$config["pre"]."category SET titl e='$_POST[title]' WHERE cat='".intval($_POST[category])."' ") or die (mysql_erro r()); $update = mysqli_query($mylink, "UPDATE ".$config["pre"]."categor y SET title='$_POST[title]' WHERE cat='".intval($_POST[category])."' ") or die ( mysqli_error($mylink));
if ($_POST[message] != "") if ($_POST[message] != "")
{ {
$update_message = mysql_query("UPDATE ".$config["pre"]."categ ory SET info='$_POST[message]' WHERE cat='".intval($_POST[category])."' "); $update_message = mysqli_query($mylink, "UPDATE ".$config["pr e"]."category SET info='$_POST[message]' WHERE cat='".intval($_POST[category])." ' ");
} }
$content = Message("cat_info_updated"); $content = Message("cat_info_updated");
} }
return $content; return $content;
} }
################################################# #################################################
# Show links waiting for a validation # Show links waiting for a validation
################################################# #################################################
# #
function Admin_showwaiting() function Admin_showwaiting()
{ {
global $start_script, $start_script_t, $tpl; global $start_script, $start_script_t, $tpl;
global $config, $custom; global $config, $custom, $mylink;
$tpl->set_file("showwait", "form_admin_show_wait.tpl"); $tpl->set_file("showwait", "form_admin_show_wait.tpl");
$tpl->set_block("showwait", "wait_row", "wait_rows"); $tpl->set_block("showwait", "wait_row", "wait_rows");
$tpl->set_var("wait_rows", ""); $tpl->set_var("wait_rows", "");
$category = mysql_query("SELECT * FROM ".$config["pre"]."links where stat $category = mysqli_query($mylink, "SELECT * FROM ".$config["pre"]."links
us=1 order by title"); where status=1 order by title");
while ($info = mysql_fetch_array($category) ) while ($info = mysqli_fetch_array($category) )
{ {
$changes = ""; $changes = "";
$title = validate_url($info['link'], $info['title']); $title = validate_url($info['link'], $info['title']);
$linkcategory_ref = mysql_query("SELECT * FROM ".$config["pre"]." $linkcategory_ref = mysqli_query($mylink, "SELECT * FROM ".$confi
category where cat='$info[cat]'"); g["pre"]."category where cat='$info[cat]'");
$linkcategory = mysql_fetch_array($linkcategory_ref); $linkcategory = mysqli_fetch_array($linkcategory_ref);
$cat = "<select name=\"categoryid:".$info['idx']."\">".Admin_show Categories($info['cat'])."</select>"; $cat = "<select name=\"categoryid:".$info['idx']."\">".Admin_show Categories($info['cat'])."</select>";
# get old link informations # get old link informations
$oldinfo = mysql_fetch_array(mysql_query("SELECT * FROM ".$config ["pre"]."links where idx='".$info["idx"]."' and status=0")); $oldinfo = mysqli_fetch_array(mysqli_query($mylink, "SELECT * FRO M ".$config["pre"]."links where idx='".$info["idx"]."' and status=0"));
if ($oldinfo['status'] == "") { if ($oldinfo['status'] == "") {
$changes = Message("new"); $changes = Message("new");
} else { } else {
if ($info['link'] != $oldinfo['link']) if ($info['link'] != $oldinfo['link'])
$changes .= Message("status_link_changed"); $changes .= Message("status_link_changed");
if ($info['cat'] != $oldinfo['cat']) if ($info['cat'] != $oldinfo['cat'])
$changes .= Message("status_cat_changed"); $changes .= Message("status_cat_changed");
if ($info['title'] != $oldinfo['title']) if ($info['title'] != $oldinfo['title'])
$changes .= Message("status_title_changed"); $changes .= Message("status_title_changed");
if ($info['message'] != $oldinfo['message']) if ($info['message'] != $oldinfo['message'])
$changes .= Message("status_message_changed"); $changes .= Message("status_message_changed");
# custom fields # custom fields
reset($custom); reset($custom);
while (list($k,$v) = each($custom)) { while (list($k,$v) = each($custom)) {
if ($info[$k] != $oldinfo[$k]) if ($info[$k] != $oldinfo[$k])
$changes .= "*"; $changes .= "*";
} }
} }
$waitinfo = mysql_fetch_array(mysql_query("SELECT * FROM ".$confi g["pre"]."wait where idx='$info[idx]'")); $waitinfo = mysqli_fetch_array(mysqli_query($mylink, "SELECT * FR OM ".$config["pre"]."wait where idx='$info[idx]'"));
$tpl->set_var ( array( $tpl->set_var ( array(
"INFO_ID" => "$info[idx]", "INFO_ID" => "$info[idx]",
"TITLE" => "$title", "TITLE" => "$title",
"INFO_MESS" => "$info[message]", "INFO_MESS" => "$info[message]",
"INFO_LINK" => "$info[link]", "INFO_LINK" => "$info[link]",
"INFO_IP" => "$waitinfo[ip]", "INFO_IP" => "$waitinfo[ip]",
"INFO_EMAIL" => "$waitinfo[email]", "INFO_EMAIL" => "$waitinfo[email]",
"CHANGES" => "<a href=\"".$start_script_t."mode=admin&more=$i nfo[idx]\">$changes</a>", "CHANGES" => "<a href=\"".$start_script_t."mode=admin&more=$i nfo[idx]\">$changes</a>",
"CATEGORY" => "$cat" "CATEGORY" => "$cat"
skipping to change at line 535 skipping to change at line 535
return $content; return $content;
} }
################################################# #################################################
# Show categories waiting for a validation # Show categories waiting for a validation
################################################# #################################################
# #
function Admin_showwaitingcat() function Admin_showwaitingcat()
{ {
global $start_script, $start_script_t, $tpl; global $start_script, $start_script_t, $tpl;
global $config; global $config, $mylink;
$tpl->set_file("showwait", "form_admin_show_waitcat.tpl"); $tpl->set_file("showwait", "form_admin_show_waitcat.tpl");
$tpl->set_block("showwait", "wait_row", "wait_rows"); $tpl->set_block("showwait", "wait_row", "wait_rows");
$tpl->set_var("wait_rows", ""); $tpl->set_var("wait_rows", "");
$category = mysql_query("SELECT * FROM ".$config["pre"]."waitcat order by $category = mysqli_query($mylink, "SELECT * FROM ".$config["pre"]."waitca
title"); t order by title");
while ($info = mysql_fetch_array($category) ) while ($info = mysqli_fetch_array($category) )
{ {
$category_list = mysql_query("SELECT * FROM ".$config["pre"]."categor y where cat='$info[cat]' or under='$info[cat]'"); $category_list = mysqli_query($mylink, "SELECT * FROM ".$config["pre" ]."category where cat='$info[cat]' or under='$info[cat]'");
$options ="<option value=\"0\">Top:/"; $options ="<option value=\"0\">Top:/";
while ($info_c = mysql_fetch_array($category_list) ) while ($info_c = mysqli_fetch_array($category_list) )
{ {
$patharray = explode(":",$info_c[pathto]); $patharray = explode(":",$info_c[pathto]);
if ($info[cat] == $info_c[cat]) if ($info[cat] == $info_c[cat])
{ {
$options .= "<option value=\"$info_c[cat]\" selected>"; $options .= "<option value=\"$info_c[cat]\" selected>";
} else { } else {
$options .= "<option value=\"$info_c[cat]\">"; $options .= "<option value=\"$info_c[cat]\">";
} }
while (list($key, $val)=each($patharray)) while (list($key, $val)=each($patharray))
{ {
if ($val != ""){ if ($val != ""){
$result_sub = mysql_query("SELECT * FROM ".$confi $result_sub = mysqli_query($mylink, "SELECT * FRO
g["pre"]."category WHERE cat='$val' ORDER BY cat ASC"); M ".$config["pre"]."category WHERE cat='$val' ORDER BY cat ASC");
$sub_title_new = mysql_fetch_array($result_sub); $sub_title_new = mysqli_fetch_array($result_sub);
$options .= "/$sub_title_new[title]"; $options .= "/$sub_title_new[title]";
} }
} }
$options .= "</option>\n"; $options .= "</option>\n";
} }
$tpl->set_var ( array( $tpl->set_var ( array(
"INFO_ID" => "$info[id]", "INFO_ID" => "$info[id]",
"INFO_TITLE" => "$info[title]", "INFO_TITLE" => "$info[title]",
skipping to change at line 593 skipping to change at line 593
return $content; return $content;
} }
################################################# #################################################
# Show links waiting to be deleted # Show links waiting to be deleted
################################################# #################################################
# #
function Admin_showdeletewaiting() function Admin_showdeletewaiting()
{ {
global $start_script, $start_script_t, $tpl; global $start_script, $start_script_t, $tpl;
global $config; global $config, $mylink;
$tpl->set_file("showwait", "form_admin_show_waitdel.tpl"); $tpl->set_file("showwait", "form_admin_show_waitdel.tpl");
$tpl->set_block("showwait", "wait_row", "wait_rows"); $tpl->set_block("showwait", "wait_row", "wait_rows");
$tpl->set_var("wait_rows", ""); $tpl->set_var("wait_rows", "");
$category = mysql_query("SELECT * FROM ".$config["pre"]."links where stat $category = mysqli_query($mylink, "SELECT * FROM ".$config["pre"]."links
us=2 order by title"); where status=2 order by title");
while ($info = mysql_fetch_array($category) ) while ($info = mysqli_fetch_array($category) )
{ {
$oldlink_ref = mysql_query("SELECT * FROM ".$config["pre"]."links $oldlink_ref = mysqli_query($mylink, "SELECT * FROM ".$config["pr
where idx='$info[idx]' and status=0"); e"]."links where idx='$info[idx]' and status=0");
$oldlink = mysql_fetch_array($oldlink_ref); $oldlink = mysqli_fetch_array($oldlink_ref);
$linkcategory_ref = mysql_query("SELECT * FROM ".$config["pre"]." $linkcategory_ref = mysqli_query($mylink, "SELECT * FROM ".$confi
category where cat='$oldlink[cat]'"); g["pre"]."category where cat='$oldlink[cat]'");
$linkcategory = mysql_fetch_array($linkcategory_ref); $linkcategory = mysqli_fetch_array($linkcategory_ref);
$title = validate_url($oldlink[link],$oldlink[title]); $title = validate_url($oldlink[link],$oldlink[title]);
$waitinfo = mysql_fetch_array(mysql_query("SELECT * FROM ".$confi g["pre"]."wait where idx='$info[idx]'")); $waitinfo = mysqli_fetch_array(mysqli_query($mylink, "SELECT * FR OM ".$config["pre"]."wait where idx='$info[idx]'"));
$tpl->set_var ( array( $tpl->set_var ( array(
"INFO_ID" => "$info[idx]", "INFO_ID" => "$info[idx]",
"INFO_OLINK" => "$oldlink[link]", "INFO_OLINK" => "$oldlink[link]",
"INFO_MESS" => "$info[message]", "INFO_MESS" => "$info[message]",
"INFO_IP" => "$waitinfo[ip]", "INFO_IP" => "$waitinfo[ip]",
"INFO_EMAIL" => "$waitinfo[email]", "INFO_EMAIL" => "$waitinfo[email]",
"TITLE" => "$title", "TITLE" => "$title",
"LTITLE" => "$linkcategory[title]" "LTITLE" => "$linkcategory[title]"
)); ));
skipping to change at line 635 skipping to change at line 635
return $content; return $content;
} }
################################################# #################################################
# #
################################################# #################################################
# #
function Admin_dodeletewaiting($_unused) function Admin_dodeletewaiting($_unused)
{ {
global $start_script, $start_script_t, $_POST; global $start_script, $start_script_t, $_POST;
global $config; global $config, $mylink;
$delete_total = $keep_total = 0; $delete_total = $keep_total = 0;
############## ##############
# This should only show the posted vars with id: in there name then strip out the other stuff... # This should only show the posted vars with id: in there name then strip out the other stuff...
# #
while (list($key, $val) = each($_POST) and ereg("id:",$key) and $key = er eg_replace("id:","",$key)) while (list($key, $val) = each($_POST) and preg_match("/id:/",$key) and $ key = preg_replace("/id:/","",$key))
{ {
if ($val == "delete") if ($val == "delete")
{ {
$delete_total++; $delete_total++;
$delete = mysql_query("DELETE FROM ".$config["pre"]."link $delete = mysqli_query($mylink, "DELETE FROM ".$config["p
s where idx='".intval($key)."' "); re"]."links where idx='".intval($key)."' ");
$delete = mysql_query("DELETE FROM ".$config["pre"]."wait $delete = mysqli_query($mylink, "DELETE FROM ".$config["p
where idx='".intval($key)."' "); re"]."wait where idx='".intval($key)."' ");
} }
if ($val == "remove") if ($val == "remove")
{ {
$remove_total++; $remove_total++;
$delete = mysql_query("DELETE FROM ".$config["pre"]."link $delete = mysqli_query($mylink, "DELETE FROM ".$config["p
s where idx='".intval($key)."' and status=2"); re"]."links where idx='".intval($key)."' and status=2");
$delete = mysql_query("DELETE FROM ".$config["pre"]."wait $delete = mysqli_query($mylink, "DELETE FROM ".$config["p
where idx='".intval($key)."' "); re"]."wait where idx='".intval($key)."' ");
} }
else if ($val == "") else if ($val == "")
{ {
$keep_total++; $keep_total++;
} }
} }
$content = Message ("delremkept", array( $content = Message ("delremkept", array(
"DEL_TOT" => "$delete_total", "DEL_TOT" => "$delete_total",
"REM_TOT" => "$remove_total", "REM_TOT" => "$remove_total",
skipping to change at line 679 skipping to change at line 679
return $content; return $content;
} }
################################################# #################################################
# Admin : add/remove waiting links # Admin : add/remove waiting links
################################################# #################################################
function Admin_dowaiting($_unused) function Admin_dowaiting($_unused)
{ {
global $start_script, $start_script_t, $_POST; global $start_script, $start_script_t, $_POST;
global $config; global $config, $mylink;
$delete_total = $keep_total = $add_total =0; $delete_total = $keep_total = $add_total =0;
############## ##############
# This should only show the posted vars with id: in there name then strip out the other stuff... # This should only show the posted vars with id: in there name then strip out the other stuff...
# #
while (list($key, $val) = each($_POST) and ereg("id:",$key) and $key = er eg_replace("id:","",$key)) while (list($key, $val) = each($_POST) and preg_match("/id:/",$key) and $ key = preg_replace("/id:/","",$key))
{ {
# make sure it''s an integer # make sure it''s an integer
$key = intval($key); $key = intval($key);
# category info and update: keep it for later # category info and update: keep it for later
if (ereg("category", $key)) continue; if (preg_match("/category/", $key)) continue;
if (ereg("updid:", $key)) continue; if (preg_match("/updid:/", $key)) continue;
# else add or delete an entry # else add or delete an entry
if ($val == "delete") if ($val == "delete")
{ {
$delete_total++; $delete_total++;
$delete_wait = mysql_query("DELETE FROM ".$config["pre"]. $delete_wait = mysqli_query($mylink, "DELETE FROM ".$conf
"wait where idx='$key' "); ig["pre"]."wait where idx='$key' ");
$delete_link = mysql_query("DELETE FROM ".$config["pre"]. $delete_link = mysqli_query($mylink, "DELETE FROM ".$conf
"links where idx='$key' and status=1"); ig["pre"]."links where idx='$key' and status=1");
} }
else if ($val == "add") else if ($val == "add")
{ {
$add_total++; $add_total++;
# remove then entry in wait # remove then entry in wait
$delete_wait = mysql_query("DELETE FROM ".$config["pre"]. "wait where idx='$key' "); $delete_wait = mysqli_query($mylink, "DELETE FROM ".$conf ig["pre"]."wait where idx='$key' ");
# get the current hits # get the current hits
$hits = mysql_fetch_array(mysql_query("select hits from " .$config["pre"]."links where idx='$key' and status=0")); $hits = mysqli_fetch_array(mysqli_query($mylink, "select hits from ".$config["pre"]."links where idx='$key' and status=0"));
if ($hits[0] == "") $hits[0] = "0"; if ($hits[0] == "") $hits[0] = "0";
# remove the old entry in links # remove the old entry in links
$delete_old = mysql_query("DELETE FROM ".$config["pre"]." links where idx='$key' and status=0"); $delete_old = mysqli_query($mylink, "DELETE FROM ".$confi g["pre"]."links where idx='$key' and status=0");
$more = ""; $more = "";
if (mysql_affected_rows() == 0) { if (mysqli_affected_rows($mylink) == 0) {
# new link update date # new link update date
$more = ", date=NOW()"; $more = ", date=NOW()";
} }
# modify the category here # modify the category here
$more .= ", cat='".intval($_POST["categoryid:".$key])."' "; $more .= ", cat='".intval($_POST["categoryid:".$key])."' ";
# make the waiting link, the active new one # make the waiting link, the active new one
$res = mysql_query("UPDATE ".$config["pre"]."links SET st atus=0, hits=".$hits[0]."$more where idx='$key' and status=1") or die (mysql_err or()); $res = mysqli_query($mylink, "UPDATE ".$config["pre"]."li nks SET status=0, hits=".$hits[0]."$more where idx='$key' and status=1") or die (mysqli_error($mylink));
# need to update the 'update' date ? # need to update the 'update' date ?
if (isset($_POST["updid:".$key])) { if (isset($_POST["updid:".$key])) {
$add = mysql_query("UPDATE ".$config["pre"]."links se t updated=NOW() where idx='$key' and status=0"); $add = mysqli_query($mylink, "UPDATE ".$config["pre"] ."links set updated=NOW() where idx='$key' and status=0");
} }
} }
else if ($val == "") else if ($val == "")
{ {
$keep_total++; $keep_total++;
} }
} }
updateRSS(); updateRSS();
skipping to change at line 749 skipping to change at line 749
return $content; return $content;
} }
################################################# #################################################
# Admin : add/delete waiting categories # Admin : add/delete waiting categories
################################################# #################################################
function Admin_dowaitingcat($_unused) function Admin_dowaitingcat($_unused)
{ {
global $start_script, $start_script_t, $_POST; global $start_script, $start_script_t, $_POST;
global $config; global $config, $mylink;
$delete_total = $keep_total = $add_total =0; $delete_total = $keep_total = $add_total =0;
############## ##############
# This should only show the posted vars with id: in there name then strip out the other stuff... # This should only show the posted vars with id: in there name then strip out the other stuff...
# #
while (list($key, $val) = each($_POST)) while (list($key, $val) = each($_POST))
{ {
if (ereg("id:",$key) and $key = ereg_replace("id:","",$key)) if (preg_match("/id:/",$key) and $key = preg_replace("/id:/","",$key) )
{ {
# make sure it''s an integer # make sure it''s an integer
$key = preg_replace("/[^0-9]+/", "", $key); $key = preg_replace("/[^0-9]+/", "", $key);
if ($val == "delete") if ($val == "delete")
{ {
$delete_total++; $delete_total++;
$delete_wait = mysql_query("DELETE FROM ".$config["pre"]. "waitcat where id='$key'"); $delete_wait = mysqli_query($mylink, "DELETE FROM ".$conf ig["pre"]."waitcat where id='$key'");
} }
else if ($val == "add") else if ($val == "add")
{ {
$add_total++; $add_total++;
$max_ref = mysql_query("select MAX(cat)+1 from ".$config[ $max_ref = mysqli_query($mylink, "select MAX(cat)+1 from
"pre"]."category"); ".$config["pre"]."category");
$number = mysql_fetch_array($max_ref); $number = mysqli_fetch_array($max_ref);
$newcat = $key.":cat"; $newcat = $key.":cat";
$main = intval($_POST[$newcat]); $main = intval($_POST[$newcat]);
if ($main == 0) if ($main == 0)
{ {
$pathto[pathto] = ":"; $pathto[pathto] = ":";
} }
else else
{ {
$pathto_ref = mysql_query("select pathto from ".$conf $pathto_ref = mysqli_query($mylink, "select pathto fr
ig["pre"]."category where cat='$main'"); om ".$config["pre"]."category where cat='$main'");
$pathto = mysql_fetch_array($pathto_ref); $pathto = mysqli_fetch_array($pathto_ref);
} }
$message = $key.":message"; $message = $key.":message";
$title = $key.":title"; $title = $key.":title";
if ($number[0] == "") $number[0] = 1; if ($number[0] == "") $number[0] = 1;
$su = mysql_query("insert into ".$config["pre"]."category $su = mysqli_query($mylink, "insert into ".$config["pre"]
(cat,under,title,info,pathto) values ('$number[0]','$main','$_POST[$title]','$_ ."category (cat,under,title,info,pathto) values ('$number[0]','$main','$_POST[$t
POST[$message]','$pathto[pathto]$number[0]:')"); itle]','$_POST[$message]','$pathto[pathto]$number[0]:')");
$delete = mysql_query("DELETE FROM ".$config["pre"]."wait $delete = mysqli_query($mylink, "DELETE FROM ".$config["p
cat where id='$key'"); re"]."waitcat where id='$key'");
} }
else if ($val == "") else if ($val == "")
{ {
$keep_total++; $keep_total++;
} }
} }
} }
$content = Message ("delkeptadd", array ( $content = Message ("delkeptadd", array (
skipping to change at line 832 skipping to change at line 832
return $content; return $content;
} }
################################################# #################################################
# #
################################################# #################################################
# #
function uLinkCount() function uLinkCount()
{ {
global $config; global $config, $mylink;
$update_ref = mysql_query("SELECT * FROM ".$config["pre"]."category"); $update_ref = mysqli_query($mylink, "SELECT * FROM ".$config["pre"]."cate gory");
$total=array(); $total=array();
while($update = mysql_fetch_array($update_ref)) while($update = mysqli_fetch_array($update_ref))
{ {
$result = mysql_query("SELECT COUNT(*) from ".$config["pre"]."lin $result = mysqli_query($mylink, "SELECT COUNT(*) from ".$config["
ks where cat='$update[cat]' and status=0"); pre"]."links where cat='$update[cat]' and status=0");
$cat_total = mysql_fetch_array($result); $cat_total = mysqli_fetch_array($result);
$update_path = explode(":",$update[pathto]); $update_path = explode(":",$update[pathto]);
while (list($key, $val)=each($update_path)) while (list($key, $val)=each($update_path))
{ {
if ($val != ""){ if ($val != ""){
$total[$val] = $cat_total[0] + $total[$val]; $total[$val] = $cat_total[0] + $total[$val];
} }
} }
} }
while (list($key, $val)=each($total)) while (list($key, $val)=each($total))
{ {
$add_totals = mysql_query("UPDATE ".$config["pre"]."category SET ttlinks=$val WHERE cat='$key'") or die (mysql_error()); $add_totals = mysqli_query($mylink, "UPDATE ".$config["pre"]."cat egory SET ttlinks=$val WHERE cat='$key'") or die (mysqli_error($mylink));
} }
$content = Message("link_count_updated"); $content = Message("link_count_updated");
return $content; return $content;
} }
################################################# #################################################
# This return the hiddend name password (HNP) # This return the hiddend name password (HNP)
################################################# #################################################
skipping to change at line 884 skipping to change at line 884
################################################# #################################################
# #
function validate_url($URL,$title) function validate_url($URL,$title)
{ {
global $config; global $config;
if ($config["no_url_check"] == 1) { if ($config["no_url_check"] == 1) {
return (Message ("red_message", array("TXT" => "$title"))); return (Message ("red_message", array("TXT" => "$title")));
} }
$URL2 = eregi_replace("http://","",$URL); $URL2 = preg_replace("/http:\/\//i", "", $URL);
$splitURL = split("/", $URL2, 2); $splitURL = explode("/", $URL2, 2);
$host= $splitURL[0]; $host= $splitURL[0];
$path= $splitURL[1]; $path= $splitURL[1];
if ( ! eregi("(\.|/$)", $path)){ if ( ! preg_match("/(\.|\/$)/", $path)){
$path="$path/"; $path="$path/";
} }
if ((eregi("\.", $host))){ if ((preg_match("/\./", $host))){
$gh = fsockopen ("$host", 80, $errno, $errstr, 5) or $error = "$e rrstr"; $gh = fsockopen ("$host", 80, $errno, $errstr, 5) or $error = "$e rrstr";
$line = ""; $line = "";
if (! isset($error)){ if (! isset($error)){
$hpath= "/".$path; $hpath= "/".$path;
fputs($gh, "HEAD $hpath HTTP/1.1\r\nHOST:$host\r\n\r\n"); fputs($gh, "HEAD $hpath HTTP/1.1\r\nHOST:$host\r\n\r\n");
$line = fgets($gh, 25); $line = fgets($gh, 25);
} }
if (eregi("200 OK", $line)){ if (preg_match("/200 OK/", $line)){
$valid = Message ("green_message", array("TXT" => $title) ); $valid = Message ("green_message", array("TXT" => $title) );
} else { } else {
$valid = Message ("red_message", array("TXT" => "$title - $error")); $valid = Message ("red_message", array("TXT" => "$title - $error"));
} }
} else { } else {
$valid = Message ("red_message", array("TXT" => $title)); $valid = Message ("red_message", array("TXT" => $title));
} }
return $valid; return $valid;
 End of changes. 84 change blocks. 
148 lines changed or deleted 148 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)