Jump to content
MakeWebGames

[Script] [ $12.00 ] vGallery


Sim

Recommended Posts

Demo Page: http://www.cellphonerpg.info/vGallery/

Price: $12.00

vGallery

Thank you for coming to help me with a few things in the vGallery script I am developing. The vGallery script is set up for one user to be able to create there own personal website gallery online. Everything is coded using with some Object Oriented Programming Methods. You could also create other admin's if you truely wanted to from phpMyAdmin to give them admin powers as well.

 

Who is the Virtual Gallery Script for?

* Artists

* Website Owners

* Beginner/Novice php/mySQL programmers

What kind of Features are given to Members?

* User Login

* User Logout

* User Registration

* User Profile's

* User Stats

* Image Comment System

* Image Rating System

* Image View Count

* Category View Count

* Forgot Password

* Categories and Multiple category browsing

*

Site Admin Can...

* View Stats

* View Script News

* Email Members (3 seperate type of emails, active, inactive or all)

* Edit News

* Edit Categories

* Add/Edit Categories

* Add/Edit Pending Comments

* Add/Edit Images

misc info

Script uses smarty templating

Thanks for reading guy's... thats it for now.. check it out.. PM me or leave your username here and i'll make you admin to check out the script if your interested.. Also, you can add me on msn; contact+orpgcreator.com

Edited by Sim
Link to comment
Share on other sites

Code Sample:

<?
include "../includes/constants.php";
class category
{
//vars
private $db;
private $smarty;


public function __construct($dbRef, $smartyRef)
{
	//vars
	$this->db = $dbRef;
	$this->smarty = $smartyRef;

	//if adding a category
	if(isset($_POST['SubmitForm']))
	{
		$this->AddCategory($_POST['textCat'], $_POST['select'], $_POST['textDesc'],$_POST['selectLogin'], "new");
	}

	//see what we are doing here...
	switch ($_GET['what'])
	{
		case "add";
			$this->displayAddCategory(0);
			$this->smarty->assign("site_page", "Add category");
			break;
		case "manage";

			if(isset($_POST['StartEditDetails']))
			{
				$this->displayEditDetails($this->db->escape($_POST['hidden']));
			}
			elseif(isset($_POST['StartDelete']))
			{
				$this->displayConfirmDelete();
			}
			elseif(isset($_POST['ConfirmDelete']))
			{
				$this->proccessDelete();
				$this->displayCategoryListings();
			}
			elseif(isset($_POST['EditDetails']))
			{
				$this->AddCategory($_POST['textCat'], $_POST['select'], $_POST['textDesc'],$_POST['selectLogin'], "edit");
			}
			else
			{
				$this->smarty->assign("site_page", "Manage Categories");
				$this->displayCategoryListings();
			}

			break;
	}

}

//delete categories and file's
public function proccessDelete()
{
	//current category
	$rec = $this->db->fetch("SELECT catSubID, catTitle FROM " . CAT_TABLE . " WHERE catID='" . $this->db->escape($_POST['hidden']) . "'");
	$rows = $this->db->fetch_array("SELECT imageID, imageFileType FROM " . IMAGE_TABLE . " WHERE imageCatID='" . $rec['catSubID'] . "'");

	//delete current category images
	foreach($rows as $rec2)
	{
		unlink("../images/" . $rec2['imageID'] . '.' . $rec2['imageFileType']);
	}


	//get sub categories
	$recs = $this->db->fetch("SELECT COUNT(catID) AS ammount FROM " . CAT_TABLE . " WHERE catSubID='" . $this->db->escape($_POST['hidden']) . "'");

	//if sub categories
	if($recs['ammount'] > 0)
	{
		//set some default values..
		$cont = false;
		$max = 1;
		$i = 0;

		$IDS[] = $this->db->escape($_POST['hidden']);

		//loop threw all words
		while($max > $i)
		{
			$rec = $this->db->fetch("SELECT *, COUNT(catID) AS amount FROM " . CAT_TABLE . " WHERE catSubID='" . $IDS[$i] . "'");
			$msg .= $rec['catTitle'] . " Category and Images deleted...<br>";

			if($rec['amount'] > 0)
			{
				$IDS[] = $rec['catID'];
				$max++;
			}

			$i++;

		}


		//loop threw all cat ids to be deleted
		for($i=0; $i<count($IDS);$i++)
		{

			//get all images associated with category being deleted
			$rows = $this->db->fetch_array("SELECT imageID, imageFileType FROM " . IMAGE_TABLE . " WHERE imageCatID='" . $IDS[$i] . "'");

			//cycle threw all image records
			foreach($rows as $rec)
			{
				//if file exists
				if(is_file("../images/" . $rec['imageID'] . '.' . $rec['imageFileType']))
				{
					//delete image file
					unlink("../images/" . $rec['imageID'] . '.' . $rec['imageFileType']);
				}
			}

			//delete records
			$this->db->del("DELETE FROM " . CAT_TABLE . " WHERE catID='" . $IDS[$i] . "'");
			$this->db->del("DELETE FROM " . IMAGE_TABLE . " WHERE imageCatID='" . $IDS[$i] . "'");
		}
	}

	//first category.. delete from
	$this->db->del("DELETE FROM " . IMAGE_TABLE . " WHERE imageCatID='" . $this->db->escape($_POST['hidden']) . "'");
	$this->db->del("DELETE FROM " . CAT_TABLE . " WHERE catID='" . $this->db->escape($_POST['hidden']) . "'");
	$this->smarty->assign("msg", $msg);
}

//display confirm delete buttton
public function displayConfirmDelete()
{
	$this->smarty->assign("delete", 'y');
	$this->smarty->assign("id", $_POST['hidden']);

}

//display details to edit
public function displayEditDetails($id)
{
	//query
	$rec = $this->db->fetch("SELECT catID, catSubID, catSubID, catTitle, catDesc, catReqLogin FROM " . CAT_TABLE . " WHERE catID='$id'");


	//set template vars
	$this->smarty->assign("edit", 'y'); 
	$this->smarty->assign("id", $rec['catID']); 
	$this->smarty->assign("name", $rec['catTitle']); 
	$this->smarty->assign("desc", $rec['catDesc']); 
	$this->smarty->assign("login_" . $rec['catReqLogin'], "selected"); 

	//list categories
	$this->displayAddCategory($rec['catSubID']);
}

//attempt to add category
public function addCategory($cat_name, $select, $desc, $login_req, $action)
{
	//query to check if category name exists for sub category if one selected..
	$rec = $this->db->fetch("SELECT COUNT(*) AS ammount FROM " . CAT_TABLE . " WHERE catTitle='" . $this->db->escape($cat_name) . "' AND catSubID='" . $this->db->escape($select) . "'");


	//setup data
	$data = array("catTitle" => $cat_name, "catDesc" => $desc,"catReqLogin" => $login_req,  "catSubID" => $select, "catDate" => time());

	if($action == "edit")
	{
		//update record
		$this->db->update(CAT_TABLE, $data, "catID='" . $_POST['hidden'] . "'");
		$this->smarty->assign("msg", "<BR>Category updated...");
		$this->displayCategoryListings();
	}

	//category doesn't exist, create it
	if($rec['ammount'] == 0 && $action == "new")
	{
		//insert data
		$this->db->insert(CAT_TABLE, $data);
		$this->smarty->assign("msg", "<BR>Category created...");
	}
	elseif($action == "new")
	{
		$this->smarty->assign("msg", "<BR>Category name allready exists...");
	}
}

//display categories for category add form
public function displayAddCategory($selected)
{
	//query
	$rows = $this->db->fetch_array("SELECT catID, catSubID, catTitle FROM " . CAT_TABLE . " ORDER BY catTitle");

	$selects[0] = "None"; 
	//loop through records
	foreach($rows as $rec)
	{
		$selects[$rec['catID']] = $rec['catTitle']; 
	}


	//set template var
	$this->smarty->assign("selects", $selects); 
	$this->smarty->assign("selected", $selected); 
}


//display all categories with some stats
public function displayCategoryListings()
{
	$Data = array();
	//query
	$rows = $this->db->fetch_array("SELECT * FROM " . CAT_TABLE . " ORDER BY catTitle");

	//loop through records
	foreach($rows as $rec)
	{			
		//set data for category in template
		$Data[] = array('name' => $rec['catTitle'], 'login_req' => $rec['catReqLogin'], 'id' => $rec['catID'], 'downloads' => $row['ammount'], 'views' => $rec['catViews'], 'description' => $rec['catDesc']);
	} 

	//assign template vars
	$this->smarty->assign("looper", $Data); 
	$this->smarty->assign("list", 'y'); 
}

}
?>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...