$displaytext"; } elseif(!empty($image)){ $ad = "\"$displaytext\""; } } } } return $ad; } function display_sponsor_link($base_url,$id){ $sql = "SELECT displaytext,url,height,width,customcode from sponsorads WHERE id = $id && status = 1 LIMIT 1"; $result = @mysql_query($sql); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $displaytext = stripslashes($row['displaytext']); $url = $row['url']; $height = $row['height']; $width = $row['width']; $customcode = stripslashes($row['customcode']); if(!empty($customcode)){ return $customcode; exit; } if(!empty($url) && !empty($displaytext)){ $ad = $base_url."sponsorout.php?id=$id"; } } } return $ad; } function insert_rating($frompage,$itemid,$rating){ if($rating > 0 && $rating < 6){ $insert_rating = mysql_query("UPDATE items set votes=votes+1, points=points+$rating where id = '$itemid'"); }else{ if($rating=="yes"){ $insert_rating = mysql_query("UPDATE items set yes=yes+1 where id = '$itemid'"); } elseif($rating=="no"){ $insert_rating = mysql_query("UPDATE items set no=no+1 where id = '$itemid'"); } } header("Location: ".$frompage.""); exit; } function random_image(){ $files = array(); $file2 = ""; $output = ""; if ($handle2 = opendir("./content/images")) { while (false !== ($file = readdir($handle2))) { if ($file != "." && $file != "..") { $files[] = $file; } } closedir($handle2); } $getRand = mt_rand(0, count($files) - 1); for ($i = 0 ; $i < count($files) ; $i++) { $file2 = $files[$getRand]; } return $file2; } // This fuction is called after someone puts in their email address to be sent a new password function send_password($emailaddress,$sitename,$contact_email,$rewrite,$base_url) { $sql_query = "SELECT id,username,email FROM users WHERE email = '$emailaddress' LIMIT 1"; $result = mysql_query($sql_query); // If the user entered a email address in the system, then it will pull the user's information // and generate a new password if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $user_id = $row['id']; $user_name = $row['username']; $user_email = $row['email']; } $alphanum = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789"; // generate random password $newpassword = substr(str_shuffle($alphanum), 0, 8); $encodedpw = md5($newpassword); // Puts the user's password in the database $add_new_password = mysql_query ("update users set password = '$encodedpw' where id = $user_id"); // Email message sent to the user with their new password $msg .='Below please find your username and password that is registered with '.$sitename.'.

'; $msg .='Username: '.$user_name.'
'; $msg .='New Password: '.$newpassword.'
'; $msg .='Feel free to login and change your current password from your EDIT profile section
'; $msg .='Thank you!'; $to = "$user_email"; $subject = "Password Recovery"; $headers ="Return-Path: ".$contact_email."\r\n"; $headers .= "From: ".$sitename." <".$contact_email.">\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html\r\n"; mail($to, $subject, $msg, $headers); $_SESSION['status']="An email has been sent to your account with your new password. Thank you!"; } // If the user entered an email address not in the system, this message is displayed else { $_SESSION['status']="Could not find that email address on file."; } // User is then redirected to the page confirming their account is now active if($rewrite==1) header("Location: ".$base_url."Forgot-Password.html"); else header("Location: ".$base_url."index.php?action=forgotpw"); exit; } function count_comments($itemid){ $sql = "SELECT count(id) AS commented_on from comments WHERE itemid = '$itemid' && status = 1"; //store the SQL query in the result variable $result = @mysql_query($sql); $i = mysql_fetch_array($result); $commented_on = $i['commented_on']; return $commented_on; } function get_username($userid,$default_user){ $sql_query = "SELECT username FROM users WHERE id = '$userid' && status = 1 LIMIT 1"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $username = stripslashes($row['username']); } } else{ $username = $default_user; } return $username; } function get_item_title($itemid){ $sql_query = "SELECT title FROM items WHERE id = '$itemid' && status = 1 LIMIT 1"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $itemtitle = stripslashes($row['title']); } } return $itemtitle; } function get_group_name($groupid){ $sql_query = "SELECT title FROM groups WHERE id = '$groupid' && status = 1 LIMIT 1"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $grouptitle = stripslashes($row['title']); } } return $grouptitle; } function is_url($url) { if (!preg_match('#^http\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $url)) { return false; } else { return true; } } function is_logged_in($base_url,$rewrite){ if($_SESSION['loggedin']!=1){ if($rewrite==1) header("Location: ".$base_url."Register.html"); else header("Location: ".$base_url."index.php?action=register"); exit; } } function clean_string($string){ $string = mysql_real_escape_string($string); return $string; } function make_friendly($string){ $string = strtolower($string); // remove all characters except spaces, a-z and 0-9 $string = ereg_replace("[^a-z0-9 ]", "", $string); // make all spaces single spaces $string = ereg_replace(" +", " ", $string); // replace spaces with - $string = str_replace(" ", "-", $string); $string = $string.".html"; return $string; } function make_friendly_no_ext($string){ $string = strtolower($string); // remove all characters except spaces, a-z and 0-9 $string = ereg_replace("[^a-z0-9 ]", "", $string); // make all spaces single spaces $string = ereg_replace(" +", " ", $string); // replace spaces with - $string = str_replace(" ", "-", $string); return $string; } function get_item_status($status){ if($status=0) $status="Inactive"; elseif($status=1) $status="Active"; elseif($status=2) $status="Inactive"; elseif($status=3) $status="Waiting for Approval"; return $status; } // This fuction is called to log the user's IP address info into the userlog function log_user() { if ($_SERVER['HTTP_X_FORWARD_FOR']) { $myip = $_SERVER['HTTP_X_FORWARD_FOR']; } else { $myip = $_SERVER['REMOTE_ADDR']; } $_SESSION['userip'] = $myip; $myid=$_SESSION['loggedinuserid']; $myusername = $_SESSION['loggedinuser']; // Check to see if the user is a Search Engien if(empty($myusername)) $myusername = se_spider($uagent); // END SE Check $currentpage = curPageURL(); $time = time(); $delete_query2 = "SELECT ipaddress,usertime FROM userlog"; $delete_exec2 = mysql_query ($delete_query2); while ($delete_result2 = mysql_fetch_array ($delete_exec2)) { $delete_time2 = $delete_result2["usertime"]; if ($delete_time2 < ($time - 86400)) { $delete_ip = $delete_result2["ipaddress"]; $query2 = "DELETE FROM userlog WHERE ipaddress='$delete_ip'"; $exec2 = mysql_query ($query2); } } $check_query2 = "SELECT ipaddress FROM userlog WHERE ipaddress='$myip'"; $check_exec2 = mysql_query ($check_query2); $check2 = mysql_num_rows ($check_exec2); if ($check2 == 0) { $refdomain = $_SESSION['refdomain']; $refpage = $_SESSION['refpage']; $insert_query2 = "INSERT INTO userlog (userid,username,ipaddress,usertime,pageviews,refdomain,refpage,currentpage) VALUES ('$myid','$myusername','$myip','$time','1','$refdomain','$refpage','$location')"; $insert_exec2 = mysql_query ($insert_query2); } else { $update_query2 = "UPDATE userlog SET usertime='$time', userid='$myid', username='$myusername', currentpage='$currentpage', pageviews=pageviews+1 WHERE ipaddress='$myip'"; $update_exec2 = mysql_query ($update_query2); } } function ban_check($type){ if ($_SERVER['HTTP_X_FORWARD_FOR']) { $myip = $_SERVER['HTTP_X_FORWARD_FOR']; } else { $myip = $_SERVER['REMOTE_ADDR']; } /* $myip2 $myip3 $myip4 */ if ($type == "site") $check_query2 = "SELECT ipaddress FROM banned WHERE ipaddress='$myip' && type = '2'"; else $check_query2 = "SELECT ipaddress FROM banned WHERE ipaddress='$myip'"; $check_exec2 = mysql_query ($check_query2); $check2 = mysql_num_rows ($check_exec2); if ($check2 != 0) $banned = "banned"; return $banned; } function add_link($websitename,$websiteurl,$websitedescription,$emailaddress,$base_url){ // First need to make sure all the required information is filled out if (empty($websitename) || empty($websiteurl) || empty($emailaddress)){ $_SESSION['submitstatus'] = "You have not entered all the required information for your link trade."; header("Location: ".$base_url."index.php?action=tradelinks"); /* Redirect browser */ return; } // End Required Check // Now we need to check and see if that URL is already in the database $array=parse_url($websiteurl); $websiteurl1 = $array['host']; $websiteurl2 = str_replace("www.", "", $websiteurl1); $websiteurl3 = "http://".trim($websiteurl2); $websiteurl4 = "http://www.".$websiteurl2; $duplicate_check = "select * from links where url like '$websiteurl1%' || url like '$websiteurl3%' || url like '$websiteurl4%'"; $duplicate_result = mysql_query($duplicate_check); if (mysql_num_rows($duplicate_result)>0){ $_SESSION['submitstatus'] = "That link is already in our database."; header("Location: ".$base_url."index.php?action=tradelinks"); /* Redirect browser */ exit; } // End Duplicate Check // Time to add the link $insert_link = mysql_query("INSERT into links set title = '$websitename', url = '$websiteurl', description = '$websitedescription', email = '$emailaddress', status = '1'"); // End Adding Link return; } function login_user($base_url,$username,$password,$frompage,$cookieme,$rewrite){ $sql = "SELECT id,preapproved,ugroup from users where username = '$username' AND password = '$password' AND status = '1'"; $result = mysql_query($sql); $num = mysql_numrows($result); if ($num != "0") { $_SESSION['loggedin'] = 1; $_SESSION['loggedinuser'] = $username; while($row = mysql_fetch_array($result)) { $userid = $row['id']; $_SESSION['loggedinuserid'] = $userid; $usergroup = $row['ugroup']; $_SESSION['usergroup'] = $usergroup; $_SESSION['preapproved'] = $row['preapproved']; } // Get group submission status $sql_query = "SELECT approval,maxday,ratio,minhits,minpoints FROM groups WHERE id = '$usergroup' && status = 1 LIMIT 1"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $_SESSION['approval'] = $row['approval']; $_SESSION['maxday'] = $row['maxday']; $_SESSION['ratio'] = $row['ratio']; $_SESSION['minhits'] = $row['minhits']; $_SESSION['minpoints'] = $row['minpoints']; } } $_SESSION['loggedinuserid'] = $userid; // If User wants to keep their info in a cooke then set the cookies if ($cookieme == 1){ // 7776000 = 90 days setcookie("un", "$username", time()+7776000); setcookie("unp", "$password", time()+7776000); } // End Cookie Setting $todaysdate = time(); $result = mysql_query( "update users set laston = '$todaysdate' where id = '$userid'"); header('Location: '.$frompage.''); exit; } else { if($rewrite==1) $newpwlink= $base_url."Forgot-Password.html"; else $newpwlink=$base_url."index.php?action=forgotpw"; if($rewrite==1) $reglink= $base_url."Register.html"; else $reglink=$base_url."index.php?action=register"; $_SESSION['loginstatus'] = "Invalid Login! If you have forgotten your password please click here to request a new one. If you have not registered yet for an account, feel free to click here to register."; header('Location: '.$frompage.''); exit(); } } function get_user_group($userid){ $sql_query2 = "SELECT ugroup FROM users WHERE id = $userid"; $result2 = mysql_query($sql_query2); if(mysql_num_rows($result2)) { //output as long as there are still available fields while($row = mysql_fetch_array($result2)) { $groupid = $row['ugroup']; } } else $groupid = 0; return $groupid; } function get_comments($base_url,$itemid,$template_directory,$commentlimit){ $CommentTemplate = file_get_contents("./templates/".$template_directory."/comment.html"); if($commentlimit>0) $commentlimit = "LIMIT $commentlimit"; else $commentlimit=""; $sql_query = "SELECT id,userid,comment,dateadded from comments WHERE itemid = '$itemid' ORDER by dateadded DESC $commentlimit"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $commentid = $row['id']; $comment = nl2br(stripslashes($row['comment'])); $commentuser = $row['userid']; $commentdate1 = $row['dateadded']; $commentuser = get_username($commentuser,"Guest"); $commentdate = date("M j",$commentdate1); $commenttime = date("g:i a",$commentdate1); if ($_SESSION['adminloggedin']==1) $deletecomment = ""; else $deletecomment = ""; // Templating Array for displaying $bodytags = array( "%comment%", // Displays the comment "%commentuser%", // Displays the username for the comment "%commentdate%", // Displays the date of the comment "%commenttime%", // Displays the time of the comment "%deletecomment%", // Admin delete comment link ); $bodyreplacements = array( "$comment", // Displays the comment "$commentuser", // Displays the username for the comment "$commentdate", // Displays the date of the comment "$commenttime", // Displays the time of the comment "$deletecomment", // Admin delete comment link ); $content.=str_replace($bodytags,$bodyreplacements,$CommentTemplate); } } return $content; } function link_item($base_url,$rewrite,$trackclicks,$contentid,$contenttitle2,$contenturl){ // If you are tracking clicks or framing out is on, then it will use the following links if ($trackclicks == 1){ // If SE FRIENDLY URLS are turned ON it will display the SE FRIENDLY LINK ... ELSE it will display the non-SE Friendly link if ($rewrite == 1) $contentlink = $base_url."media/".$contentid."/".$contenttitle2; else $contentlink = $base_url."itemout.php?id=".$contentid; } // End tracking clicks links // Otherwise it will use the following link else{ $contentlink = $contenturl; } return $contentlink; } // This fuction is called to confirm a user's account is EMAIL confirmation is turned on and // the user clicks on their link in the email function confirm_account($un,$confirmation,$base_url,$rewrite,$email_confirmation) { $find_user = "SELECT id,status,confirmation,referredby FROM users WHERE username = '$un'"; $find_user_result = mysql_query($find_user); if(mysql_num_rows($find_user_result)) { while($row = mysql_fetch_array($find_user_result)) { $uid = $row['id']; $user_status = $row['status']; $user_confirmation_number = $row['confirmation']; $referredby = $row['referredby']; } } // If the user is banned or already confirmed, they will be redirected to the main page if ($user_status != 3) { header("Location: $base_url"); exit; } // If the confirmation link is invalid, they will be redirected to the main page if ($confirmation != $user_confirmation_number) { header("Location: $base_url"); exit; } // If the user's confirmation link is correct, the user is confirmed $update_status = mysql_query("update users set status= '1' where id = $uid"); if($referredby>0){ $sql_query = "SELECT ugroup FROM users WHERE id = '$referredby'"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $group = $row['ugroup']; } } else{ $group = 0; } $sql_query = "SELECT refpoints FROM groups WHERE id = '$group'"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $refpoints = $row['refpoints']; } } else{ $refpoints = 0; } $update_ref_points = mysql_query("UPDATE users set points=points+$refpoints where id = '$referredby'"); } if($rewrite==1) $outlink = $base_url."Account-Confirmed.html"; else $outlink = $base_url."index.php?action=accountconfirmed"; // User is then redirected to the page confirming their account is now active header("Location: ".$outlink.""); exit; } function resize($filename,$width,$height,$newwidth,$newheight) { $format = 'image/jpeg'; $source = imagecreatefromjpeg($dir_name . $filename); $thumb = imagecreatetruecolor($newwidth,$newheight); imagealphablending($thumb, false); //$source = @imagecreatefromjpeg($dir_name . $filename); imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); $filename=$output_dir . $filename; @imagejpeg($thumb, $filename); return; } function credit_user_domain($referral1,$referral2){ $sql_query = "SELECT id,userid FROM domains WHERE domain = '$referral2' || domain = '$referral1' LIMIT 1"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $domainid = $row['id']; $domainuser = $row['userid']; // Now we need to see how many points this user gets $sql_query = "SELECT ugroup FROM users WHERE id = '$domainuser'"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $group = $row['ugroup']; } } else{ $group = 0; } $sql_query = "SELECT inpoints FROM groups WHERE id = '$group'"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $inpoints = $row['inpoints']; } } else{ $inpoints = 0; } // Now its time to update the domain and user stats $update_domain = mysql_query("UPDATE domains set dayin=dayin+1, hitsin=hitsin+1 where id = '$domainid'"); $update_user = mysql_query("UPDATE users set points=points+$inpoints where id = '$domainuser'"); } } return; } function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } function se_spider(){ $uagent = $_SERVER['HTTP_USER_AGENT']; if(eregi("googlebot",$uagent)) $content = "GoogleBot"; elseif(eregi("ia_archiver",$uagent)) $content = "Alexa"; elseif(eregi("msnbot",$uagent)) $content = "MSN"; elseif(eregi("wget",$uagent)) $content = "WGET :: Possible Leech"; elseif(eregi("yahoo",$uagent)) $content = "Yahoo!"; elseif(eregi("teomaagent",$uagent)) $content = "Teoma"; elseif(eregi("slurp",$uagent)) $content = "Slurp"; elseif(eregi("ask jeeves",$uagent)) $content = "Ask Jeeves"; if(!empty($content)) $content="$content"; return $content; } function online_users(){ $CurTime = time(); $CutOff = $CurTime - 600; $sql = "SELECT count(ipaddress) AS online_users from userlog WHERE usertime > $CutOff"; //store the SQL query in the result variable $result = mysql_query($sql); $i = mysql_fetch_array($result); $online_users = $i['online_users']; return $online_users; } ?> $today) && (startdate = 0 || startdate < $today) ORDER BY RAND() LIMIT $limit"; //store the SQL query in the result variable $result = mysql_query($featured_query); if(mysql_num_rows($result)) { while($row = mysql_fetch_array($result)) { $plugtitle = stripslashes($row['title']); $plugtitle2 = make_friendly($plugtitle); $plugimage = $row['image']; $plugurl = $row['url']; $plugid = $row['id']; $plugalttext = stripslashes($row['alttext']); if ($rewrite == 1) $plugurl = $base_url."plug/".$plugid."/".$plugtitle2; else $plugurl = $base_url."plugout.php?id=".$plugid; $featuredcontent = $featuredcontent."\"$plugalttext\" "; } } return $featuredcontent; } function most_popular($base_url,$trackclicks,$frameout,$rewrite,$default_image,$template_directory,$limit){ $x = 0; $sql_query = "SELECT title,id,url,image from items WHERE status = 1 && image != '' ORDER BY hits DESC LIMIT $limit"; //store the SQL query in the result variable $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $x++; $contenttitle = ucwords(stripslashes($row['title'])); $id = $row['id']; $contenturl = $row['url']; $contentimage = $row['image']; $title = make_friendly($contenttitle); if(empty($contentimage)) $contentimage = $base_url."templates/".$template_directory."/images/".$default_image; else $contentimage = $base_url."content/images/".$contentimage; if ($trackclicks == 1 || $frameout == 1){ if ($rewrite == 1) $itemlink = $base_url."media/".$id."/".$title; else $itemlink = $base_url."itemout.php?id=".$id; } else{ $itemlink = $contenturl; } $content.="\"$contenttitle\""; if ($x==2){ $content.="
"; $x=0; } } } return $content; } function list_category_feeds($base_url,$trackclicks,$rewrite){ if ($rewrite != 0 && $trackclicks != 0){ $sql_query2 = "SELECT * FROM categories WHERE status = 1 ORDER by title ASC"; $result2 = mysql_query($sql_query2); if(mysql_num_rows($result2)) { //output as long as there are still available fields while($row = mysql_fetch_array($result2)) { $catid = $row['id']; $catname = $row['title']; $catname = stripslashes($catname); $feeds = $feeds."- $catname
"; } } } return $feeds; } function latest_searches($base_url,$rewrite,$limit){ $x = 0; $sql_query = "SELECT * from searches WHERE results > 0 ORDER BY date DESC LIMIT $limit"; //store the SQL query in the result variable $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $x++; $searchid = $row['id']; $searchterm = stripslashes($row['searchterm']); $title = make_friendly($searchterm); if (strlen($searchterm>25)) $searchterm2 = substr($searchterm,0,25)."..."; else $searchterm2 = $searchterm; if ($rewrite == 1) $itemlink = "".$searchterm2.""; else $itemlink = "".$searchterm2.""; $content = $content.$x." ".$itemlink."
"; } } return $content; } function submit_category_list(){ $sql_query2 = "SELECT * FROM categories WHERE status = 1 ORDER by title ASC"; $result2 = mysql_query($sql_query2); if(mysql_num_rows($result2)) { //output as long as there are still available fields while($row = mysql_fetch_array($result2)) { $catid = $row['id']; $catname = $row['title']; $catname = stripslashes($catname); $content = $content.""; } } return $content; } function cat_jump_list($rewrite,$base_url){ $content = "
"; $content = $content.''; $content = $content. ''; $content = $content. '
'; return $content; } function display_links($base_url,$sortlinks,$realurl){ if ($sortlinks ==1) $orderby = "ORDER BY dayin DESC"; elseif ($sortlinks ==2) $orderby = "ORDER BY totalin DESC"; elseif ($sortlinks ==3) $orderby = "ORDER BY title ASC"; else $orderby = "ORDER BY RAND()"; $sql_query = "SELECT * FROM links WHERE status = 1 $orderby"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $linkid = $row['id']; $websitename = stripslashes($row['title']); $websiteurl = $row['url']; $websitedescription = stripslashes($row['description']); $totalin = $row['totalin']; $totalout = $row['totalout']; if ($realurl ==1) $websitelink = "$websitename"; else $websitelink = "$websitename"; $content = $content."$websitelink $websitedescription (IN: $totalin | OUT: $totalout)
"; } } return $content; } function display_top_links($base_url,$sorttoplinks,$maxtoplinks,$realurl){ if ($sorttoplinks ==1) $orderby = "ORDER BY dayin DESC"; elseif ($sorttoplinks ==2) $orderby = "ORDER BY totalin DESC"; elseif ($sorttoplinks ==3) $orderby = "ORDER BY title ASC"; else $orderby = "ORDER BY RAND()"; $sql_query = "SELECT * FROM links WHERE status = 1 $orderby LIMIT $maxtoplinks"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $linkid = $row['id']; $websitename = stripslashes($row['title']); $websiteurl = $row['url']; $websitedescription = stripslashes($row['description']); // Trims the link name down to 40 characters if (strlen($websitename)>25) $websitename = substr($websitename,0,25)."..."; $totalin = $row['totalin']; $dayin = $row['dayin']; if ($realurl ==1) $websitelink = "$websitename"; else $websitelink = "$websitename"; $content = $content.$websitelink."
"; } } return $content; } function get_user_stats($template_directory){ $StatsTemplate = file_get_contents("./templates/".$template_directory."/userstats.html"); $loggedinid = $_SESSION['loggedinuserid']; $username = $_SESSION['loggedinuser']; // Get the amount of points the user has $sql_query = "SELECT points,referrals FROM users WHERE id = '$loggedinid'"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $userpoints = $row['points']; $userreferrals = $row['referrals']; } } // Get the usre's domain stats $hitsin = 0; $hitsout = 0; $sql_query = "SELECT hitsin,hitsout FROM domains WHERE userid = '$loggedinid'"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $domainhitsin = $domainhitsin+$row['hitsin']; $domainhitsout = $domainhitsout+$row['hitsout']; } } // Get the total number of hits out from user submitted items $sql = "SELECT SUM(hits)AS sum_hits FROM `items` WHERE userid = '$loggedinid'"; $result = mysql_query($sql); $i = mysql_fetch_array($result); $itemhitsout = $i['sum_hits']; // Calculate the hits ratio $totalhits = $domainhitsin+$domainhitsout; if($totalhits<1) $ratio="0%"; else{ if($domainhitsout==0) $ratio = $domainhitsin*100; else $ratio = ($domainhitsin/$domainhitsout)*100; } $ratio = round($ratio,2); // Templating Array for displaying $bodytags = array( "%points%", // Number of points the user has "%domainhitsin%", // Number of hits in the user has from their submitted domain(s) "%domainhitsout%", // Number of hits out the user has from their submitted domain(s) "%itemhitsout%", // Number of hits out the user has from their submitted item(s) "%ratio%", // Current user traffic ratio (domain + item combined) "%referrals%", // Number of referrals the user has "%username%", // The username of the user ); $bodyreplacements = array( "$userpoints", // Number of points the user has "$domainhitsin", // Number of hits in the user has from their submitted domain(s) "$domainhitsout", // Number of hits out the user has from their submitted domain(s) "$itemhitsout", // Number of hits out the user has from their submitted item(s) "$ratio", // Current user traffic ratio (domain + item combined) "$userreferrals", // Number of referrals the user has "$username", // The username of the user ); $content.= str_replace($bodytags,$bodyreplacements,$StatsTemplate); $content.= "
".get_user_items($template_directory); return $content; } function get_user_items($template_directory){ $UserItemsTemplate = file_get_contents("./templates/".$template_directory."/useritems.html"); $loggedinid = $_SESSION['loggedinuserid']; // Get the user's item stats $hitsin = 0; $hitsout = 0; $sql_query = "SELECT id,title,url,hits,status,date,votes,points,yes,no FROM items WHERE userid = '$loggedinid' ORDER BY date DESC"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $itemurl = $row['url']; $itemtitle = stripslashes($row['title']); $itemid = $row['id']; $itemhits = $row['hits']; $itemdate1 = $row['date']; $itemstatus = $row['status']; $itempoints = $row['points']; $itemvotes = $row['votes']; $itemyes = $row['yes']; $itemno = $row['no']; $itemdate = date("M j Y",$itemdate1); $itemtime = date("g:i a",$itemdate1); $itemstatus = get_item_status($itemstatus); // Templating Array for displaying $bodytags = array( "%itemtitle%", // Title of the item "%itemurl%", // URL to the item "%date%", // Item submit date "%time%", // Iteem submit time "%views%", // Item views "%itemstatus%", // Item status ); $bodyreplacements = array( "$itemtitle", // Title of the item "$itemurl", // URL to the item "$itemdate", // Item submit date "$itemtime", // Iteem submit time "$itemhits", // Item views "$itemstatus", // Item status ); $content.= str_replace($bodytags,$bodyreplacements,$UserItemsTemplate); } } return $content; } function get_user_domains($template_directory,$base_url,$rewrite){ $UserDomainsTemplate = file_get_contents("./templates/".$template_directory."/userdomains.html"); $UserDomainStatsTemplate = file_get_contents("./templates/".$template_directory."/userdomainstats.html"); $loggedinid = $_SESSION['loggedinuserid']; $username = $_SESSION['loggedinuser']; // Get the user's domain stats $sql_query = "SELECT id,domain,title,hitsin,hitsout,dayin,dayout FROM domains WHERE userid = '$loggedinid' && status = 1 ORDER BY title ASC"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $domainid = $row['id']; $domain = $row['domain']; $domaintitle = stripslashes($row['title']); $hitsin = $row['hitsin']; $hitsout = $row['hitsout']; $dayin = $row['dayin']; $dayout = $row['dayout']; // Calculate the ratios if($dayin < 1) $dayratio = "0"; elseif($dayout < 1) $dayratio = $dayin*100; else $dayratio = ($dayin / $dayout)*100; $dayratio =round($dayratio,2)."%"; if($hitsin < 1) $totalratio = "0"; elseif($hitsout < 1) $totalratio = $hitsin*100; else $totalratio = ($hitsin / $hitsout)*100; $totalratio = round($totalratio,2)."%"; $deleteicon = $base_url."templates/$template_directory/images/icon_delete.gif"; if($rewrite ==1) $deletelink = $base_url."Delete-Domain-$domainid.html"; else $deletelink = $base_url."index.php?action=deletedomain&id=$domainid"; // Templating Array for displaying each domain and its stats $bodytags = array( "%domain%", // The domain name "%domaintitle%", // Title for the domain the user entered "%totalin%", // Total number of hits in the domain has sent "%totalout%", // Total number of hits out to the domain "%dayin%", // Number of hits in TODAY from the domain "%dayout%", // Number of hits out TODAY to the domain "%dayratio%", // Ratio of hits in/out for TODAY "%totalratio%", // Overall ratio of hits in/out "%deleteicon%", // This will display the DELETE IMAGE ICON "%deletelink%", // This is the link that will be used to delete the domain ); $bodyreplacements = array( "$domain", // The domain name "$domaintitle", // Title for the domain the user entered "$hitsin", // Total number of hits in the domain has sent "$hitsout", // Total number of hits out to the domain "$dayin", // Number of hits in TODAY from the domain "$dayout", // Number of hits out TODAY to the domain "$dayratio", // Ratio of hits in/out for TODAY "$totalratio", // Overall ratio of hits in/out "$deleteicon", // This will display the DELETE IMAGE ICON "$deletelink", // This is the link that will be used to delete the domain ); $userdomains.= str_replace($bodytags,$bodyreplacements,$UserDomainStatsTemplate); } } // See if there are any status/error messages that need to be displayed on the page if(!empty($_SESSION['status'])){ $status = $_SESSION['status']."
"; $_SESSION['status']=""; } // Templating Array for displaying $bodytags = array( "%username%", // The username of the user "%status%", // Displays the status (and error messages) "%userdomains%", // List of the user's domains ); $bodyreplacements = array( "$username", // The username of the user "$status", // Displays the status (and error messages) "$userdomains", // List of the user's domains ); $content.= str_replace($bodytags,$bodyreplacements,$UserDomainsTemplate); return $content; } function display_comment_item($itemid,$template_directory,$base_url,$default_user,$rewrite,$frameout,$default_image){ $CommentItemTemplate = file_get_contents("./templates/".$template_directory."/commentitem.html"); $sql_query = "SELECT * FROM items WHERE id = $itemid && status = 1 LIMIT 1"; $result = mysql_query($sql_query); if(mysql_num_rows($result)) { //output as long as there are still available fields while($row = mysql_fetch_array($result)) { $itemurl = $row['url']; $itemtitle = stripslashes($row['title']); $itemdescription = nl2br(stripslashes($row['description'])); $itemimage = $row['image']; $itemhits = $row['hits']; $itemdate1 = $row['date']; $itemcategory = $row['category']; $itempoints = $row['points']; $itemvotes = $row['votes']; $itemyes = $row['yes']; $itemno = $row['no']; $itemuser = $row['userid']; $itemuser = get_username($itemuser,$default_user); $itemtitle2 = make_friendly($itemtitle); $itemdate = date("M j Y",$itemdate1); $itemtime = date("g:i a",$itemdate1); // Get Category Name $category_query = "SELECT title,defaultimage FROM categories where id = $itemcategory && status = 1 LIMIT 1"; //store the SQL query in the result variable $result = mysql_query($category_query); if(mysql_num_rows($result)) { while($row = mysql_fetch_array($result)) { $itemcategorytitle = stripslashes($row['title']); $itemcategorydefaultimage = $row['defaultimage']; } } else $itemcategorytitle = "Media"; if(empty($itemcategorydefaultimage)) $itemcategorydefaultimage = $base_url."templates/".$template_directory."/images/".$default_image; else $itemcategorydefaultimage = $base_url."templates/".$template_directory."/images/".$itemcategorydefaultimage; if(empty($itemimage)) $itemimage = $itemcategorydefaultimage; else $itemimage = $base_url."content/images/".$itemimage; $itemcategorytitle2 = make_friendly($itemcategorytitle); // End getting Category Name // Make the Category for the Item Hyperlinked if ($itemcategory>0){ if($rewrite==1) $itemcategorylink=$base_url."categories/$itemcategory/$itemcategorytitle2"; else $itemcategorylink=$base_url."index.php?c=$itemcategory"; } $itemouturl = link_item($base_url,$rewrite,$trackclicks,$itemid,$itemtitle2,$itemurl); // Templating Array for displaying $bodytags = array( "%itemtitle%", // Title of the item "%itemurl%", // URL to the item "%itemouturl%", // OUT URL to the item "%date%", // Item submit date "%time%", // Iteem submit time "%views%", // Item views "%itemdescription%", // Item description "%itemimage%", // Item Image "%category%", // Item Category "%categorylink%", // Item Category URL "%submittedby%", // Username of who submitted the item ); $bodyreplacements = array( "$itemtitle", // Title of the item "$itemurl", // URL to the item "$itemouturl", // OUT URL to the item "$itemdate", // Item submit date "$itemtime", // Iteem submit time "$itemhits", // Item views "$itemdescription", // Item description "$itemimage", // Item Image "$itemcategorytitle", // Item Category "$itemcategorylink", // Item Category URL "$itemuser", // Username of who submitted the item ); $content.= str_replace($bodytags,$bodyreplacements,$CommentItemTemplate); } } return $content; } ?>