"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/lib_main.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_main.php3  (mythreads-links_1.2.0):lib_main.php3  (mythreads-links_1.2.1)
<?php <?php
#-----------------------------------------------------------------> #----------------------------------------------------------------->
# $Id: lib_main.php3,v 1.76 2015/05/29 17:15:20 ldrolez Exp $ # $Id: lib_main.php3,v 1.71 2010/05/04 18:29:59 ldrolez Exp $
# #
# Website: http://mythreads.sourceforge.net # Website: http://mythreads.sourceforge.net
# #
# Desc: lib_main.php3. All the main functions are stored here.... # Desc: lib_main.php3. All the main functions are stored here....
# #
# #
# 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.
# #
skipping to change at line 42 skipping to change at line 42
$tpl->p("MyOutput"); $tpl->p("MyOutput");
} }
################################################# #################################################
# #
################################################# #################################################
# #
# print Main page with just main category's # print Main page with just main category's
function mainPage() function mainPage()
{ {
global $tpl, $config, $start_script, $start_script_t, $mylink, $language; global $tpl, $config, $start_script, $start_script_t, $mylink, $language, $m ylink;
$a = 0; $a = 0;
$cache_file = $config["cache_dir"] . "frontpage.cache". $language; $cache_file = $config["cache_dir"] . "frontpage.cache". $language;
$time = split(" ", microtime()); $time = explode(" ", microtime());
srand((double)microtime()*1000000); srand((double)microtime()*1000000);
$cache_time_rnd = 60 - rand(0, 60); $cache_time_rnd = 60 - rand(0, 60);
if ( (!(file_exists($cache_file))) || ((filectime($cache_file) + $config["ca che_time"] - $time[1]) + $cache_time_rnd < 0) || (!(filesize($cache_file))) ) if ( (!(file_exists($cache_file))) || ((filectime($cache_file) + $config["ca che_time"] - $time[1]) + $cache_time_rnd < 0) || (!(filesize($cache_file))) )
{ {
if (!$result = mysql_query("SELECT cat,title,ttlinks,info FROM ".$config[ if (!$result = mysqli_query($mylink, "SELECT cat,title,ttlinks,info FROM
"pre"]."category WHERE under='0' ORDER BY title")) { ".$config["pre"]."category WHERE under='0' ORDER BY title")) {
echo "<br/><h2><font color=\"red\">DATABASE ERROR: ".mysql_error()."< echo "<br/><h2><font color=\"red\">DATABASE ERROR: ".mysqli_error($my
/font></h2><br>"; link)."</font></h2><br>";
} }
$links = "<table width=\"100%\" cellpadding=\"4\"><tr>"; $links = "<table width=\"100%\" cellpadding=\"4\"><tr>";
while ($info = mysql_fetch_array($result)) while ($info = mysqli_fetch_array($result))
{ {
$a++; $a++;
$links_under = ""; $links_under = "";
$sublinks_ref = mysql_query("SELECT cat,title FROM ".$config["pre"]." category WHERE under='$info[cat]' ORDER BY title"); $sublinks_ref = mysqli_query($mylink, "SELECT cat,title FROM ".$confi g["pre"]."category WHERE under='$info[cat]' ORDER BY title");
if ($sublinks_ref != 0) { if ($sublinks_ref != 0) {
$max = $config["max_sublinks"]; $max = $config["max_sublinks"];
$num_rows = mysql_num_rows($sublinks_ref); $num_rows = mysqli_num_rows($sublinks_ref);
if ( $num_rows < $config["max_sublinks"] ) { if ( $num_rows < $config["max_sublinks"] ) {
$max = $num_rows; $max = $num_rows;
} }
for ($i=0; $i < $max; $i++) { for ($i=0; $i < $max; $i++) {
$sublinks = mysql_fetch_array($sublinks_ref); $sublinks = mysqli_fetch_array($sublinks_ref);
if ($i == 0) { if ($i == 0) {
$links_under .= "<a href=\"".$start_script_t."category=$s ublinks[cat]\">$sublinks[title]</a>"; $links_under .= "<a href=\"".$start_script_t."category=$s ublinks[cat]\">$sublinks[title]</a>";
} else { } else {
$links_under .= ", <a href=\"".$start_script_t."category= $sublinks[cat]\">$sublinks[title]</a>"; $links_under .= ", <a href=\"".$start_script_t."category= $sublinks[cat]\">$sublinks[title]</a>";
} }
} }
# print '...' if there are more sub categories than shown # print '...' if there are more sub categories than shown
if ( $num_rows > $config["max_sublinks"] ) { if ( $num_rows > $config["max_sublinks"] ) {
$links_under .= "&nbsp;<a href=\"".$start_script_t."category= $info[cat]\">...</a>"; $links_under .= "&nbsp;<a href=\"".$start_script_t."category= $info[cat]\">...</a>";
} }
skipping to change at line 142 skipping to change at line 142
################################################# #################################################
# #
################################################# #################################################
# #
# View links page # View links page
function viewPage($category) function viewPage($category)
{ {
######### #########
# global variables # global variables
global $config, $start_script, $start_script_t, $tpl; global $config, $start_script, $start_script_t, $tpl, $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,info FROM ".$config["pr e"]."category where under='$category' ORDER BY 'title'"); $result_t = mysqli_query($mylink, "SELECT cat,title,ttlinks,info FROM ".$ config["pre"]."category where under='$category' ORDER BY 'title'");
// Vertical Alpha routine start (Ratt 26 Nov 02) // Vertical Alpha routine start (Ratt 26 Nov 02)
// Counts the number of entries to display // Counts the number of entries to display
$alpha_count = 0; $alpha_count = 0;
while ($alpha_array[$alpha_count++] = mysql_fetch_array($result_t)); while ($alpha_array[$alpha_count++] = mysqli_fetch_array($result_t));
// Takes last increment off the stack due to the way MySQL and PHP handle queries (there // Takes last increment off the stack due to the way MySQL and PHP handle queries (there
// is 1 more than the actual number of entries, because of the NULL test. // is 1 more than the actual number of entries, because of the NULL test.
$alpha_count--; $alpha_count--;
if ($alpha_count == 0) return ""; if ($alpha_count == 0) return "";
// Calculate how many rows are going to be needed. If it's less than one, it's obviously 1 :) // Calculate how many rows are going to be needed. If it's less than one, it's obviously 1 :)
$alpha_row_count = ceil($alpha_count / $config[across]); $alpha_row_count = ceil($alpha_count / $config[across]);
skipping to change at line 209 skipping to change at line 209
} }
################################################# #################################################
# #
################################################# #################################################
# #
# This function displays the different categories of links there are. # This function displays the different categories of links there are.
function display_category($category) function display_category($category)
{ {
global $start_script, $start_script_t; global $start_script, $start_script_t;
global $config; global $config, $mylink;
$content = ""; $content = "";
$result_sub = mysql_query("SELECT pathto FROM ".$config["pre"]."category $result_sub = mysqli_query($mylink, "SELECT pathto FROM ".$config["pre"].
WHERE pathto LIKE '%:$category:'"); "category 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']);
$content .= "<a href=\"$start_script\">".Message("top_bt")."</a>"; $content .= "<a href=\"$start_script\">".Message("top_bt")."</a>";
while (list($key, $val)=each($patharray)) while (list($key, $val)=each($patharray))
{ {
if ($val != ""){ if ($val != ""){
$result_sub = mysql_query("SELECT title,cat FROM ".$confi $result_sub = mysqli_query($mylink, "SELECT title,cat 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);
$content.= "/<a href=\"".$start_script_t."category=$sub_t itle_new[cat]\">$sub_title_new[title]</a>"; $content.= "/<a href=\"".$start_script_t."category=$sub_t itle_new[cat]\">$sub_title_new[title]</a>";
} }
} }
return $content; return $content;
} }
################################################# #################################################
# #
################################################# #################################################
# #
# This function displays the links contained in the database for a particular ca tegory. # This function displays the links contained in the database for a particular ca tegory.
function display_category_links($category,$view) function display_category_links($category,$view)
{ {
global $config, $nomore, $view_start, $start_script, $start_script_t, $up date_link, $add_link, $tpl; global $config, $nomore, $view_start, $start_script, $start_script_t, $up date_link, $add_link, $tpl, $mylink;
######### #########
# $view hold the from for LIMIT. Must not be 0 # $view hold the from for LIMIT. Must not be 0
if (! isset($view)){ $view='0';} if (! isset($view)){ $view='0';}
$view_start = $view; $view_start = $view;
$view_stop = $view + $config["max_displayed_links"]; $view_stop = $view + $config["max_displayed_links"];
######### #########
# count how many and not go over the max... # count how many and not go over the max...
$af = mysql_query("SELECT COUNT(*) FROM ".$config["pre"]."links WHERE cat $af = mysqli_query($mylink, "SELECT COUNT(*) FROM ".$config["pre"]."links
='$category' and status=0"); WHERE cat='$category' and status=0");
$howmany = mysql_fetch_array($af); $howmany = mysqli_fetch_array($af);
if ($howmany[0] <= $view_stop) if ($howmany[0] <= $view_stop)
{ {
$view_stop = $howmany[0]; $view_stop = $howmany[0];
$nomore=1; $nomore=1;
} }
$link_prev_next = showNext($category,$view_stop,$view_start,$nomore); $link_prev_next = showNext($category,$view_stop,$view_start,$nomore);
$cat_links .= $link_prev_next; $cat_links .= $link_prev_next;
$result = mysql_query( "SELECT title,idx,message,date,hits FROM ".$config ["pre"]."links WHERE cat='$category' and status=0 ORDER BY title LIMIT $view_sta rt,".$config["max_displayed_links"]); $result = mysqli_query($mylink, "SELECT title,idx,message,date,hits FROM ".$config["pre"]."links WHERE cat='$category' and status=0 ORDER BY title LIMIT $view_start,".$config["max_displayed_links"]);
if (mysql_numrows($result)) if (mysqli_num_rows($result))
{ {
# as we append data, make sure to reset link_rows # as we append data, make sure to reset link_rows
$tpl->set_var("link_rows", ""); $tpl->set_var("link_rows", "");
while ($list = mysql_fetch_array($result) ) while ($list = mysqli_fetch_array($result) )
{ {
limitlength_cat($list); limitlength_cat($list);
$idx = $list["idx"]; $idx = $list["idx"];
$tpl->set_var( array( $tpl->set_var( array(
"LINK_TITLE" => $list["title"], "LINK_TITLE" => $list["title"],
"LINK_MESSAGE" => $list["message"], "LINK_MESSAGE" => $list["message"],
"LINK_ADDED" => $list["date"], "LINK_ADDED" => $list["date"],
"LINK_HITS" => $list["hits"], "LINK_HITS" => $list["hits"],
"LINK_GO" => $start_script_t."count=$idx", "LINK_GO" => $start_script_t."count=$idx",
skipping to change at line 348 skipping to change at line 348
$tpl->set_block ("start", "search_title", "nbsp"); $tpl->set_block ("start", "search_title", "nbsp");
$tpl->set_var ("deleteme" , ""); $tpl->set_var ("deleteme" , "");
$tpl->set_var ("nbsp" , "&nbsp;"); $tpl->set_var ("nbsp" , "&nbsp;");
} }
################################################# #################################################
# Counts the hits a particular link gets # Counts the hits a particular link gets
################################################# #################################################
function countIt($idx, $redir = 0) { function countIt($idx, $redir = 0) {
global $config; global $config, $_SERVER, $mylink;
$lr = $config["local_redirect"]; $lr = $config["local_redirect"];
# get the remote IP address # get the remote IP address
$ipadd = trim(getenv("REMOTE_ADDR")); $ipadd = trim(getenv("REMOTE_ADDR"));
$result = mysql_query("SELECT link,lastip FROM ".$config["pre"]."links WH $result = mysqli_query($mylink, "SELECT link,lastip FROM ".$config["pre"]
ERE idx='$idx' and status=0"); ."links WHERE idx='$idx' and status=0");
$list = mysql_fetch_array($result); $list = mysqli_fetch_array($result);
if ($lr != "") { if ($lr != "") {
if (ereg("^[a-zA-Z]+://", $list["link"])) { if (preg_match("/^[a-zA-Z]+:\/\//", $list["link"])) {
$lr = ""; $lr = "";
} }
} }
if ($redir != 0) { if ($redir != 0) {
# redirect if redir not null # redirect if redir not null
header("Location: ".$lr.$list["link"]."\n\n"); header("Location: ".$lr.$list["link"]."\n\n");
} }
# Bot check, don't count hits from bots
if (preg_match('/bot|curl|crawler|spider|google|infoseek|slurp|scooter/i'
, $_SERVER['HTTP_USER_AGENT'], $matches)) {
return;
exit(1);
}
if ($list["lastip"] != $ipadd) { if ($list["lastip"] != $ipadd) {
# new IP: count it # new IP: count it
$result = mysql_query("UPDATE ".$config["pre"]."links SET hits=hi $result = mysqli_query($mylink, "UPDATE ".$config["pre"]."links SET h
ts+1 , lastip='$ipadd' WHERE idx='$idx' and status=0"); its=hits+1 , lastip='$ipadd' WHERE idx='$idx' and status=0");
if (!$result){ if (!$result){
$error = mysql_error(); $error = mysqli_error($mylink);
print $error; print $error;
exit(1); exit(1);
} }
} }
} }
################################################### ###################################################
# User : Add a link in the queue # User : Add a link in the queue
# Admin : Direct add / modify # Admin : Direct add / modify
################################################### ###################################################
function doaddWaitLink($_unused, $mode = "") function doaddWaitLink($_unused, $mode = "")
{ {
global $linkbackurl; global $linkbackurl;
global $config, $custom; global $config, $custom, $mylink;
global $_GET, $_POST; global $_GET, $_POST;
$status = 1; $status = 1;
$new = 0; $new = 0;
if ($config['security_code'] != "" && getuser() != "admin") { if ($config['security_code'] != "" && getuser() != "admin") {
# check the security code # check the security code
if ($_POST["security"] == "" || $_POST["securitycode"] == "") { if ($_POST["security"] == "" || $_POST["securitycode"] == "") {
$error = Message("error_security_code"); $error = Message("error_security_code");
} else if ($_POST["security"] != ImageGenSecretRef($_POST["securi tycode"])) { } else if ($_POST["security"] != ImageGenSecretRef($_POST["securi tycode"])) {
skipping to change at line 430 skipping to change at line 437
# is the delete flag set ? # is the delete flag set ?
if (isset($_POST["delete"])) if (isset($_POST["delete"]))
{ {
# TODO: handle direct admin deletion. # TODO: handle direct admin deletion.
$status = 2; $status = 2;
} }
else else
{ {
if ($_POST[idx] != "") { if ($_POST[idx] != "") {
# old link being edited # old link being edited
$exists_wait = mysql_numrows(mysql_query("SELECT idx FROM ".$config[" pre"]."links where idx='".intval($_POST[idx])."' and status<>0")); $exists_wait = mysqli_num_rows(mysqli_query($mylink, "SELECT idx FROM ".$config["pre"]."links where idx='".intval($_POST[idx])."' and status<>0"));
if ($exists_wait != 0) if ($exists_wait != 0)
{ {
$error .= Message ("error_already_in_update_queue"); $error .= Message ("error_already_in_update_queue");
} }
} else { } else {
# Assign an idx # Assign an idx
$max = mysql_fetch_array(mysql_query("select MAX(idx)+1 from ".$confi g["pre"]."links")); $max = mysqli_fetch_array(mysqli_query($mylink, "select MAX(idx)+1 fr om ".$config["pre"]."links"));
if ($max[0] == "") $max[0] = 1; if ($max[0] == "") $max[0] = 1;
$_POST[idx] = $max[0]; $_POST[idx] = $max[0];
$new = 1; $new = 1;
} }
if (getuser() == "admin" ) { if (getuser() == "admin" ) {
# direct add/mod # direct add/mod
# if the admin is adding a new link using the admin panel, # if the admin is adding a new link using the admin panel,
# do not put this new link in the wait queue. # do not put this new link in the wait queue.
if ($_GET["mode"] == "admin") { if ($_GET["mode"] == "admin") {
$status = 0; $status = 0;
skipping to change at line 496 skipping to change at line 503
# for checkboxes # for checkboxes
if (!isset($_POST[$k]) && $v == "bool") { if (!isset($_POST[$k]) && $v == "bool") {
$mod[$kl] = "'0'"; $mod[$kl] = "'0'";
} }
} }
$idx = intval($_POST[idx]); $idx = intval($_POST[idx]);
$numold = 0; $numold = 0;
if ((getuser() == "admin" && $status != 2) || ($config["anonymous_add "] == 1)) { if ((getuser() == "admin" && $status != 2) || ($config["anonymous_add "] == 1)) {
# find the old link entry # find the old link entry
$sql = "select idx from ".$config["pre"]."links where idx='".$idx ."'"; $sql = "select idx from ".$config["pre"]."links where idx='".$idx ."'";
$numold = mysql_num_rows(mysql_query( $sql )); $numold = mysqli_num_rows(mysqli_query($mylink, $sql));
# new link ? set the date # new link ? set the date
if ($numold == 0) { if ($numold == 0) {
$mod["date"] = "NOW()"; $mod["date"] = "NOW()";
} else { } else {
# status=3 : direct edit # status=3 : direct edit
$mod["status"] = 3; $mod["status"] = 3;
# mark the link as updated ? # mark the link as updated ?
# Quick hack. I should add a check box ! # Quick hack. I should add a check box !
if ($email == "update") $mod["updated"] = "NOW()"; if ($email == "update") $mod["updated"] = "NOW()";
} }
} }
dbDupMod($config["pre"]."links", "WHERE idx='$idx'", $mod); dbDupMod($config["pre"]."links", "WHERE idx='$idx'", $mod);
if ($numold != 0) { if ($numold != 0) {
# admin mode in direct edit, delete the old link # admin mode in direct edit, delete the old link
$sql = "delete from ".$config["pre"]."links where idx='$idx' and status=0"; $sql = "delete from ".$config["pre"]."links where idx='$idx' and status=0";
$ref = mysql_query( $sql ); $ref = mysqli_query( $mylink, $sql );
# and alter the temporary entry # and alter the temporary entry
$sql = "update ".$config["pre"]."links set status=0 where idx='$i dx' and status=3 "; $sql = "update ".$config["pre"]."links set status=0 where idx='$i dx' and status=3 ";
$ref = mysql_query( $sql ); $ref = mysqli_query( $mylink, $sql );
} else { } else {
# not direct admin edit # not direct admin edit
if ($status != 0) { if ($status != 0) {
# insert some info about the modification # insert some info about the modification
$ip_addy=getenv("REMOTE_ADDR"); $ip_addy=getenv("REMOTE_ADDR");
$su = mysql_query("insert into ".$config["pre"]."wait (idx,em ail,ip,date) values( $su = mysqli_query($mylink, "insert into ".$config["pre"]."wa it (idx,email,ip,date) values(
'".intval($_POST[idx])."', '".intval($_POST[idx])."',
'$email' , '$email' ,
'$ip_addy' , '$ip_addy' ,
NOW() )") or die (mysql_error()); NOW() )") or die (mysqli_error($mylink));
} else { } else {
# only call updaterss if the admin does a direct add through the # only call updaterss if the admin does a direct add through the
# admin panel # admin panel
if ($numold == 0 && getuser() == "admin") updateRSS(); if ($numold == 0 && getuser() == "admin") updateRSS();
} }
} }
if (getuser() == "admin") { if (getuser() == "admin") {
$content .= Message ("link_added", array("LINK" => htmlentities($ _POST['link']))); $content .= Message ("link_added", array("LINK" => htmlentities($ _POST['link'])));
} else { } else {
skipping to change at line 564 skipping to change at line 571
# $tbl = table's name # $tbl = table's name
# $where = SQL WHERE clause (which should begin by 'WHERE ') # $where = SQL WHERE clause (which should begin by 'WHERE ')
# $mod = array of columns to modify # $mod = array of columns to modify
################################################# #################################################
function dbDupMod($tbl,$where,$mod) function dbDupMod($tbl,$where,$mod)
{ {
global $config, $mylink, $database; global $config, $mylink, $database;
# get the fields info # get the fields info
$fields = mysql_list_fields($database, $tbl, $mylink); #$fields = mysqli_list_fields($mylink, $database, $tbl, $mylink);
$columns = mysql_num_fields($fields); #$columns = mysqli_num_fields($fields);
$sqlq = "SELECT * FROM $tbl $where"; $sqlq = "SELECT * FROM $tbl $where";
$ref = mysql_query( $sqlq ) or die (mysql_error()); $ref = mysqli_query( $mylink, $sqlq ) or die (mysqli_error($mylink));
$data = mysql_fetch_array($ref); $data = mysqli_fetch_array($ref);
$fds = mysqli_fetch_fields($ref);
#$sql = "INSERT INTO $tbl SELECT "; does not work with mysql so move #$sql = "INSERT INTO $tbl SELECT "; does not work with mysql so move
#the data the dumb way ! #the data the dumb way !
$sqli = "INSERT INTO $tbl ("; $sqli = "INSERT INTO $tbl (";
$sqld = "VALUES ( "; $sqld = "VALUES ( ";
for ($i = 0; $i < $columns; $i++) { for ($i = 0; $i < count($fds); $i++) {
$f = mysql_field_name($fields, $i); $f = $fds[$i]->name;
$sqli .= $f.","; $sqli .= $f.",";
# modify on the fly the data which needs to be modified # modify on the fly the data which needs to be modified
if (isset($mod[$f])) { if (isset($mod[$f])) {
$f = $mod[$f]; $f = $mod[$f];
} else { } else {
if (is_array($data)) { if (is_array($data)) {
$f = "'$data[$f]'"; $f = "'$data[$f]'";
} else { } else {
$f = "''"; $f = "''";
} }
} }
$sqld .= $f.","; $sqld .= $f.",";
} }
$sqld[strlen($sqld)-1] = " "; $sqld[strlen($sqld)-1] = " ";
$sqli[strlen($sqli)-1] = " "; $sqli[strlen($sqli)-1] = " ";
$sqli .= ") ".$sqld.")"; $sqli .= ") ".$sqld.")";
#echo($sqli); #echo($sqli);
#die(); #return; #die(); #return;
$result = mysql_query( $sqli ) or die (mysql_error()); $result = mysqli_query( $mylink, $sqli ) or die (mysqli_error($mylink));
} }
################################################# #################################################
# Returns the kind of user logged in # Returns the kind of user logged in
# (currently "" or "admin") # (currently "" or "admin")
################################################# #################################################
function getuser() function getuser()
{ {
global $_POST, $_COOKIE; global $_POST, $_COOKIE;
global $admin_userpass, $admin_username, $admin_password; global $admin_userpass, $admin_username, $admin_password;
skipping to change at line 656 skipping to change at line 664
//print_r($sub); //print_r($sub);
die("No spam here !"); die("No spam here !");
} }
#$sub = preg_replace($re, "", $sub); #$sub = preg_replace($re, "", $sub);
$to = preg_replace($re, "", $to); $to = preg_replace($re, "", $to);
$from = preg_replace($re, "", $from); $from = preg_replace($re, "", $from);
if (function_exists ("email")) { if (function_exists ("email")) {
# email function found : we are running on online.fr's servers # email function found : we are running on online.fr's servers
ereg ("^[^@]+", $from, $newfrom); preg_match ("/^[^@]+/", $from, $newfrom);
$ret = email($newfrom[0], $to, $sub, $text); $ret = email($newfrom[0], $to, $sub, $text);
} else { } else {
$ret = mail($to, $sub, $text, "From: $from \r\n"); $ret = mail($to, $sub, $text, "From: $from \r\n");
} }
return $ret; return $ret;
} }
################################################# #################################################
# This function displays newly added links. # This function displays newly added links.
################################################# #################################################
function Newly_Added($max_new_links) function Newly_Added($max_new_links)
{ {
global $tpl, $start_script, $start_script_t, $update_link; global $tpl, $start_script, $start_script_t, $update_link;
global $config; global $config, $mylink;
$cont = ""; $cont = "";
$result = mysql_query( "SELECT title,idx,message,date,hits FROM ".$config ["pre"]."links WHERE status=0 ORDER BY date DESC,hits LIMIT 0,$max_new_links"); $result = mysqli_query( $mylink, "SELECT title,idx,message,date,hits FROM ".$config["pre"]."links WHERE status=0 ORDER BY date DESC,hits LIMIT 0,$max_new _links");
if (mysql_numrows($result)) if (mysqli_num_rows($result))
{ {
# as we append data, make sure to reset link_rows # as we append data, make sure to reset link_rows
$tpl->set_var("link_rows", ""); $tpl->set_var("link_rows", "");
while ($list = mysql_fetch_array($result) ) while ($list = mysqli_fetch_array($result) )
{ {
limitlength($list); limitlength($list);
$idx = $list["idx"]; $idx = $list["idx"];
$tpl->set_var( array( $tpl->set_var( array(
"LINK_TITLE" => $list["title"], "LINK_TITLE" => $list["title"],
"LINK_MESSAGE" => $list["message"], "LINK_MESSAGE" => $list["message"],
"LINK_ADDED" => $list["date"], "LINK_ADDED" => $list["date"],
"LINK_HITS" => $list["hits"], "LINK_HITS" => $list["hits"],
"LINK_GO" => $start_script_t."count=$idx", "LINK_GO" => $start_script_t."count=$idx",
"LINK_MORE" => $start_script_t."more=$idx", "LINK_MORE" => $start_script_t."more=$idx",
skipping to change at line 713 skipping to change at line 721
return $cont; return $cont;
} }
################################################# #################################################
# This function displays newly updated links. # This function displays newly updated links.
################################################# #################################################
function Newly_Updated($max_upd_links) function Newly_Updated($max_upd_links)
{ {
global $tpl, $start_script, $start_script_t, $update_link; global $tpl, $start_script, $start_script_t, $update_link;
global $config; global $config, $mylink;
$cont = ""; $cont = "";
$result = mysql_query( "SELECT title,idx,message,updated,hits FROM ".$con fig["pre"]."links WHERE updated<>'' and status=0 ORDER BY updated DESC,hits LIMI T 0,$max_upd_links"); $result = mysqli_query( $mylink, "SELECT title,idx,message,updated,hits F ROM ".$config["pre"]."links WHERE updated<>'' and status=0 ORDER BY updated DESC ,hits LIMIT 0,$max_upd_links");
if (mysql_numrows($result)) if (mysqli_num_rows($result))
{ {
# as we append data, make sure to reset link_rows # as we append data, make sure to reset link_rows
$tpl->set_var("link_rows", ""); $tpl->set_var("link_rows", "");
while ($list = mysql_fetch_array($result) ) while ($list = mysqli_fetch_array($result) )
{ {
limitlength($list); limitlength($list);
$idx = $list["idx"]; $idx = $list["idx"];
$tpl->set_var( array( $tpl->set_var( array(
"LINK_TITLE" => $list["title"], "LINK_TITLE" => $list["title"],
"LINK_MESSAGE" => $list["message"], "LINK_MESSAGE" => $list["message"],
"LINK_ADDED" => $list["updated"], "LINK_ADDED" => $list["updated"],
"LINK_HITS" => $list["hits"], "LINK_HITS" => $list["hits"],
"LINK_GO" => $start_script_t."count=$idx", "LINK_GO" => $start_script_t."count=$idx",
"LINK_MORE" => $start_script_t."more=$idx", "LINK_MORE" => $start_script_t."more=$idx",
skipping to change at line 754 skipping to change at line 762
return $cont; return $cont;
} }
################################################# #################################################
# This function displays top hits. # This function displays top hits.
################################################# #################################################
function Top_Hits($max_top_links) function Top_Hits($max_top_links)
{ {
global $tpl, $start_script, $start_script_t, $update_link; global $tpl, $start_script, $start_script_t, $update_link;
global $config; global $config, $mylink;
$cont = ""; $cont = "";
$result = mysql_query( "SELECT title,idx,message,date,hits FROM ".$config ["pre"]."links WHERE hits<>0 and status=0 ORDER BY hits DESC LIMIT 0,$max_top_li nks "); $result = mysqli_query( $mylink, "SELECT title,idx,message,date,hits FROM ".$config["pre"]."links WHERE hits<>0 and status=0 ORDER BY hits DESC LIMIT 0,$ max_top_links ");
if (mysql_numrows($result)) if (mysqli_num_rows($result))
{ {
# as we append data, make sure to reset link_rows # as we append data, make sure to reset link_rows
$tpl->set_var("link_rows", ""); $tpl->set_var("link_rows", "");
while ($list = mysql_fetch_array($result) ) while ($list = mysqli_fetch_array($result) )
{ {
$idx = $list["idx"]; $idx = $list["idx"];
limitlength($list); limitlength($list);
$tpl->set_var( array( $tpl->set_var( array(
"LINK_TITLE" => $list["title"], "LINK_TITLE" => $list["title"],
"LINK_MESSAGE" => $list["message"], "LINK_MESSAGE" => $list["message"],
"LINK_ADDED" => $list["date"], "LINK_ADDED" => $list["date"],
"LINK_HITS" => $list["hits"], "LINK_HITS" => $list["hits"],
"LINK_GO" => $start_script_t."count=$idx", "LINK_GO" => $start_script_t."count=$idx",
"LINK_MORE" => $start_script_t."more=$idx", "LINK_MORE" => $start_script_t."more=$idx",
skipping to change at line 828 skipping to change at line 836
} }
################################################# #################################################
# This function displays more information using # This function displays more information using
# details.tpl template # details.tpl template
################################################# #################################################
function showMore($idx, &$title, $status = 0) function showMore($idx, &$title, $status = 0)
{ {
global $tpl, $start_script, $start_script_t, $update_link; global $tpl, $start_script, $start_script_t, $update_link;
global $config, $custom; global $config, $custom, $mylink;
$cont = ""; $cont = "";
$result = mysql_query( "SELECT * FROM ".$config["pre"]."links WHERE idx=\ $result = mysqli_query( $mylink, "SELECT * FROM ".$config["pre"]."links W
"$idx\" and status=$status"); HERE idx=\"$idx\" and status=$status");
if (mysql_numrows($result)) if (mysqli_num_rows($result))
{ {
$list = mysql_fetch_array($result); $list = mysqli_fetch_array($result);
$cat = display_category($list["cat"]); $cat = display_category($list["cat"]);
$idx = $list["idx"]; $idx = $list["idx"];
$tpl->set_var( array( $tpl->set_var( array(
"LINK_TITLE" => $list["title"], "LINK_TITLE" => $list["title"],
"LINK_MESSAGE" => $list["message"], "LINK_MESSAGE" => $list["message"],
"LINK_MESSAGE_BR" => preg_replace("/\n/", "<br/>", $list[ "message"]), "LINK_MESSAGE_BR" => preg_replace("/\n/", "<br/>", $list[ "message"]),
"LINK_ADDED" => $list["date"], "LINK_ADDED" => $list["date"],
"LINK_UPDATED" => $list["updated"], "LINK_UPDATED" => $list["updated"],
"LINK_LINK" => $list["link"], "LINK_LINK" => $list["link"],
"LINK_HITS" => $list["hits"], "LINK_HITS" => $list["hits"],
"LINK_CATEGORY" => $cat, "LINK_CATEGORY" => $cat,
"LINK_GO" => $start_script_t."count=$idx", "LINK_GO" => $start_script_t."count=$idx",
"LINK_MORE" => $start_script_t."more=$idx", "LINK_MORE" => $start_script_t."more=$idx",
"LINK_EDIT" => "$update_link&link=$idx" "LINK_EDIT" => "$update_link&link=$idx",
"LINK_IDX" => $idx
)); ));
# now process custom rows # now process custom rows
reset($custom); reset($custom);
while (list($k,$v) = each($custom)) { while (list($k,$v) = each($custom)) {
$ku = strtoupper($k); $ku = strtoupper($k);
$dt = $list[$k]; $dt = $list[$k];
if ($dt != "") { if ($dt != "") {
# set data # set data
$tpl->set_var ($ku, filterOut($v, $dt)); $tpl->set_var ($ku, filterOut($v, $dt));
} else { } else {
skipping to change at line 925 skipping to change at line 934
return $cont; return $cont;
} }
################################################# #################################################
# SQL escape function # SQL escape function
################################################# #################################################
function sqlesc($str) function sqlesc($str)
{ {
global $mylink; global $mylink;
if (version_compare(phpversion(),"4.3.0") == "+1") return mysqli_escape_string($mylink, $str);
return mysql_real_escape_string($str, $mylink);
else
return mysql_escape_string($str);
} }
################################################# #################################################
# Content filtering functions # Content filtering functions
################################################# #################################################
function filterIn($type, $text) function filterIn($type, $text)
{ {
switch ($type) { switch ($type) {
case "text": case "text":
$text = htmlspecialchars($text); $text = htmlspecialchars($text);
break; break;
case "link": case "link":
# do not strip & in links # do not strip & in links
$text = htmlspecialchars($text); $text = htmlspecialchars($text);
$text = ereg_replace("&amp;", "&", $text); $text = preg_replace("/&amp;/", "&", $text);
break; break;
case "bool": case "bool":
if ($text == "on") $text = 1; if ($text == "on") $text = 1;
if ($text != "1") $text = 0; if ($text != "1") $text = 0;
break; break;
} }
return $text; return $text;
} }
function filterOut($type, $text) function filterOut($type, $text)
 End of changes. 56 change blocks. 
80 lines changed or deleted 87 lines changed or added

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