$max_width){ $scale = (float)$max_width/(float)$width; $width = (int) $width*$scale; $height = (int) $height*$scale; } if($height>$max_height){ $scale = (float)$max_height/(float)$height; $width = (int) $width*$scale; $height = (int) $height*$scale; } return array($width,$height); } function logout() { global $f; session_start(); session_destroy(); // header ("Set-Cookie: logged=$f; expires=Wed, 2-Jan-1987 00:00:00 GMT; path=/;"); // header ("Set-Cookie: modlogin=$f; expires=Wed, 2-Jan-1987 00:00:00 GMT; path=/;"); // header ("Set-Cookie: ivadmin=$f; expires=Wed, 2-Jan-1987 00:00:00 GMT; path=/;"); setcookie("logged","",0,'/','',0); setcookie("modlogin","",0,'/','',0); setcookie("ivadmin","",0,'/','',0); header("index.php"); } if ((isset($f)) && $f == "logout") logout(); require ("config.php"); langindex(); if (!$template) $template = "template1.php"; $cookieinfo = $HTTP_COOKIE_VARS[logged]; $originalc=$c; // $u (user) $c (category) $f (function) $id ( id #) if(!isset($c)) $c = "all"; if(IsSet($men_x)) $c="men"; if(IsSet($women_x)) $c="women"; $lastpicture=""; // connect to the database until the end mysql_connect($host,$user,$pass); @mysql_select_db($database) or die( "Unable to select database"); // if visitor just voted, update the last image's record first if (!isset($vote)) { if(IsSet($vote1_x)) $vote=1; // support for image inputs if(IsSet($vote2_x)) $vote=2; if(IsSet($vote3_x)) $vote=3; if(IsSet($vote4_x)) $vote=4; if(IsSet($vote5_x)) $vote=5; if(IsSet($vote6_x)) $vote=6; if(IsSet($vote7_x)) $vote=7; if(IsSet($vote8_x)) $vote=8; if(IsSet($vote9_x)) $vote=9; if(IsSet($vote10_x)) $vote=10; } if (isset($vote)) { if ($vote != 99 && $vote > 10) $vote = 10; if($vote == "1") $whatvote = "one"; if($vote == "2") $whatvote ="two"; if($vote == "3") $whatvote ="three"; if($vote == "4") $whatvote ="four"; if($vote == "5") $whatvote ="five"; if($vote == "6") $whatvote ="six"; if($vote == "7") $whatvote ="seven"; if($vote == "8") $whatvote ="eight"; if($vote == "9") $whatvote ="nine"; if($vote == "10") $whatvote ="ten"; // if ($vote < 3) $oldrate+= 2; if ($donerep < 1) $donerep=0; if ($vote == "99") { if ($donerep <= 1) { $result=mysql_query("SELECT reported FROM $imagetable WHERE id = '$imgid'") or die(mysql_error()); $reports=mysql_result($result,0,"reported"); $reports++; mysql_query("UPDATE $imagetable SET reported = '$reports', reason = 'autobroken' WHERE id = '$imgid'") or die(mysql_error()); if ( $reports >= $maxreport) mysql_query("UPDATE $imagetable SET status = 'reported' WHERE id = '$imgid'") or die(mysql_error()); $donerep++; } $vote = "?"; $oldaverage = "?"; $oldtotal = "?"; $image = "broken.gif"; } else { $result=mysql_query("SELECT * FROM $imagetable WHERE id = '$imgid'"); $oldvoter1=mysql_result($result,0,"voter1"); $oldvoter2=mysql_result($result,0,"voter2"); $oldvoter3=mysql_result($result,0,"voter3"); $oldvoter4=mysql_result($result,0,"voter4"); $oldvoter5=mysql_result($result,0,"voter5"); $oldrate=mysql_result($result,0,"rate"); $oldno=mysql_result($result,0,$whatvote); $oldtotal=mysql_result($result,0,"total"); if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"] != "") $ip = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]; else $ip = $HTTP_SERVER_VARS["REMOTE_ADDR"]; if (strlen($ip) < 6) $ip = $REMOTE_ADDR; if ($oldvoter1 != $ip && $oldvoter2 != $ip && $oldvoter3 != $ip && $oldvoter4 != $ip && $oldvoter5 != $ip) { if ($vote != 0) $oldtotal++; $oldrate += $vote; $oldno++; $oldaverage = $oldrate/$oldtotal; $oldaverage = sprintf ('%0.1f', $oldaverage); mysql_query("UPDATE $imagetable SET voter1 = '$ip', voter2 = '$oldvoter1', voter3 = '$oldvoter2', voter4 = '$oldvoter3', voter5 = '$oldvoter4' where id = '$imgid'"); mysql_query("UPDATE $imagetable SET rate = '$oldrate', total = '$oldtotal', $whatvote = '$oldno', average = '$oldaverage' where id = '$imgid'"); } else { $oldaverage = $oldrate/$oldtotal; $oldaverage = sprintf ('%0.1f', $oldaverage); } if($oldtotal < $votesneeded) $oldaverage = "?"; $rrate = round ($oldaverage); $rrate--; } $lastpicture=""; if ($des) $lastpicture.="
".YOURVOTE." ".OVERALL." ".VOTES."
$vote $oldaverage $oldtotal
"; } // pick category option stripslashes($categories); if ($pickcat == "radio") { $pickcat = ""; $pickcat .= "
".DISPLAY."
"; foreach ($categories as $a) { $pickcat .= "$a
"; } $pickcat .= "
".VIEWALL; $pickcat .= "
"; } else { $pickcat = "";} // select next picture from the database if (isset($who)) { $result = mysql_query("SELECT id FROM $imagetable WHERE name = '$who' order by average desc LIMIT 1"); $id = mysql_result($result,0,"id"); } if ($id > 0){ $result = mysql_query("SELECT * FROM $imagetable WHERE id = '$id' LIMIT 1"); $rowz =mysql_num_rows($result); if ($rowz < 1) $id = 0; } if ($id > 0) { $query = "SELECT * FROM $imagetable WHERE id = '$id' LIMIT 1"; $counter = 0; $result = mysql_query("SELECT id FROM $imagetable WHERE status = 'active' order by id DESC"); while ($row = mysql_fetch_array ($result)) { if ($row["id"] == $id) { break; } $counter++; } $rnum = $counter; } else { srand ((double)microtime()*1000000); if ($c == "all") { if (($order == "loop")&& (isset($rnum))) { $result = mysql_query("SELECT id FROM $imagetable WHERE status = 'active' and category = '{$categories[0]}' order by id DESC"); $rnum++; $rowz = mysql_num_rows($result); if ($rowz < 1) { langerrors();print NOIMAGES; exit; } if ($rnum >= $rowz) $rnum = 0; } else { $result = mysql_query("SELECT id FROM $imagetable WHERE status = 'active' and category = '{$categories[0]}'"); $rowz = mysql_numrows($result); if ($rowz < 1) {langerrors();print NOIMAGES; exit;} $rnum = rand() % $rowz; } $query = "SELECT * FROM $imagetable WHERE id = "; $query .= mysql_result($result,$rnum,"id"); } else { // query for specific category $result = mysql_query("SELECT id FROM $imagetable WHERE category = '{$categories[0]}' AND status = 'active' order by name"); $rowz = mysql_numrows($result); if ($rowz < 1) {langerrors();print NOIMAGES; exit;} if (($order == "loop")&& (isset($rnum))) { $rnum++; if ($rnum >= $rowz) $rnum = 0; } else $rnum = rand() % $rowz; $query = "SELECT * FROM $imagetable WHERE id = "; $query .= mysql_result($result,$rnum,"id"); } } $result=mysql_query($query); $newuser=mysql_fetch_array($result); $newid =$newuser["id"]; $newmember=$newuser["name"]; $newurl =$newuser["url"]; $category =$newuser["category"]; $resize =$newuser["resize"]; $description =$newuser["description"]; // Loads id # of user's other images in $imgresult // the next two lines can be removed if you don't use this feature $imgresult=mysql_query("SELECT id FROM $imagetable WHERE name='$newmember'"); $numimages = mysql_num_rows($imgresult); $userresult = mysql_query("SELECT * FROM $usertable WHERE name= '$newmember'") or die(mysql_error()); $newinfo=mysql_fetch_array($userresult); /* delete this line to add the $homepage variable $result2 = mysql_query("SELECT homepage FROM $usertable WHERE name= '$newmember'"); $homepage = mysql_result($result2,0,"homepage"); delete this line to add the $homepage variable */ if ($reportauto == "yes") $autoreport = " name=userImage onAbort=\"document.reportForm.submit()\" onError=\"document.reportForm.submit()\""; if($resize == "yes") $newimage = "\n"; else { $newimage = "\n"; } if($max_width > 0 && (ereg( "[4-9]\.[0-9]\.[5-9].*", phpversion() ) || ereg("[4-9]\.[1-9]\.[0-9].*", phpversion() ) ) ) { list($image_width,$image_height) = GetImageSize($newurl); list($displaywidth,$displayheight) = resizepic($image_width,$image_height); $newimage = "\n"; } if ($commentson > 0) { // get sample comments for user if ($commentson == 1) $mailresult=mysql_query("SELECT * FROM $commenttable WHERE name='$newid' and status='ok' ORDER BY id DESC LIMIT $samplecomments"); else $mailresult=mysql_query("SELECT * FROM $commenttable WHERE name='$newid' ORDER BY id DESC LIMIT $samplecomments"); $samplecomments = mysql_num_rows($mailresult); if ($samplecomments == 0) { $samples = NOCOMMENTS; $samples .= "
".POSTCOMMENT.""; } else { $samples = VIEWERCOMMENTS.":
"; $bgcolor = "#E0E0E0"; $samples.= "\n"; while ($row = mysql_fetch_array($mailresult)) { $datearray[]=$row["datestamp"]; $comid=$row["id"]; $fromuser=$row["fromuser"]; $datestamp=$row["datestamp"]; $commentrate=$row["subject"]; $body=$row["body"]; $samples.= ""; if ( $bgcolor == "#E0E0E0") $bgcolor = "#F2F2F2"; else $bgcolor = "#E0E0E0"; } $samples.= ""; $samples.="
\n"; $samples.= BY.": $fromuser ($datestamp)  ".RATING.": $commentrate"; if (isset($ivadmin) || $fromuser==$logged) $samples .= "      [".REMOVE."]"; $samples.= "
$body
\n"; $samples.= "
".VIEWALLCOMS."  ".POSTCOMMENT."
"; } } mysql_close (); // done with database? better close it if ($numimages > 1) { $otherpics = "Other pictures for this user ($numimages total):
"; $i=1; while ($i <= $numimages) { $imid = mysql_result($imgresult,$i-1,"id"); if ($newid != $imid) $otherpics .= ""; $otherpics .= "Pic".$i; if ($newid != $imid) $otherpics .= ""; $otherpics .= "  "; $i=$i+1; } $otherpics.= "

"; } $loginbox = ""; if ($f == "logout") { setcookie("logged","",0,'/','',0); setcookie("modlogin","",0,'/','',0); setcookie("ivadmin","",0,'/','',0); $loginbox = LOGGEDOUT."

"; } if ((isset ($logged)) && ($f != "logout")) $loginbox = LOGGEDIN." $cookieinfo.

".YOURACCT."
".LOGOUT."
"; else { $loginbox .= "".SUBMITPIC."
"; //$loginbox .= "".LOGIN."
"; //$loginbox .= "".YOURACCT."
"; if ((!isset($logged) || ($f="logout"))) { $loginbox .="
"; $loginbox .=""; $loginbox .="

   User ID : "; $loginbox .="
Password : 
"; $loginbox .="
                "; $loginbox .="
"; } } if ((isset ($ivadmin)) && ($f != "logout")) $loginbox .= ADMINLOGGED; include ("./$template"); exit; ?>