SIDEFEED

Forum
Last Post
Threads / Messages

Hedgen

Member
Member
Joined
Oct 29, 2012
Messages
36
Points
0
Mysidian Dollar
3,188
SIDEFEED Question

I figured out moving the login box. This is my edited class_page.php code:

  Spoiler: class_page.php code 
PHP:
<?php

class Page{
  // The page class for Mysidia Adoptables
  
  public $type;
  public $name;
  private $header;
  private $links;
  private $sidebar;
  private $ads;
  private $credits;
  private $title = "";
  private $content = "";
  private $date = "";
  private $code;
  private $item;
  private $time;
  private $group;

  public function __construct(){
     // The initialization of this script
	 
	 $this->links =(defined("SUBDIR") and SUBDIR == "AdminCP")?$this->getadmlinks():$this->getlinks();
	 $this->sidebar = $this->getsidebar();
	 $this->ads =(defined("SUBDIR") and SUBDIR == "AdminCP")?"":$this->getads("any");
     $this->credits = $this->getcredits();
  }
  
  public function gettitle(){
     if(empty($this->title)) throw new Exception('The page has no title.');
     return $this->title;
  }
  
  public function settitle($title){
     if(empty($title)) throw new Exception('Cannot set title for this page.');
	 else $this->title = $title;
  }
  
  public function getcontent(){
     if(empty($this->title)) throw new Exception('The page has no content.');
     return $this->content;
  }
  
  public function addcontent($content, $overwrite = FALSE){
     if(empty($this->content) or $overwrite == TRUE) $this->content = $content;
	 else $this->content .= $content;
  }
  
  public function getpage($name){
     // This method retrieve page info from database, if the page is a custom page created by admins
  
     global $mysidia;
     $pageinfo = $mysidia->db->select("content", array(), "page ='{$name}'")->fetchObject();
	 if(!is_object($pageinfo)) throw new InvalidIDException('Cannot find page {$name} in database.');
	 $this->type = "Custom";
	 $this->name = $name;
	 $this->title = stripslashes($pageinfo->title);
	 $this->content = stripslashes($pageinfo->content);
	 $this->date = $pageinfo->date;
     $this->code = $pageinfo->code;	 
     $this->item = $pageinfo->item;
     $this->time = $pageinfo->time;
     $this->group = $pageinfo->group;
     $this->getaccess();
  }

  private function getaccess(){
     global $mysidia;
     if($this->code){
        if($mysidia->input->post("code")){
           // A promocode has been entered, now process the request.
           if($this->code != $mysidia->input->post("code")) throw new NoPermissionException($mysidia->lang->wrongcode);     
           
           $promo = new Promocode($mysidia->input->post("code"));
           if($promo->pid == 0 or !$promo->validate($mysidia->input->post("code"))) throw new NoPermissionException($mysidia->lang->nocode);          
           
           // Now execute the action of using this promocode.
           if(!$mysidia->input->post("item")) $promo->execute();
        }
        else{
           // Show a basic form for user to enter promocode.
           $promoform = "<br><form name='form1' method='post' action='pages.php?page={$this->name}'><p>Your Promo Code: 
                         <input name='code' type='text' id='code'></p>
                         <p><input type='submit' name='submit' value='Enter Code'></p></form>";
           $this->title = $mysidia->lang->code_title;
           $this->content = $mysidia->lang->code.$promoform;
           return FALSE;
        }
     }
     if($this->item){
        if($mysidia->input->post("item")){
           // An item has been selected, now process the request.
           if($mysidia->input->post("item") != $this->item) throw new NoPermissionException($mysidia->lang->wrongitem);
           
           $item = new PrivateItem($this->item, $mysidia->user->username);
           if($item->iid == 0 or $item->quantity < 1) throw new NoPermissionException($mysidia->lang->noitem);
           
           // Consume one quantity of this item if it is consumable.
           if($item->consumable == "yes") $item->remove();
        }
        else{
           // Show a basic form for user to choose an item.
           $itemform = "<form name='form1' method='post' action='pages.php?page={$this->name}'><br>
                        <b>Choose an Item:</b>
                        (The quantity of each item you own is shown inside the parentheses)<br> 
                        <select name='item' id='item'><option value='none' selected>None Selected</option>";
           $stmt = $mysidia->db->select("inventory", array("itemname", "quantity"), "owner = '{$mysidia->user->username}'");
           while($items = $stmt->fetchObject()){
		      $itemform .= "<option value='{$items->itemname}'>{$items->itemname} ({$items->quantity})</option>";	
           } 
           $itemform .= "</select></p><input name='code' type='hidden' id='code' value='{$this->code}'>
                         <p><input type='submit' name='submit' value='Use Item'></p></form>";

           $this->title = $mysidia->lang->item_title;
           $this->content = $mysidia->lang->item.$itemform;
           return FALSE;
        }
     }
     if($this->time){
        $time = strtotime($this->time);
        $current = time();
        if($current < $time) throw new NoPermissionException($mysidia->lang->wrongtime);
     }
     if($this->group){
        $group = $mysidia->usergroup->gid;
        if($group != $this->group) throw new NoPermissionException($mysidia->lang->notgroup);
     }
     return TRUE;
  }

  private function startheader(){
     global $mysidia;
     if($this->header) throw new Exception("Header already started.");
     $this->header = "<html><head><title>MyMysidia Admin » {$mysidia->settings->browsertitle}</title>";
  }

  private function endheader(){
     if(!$this->header) throw new Exception("Header not started yet.");
     $this->header .= "</head>";
  }

  private function getstyle($style, $path = ""){
     if(!$this->header) throw new Exception("Header not started yet.");
     $path = (defined("SUBDIR") and SUBDIR == "AdminCP")?
             "http://".DOMAIN.SCRIPTPATH."/templates/newacp/css/":
             "http://".DOMAIN.SCRIPTPATH."/css/";     
     $this->header .= "<link rel='stylesheet' href='{$path}{$style}' type='text/css' />";
  }

  private function getscript($script, $path = ""){
     // This method load javascript in header.
     if(!$this->header) throw new Exception("Header not started yet.");
     if(empty($path)) $path = "http://".DOMAIN.SCRIPTPATH."/js/";
     $this->header .= "<script type='text/javascript' src='{$path}{$script}'></script>";
  }

  private function getbody($template){
     // The temporary way to get AdminCP body, this will be revised in Mys v1.3.3
     $patterns = array("/:INDEX:/", "/:ADOPT:/", "/:LEVEL:/", "/:OWNEDADOPT:/", "/:IMAGE:/", "/:USER:/", "/:USERGROUP:/", "/:ITEM:/", "/:SHOP:/", "/:INVENTORY:/", "/:CONTENT:/", "/:MENU:/", "/:PROMO:/", "/:SETTINGS:/", "/:AD:/");
     $path = "http://www.".DOMAIN.SCRIPTPATH."/admincp";
     $replacements = array($path, $path."/adopt", $path."/level", $path."/ownedadopt", $path."/image", $path."/user", $path."/usergroup", 
                           $path."/item", $path."/shop", $path."/inventory", $path."/content", $path."/menu", $path."/promo", $path."/settings", $path."/ads"); 
     $body = preg_replace($patterns, $replacements, $template);
     return $body;
  }
  
  private function getlinks(){
     // This method gets the links for the top bar from the database
     
     global $mysidia;	
     /*I copied the "if" statement from the getsidebar() function and edited it here to make it work. */
     if($mysidia->user->isloggedin == TRUE) {
		$msgctr = "<a href='messages.php'>Messages</a>";		
		$data = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->fetchAll();

		if(count($data) > 0) $msgctr = "<a href='messages.php'>Messages <b>(".count($data).")</b></a>";
		$links = "<div class='ddmenu'>{$mysidia->settings->cost}: {$mysidia->user->money}.<br>";
	 }
	 else {
		$links = "<div class='ddmenu'><b style='text-align:center'><u>Member Login:</u></b>
		<form name='form1' method='post' action='login.php'>
		  Username:<input name='username' type='text' id='username'>
		  Password:<input name='password' type='password' id='password'>
		  <input type='submit' name='Submit' value='Log In'>";
	 } 
     $links .= "\n<ul>";			 
     $stmt = $mysidia->db->select("links", array(), "linkparent < 1 ORDER BY id ASC");   	
     while ($category = $stmt->fetchObject()) {
        $links .= "\n<li><a class='hide' href='{$category->linkurl}'>{$category->linktext}</a>
               \n<ul>";
        $stmt2 = $mysidia->db->select("links", array(), "linkparent='{$category->id}' ORDER BY id ASC");
        while($item = $stmt2->fetchObject()){
            $links .= "<li><a href='{$item->linkurl}' title='{$item->linktext}'>{$item->linktext}</a></li>";      
        }
        $links .= "</ul>
              \n</li>";
     }	
     $links .= "\n</ul>";
     return $links;
  }
  
  public function getlinkname($lid){
     global $mysidia;
     $link = $mysidia->db->select("links", array("linktext"), "id='{$lid}'")->fetchColumn();	
     return $link;   
  }
  
  private function getadmlinks(){
	  //This method shows special links to the site admin

	  $links = "<li><a href='index.php'>Home</a></li>
	            <li><a href='adopt.php'>Change Adoptables</a></li>
	            <li><a href='content.php'>Change Content</a></li>
	            <li><a href='users.php'>Change Users</a></li>
	            <li><a href='items.php'>Change Items</a></li>
	            <li><a href='settings.php'>Site Settings</a></li>
	            <li><a href='ads.php'>Manage Ads</a></li>";
      return $links;
  } 
  
  private function getsidebar(){
  	 //This function determines what shows in the side bar of the template

	 global $mysidia; 
	 if($mysidia->user->isloggedin == TRUE) {
		$msgctr = "<a href='messages.php'>Messages</a>";		
		$data = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->fetchAll();

		if(count($data) > 0) $msgctr = "<a href='messages.php'>Messages <b>(".count($data).")</b></a>";
		$sidebar = "{$mysidia->settings->cost}: {$mysidia->user->money}.<br />
		           <a href='donate.php'>Donate Yukkuriens</a><br />
		           <br /><strong>Your links:</strong><br />
		           <a href='adopt.php'>Adopt</a>
		           <a href='pound.php'>Pounded</a>
		           <a href='myadopts.php'>Manage</a>
		           <a href='account.php'>My Account</a>
		           <a href='logout.php'>Log Out</a>";

		$row = $mysidia->db->select("users", array("uid", "username"), "username='{$mysidia->user->username}' and usergroup='1'")->fetchObject();		
		if(is_object($row)) $sidebar .= "<a href='admincp/'>Admin Center</a><br />";
	 }
	 else {
		$sidebar = "";
	 }
	
    $omembers = $mysidia->db->select("online", array(), "username != 'Visitor'")->fetchAll();
	$ovisitors = $mysidia->db->select("online", array(), "username = 'Visitor'")->fetchAll();
    $sidebar .= "Online:<br /><a href='online.php'>".count($omembers)." Members<br />".count($ovisitors)." Guests</a>";
	return $sidebar;
  }
  
  private function getads($page = ""){
	 // The method to display site advertisements
	
	 global $mysidia;
	 if($page == "any") $page = "";	
     $row = $mysidia->db->select("ads", array(), "page = '{$page}' and status = 'active' ORDER BY RAND() LIMIT 1")->fetchObject();		
	 if(is_object($row)) {
		$value= $row->text;
		$value = stripslashes($value);
		$aid= $row->id;
		$actualimpressions= $row->actualimpressions;
		$impressions= $row->impressions;

		if($impressions == "") $impressions = 0;
		$actualimpressions = $actualimpressions + 1;

		//Update the impressions count
		$mysidia->db->update("ads", array("actualimpressions" => $actualimpressions), "id='{$aid}'");
		//Check that ad is not over max impressions...
		if ($actualimpressions >= $impressions and $impressions != 0) $mysidia->db->update("ads", array("status" => "inactive"), "id='{$aid}'");
	 }
	 else $value = "";
	 return $value;
  }

  private function getcredits(){
     $mysversion = "Mysidia Adoptables".Mysidia::version;
     return "Powered by <a href='http://www.mysidiaadoptables.com'>Mysidia Adoptables {$mysversion}</a>";
  }

  public function showpage(){
     // The core method to output a page
  
     global $mysidia;
	 $usertheme = $mysidia->user->gettheme();
	 $title = stripslashes($this->title);
	 $content = stripslashes($this->content);
     $credits = htmlentities($this->credits);
	 $theme = (!empty($usertheme))?$mysidia->user->gettheme():$mysidia->settings->theme;
	 $themeurl = (defined("SUBDIR") and SUBDIR == "AdminCP")?"../templates/newacp/template.html":"templates/{$theme}/template.html";
     $patterns = array("/:ARTICLETITLE:/","/:ARTICLECONTENT:/", "/:ARTICLEDATE:/", "/:BROWSERTITLE:/", "/:SITENAME:/", "/:SLOGAN:/", "/:LINKSBAR:/", "/:SIDEFEED:/", "/:ADS:/", "/:CREDITS:/");
     $replacements = array($title, $content, $this->date, $mysidia->settings->browsertitle, $mysidia->settings->sitename, $mysidia->settings->slogan, $this->links, $this->sidebar, $this->ads);
     $template = file_get_contents($themeurl);
	 // now that we have our stuff, let's start making it all into a webpage
 
     $body = preg_replace($patterns, $replacements, $template);
     if(defined("SUBDIR") and SUBDIR == "AdminCP"){
         $this->startheader();
         $this->getstyle("acp-style.css");
         $this->getscript("jquery.min.js", "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/");
         $this->getscript("acp.js");
         $this->endheader();
         $body = $this->getbody($body);
     }

     $html = $this->header.$body; 
	 return $html;
  }
  
}
?>

  Spoiler: Figured this out 


Is there a way to move around and split up SIDEFEED stuff? I want to put the login and money amount someplace else on my side and have the links as an icon menu (the icon menu being down the left side of my site)

So something like this:

  Spoiler: Image 
sothis.png


I know it might be difficult but I was just curious if it would be easyish.

Edit: I am using version 1.3.2

Edit 2:
I am looking at the class_page.php file at the sidefeed code, and I was wondering if I could take this bit of code:
PHP:
if($mysidia->user->isloggedin == TRUE) {
		$msgctr = "<a href='messages.php'>Messages</a>";		
		$data = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->fetchAll();

		if(count($data) > 0) $msgctr = "<a href='messages.php'>Messages <b>(".count($data).")</b></a>";
		$sidebar = "{$mysidia->settings->cost}: {$mysidia->user->money}.<br />
		           <a href='donate.php'>Donate Yukkuriens</a><br />
		           <br /><strong>Your links:</strong><br />
		           <a href='adopt.php'>Adopt</a>
		           <a href='pound.php'>Pounded</a>
		           <a href='myadopts.php'>Manage</a>
		           <a href='account.php'>My Account</a>
		           <a href='logout.php'>Log Out</a>";

		$row = $mysidia->db->select("users", array("uid", "username"), "username='{$mysidia->user->username}' and usergroup='1'")->fetchObject();		
		if(is_object($row)) $sidebar .= "<a href='admincp/'>Admin Center</a><br />";
	 }
	 else {
		$sidebar = "<b style='text-align:center'><u>Member Login:</u></b><br />
		<form name='form1' method='post' action='login.php'>
		  <p style='text-align:center'>Username: <p id='loginbox'><input name='username' type='text' id='username'></p></p>
		  <p style='text-align:center'>Password: <p id='loginbox'><input name='password' type='password' id='password'></p></p>
		  <p style='text-align:center'><input type='submit' name='Submit' value='Log In'></p>
		</form>Don't have an account?<br /><a href='register.php'>Register Free</a><br /><a href='forgotpass.php'>Forgot Password?</a><br />";
	 }
and edit it on the template page for the login part, and get it to work.
(I'm seeing how easy it would be before I attempt it in case I accidentally break something xD) (I am in a php/mysql class right now and just started, but I do have some knowledge from watching php videos online, and also have some basic programming knowledge)
 
Last edited:
Oh thats good to know, anyway you may want to share your experience with a few other users who wish to move the locations of some certain widgets/modules around on their sites.
 
I'll try explaining it later when I get home, and hopefully I can explain it in a way that people can understand ^^' (I'm at school right now working on C# homework and php/mysql homework) It took me awhile to finally get it to look right on my site but even then I can't get the login box above my menu to center. I'm trying to get a good site layout down before I add anything else to my site.

Edit: Should I put it in the tutorials and tips section? Or would it be under the modification section?
 
Last edited:
Well you sure can post a thread in the tutorials section, I am sure thats where it should fit into anyway.
 
Similar threads
Thread starter Title Forum Replies Date
Hedgen SIDEFEED Location? Templates and Themes 7

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,129
Members
1,603
Latest member
Monako
BETA

Latest Threads

Latest Posts

Top