function random_photo(){ $info = $GLOBALS["Member"]->info(); if(!$GLOBALS["settings"][show_unapproved]) $add = " AND photos.approved='1' "; else $add = ""; $ages[1]["start"] = adodb_mktime(0,0,59,date("n"),date("j"),date("Y")-18); $ages[1]["end"] = adodb_mktime(0,0,59,date("n"),date("j"),date("Y")-25); $ages[2]["start"] = adodb_mktime(0,0,59,date("n"),date("j"),date("Y")-26); $ages[2]["end"] = adodb_mktime(0,0,59,date("n"),date("j"),date("Y")-32); $ages[3]["start"] = adodb_mktime(0,0,59,date("n"),date("j"),date("Y")-33); $ages[3]["end"] = adodb_mktime(0,0,59,date("n"),date("j"),date("Y")-40); $ages[4]["start"] = adodb_mktime(0,0,59,date("n"),date("j"),date("Y")-41); $sql_query = "SELECT * FROM photo_settings WHERE mem_id=".$info["mem_id"]; $settings = $GLOBALS["DB"]->row($sql_query); if($settings["gender"]) $add.= " AND profiles.gender='".$settings["gender"]."'"; if($settings["age"]){ if($ages[$settings["age"]]["start"]) $add.= " AND profiles.birthdate <= ".$ages[$settings["age"]]["start"]; if($ages[$settings["age"]]["end"]) $add.= " AND profiles.birthdate >= ".$ages[$settings["age"]]["end"]; }//if if($settings["keyword"]) $add.= " AND photos.caption LIKE '%".mysql_escape_string($settings["keyword"])."%' "; $pho_id = $GLOBALS["Get"]->type_val("pho_id","integer"); if($pho_id) $sql_query = "SELECT pho_id,mem_id,photo,posted,caption FROM photos WHERE pho_id=".$pho_id; else $sql_query = "SELECT pho_id,photos.mem_id,photos.photo,photos.posted,photos.caption FROM photos,profiles WHERE photos.mem_id=profiles.mem_id AND voting='1' ".$add." AND photos.mem_id!=".$info["mem_id"]." ORDER BY RAND() LIMIT 0,1"; $photo = $GLOBALS["DB"]->row($sql_query); $photo["posted"] = photo_posted($photo["posted"]); $photo["caption"] = hs_wordwrap($photo["caption"],50); if($photo["mem_id"]){ $photo["link"]["profile"] = build_link("profile",$photo["mem_id"]); $photo["link"]["message"] = "index.php?page=mailbox§ion=message&recipient=".$photo["mem_id"]; $photo["link"]["instant_message"] = "javascript:HS_LaunchChat(".$photo["mem_id"].")"; $photo["link"]["ecard"] = "index.php?page=ecards&recipient_id=".$photo["mem_id"]; }//if if($photo["photo"]){ $GLOBALS["forms"]["rate_photo"]["start"] = ereg_replace("\"rate_pho_id\" value=\"\"","\"rate_pho_id\" value=\"".$photo["pho_id"]."\"",$GLOBALS["forms"]["rate_photo"]["start"]); $sql_query = "SELECT * FROM photo_comments WHERE pho_id=".$photo["pho_id"]; $result = $GLOBALS["DB"]->result($sql_query); $comments = array(); foreach($result as $res){ $comment["author"] = $GLOBALS["Network"]->card($res["mem_id"]); $comment["comment"] = nl2br($res["comment"]); $comments[] = $comment; }//foreach $GLOBALS["smarty"]->assign("comments",$comments); }//if $GLOBALS["smarty"]->assign("photo",$photo); }//random_photo