示例#1
0
文件: page.php 项目: Bossgod/3ch
 function foot()
 {
     require_once "foot.php";
     //$footer = new Footer;
     return Footer::format();
     //$footer->format();//strict standards prefers <- over -> Footer::format(); for some reason
 }
示例#2
0
文件: log.php 项目: Bossgod/3ch
 function update($resno = 0, $rebuild = 0)
 {
     global $path, $mysql;
     require_once CORE_DIR . "/postform.php";
     require_once CORE_DIR . "/page/head.php";
     $postform = new PostForm();
     $head = new Head();
     $this->update_cache();
     //Muh speed increase (for when the function calls itself). Otherwise call Log->update_cache() manually.
     $find = false;
     $resno = (int) $resno;
     $log = $this->cache;
     if ($resno) {
         if (!isset($log[$resno])) {
             $this->update(0, $rebuild);
             // the post didn't exist, just rebuild the indexes
             return;
         } else {
             if ($log[$resno]['resto']) {
                 $this->update($log[$resno]['resto'], $rebuild);
                 // $resno is a reply, try rebuilding the parent
                 return;
             }
         }
     }
     if ($resno) {
         $treeline = array($resno);
         //if(!$treeline=$mysql->query("select * from ".SQLLOG." where root>0 and no=".$resno." order by root desc")){echo S_SQLFAIL;}
     } else {
         $treeline = $log['THREADS'];
         //if(!$treeline=$mysql->query("select * from ".SQLLOG." where root>0 order by root desc")){echo S_SQLFAIL;}
     }
     //Finding the last entry number
     if (!($result = $mysql->query("select max(no) from " . SQLLOG))) {
         echo S_SQLFAIL;
     }
     $row = $mysql->fetch_array($result);
     $lastno = (int) $row[0];
     $mysql->free_result($result);
     $counttree = count($treeline);
     //$counttree=mysql_num_rows($treeline);
     if (!$counttree) {
         $logfilename = PHP_SELF2;
         $dat = $head->generate() . $postform->format($resno);
         $this->print_page($logfilename, $dat);
     }
     if (UPDATE_THROTTLING >= 1) {
         $update_start = time();
         touch("updatelog.stamp", $update_start);
         $low_priority = false;
         clearstatcache();
         if (@filemtime(PHP_SELF) > $update_start - UPDATE_THROTTLING) {
             $low_priority = true;
             //touch($update_start . ".lowprio");
         } else {
             touch(PHP_SELF, $update_start);
         }
         // 	$mt = @filemtime(PHP_SELF);
         //  	touch($update_start . ".$mt.highprio");
     }
     //using CACHE_TTL method
     if (CACHE_TTL >= 1) {
         if ($resno) {
             $logfilename = RES_DIR . $resno . PHP_EXT;
         } else {
             $logfilename = PHP_SELF2;
         }
         //if(USE_GZIP == 1) $logfilename .= '.html';
         // if the file has been made and it's younger than CACHE_TTL seconds ago
         clearstatcache();
         if (file_exists($logfilename) && filemtime($logfilename) > time() - CACHE_TTL) {
             // save the post to be rebuilt later
             rebuildqueue_add($resno);
             // if it's a thread, try again on the indexes
             if ($resno && !$rebuild) {
                 $this->update();
             }
             // and we don't do any more rebuilding on this request
             return true;
         } else {
             // we're gonna update it now, so take it out of the queue
             rebuildqueue_remove($resno);
             // and make sure nobody else starts trying to update it because it's too old
             touch($logfilename);
         }
     }
     for ($page = 0; $page < $counttree; $page += PAGE_DEF) {
         $head->info['page']['title'] = "/" . BOARD_DIR . "/" . ($resno && !empty($log[$resno]['sub']) ? " - " . $log[$resno]['sub'] : '') . " - " . TITLE;
         $dat = $head->generate();
         $dat .= $postform->format($resno);
         if (!$resno) {
             $st = $page;
         }
         $dat .= '<form name= "delform" action="' . PHP_SELF_ABS . '" method="post">';
         for ($i = $st; $i < $st + PAGE_DEF; $i++) {
             list($_unused, $no) = each($treeline);
             if (!$no) {
                 break;
             }
             //This won't need needed once the extra fluff is dealt with as we can just use the Index class.
             require_once CORE_DIR . "/thread/thread.php";
             $thread = new Thread();
             $thread->inIndex = $resno ? false : true;
             $dat .= $thread->format($no);
             // Deletion pending (We'll disable this for now as it currently serves no purpose)
             /*if (isset($log[$no]['old']))
               $dat .= "<span class=\"oldpost\">" . S_OLD . "</span><br>\n"; */
             $resline = $log[$no]['children'];
             ksort($resline);
             $countres = count($log[$no]['children']);
             $t = 0;
             if ($sticky == 1) {
                 $disam = 1;
             } elseif (defined('REPLIES_SHOWN')) {
                 $disam = REPLIES_SHOWN;
             } else {
                 $disam = 5;
             }
             $s = $countres - $disam;
             $cur = 1;
             while ($s >= $cur) {
                 list($row) = each($resline);
                 if ($log[$row]["fsize"] != 0) {
                     $t++;
                 }
                 $cur++;
             }
             if ($countres != 0) {
                 reset($resline);
             }
             /*possibility for ads after each post*/
             $dat .= "</span><br clear=\"left\" /><hr />\n";
             if (USE_ADS3) {
                 $dat .= ADS3 . '<hr>';
             }
             if ($resno) {
                 $dat .= "[<a href='" . PHP_SELF2_ABS . "'>" . S_RETURN . "</a>] [<a href='{$resno}" . PHP_EXT . "#top'>Top</a>]<hr>";
             }
             clearstatcache();
             //clear stat cache of a file
             //mysql_free_result($resline);
             $p++;
             if ($resno) {
                 break;
             }
             //only one tree line at time of res
         }
         //afterPosts div is closed in general/foot.php
         $dat .= '<div class="afterPosts" /><table align="right"><tr><td class="delsettings" nowrap="nowrap" align="center">
 <input type="hidden" name="mode" value="usrdel" />' . S_REPDEL . '[<input type="checkbox" name="onlyimgdel" value="on" />' . S_DELPICONLY . ']
 ' . S_DELKEY . '<input type="password" name="pwd" size="8" maxlength="8" value="" />
 <input type="submit" value="' . S_DELETE . '" /><input type="button" value="Report" onclick="var o=document.getElementsByTagName(\'INPUT\');for(var i=0;i<o.length;i++)if(o[i].type==\'checkbox\' && o[i].checked && o[i].value==\'delete\') return reppop(\'' . PHP_SELF_ABS . '?mode=report&no=\'+o[i].name+\'\');"></tr></td></form><script>document.delform.pwd.value=l("saguaro_delpass");</script></td></tr></table>';
         /*<script language="JavaScript" type="script"><!--
           l();
           //--></script>';*/
         //Delete this after implementing Index class.
         if (!$resno) {
             // if not in reply to mode
             $prev = $st - PAGE_DEF;
             $next = $st + PAGE_DEF;
             //  Page processing
             $dat .= "<table align=left border=1 class=pages><tr>";
             if ($prev >= 0) {
                 if ($prev == 0) {
                     $dat .= "<form action=\"" . PHP_SELF2 . "\" method=\"get\" /><td>";
                 } else {
                     $dat .= "<form action=\"" . $prev / PAGE_DEF . PHP_EXT . "\" method=\"get\"><td>";
                 }
                 $dat .= "<input type=\"submit\" value=\"" . S_PREV . "\" />";
                 $dat .= "</td></form>";
             } else {
                 $dat .= "<td>" . S_FIRSTPG . "</td>";
             }
             $dat .= "<td>";
             for ($i = 0; $i < $counttree; $i += PAGE_DEF) {
                 if ($i && !($i % (PAGE_DEF * 2))) {
                     $dat .= " ";
                 }
                 if ($st == $i) {
                     $dat .= "[" . $i / PAGE_DEF . "] ";
                 } else {
                     if ($i == 0) {
                         $dat .= "[<a href=\"" . PHP_SELF2 . "\">0</a>] ";
                     } else {
                         $dat .= "[<a href=\"" . $i / PAGE_DEF . PHP_EXT . "\">" . $i / PAGE_DEF . "</a>] ";
                     }
                 }
             }
             $dat .= "</td>";
             if ($p >= PAGE_DEF && $counttree > $next) {
                 $dat .= "<td><form action=\"" . $next / PAGE_DEF . PHP_EXT . "\" method=\"get\">";
                 $dat .= "<input type=\"submit\" value=\"" . S_NEXT . "\" />";
                 $dat .= "</form></td>";
             } else {
                 $dat .= "<td>" . S_LASTPG . "</td>";
             }
             $dat .= "</tr></table><br clear=\"all\" />\n";
         } else {
             $dat .= "<br />";
         }
         //end delete
         require_once CORE_DIR . "/page/foot.php";
         $foot = new Footer();
         $dat .= $foot->format();
         if ($resno) {
             $logfilename = RES_DIR . $resno . PHP_EXT;
             $this->print_page($logfilename, $dat);
             $dat = '';
             if (!$rebuild) {
                 $deferred = $this->update(0);
             }
             break;
         }
         if ($page == 0) {
             $logfilename = PHP_SELF2;
         } else {
             $logfilename = $page / PAGE_DEF . PHP_EXT;
         }
         $this->print_page($logfilename, $dat);
         //chmod($logfilename,0666);
     }
     //mysql_free_result($treeline);
     if (isset($deferred)) {
         return $deferred;
     }
     return false;
 }