Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.47 KB | None | 0 0
  1. <?php
  2.     include ("engine.class.php");
  3.     include ("markasnewpost.class.php");
  4.  
  5.     class DxTemplate extends Engine
  6.     {
  7.         public function __construct ()
  8.         {
  9.             include ("config.php");
  10.             include_once ("mysql.class.php");
  11.             $this->sql = new MySQL ($date["db_host"], $date["db_user"], $date["db_pass"], $date["db_name"]);
  12.             $this->MarkAsNewPost = new MarkAsNewPost ();
  13.         }
  14.         public function Head ($title)
  15.         {
  16.             $this->title = $title;
  17.             $header = new Engine();
  18.            
  19.             return $header -> assign ("template/Default/header.tmp", "TITLE", $this->title);
  20.         }
  21.        
  22.         public function includeCSS ($css)
  23.         {
  24.             $css = "\n" . '<link rel="stylesheet" type="text/css" href="' . $css . '" />';
  25.            
  26.             return $css;
  27.         }
  28.        
  29.         public function includeJS ($script)
  30.         {
  31.             $source = "\n" . '<script type="text/javascript" src="' . $script . "\">\n</script>" . "\n";
  32.            
  33.             return $source;
  34.         }
  35.        
  36.         public function openBody ($n)
  37.         {
  38.             $source = "\t</head>\n\n\t<body onload=\"slideMenuInit()\">";
  39.             ($n == 1) ? $source .= "<br />\n" : null;
  40.            
  41.             return $source;
  42.         }
  43.        
  44.         public function closeBody ()
  45.         {
  46.             $source = "\n\t</body>\n</html>";
  47.             return $source;
  48.         }
  49.        
  50.         public function openDiv ($class)
  51.         {
  52.             $source = "\t\t" . '<div class = "' . $class . '">' . "\n";
  53.             return $source;
  54.         }
  55.        
  56.         public function closeDiv ()
  57.         {
  58.             $source = "\n\t\t</div>\n";
  59.             return $source;
  60.         }
  61.        
  62.         public function setMenu ($php_self, $n)
  63.         {
  64.            
  65.             $php_self = $php_self[count($php_self)-1];
  66.            
  67.             $main = '<table width="100%"><tr><td class="border"><a class="link" href="index.php">Home</a> | <a class="link" href="register.php">Register</a> | <a class="link" href="login.php">Login</a>';
  68.                    
  69.             if ($php_self == 'index.php' || $php_self == 'register.php' || $php_self == 'login.php')
  70.             {
  71.                 $menu = $main . '</td></tr></table>';
  72.             }
  73.             else if ($php_self == 'viewSection.php')
  74.             {
  75.                 $id = protectVar ($_GET['id']);
  76.                 if (empty($_GET['action']))
  77.                 {
  78.                     $vs = '| <a class="link" href="' . $php_self . '?id=' . $id . '&action=newTopic' . '">New Topic</a></td>';
  79.                     $menu = $main . $vs . '</td></tr></table>';
  80.                 }
  81.             }
  82.             else if ($php_self == 'viewTopic.php')
  83.             {
  84.                 $id = protectVar ($_GET['id']);
  85.                 if (empty($_GET['action']))
  86.                 {
  87.                     $menu = '<table class="border"><tr><td class="border"><a class="link" href="' . $php_self . '?id=' . $id . '&action=newPost' . '">New Post</a> | <a class="link" href="javascript:history.back()">Back</a></td></tr></table>';
  88.                 }
  89.             }
  90.            
  91.             return $menu;
  92.         }
  93.        
  94.         public function printForum()
  95.         {
  96.             $query_f = $this->sql->sendQuery ("SELECT * FROM sections");
  97.             $query_m = $this->sql->sendQuery ("SELECT * FROM sections");
  98.             $control_admin = $this->sql -> sendQuery ("SELECT * FROM user WHERE username = '" . $_COOKIE['username'] . "'");
  99.             //print '           Forum:';
  100.            
  101.             while ($result = mysql_fetch_array ($control_admin))
  102.             {
  103.                 $class = $result['class'];
  104.                 $password = $result['password'];
  105.             }
  106.  
  107.             print '<table width="100%" class="body">
  108.                     <tr><td>Forum:</td><td>Ultimo messaggio:</td></tr>';
  109.            
  110.             while ($result_f = mysql_fetch_array ($query_f))
  111.             {
  112.                 $code_left[] = '<td><p class="sections"> <a class="link" href="viewSection.php?id=' . $result_f['id'] . '">'. $result_f['name'] . "</a> <br />" . $result_f['description'];
  113.  
  114.                 if ($class == 'admin' && $password == $_COOKIE['password'])
  115.                 {
  116.  
  117.                     $code_left[] = "<a class='link' href='admin.php?deleteSection=" . $result_f['id'] . "'>[x]</a></p></td>\n\t\t\t";
  118.                 }
  119.                 else
  120.                 {
  121.                     $code_left[] = "</p></td>\n\t\t\t";
  122.                 }
  123.             }
  124.             //print '           Ultimo Messaggio:';
  125.    
  126.             while ($result_m = mysql_fetch_array ($query_m))
  127.             {
  128.                 $code_right[] = '<td><p class="sections">' . $result_m['date_time'] . ' <br /> ' . $result_m['last_author'] . " </p></td>\n\t\t\t";
  129.             }
  130.            
  131.             $count_left = count ($code_left);
  132.             $count_right = count ($code_right);
  133.             $i = 0;
  134.             $j = 0;
  135.            
  136.             while ($i < $count_left-1)
  137.             {
  138.                 print "<tr>";
  139.                 print $code_left[$i] . $code_left[++$i];
  140.                 print $code_right[$j++];
  141.                 print "</tr>";
  142.                 $i++;
  143.             }
  144.             print "</table>";
  145.         }
  146.        
  147.         public function printLastMessage()
  148.         {
  149.             $query = $this->sql->sendQuery ("SELECT * FROM sections");
  150.             //print '           Ultimo Messaggio:';
  151.    
  152.             while ($result = mysql_fetch_array ($query))
  153.             {
  154.                 //print '<p class="sections">' . $result['date_time'] . ' <br /> ' . $result['last_author'] . " </p>\n\t\t\t";
  155.             }
  156.         }
  157.        
  158.         public function printTopics($id)
  159.         {
  160.             $query_t = $this->sql -> sendQuery ("SELECT * FROM topics WHERE id_sections = '$id'");
  161.             $query_m = $this->sql -> sendQuery ("SELECT * FROM topics WHERE id_sections = '$id'");
  162.             $control_admin = $this->sql -> sendQuery ("SELECT * FROM user WHERE username = '" . $_COOKIE['username'] . "'");
  163.  
  164.             //print '           Section:';
  165.            
  166.             print '<table width="100%" class="body">
  167.                     <tr><td>Topics:</td><td>Ultimo messaggio:</td></tr>';
  168.                    
  169.             while ($result = mysql_fetch_array ($control_admin))
  170.             {
  171.                 $class = $result['class'];
  172.                 $password = $result['password'];
  173.             }
  174.            
  175.             while ($result_t = mysql_fetch_array ($query_t))
  176.             {
  177.                 $date_time = eregi_replace("[/,: ]", "", $result_t['date_time']);
  178.                 $code_left[] = '<td><p class="sections"><a class="link" href="viewTopic.php?id=' . $result_t['id'] . '">'. $result_t['name'] . "</a><br />";
  179.                
  180.                 if ($class == 'admin' && $password == $_COOKIE['password'])
  181.                 {
  182.                     if ($this->MarkAsNewPost->SetNewPost ($date_time))
  183.                     {
  184.                         if ($this->MarkAsNewPost->UnsetNewPost ($result_t['id'], $date_time))
  185.                         {
  186.                             $code_left[] = "<a class='link' href='admin.php?deleteTopic=" . $result_t['id'] . "'>[x]</a></p></td>\n\t\t\t";
  187.                         }
  188.                         else
  189.                         {
  190.                             $code_left[] = "<a class='link' href='admin.php?deleteTopic=" . $result_t['id'] . "'>[x]</a>[NEW]</p></td>\n\t\t\t";
  191.                         }
  192.                     }
  193.                     else
  194.                     {
  195.                         $code_left[] = "<a class='link' href='admin.php?deleteTopic=" . $result_t['id'] . "'>[x]</a> </p></td>\n\t\t\t";
  196.                     }
  197.                 }
  198.                 else
  199.                 {
  200.                     if ($this->MarkAsNewPost->SetNewPost ($date_time))
  201.                     {
  202.                         if ($this->MarkAsNewPost->UnsetNewPost ($result_t['id'], $date_time))
  203.                         {
  204.                             $code_left[] = "</p></td>\n\t\t\t";
  205.                         }
  206.                         else
  207.                         {
  208.                             $code_left[] = "[NEW]</p></td>\n\t\t\t";
  209.                         }
  210.                     }
  211.                     else
  212.                     {
  213.                         $code_left[] = "</p></td>\n\t\t\t";
  214.                     }
  215.                 }
  216.             }
  217.            
  218.             while ($result_m = mysql_fetch_array ($query_m))
  219.             {
  220.                 $code_right[] = '<td><p class="sections">' . $result_m['date_time'] .'<br />' . $result_m['last_author'] . '</p></td>' . "\n\t\t\t";
  221.             }
  222.            
  223.             $count_left = count ($code_left);
  224.             $count_right = count ($code_right);
  225.             $i = 0;
  226.             $j = 0;
  227.            
  228.             while ($i < $count_left-1)
  229.             {
  230.                 print "<tr>";
  231.                 print $code_left[$i] . $code_left[++$i];
  232.                 print $code_right[$j++];
  233.                 print "</tr>";
  234.                 $i++;
  235.             }
  236.             print "</table>";
  237.         }
  238.        
  239.         public function printLastMessageTopics ($id)
  240.         {
  241.             $query = $this->sql -> sendQuery ("SELECT * FROM topics WHERE id_sections = '$id'");
  242.             print '         Ultimo Messaggio:';
  243.        
  244.             while ($result = mysql_fetch_array ($query))
  245.             {
  246.                 print '<p class="sections">' . $result['date_time'] .'<br />' . $result['last_author'] . '</p>' . "\n\t\t\t";
  247.             }
  248.         }
  249.        
  250.         public function printTopicAndPost ($id)
  251.         {
  252.             $query = $this->sql->sendQuery ("SELECT * FROM topics WHERE id='$id'");
  253.             $query_post = $this->sql->sendQuery ("SELECT * FROM posts WHERE id_topics='$id'");
  254.  
  255.             $result = mysql_fetch_array ($query);
  256.  
  257.             //$clickUp = unserialize ($_COOKIE['clickUp']);        
  258.             //$clickUp[] = $result['id'];
  259.             //$clickUp = serialize ($clickUp);
  260.             //setcookie ("clickUp", $clickUp, time () + (3600 * 24), "/");             
  261.            
  262.             $date_time = eregi_replace("[/,: ]", "", $result['date_time']);
  263.             $this->MarkAsNewPost->SetClickUp ($result['id'], $date_time);
  264.        
  265.             print "         <table width='100%' class='border'>\n           <tr>\n";
  266.    
  267.             print '             <td class="body-right" valign="top"><p align="justify" class="sections">' . $result['author'] . ":</p></td>\n";
  268.             print '             <td class="body-left" valign="top"><p align="justify" class="sections">' . $result['text'] . "</p></td></tr>\n</tr><tr>";
  269.            
  270.             while ($result_post = mysql_fetch_array($query_post))
  271.             {
  272.                 print '             <td class="body-right" valign="top"><p align="justify" class="sections">' . $result_post['author'] . ":</p></td>\n";
  273.                 print '             <td class="body-left" valign="top"><p align="justify" class="sections">' . $result_post['text'] . "</p></td></tr>\n";
  274.             }
  275.         }
  276.     }
  277. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement