So today ive attempted to create a page data handler for my new photography website system.
In on of my files in my project first calls these things:
PHP Code:
require_once("./config.php");
function check_content_status(){
$fetch = new fetchPageActions;
$main = new main_content_class;
$pg = isset($_GET["page"])? $_GET["page"]: 1;
$pga = isset($_GET["pageAction"])? $_GET["pageAction"]:"";
$fetchCount = count($fetch->fetchPage);
$fetchIfs = "";
$fetchAntiIfs = "";
$find = true;
for($i=0; $fetchCount>$i; $i++) {
if($pga==$fetch->fetchPage[$i]) {
$main->findPageData($fetch->fetchPgID[$pga]);
$find = false;
} else if($find && $pga!=$fetch->fetchPage[$i]) {
if($i+1==$fetchCount) {
$main->findPageData($pg);
}
}
}
}
$main = new main_content_class;
$main->getLinkData();
check_content_status();
$main->fetchPage($main->pageNumber, $main->type, $main->pageName, $main->doSideBar);
and when these things are called, its supposed to include another file adding some content to my website but it doesnt work.. I tweaked one small thing and it stopped working. I cant figure out what it is but maybe a fresh view will solve the mystery.. OH! and here is my main_content_class:
PHP Code:
class main_content_class {
/////////////////////////////////
//// Page content ////
///////////////////////////////
public $pageName;
public $pageNumber;
public $date;
public $data;
public $status;
public $doSideBar = false;
public $dos = true;
public $i = 0;
public $type;
public $redirectCode;
function findPageData($pgID) {
if(empty($pgID)){
$pgID = 1;
}
if(!is_numeric($pgID)){
die("page doesn't exist!");
}
$ck = mysql_query("SELECT * FROM mainContent WHERE page_id=".$pgID."");
while($row = mysql_fetch_array($ck)){
$this->i++;
}
if($this->i == 0){
die("page doesn't exist!");
}else if($this->i == 1){
$misc = new misc;
$get = mysql_query("SELECT * FROM mainContent WHERE page_id='".$pgID."'") or die(mysql_error());
while($row = mysql_fetch_array($get)){
$this->pageName = $row['name'];
$this->pageNumber = $row['page_id'];
$this->date = $row['date'];
$this->data = $misc->bbcode($row['data']);
$this->status = $row['show_status'];
$this->type = $row['type'];
//////////////SIDE BAR/////////////////
if($row['show_side_bar'] == 'true'){
$this->doSideBar = true;
} else if($row['show_side_bar'] == 'false') {
$this->doSideBar = false;
}
/////////////END SIDE BAR//////////////
///redirection fixes below
if($this->type == "doregister") {
$register = new register_class($_POST['username'], $_POST['pass'], $_POST['pass2'], $_POST['email'], $_POST['fname'],
$_POST['lname'], $_POST['phone1'], $_POST['phone2'], $_POST['address1'], $_POST['address2'],
$_POST['state'], $_POST['city'], $_POST['zip']);
$this->redirectCode = "doregister";
}
}
}
}
function fetchPage($pid, $ptype, $pname, $doSB) {
require_once("./include/templates/loader.php");
$load = new load_templates;
///////////////////SIDE BAR OUTPUT//////////////////////
if($doSB == true) {
$this->startSidebar("<div id='sidebar'>", "</div>", "<h1>", "</h1>", "<div class='left-box'><ul class='sidemenu'>", "</ul></div>", "<li>", "</li>");
}
////////////////// PAGE DATA OUTPUT ///////////////////
if($ptype == "cpedits"){
require_once($load->skinDir."pages/".$load->doPage[$this->type]);
include("./include/templates/main_template/pages/cpedits.php");
} else if($ptype == "login"){
require_once($load->skinDir."pages/".$load->doPage[$this->type]);
} else if($ptype == "register"){
require_once($load->skinDir."pages/".$load->doPage[$this->type]);
} else if($ptype == "reqnewpass"){
require_once($load->skinDir."pages/".$load->doPage[$this->type]);
} else if($ptype == "doregister"){
//if(!isset($_POST['username'])) {
// $fetch = new fetchPageActions;
//die("index.php?pageAction=register");
//}
}
}
function doesnotexist(){
$this->pageName = "does not exist";
}
//////////////////////////////////
//// Side Bar /////
////////////////////////////////
public $n = 0;
function startSidebar($boxStart, $boxEnd, $titleStart, $titleEnd, $containerStart, $containerEnd, $linkStart, $linkEnd) {
//require_once './config.php';
//$mysql = new mysql_class("localhost", "root", "root", "gal");
echo $boxStart;
$load = new load_templates;
$sql = "SELECT * FROM nav_bar WHERE parent='true' order by parent_id";
$get = mysql_query($sql) or die(mysql_error() . '<br />'. $query2);
$i = 0;
while($row = mysql_fetch_array($get)) {
$parent_id[$i] = $row['parent_id'];
$parent_name[$i] = $row['text'];
$i++;
}
$parentc = count($parent_id);
for($r=0; $parentc > $r; $r++) {
#### Parent Title ####
echo $titleStart."".$parent_name[$r]."".$titleEnd;
#### Container Start ####
echo $containerStart;
$sql = "SELECT * FROM nav_bar WHERE parent='false' AND parent_id='".$parent_id[$r]."' order by lorder";
$get = mysql_query($sql) or die(mysql_error() . '<br />'. $query2);
while($row = mysql_fetch_array($get)) {
echo $linkStart."<a href='".$row['link']."'>".$row['text']."</a>".$linkEnd;
}
#### Container End
echo $containerEnd;
}
echo $boxEnd;
}
//////////////////////////////////
//// Header Link data /////
////////////////////////////////
public $title = array();
public $link = array();
public $pg_num = array();
public $getHeaderLinks = "";
function getLinkData(){
$get = mysql_query("SELECT * FROM head_links"); //id="current"
while($row = mysql_fetch_array($get)) {
$this->title[$this->i] = $row['name'];
$this->link[$this->i] = $row['link'];
$this->pg_num[$this->i] = $row['page_id'];
$this->i++;
}
$count = count($this->title) - 1;
$this->i = 0;
while($count >= $this->i) {
isset($this->links)? $this->links : " ";
isset($this->title)? $this->title : " ";
$this->getHeaderLinks = $this->getHeaderLinks." <li ".$this->isCurrent($this->pg_num[$this->i])."><a href='".$this->link[$this->i]."'><span>".$this->title[$this->i]."</span></a></li>";
$this->i++;
}
}
function isCurrent($id) {
if(isset($_GET['pageAction'])) {
$pga = isset($_GET["pageAction"])? $_GET["pageAction"]:"";
$action = array("login"=>"15","register"=>"16","gallery"=>"17","portfolio"=>"18","changepass"=>"19","reqnewpass"=>"20");
if(($pga=="login") || ($pga=="register") || ($pga=="gallery") || ($pga=="portfolio") || ($pga=="changepass") || ($pga=="reqnewpass")) {
if($id==$action[$pga]) {
return 'id="current"';
}
}
} else if(isset($_GET['page'])) {
$pg = isset($_GET['page'])? $_GET['page']:"";
if(empty($pg)){
$pg = 1;
}
if($id==$pg){
return 'id="current"';
}
} else if(!isset($_GET['page']) AND !isset($_GET['pageAction']) AND $id==1) {
return 'id="current"';
}
}
}