$counter % $GLOBALS['opt_photos_line']; $i--) photo_list_empty(); photo_line_end(); } photo_list_end(); } function view_topic() { if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lread']) error(MSG_e_f_norightsread); $forum=$GLOBALS['forum']; $topic=$GLOBALS['topic']; $link=$GLOBALS['link']; $rated=common_topic_view($topic); $sql = "SELECT ph.* FROM ".$GLOBALS['DBprefix']."Photo ph WHERE ph_tid=$topic"; $res = db_query($sql,$link); $phdata=db_fetch_array($res); db_free_result($res); $tdata=$GLOBALS['intopic']; $sql = "SELECT p.*, u.u__name, u.u_id FROM ".$GLOBALS['DBprefix']."Post p, ".$GLOBALS['DBprefix']."User u ". "WHERE p.p_tid=$topic AND u.u_id=p.p_uid AND p.p__premoderate=0 ORDER BY p_id"; $res = db_query($sql,$link); $pdata=db_fetch_array($res); photo_display($tdata,$phdata,$pdata,$rated); $numrows=db_num_rows($res); if ($numrows>1) { photo_discuss_start(); while ($phentry=db_fetch_array($res)) { photo_discuss_entry($phentry); } photo_discuss_end($tdata['t_id']); } $trash['p__bcode']=$GLOBALS['inforum']['f_bcode']; $trash['p__smiles']=$GLOBALS['inforum']['f_smiles']; if ($GLOBALS['inuserlevel']>=$GLOBALS['inforum']['f_lpost']) photo_discuss_form($trash,MSG_ph_addcoment,"do_post"); } function do_post() { $link=$GLOBALS['link']; $tid=$GLOBALS['topic']; process_post($tid); topic_message(MSG_a_commentadded,1); } function add_photo() { $pdata['p__bcode']=$GLOBALS['inforum']['f_bcode']; $pdata['p__smiles']=$GLOBALS['inforum']['f_smiles']; photo_edit_form($tdata,$pdata,"do_topic",MSG_ph_adding); } function do_topic() { if ($GLOBALS['inuserlevel']<$inforum['f_ltopic']) error(MSG_e_t_norights); if ($GLOBALS['inforum']['f_status']!=0) error(MSG_e_f_closed); $forum=$GLOBALS['forum']; $link=$GLOBALS['link']; if (!getvar("p_text")) $_POST['p_text']=str_repeat(" ",$GLOBALS['opt_minpost']+1); if (!getvar("t_title")) { $sql = "SELECT COUNT(*)+1 FROM ".$GLOBALS['DBprefix']."Topic WHERE t_fid=".$GLOBALS['forum']; $res = db_query($sql,$link); list($count)=db_fetch_row($res); db_free_result($res); $_POST['t_title']=MSG_photo." ".$count; } if (!$GLOBALS['opt_photos_line']) $GLOBALS['opt_photos_line']=5; if (!$GLOBALS['opt_photo_thumb_y']) $GLOBALS['opt_photo_thumb_y']=100; // if (!$GLOBALS['opt_photo_size_x']) $GLOBALS['opt_photo_size_x']=720; if (!$GLOBALS['opt_thumb_qlty']) $GLOBALS['opt_thumb_qlty']=70; if (!$GLOBALS['opt_photo_qlty']) $GLOBALS['opt_photo_qlty']=70; if (!is_uploaded_file($_FILES['photo']['tmp_name'])) error(MSG_e_ph_nophoto); $fh=fopen($_FILES['photo']['tmp_name'],"rb"); $buffer=fread($fh,$_FILES['photo']['size']); fclose($fh); $fullimg=imagecreatefromstring($buffer); if (!$fullimg) error(MSG_e_ph_badfile); $sizey=imagesy($fullimg); $sizex=imagesx($fullimg); $coeff=$sizex/$sizey; $thumb=imagecreatetruecolor(floor($GLOBALS['opt_photo_thumb_y']*$coeff),$GLOBALS['opt_photo_thumb_y']); if ($GLOBALS['opt_GD2']) imagecopyresampled($thumb,$fullimg,0,0,0,0,$GLOBALS['opt_photo_thumb_y']*$coeff,$GLOBALS['opt_photo_thumb_y'],$sizex,$sizey); else imagecopyresized($thumb,$fullimg,0,0,0,0,floor($GLOBALS['opt_photo_thumb_y']*$coeff),$GLOBALS['opt_photo_thumb_y'],$sizex,$sizey); $tmpname=tempnam("temp/","ph"); imagejpeg($thumb,$tmpname,$GLOBALS['opt_thumb_qlty']); $fh=fopen($tmpname,"r"); $thumbdata=addslashes(fread($fh,filesize($tmpname))); fclose($fh); unlink($tmpname); if ($GLOBALS['opt_photo_size_x']) { $photo=imagecreatetruecolor($GLOBALS['opt_photo_size_x'],floor($GLOBALS['opt_photo_size_x']/$coeff)); if ($GLOBALS['opt_GD2']) imagecopyresampled($photo,$fullimg,0,0,0,0,$GLOBALS['opt_photo_size_x'],floor($GLOBALS['opt_photo_size_x']/$coeff),$sizex,$sizey); else imagecopyresized($photo,$fullimg,0,0,0,0,$GLOBALS['opt_photo_size_x'],$GLOBALS['opt_photo_size_x']/$coeff,$sizex,$sizey); $tmpname=tempnam("temp/","ph"); imagejpeg($photo,$tmpname,$GLOBALS['opt_photo_qlty']); $fh=fopen($tmpname,"r"); $photodata=addslashes(fread($fh,filesize($tmpname))); fclose($fh); unlink($tmpname); } else $photodata=addslashes($buffer); imagedestroy($fullimg); if ($GLOBALS['opt_photo_size_x']) imagedestroy($photo); imagedestroy($thumb); $trash=rand(); $key=substr(md5($trash),0,8); $sqldata = build_sql("t_"); $sqldata.= check_topic_params(); $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Topic SET t_fid=$forum, $sqldata"; $res = db_query($sql,$link); $tid = db_insert_id($res); $sql = "INSERT INTO ".$GLOBALS['DBprefix']."Photo SET ph_tid=".$tid.", ph_key=\"$key\", ph_thumb=\"$thumbdata\", ph_image=\"$photodata\""; $res = db_query($sql,$link); $pid=process_post($tid); topic_increment($forum,$tid,$pid); topic_message(MSG_a_added,1); } function edit_photo() { $link=$GLOBALS['link']; $tid=$GLOBALS['topic']; $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Topic WHERE t_id=$tid"; $res = db_query($sql,$link); $tdata = db_fetch_array($res); db_free_result($res); $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=$tid"; $res = db_query($sql,$link); $pdata=db_fetch_array($res); db_free_result($res); $sql = "DELETE FROM ".$GLOBALS['DBprefix']."TopicView WHERE tid=$tid"; $res = db_query($sql,$link); photo_edit_form($tdata,$pdata,"do_edit",MSG_a_edit); } function do_edit() { if ($inuserlevel<$inforum['f_lmoderate']) error(MSG_e_t_norights); $forum=$GLOBALS['forum']; $link=$GLOBALS['link']; $sqldata = build_sql("t_"); $sql = "UPDATE ".$GLOBALS['DBprefix']."Topic SET $sqldata WHERE t_id=".$GLOBALS['topic']; $res = db_query($sql,$link); $tid = db_insert_id($res); if (!$GLOBALS['opt_photos_line']) $GLOBALS['opt_photos_line']=5; if (!$GLOBALS['opt_photo_thumb_y']) $GLOBALS['opt_photo_thumb_y']=100; // if (!$GLOBALS['opt_photo_size_x']) $GLOBALS['opt_photo_size_x']=720; if (!$GLOBALS['opt_thumb_qlty']) $GLOBALS['opt_thumb_qlty']=70; if (!$GLOBALS['opt_photo_qlty']) $GLOBALS['opt_photo_qlty']=70; if (is_uploaded_file($_FILES['photo']['tmp_name'])) { $fh=fopen($_FILES['photo']['tmp_name'],"rb"); $buffer=fread($fh,$_FILES['photo']['size']); fclose($fh); $fullimg=imagecreatefromstring($buffer); if (!$fullimg) error(MSG_e_ph_badfile); $xsize=imagesx($fullimg); $ysize=imagesy($fullimg); $coeff=$xsize/$ysize; $thumb=imagecreate(floor($GLOBALS['opt_photo_thumb_y']*$coeff),$GLOBALS['opt_photo_thumb_y']); if ($GLOBALS['opt_GD2']) imagecopyresampled($thumb,$fullimg,0,0,0,0,$GLOBALS['opt_photo_thumb_y']*$coeff,$GLOBALS['opt_photo_thumb_y'],$sizex,$sizey); else imagecopyresized($thumb,$fullimg,0,0,0,0,floor($GLOBALS['opt_photo_thumb_y']*$coeff),$GLOBALS['opt_photo_thumb_y'],$sizex,$sizey); $tmpname=tempnam("temp/","ph"); imagejpeg($thumb,$tmpname,$GLOBALS['opt_thumb_qlty']); $fh=fopen($tmpname,"r"); $thumbdata=addslashes(fread($fh,filesize($tmpname))); fclose($fh); unlink($tmpname); if ($GLOBALS['opt_photo_size_x']) { $photo=imagecreate($GLOBALS['opt_photo_size_x'],floor($GLOBALS['opt_photo_size_x']/$coeff)); if ($GLOBALS['opt_GD2']) imagecopyresampled($thumb,$fullimg,0,0,0,0,$GLOBALS['opt_photo_size_x'],floor($GLOBALS['opt_photo_size_x']/$coeff),$sizex,$sizey); else imagecopyresized($photo,$fullimg,0,0,0,0,$GLOBALS['opt_photo_size_x'],$GLOBALS['opt_photo_size_x']/$coeff,$sizex,$sizey); $tmpname=tempnam("temp/","ph"); imagejpeg($photo,$tmpname,$GLOBALS['opt_photo_qlty']); $fh=fopen($tmpname,"r"); $photodata=addslashes(fread($fh,filesize($tmpname))); fclose($fh); unlink($tmpname); } else $photodata=$buffer; imagedestroy($full); imagedestroy($photo); imagedestroy($thumb); $sql = "UPDATE ".$GLOBALS['DBprefix']."Photo SET ph_thumb=\"$thumbdata\", ph_image=\"$photodata\" WHERE ph_tid=".$GLOBALS['topic']; $res = db_query($sql,$link); } $sql = "SELECT MIN(p_id) FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=".$GLOBALS['topic']; $res = db_query($sql,$link); list($pid)=db_fetch_row($res); $sqldata = build_sql("p_"); $sqldata.= check_post_params(); $sql = "UPDATE ".$GLOBALS['DBprefix']."Post SET $sqldata WHERE p_id=$pid"; $res = db_query($sql,$link); topic_message(MSG_a_saved,1); } function do_delete_photo() { if ($inuserlevel<$inforum['f_lmoderate']) error(MSG_e_t_norights); $tid=$GLOBALS['topic']; $link=$GLOBALS['link']; $sql = "DELETE FROM ".$GLOBALS['DBprefix']."Photo WHERE ph_tid=$tid"; $res = db_query($sql,$link); delete_topic($tid); forum_resync($GLOBALS['forum']); $GLOBALS['refpage']="index.php?f=".$GLOBALS['forum']; message(MSG_t_deleted); } function do_print() { $link=$GLOBALS['link']; $tid=$GLOBALS['topic']; $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Topic WHERE t_id=$tid"; $res = db_query($sql,$link); $tdata = db_fetch_array($res); db_free_result($res); $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Post WHERE p_tid=$tid LIMIT 1"; $res = db_query($sql,$link); $pdata=db_fetch_array($res); db_free_result($res); $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Photo WHERE ph_tid=$tid"; $res = db_query($sql,$link); $phdata = db_fetch_array($res); photo_print_form($tdata,$phdata,$pdata); } function delete_confirm() { $params['t']=$GLOBALS['topic']; confirm("photos","do_delete_photo",$params,MSG_a_deleteconfirm." ".$GLOBALS['intopic']['t_title'],"index.php?t=".$GLOBALS['topic']); } function edit_comment() { $link=$GLOBALS['link']; if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lmoderate']) error(MSG_e_mod_norights); $pid = getvar("p"); $sql = "SELECT * FROM ".$GLOBALS['DBprefix']."Post WHERE p_id=$pid AND p_tid=".$GLOBALS['topic']; $res = db_query($sql,$link); $pdata = db_fetch_array($res); photo_discuss_form($pdata,MSG_a_editcoment,"do_edit_comment"); } function do_edit_comment() { if (getvar("delete")) { do_delete_comment(); return; } $pid=getvar("p"); $link=$GLOBALS['link']; if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lmoderate']) error(MSG_e_mod_norights); unset($_POST['p_uid']); unset($_POST['p_tid']); $inforum=$GLOBALS['inforum']; $sqldata = build_sql("p_"); $sqldata .= check_post_params(); $sql = "UPDATE ".$GLOBALS['DBprefix']."Post SET $sqldata WHERE p_id=\"$pid\""; $res = db_query($sql,$link); topic_message(MSG_p_edited,1); } function do_delete_comment() { $pid=getvar("p"); $link=$GLOBALS['link']; if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lmoderate']) error(MSG_e_mod_norights); delete_post($pid); topic_resync($GLOBALS['topic']); forum_resync($GLOBALS['forum']); topic_message(MSG_p_deleted); } function photos_locations($locations) { push_parents($locations,$GLOBALS['inforum']['f_parent']); if ($GLOBALS['action']=="photos_view") { if ($GLOBALS['topic']) { array_push($locations,"".$GLOBALS['inforum']['f_title'].""); array_push($locations,$GLOBALS['intopic']['t_title']); } else { array_push($locations,$GLOBALS['inforum']['f_title']); } } if ($GLOBALS['action']=="edit_photo") { array_push($locations,MSG_ph_edit); } elseif ($GLOBALS['action']=="edit_comment") { array_push($locations,MSG_ph_editcomment); } elseif ($GLOBALS['action']=="add_photo") { array_push($locations,MSG_ph_adding); } return $locations; }