Location: PHPKode > scripts > SelectaPix Image Gallery > classes/admin_page.php
<?php
/* +----------------------------------------------------------------------+
   |SelectaPix Open Source Gallery	                                      |
   +----------------------------------------------------------------------+
   | Copyright (c) 2004 OutOfTheTrees			                          |
   |                                                                      |
   | http://www.outofthetrees.co.uk/index.php                             |
   | 												                      |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.0 of the GPL license,       |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.outofthetrees.co.uk/license/2_0.txt.                      |
   | If you did not receive a copy of the SelectaPix license and are 	  |
   | unable to obtain it through the world-wide-web, please send a note   |
   | to hide@address.com so we can mail you a copy immediately.|
   +----------------------------------------------------------------------+ */
if (!defined("ACCESS")) {
    die ("Direct request denied");
}

class admin_page {

	var $f, $update_album, $add_sub_album, $delete_album, $delete_image, $update_image, $action;

	function admin_page($f) {
		$this->f =& $f;
		$this->site_name = SITE_NAME;
		$this->site_url = SITE_URL;
		$this->site_dir = SITE_DIR;
		$this->site_path = SITE_PATH;
		$this->img_dir = IMAGE_DIR;
		$this->album_table = SQL_ABM_TBL;
		$this->image_table = SQL_IMG_TBL;
	}

	function handle_post() {
		$this->f->util->ForceInt((@$this->albumID = $_REQUEST['albumID']), 0);
		$this->f->util->ForceInt((@$this->parentID = $_REQUEST['parentID']), 0);
		$this->f->util->ForceInt((@$this->parent_albumID = $_REQUEST['parent_albumID']), 0);
		$this->f->util->ForceInt((@$this->imageID = $_REQUEST['imageID']), 0);
	    @$update_album = $_POST['update_album'];
	    @$add_album = $_POST['add_album'];
	    @$add_sub_album = $_POST['add_sub_album'];
	    @$delete_album = $_POST['delete_album'];
	    @$delete_image = $_POST['delete_image'];
	    @$update_image = $_POST['update_image'];
	    @$action = $_GET['action'];
	    $img = $this->f->objectBuilder->NewFrameworkObject($this->f, "image");
	    $abm = $this->f->objectBuilder->NewFrameworkObject($this->f, "album");
	    if($update_album && ($_SESSION['RoleLevel'] < 2)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
		elseif($update_album && ($_SESSION['RoleLevel'] >= 2)) {
	        $this->news = $abm->update_album();
	    }
	    if($add_album && ($_SESSION['RoleLevel'] < 4)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
		elseif($add_album && ($_SESSION['RoleLevel'] >= 4)) {
	        $this->news = $abm->add_album('0');
	    }
	    if($add_sub_album && ($_SESSION['RoleLevel'] < 4)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
		elseif($add_sub_album && ($_SESSION['RoleLevel'] >= 4)) {
	        $this->news = $abm->add_album($this->parent_albumID);
	    }
	    if($delete_album && ($_SESSION['RoleLevel'] < 4)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
		elseif($delete_album && ($_SESSION['RoleLevel'] >= 4)) {
	        $this->news = $abm->delete_album();
	    }
	    if($delete_image && ($_SESSION['RoleLevel'] < 4)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
		elseif($delete_image && ($_SESSION['RoleLevel'] >= 4)) {
	        $this->news = $img->delete_image();
	    }
	    if(($action == 'enable_image') && ($_SESSION['RoleLevel'] < 2)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
		elseif(($action == 'enable_image') && ($_SESSION['RoleLevel'] >= 2)) {
	        $this->news = $img->update_image_status($action, $_GET['target']);
	    }
	    if(($action == 'disable_image') && ($_SESSION['RoleLevel'] < 2)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
		elseif(($action == 'disable_image') && ($_SESSION['RoleLevel'] >= 2)) {
	        $this->news = $img->update_image_status($action, $_GET['target']);
	    }
	    if(($action == 'enable_album') && ($_SESSION['RoleLevel'] < 2)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
		elseif(($action == 'enable_album') && ($_SESSION['RoleLevel'] >= 2)) {
	        $this->news = $abm->update_album_status($action, $_GET['target']);
	    }
	    if(($action == 'disable_album') && ($_SESSION['RoleLevel'] < 2)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
		elseif(($action == 'disable_album') && ($_SESSION['RoleLevel'] >= 2)) {
	        $this->news = $abm->update_album_status($action, $_GET['target']);
	    }
	    if($update_image && ($_SESSION['RoleLevel'] < 2)) {
	        $this->news = '<p class="badnews">You do not have sufficient administrative rights to perform this action</p>';
	    }
	    if($update_image && ($_SESSION['RoleLevel'] >= 2)) {
	    	$this->news = $img->update_image();
	        // Check if the image has been moved to a new album
	        $data = $this->f->conn->query($img->get_albumid_by_imageid($this->imageID));
	        if(($data[0]['albumID'] != $this->f->util->ForceInt($_POST['albumID'], 0)) && ($data[0]['parent_albumID'] != $this->f->util->ForceInt($_POST['parentID'], 0))) {
	        	$this->news .= '<p class="goodnews">You have successfully moved this image from this album.</p>#@# - MOVED - #@#';
	        }
	    }
	    return $this->news;
	}

	function upload_links($albumID, $parentID) {
		echo "\n\n<div class=\"addpics\">Upload images to this album:<br />";
	    echo "<a href=\"upload.php?albumID=".$albumID."&amp;parentID=$parentID&amp;request=single\">\n";
	    echo "<img src=\"images/upload_single_image_small.gif\" width=\"24\" height=\"24\" alt=\"Upload single image\" />single</a>\n";
	    echo "<a href=\"upload.php?albumID=".$albumID."&amp;parentID=$parentID&amp;request=multiple\">\n";
	    echo "<img src=\"images/upload_multiple_images_small.gif\" width=\"24\" height=\"24\" alt=\"Upload multiple images\" />multiple</a></div>\n\n";
	}
}
?>
Return current item: SelectaPix Image Gallery