All pastes #364730 Raw Edit

Mine

public text v1 · immutable
#364730 ·published 2007-02-20 11:04 UTC
rendered paste body
<?
/*--------------------------------------------+
| PHP-Fusion 6 - Content Management System    |
|---------------------------------------------|
| author: Nick Jones (Digitanium) ?2002-2005  |
| web: http://www.php-fusion.co.uk            |
| email: nick@php-fusion.co.uk                |
|---------------------------------------------|
| Released under the terms and conditions of  |
| the GNU General Public License (Version 2)  |
+---------------------------------------------+
| Photo Gallery coded by CrappoMan            |
| email: simonpatterson@dsl.pipex.com         |
+--------------------------------------------*/

require_once "../../maincore.php";
require_once BASEDIR."subheader.php";
require_once BASEDIR."side_left.php";

include LOCALE.LOCALESET."admin/main.php";
include LOCALE.LOCALESET."admin/photos.php";

if (file_exists(INFUSIONS."member_photo_upload/locale/".$settings['locale'].".php")) {
	include INFUSIONS."member_photo_upload/locale/".$settings['locale'].".php";
} else {
	include INFUSIONS."member_photo_upload/locale/English.php";
}

function builduseroptionlist($selected_user_id=1){
	global $db_prefix;
	$user_option_list="";
	$levels = array_reverse(array(1=>USER1, USER2, USER3, USER4), true);
	$modlevel = $levels[$modlevel];
	foreach($levels as $level=>$modlevel){
		$uresult=dbquery("SELECT * FROM ".$db_prefix."users WHERE user_mod='$level' ORDER BY user_name");
		if(dbrows($uresult)>0){
			$user_option_list.="<optgroup label='$modlevel'>";
			while($udata=dbarray($uresult)){
				if($udata['user_id']==$selected_user_id) {$sel=" selected";}else{$sel="";}
				$user_option_list.="<option $sel value='".$udata['user_id']."'>".$udata['user_name']."</option>";
			}
			$user_option_list.="</optgroup>";
		}
	}
	return $user_option_list;
}

if(!iMEMBER){
	opentable($locale['402']);
		echo $locale['MUP_004']."\n";
	closetable();
}elseif(isset($_POST['btn_cancel'])){
	fallback(FUSION_SELF."?album_id=".$album_id);
}elseif(($action == "deletephotopic") && isset($photo_id)) {
	if(file_exists(PHOTOS.$photo_id.".jpg")) unlink(PHOTOS.$photo_id.".jpg");
	if(file_exists(PHOTOS.$photo_id."t.jpg")) unlink(PHOTOS.$photo_id."t.jpg");
	fallback(FUSION_SELF."?action=editphoto&amp;photo_id=".$photo_id);
}elseif($action=="deletephoto"){
	if(isset($photo_id)){
		$data=dbarray(dbquery("SELECT album_id, photo_order FROM ".$db_prefix."photos WHERE photo_id='$photo_id'"));
		$album_id=$data['album_id'];
		$photo_order=$data['photo_order'];
		$result=dbquery("UPDATE ".$db_prefix."photos SET photo_order=(photo_order-1) WHERE photo_order>'$photo_order'");
		$result=dbquery("DELETE FROM ".$db_prefix."photos WHERE photo_id='$photo_id'");
		if(file_exists(PHOTOS.$photo_id.".jpg")) unlink(PHOTOS.$photo_id.".jpg");
		fallback(FUSION_SELF."?album_id=".$album_id);
	}
}elseif(isset($_POST['btn_save_photo'])){
	$photo_title=stripinput($photo_title);
	$result=dbquery("SELECT photo_title FROM ".$db_prefix."photos WHERE photo_title='$photo_title' AND photo_id<>'$photo_id' AND album_id='$album_id'");
	if(dbrows($result)!=0){
		$error=$locale['422'];
	}else{
		$error="";
		if($action=="editphoto"){
			if($photo_order<$photo_order2){
				$result=dbquery("UPDATE ".$db_prefix."photos SET photo_order=(photo_order+1) WHERE photo_order>='$photo_order' AND photo_order<'$photo_order2'");
			}elseif($photo_order>$photo_order2){
				$result=dbquery("UPDATE ".$db_prefix."photos SET photo_order=(photo_order-1) WHERE photo_order>'$photo_order2' AND photo_order<='$photo_order'");
			}
			$result=dbquery("UPDATE ".$db_prefix."photos SET album_id='$album_id',photo_title='$photo_title',photo_date='".time()."', user_id='$photo_added_by',photo_order='$photo_order' WHERE photo_id='$photo_id'");
		}else{
			if($photo_order==""){
				$photo_order=dbresult(dbquery("SELECT MAX(photo_order) FROM ".$db_prefix."photos WHERE album_id='$album_id'"),0)+1;
			}else{
				$result=dbquery("UPDATE ".$db_prefix."photos SET photo_order=(photo_order+1) WHERE photo_order>='$photo_order' AND album_id='$album_id'");
			}
			$result=dbquery("INSERT INTO ".$db_prefix."photos VALUES ('','$album_id','$photo_title','".time()."','".$userdata['user_id']."','0','$photo_order')");
		}
		$photo_id=dbresult(dbquery("SELECT photo_id FROM ".$db_prefix."photos WHERE photo_title='$photo_title' AND album_id='$album_id'"),0);
		if(is_uploaded_file($_FILES['photo_pic_file']['tmp_name'])){
			if($_FILES['photo_pic_file']['size']>=$settings['album_max_b']){
				$error=sprintf($locale['423'], $settings['album_max_b']);
			}elseif(!$imageFile=@getImageSize($_FILES['photo_pic_file']['tmp_name'])){
				$error=$locale['424'];
			}elseif($imageFile[2]<>2){
				$error=$locale['425'];
			}elseif($imageFile[0]>2000||$imageFile[1]>2000){
				$error=sprintf($locale['426'], $settings['album_max_w'], $settings['album_max_h']);
			}else{
				if(file_exists(PHOTOS.$photo_id.".jpg")) unlink(PHOTOS.$photo_id.".jpg");
				if(file_exists(PHOTOS.$photo_id."t.jpg")) unlink(PHOTOS.$photo_id."t.jpg");
				move_uploaded_file($_FILES['photo_pic_file']['tmp_name'], PHOTOS.$photo_id.".jpg");
				chmod(PHOTOS.$photo_id.".jpg",0644);
				createThumbnail(PHOTOS.$photo_id.".jpg",PHOTOS.$photo_id."t.jpg",$settings['thumb_image_w'],$settings['thumb_image_h']);
			}
		}
	}
	if($error<>""){
		opentable($locale['420']);
			echo"<div style='text-align:center'><p><span class='required'>".$locale['421']."</span><br /><span class='small'>$error</span></p></div>\n";
		closetable();
	}else{
		fallback(BASEDIR."photogallery.php?album=".$album_id);
	}
}elseif($action=="mup"){
	$data=dbarray(dbquery(
		"SELECT t1.photo_id id1, t2.photo_id id2, t1.album_id
		FROM ".$db_prefix."photos t1 INNER JOIN ".$db_prefix."photos t2
		WHERE t1.photo_order = t2.photo_order+1 AND t1.photo_id = '$photo_id' AND t2.album_id='$album_id'"
	));
	$id1=$data['id1'];
	$id2=$data['id2'];
	$result=dbquery("UPDATE ".$db_prefix."photos SET photo_order=photo_order-1 WHERE photo_id='$id1'");
	$result=dbquery("UPDATE ".$db_prefix."photos SET photo_order=photo_order+1 WHERE photo_id='$id2'");
	fallback(FUSION_SELF."?album_id=".$album_id);
}elseif($action=="mdown"){
	$data=dbarray(dbquery(
		"SELECT t1.photo_id id1, t2.photo_id id2, t1.album_id
		FROM ".$db_prefix."photos t1 INNER JOIN ".$db_prefix."photos t2
		WHERE t1.photo_order = t2.photo_order-1 AND t1.photo_id = '$photo_id' AND t2.album_id='$album_id'"
	));
	$id1=$data['id1'];
	$id2=$data['id2'];
	$result=dbquery("UPDATE ".$db_prefix."photos SET photo_order=photo_order+1 WHERE photo_id='$id1'");
	$result=dbquery("UPDATE ".$db_prefix."photos SET photo_order=photo_order-1 WHERE photo_id='$id2'");
	fallback(FUSION_SELF."?album_id=".$album_id);
}else{
	if($action=="editphoto"){
		$result=dbquery(
			"SELECT tp.*, user_name, COUNT(comment_id) comment_count
			FROM (".$db_prefix."photos tp INNER JOIN ".$db_prefix."users USING (user_id))
			LEFT JOIN ".$db_prefix."comments ON photo_id = comment_item_id AND comment_type = 'P'
			WHERE photo_id='$photo_id' GROUP BY photo_id ORDER BY photo_order"
		);
		$data=dbarray($result);
		$photo_id=$data['photo_id'];
		$album_id=$data['album_id'];
		$photo_title=stripslashes($data['photo_title']);
		$photo_added_by=$data['user_id'];
		$photo_added_by_name=$data['user_name'];
		$photo_order=$data['photo_order'];
		$photo_comments=$data['comment_count'];
		opentable($locale['401']." - ($photo_id - $photo_title)");
	}else{
		opentable($locale['402']);
	}

$result = dbquery("SELECT * FROM ".$db_prefix."photo_albums WHERE album_id=19 ORDER BY album_id DESC");
		while ($data = dbarray($result)) {
			$albumsel = ($album_id == $data['album_id'] ? " selected" : "");
			$albumlist .= "<option value='".$data['album_id']."'$albumsel>".$data['album_title']."</option>\n";
		}

	echo "<form name='frm_add_photo' method='post' action='".FUSION_SELF."' enctype='multipart/form-data'>\n";
	echo "<table align='center' cellspacing='0' cellpadding='0' class='tbl'>\n";
	echo "<input type='hidden' name='album_id' value='$album_id'>\n";
	if($action=="editphoto"){
		echo "<input type='hidden' name='photo_id' value='$photo_id'>\n";
		echo "<input type='hidden' name='action' value='editphoto'>";
		echo "<input type='hidden' name='photo_order2' value='$photo_order'>";
	}
	echo "<tr><td>".$locale['404'].":</td><td><input type='textbox' name='photo_title' value=\"$photo_title\" maxlength='100' class='textbox' style='width:250px;'></td></tr>\n";
	echo "<tr><td width='100'>".$locale['MUP_005']."</td>
<td><select name='album_id' class='textbox' style='width:250px;'>
$albumlist</select></td></tr>\n";

	if(file_exists(PHOTOS.$photo_id."t.jpg")){
		echo "<tr><td valign='top'>".$locale['406'].":</td><td><img src='".PHOTOS.$photo_id."t.jpg' border='1' alt='".$locale['418']."' width='".$settings['thumb_image_w']."' height='".$settings['thumb_image_h']."'></td></tr>\n";
	}
	echo "<tr><td valign='top'>".$locale['405'].":";
	if(file_exists(PHOTOS.$photo_id.".jpg")){
		echo "<br /><br /><a class='small' href='$PHP_SELF?action=deletephotopic&photo_id=$photo_id'>".$locale['412']."</a></td><td><img src='".PHOTOS.$photo_id.".jpg' border='1' alt='".$locale['418']."'>";
	}else{
		echo "</td><td><input type='file' name='photo_pic_file' class='textbox' style='width:250px;'><br />
<span class='small alt'>".sprintf($locale['419'], $settings['thumb_image_w'], $settings['thumb_image_h'])."</span>";
	}

	echo "</td></tr>\n<tr><td colspan='2' align='center'><hr><input type='submit' name='btn_save_photo' value='".$locale['414']."' class='button' style='width:80px;'>\n";
	if($action=="editphoto"){
		echo "<input type='submit' name='btn_cancel' value='".$locale['415']."' class='button' style='width:80px;'>\n";
	}
	echo "</td></tr>\n</table></form>\n";
	closetable();
	tablebreak();
	if($action=="editphoto" && $photo_comments>0){
		opentable("Photo Comments");
		$result = dbquery(
			"SELECT user_name, fc.*
			FROM ".$db_prefix."comments AS fc LEFT JOIN ".$db_prefix."users
			ON comment_name = user_id
			WHERE comment_item_id='$photo_id' AND comment_type='P'
			ORDER BY comment_datestamp ASC"
		);
		$cnt_comments = dbrows($result);
		if ($cnt_comments != 0) {
			$i = 1;
			while ($data = dbarray($result)) {
				echo "<span class=\"shoutboxname\">";
				if ($data['user_name']) {
					echo "<a href=\"".BASEDIR."profile.php?lookup=".$data['comment_name']."\">".$data['user_name']."</a>";
				} else {
					echo $data['comment_name'];
				}
				echo "</span><br />\n".parsesmileys(parseubb($data['comment_message']))."<br />\n<span class=\"shoutboxdate\">";
				echo strftime($settings['longdate'], $data['comment_datestamp'])."</span>\n";
				if ($i != $cnt_comments) {
					echo "<br /><br />\n";
				} else {
					echo "\n";
				}
				$i++;
			}
		} else {
			echo $locale['601']."\n";
		}
		closetable();
		tablebreak();
	}

}

echo "</td>\n";
include BASEDIR."side_right.php";
include BASEDIR."footer.php";
?>