Advertisement
bejiitas_wrath

4chan index.php code.

Apr 18th, 2025
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.07 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'lib/util.php';
  4.  
  5. define('IS_4CHANNEL', preg_match('/(^|\.)4channel.org$/', $_SERVER['HTTP_HOST']));
  6.  
  7. $url_domain = (IS_4CHANNEL ? '4channel.org' : '4chan.org');
  8.  
  9. $custom_header = '';
  10.  
  11. $custom_footer = '';
  12.  
  13. if (IS_4CHANNEL) {
  14. //$custom_footer = "<script>var a= document.createElement('script');a.src = 'https://powerad.ai/script.js';a.setAttribute('async','');top.document.querySelector('head').appendChild(a);</script>";
  15. }
  16.  
  17. function build_post_json($post) {
  18. $fields = array(
  19. 'board', 'type', 'no', 'resto', 'name', 'email', 'sub', 'com', 'id', 'capcode', 'now', 'replies', 'images'
  20. );
  21.  
  22. $FORCED_ANON_ARR = array(
  23. 'b',
  24. 'soc',
  25. );
  26.  
  27. $COUNTRY_FLAGS_ARR = array(
  28. 'int',
  29. 'sp',
  30. 'pol'
  31. );
  32.  
  33. $json = array();
  34.  
  35. foreach ($fields as $key) {
  36. $json[$key] = $post[$key];
  37. }
  38.  
  39. if ($json['com']) {
  40. $json['com'] = preg_replace('/&gt;&gt;([0-9]+)/', '<a href="#" class="quotelink">&gt;&gt;$1</a>', $json['com']);
  41. }
  42.  
  43. if ($post['filedeleted'] == '0') {
  44. if ($post['ext'] != '') {
  45. $fields = array('ext', 'fsize', 'tim', 'tn_w', 'tn_h', 'filename', 'w', 'h');
  46.  
  47. foreach ($fields as $key) {
  48. $json[$key] = $post[$key];
  49. }
  50. }
  51. }
  52. else {
  53. $json['filedeleted'] = 1;
  54. }
  55.  
  56. if (strpos($json['name'], '</span> <span class="postertrip">') !== false) {
  57. $name = explode('</span> <span class="postertrip">', $json['name']);
  58. $json['name'] = $name[0];
  59. $json['trip'] = $name[1];
  60. }
  61.  
  62. if (strpos($json['sub'], 'SPOILER<>') === 0) {
  63. $json['sub'] = substr($json['sub'], 9);
  64. $json['spoiler'] = 1;
  65. }
  66.  
  67. if (in_array($json['board'], $FORCED_ANON_ARR)
  68. && ($post['capcode'] != 'admin' && $post['capcode'] != 'admin_hl')
  69. ) {
  70. unset($json['trip']);
  71. unset($json['email']);
  72. $json['name'] = 'Anonymous';
  73. }
  74.  
  75. if (in_array($json['board'], $COUNTRY_FLAGS_ARR) && $post['capcode'] == 'none') {
  76. $json['country'] = $post['country'];
  77. }
  78.  
  79. return $json;
  80. }
  81.  
  82. // cookies and option settings
  83. $options = array();
  84. function do_option($option, $cookiename, $valid_options) {
  85. global $options;
  86. if(isset($_COOKIE[$cookiename]) or isset($_GET[$option])) {
  87. if(isset($_GET[$option])) // new setting
  88. $options[$option] = $_GET[$option];
  89. else // cookied setting
  90. $options[$option] = $_COOKIE[$cookiename];
  91. // check validity
  92. if(!in_array($options[$option], $valid_options))
  93. $options[$option] = $valid_options[0];
  94.  
  95. setcookie($cookiename, $options[$option], time()+365*24*3600, "/");
  96. }
  97. // no cookie or GET, use default value
  98. else {
  99. $options[$option] = $valid_options[0];
  100. }
  101. }
  102.  
  103. do_option('filter_boards', 'fpb', array('all', 'ws', 'nws', 'allc'));
  104. //do_option('filter_text', 'fptxt', array('hide','show'));
  105. do_option('content', 'fpc', array('ws', 'nws', 'all'));
  106.  
  107. // override ws/nws filter
  108. if (IS_4CHANNEL || (isset($_GET['c']) && $_GET['c'] === 'ws')) {
  109. $options['filter_boards'] = 'ws';
  110. $options['content'] = 'ws';
  111. }
  112.  
  113. $options['use_catalog'] = isset($_COOKIE['fpcat']);
  114.  
  115. $options['disclaimer_done'] = false;
  116. if(isset($_COOKIE['4chan_disclaimer'])) {
  117. $options['disclaimer_done'] = $_COOKIE['4chan_disclaimer'];
  118. setcookie('4chan_disclaimer', $_COOKIE['4chan_disclaimer'], time()+365*24*3600, "/");
  119. }
  120.  
  121. $options['last_announce_closed'] = 0;
  122. if(isset($_COOKIE['annc'])) {
  123. $options['last_announce_closed'] = $_COOKIE['annc'];
  124. setcookie('annc', $_COOKIE['annc'], time()+365*24*3600, "/");
  125. }
  126.  
  127. $options['whatis4chan_closed'] = 0;
  128. if(isset($_COOKIE['wi4c'])) {
  129. $options['whatis4chan_closed'] = $_COOKIE['wi4c'];
  130. setcookie('wi4c', $_COOKIE['wi4c'], time()+365*24*3600, "/");
  131. }
  132.  
  133. $use_frames = !isset($_GET['noframes']);
  134.  
  135. if(isset($_COOKIE['4chan_frames']) && $_COOKIE['4chan_frames'] && $use_frames) {
  136. $options['4chan_frames'] = 1;
  137. }
  138. else {
  139. $options['4chan_frames'] = 0;
  140. }
  141. // page content
  142. function title() {
  143. echo "4chan";
  144. }
  145.  
  146.  
  147. function iOSmeta() {
  148. // echo '<meta name="apple-itunes-app" content="app-id=1124861180, affiliate-data=4chan" />';
  149. }
  150.  
  151. function anti_adblock() { ?>
  152.  
  153. <? }
  154.  
  155.  
  156. $announce_type = 0;
  157. $announce_serial = 0;
  158.  
  159. if (!$options['whatis4chan_closed']) {
  160. $announce_type = 1;
  161. }
  162.  
  163. if(file_exists('data/announce.txt')) {
  164. $announce_content = file('data/announce.txt');
  165. // first line is serial number, strip out non-digits (gets rid of newline and possible BOM etc.)
  166. $announce_serial = (int) preg_replace("#[^0-9]#", "", array_shift($announce_content));
  167. // rest is body
  168. $announce_content = trim(implode("", $announce_content));
  169.  
  170. if ($announce_content !== '' && $options['last_announce_closed'] < $announce_serial) {
  171. $announce_type = 2;
  172. }
  173. }
  174.  
  175. //echo "<!-- ".$options['last_announce_closed']." $announce_serial $show_announce-->";
  176.  
  177. function announce_title() {
  178. global $announce_type;
  179. if ($announce_type === 1) {
  180. ?>What is 4chan?<?
  181. }
  182. else if ($announce_type === 2) {
  183. ?>Announcement<?
  184. }
  185. }
  186.  
  187. function announce_content() {
  188. global $options, $announce_content, $announce_type;
  189. if($announce_type === 1) { ?><div id="wot-cnt"></div><? }
  190. else if ($announce_type === 2) {
  191. echo $announce_content;
  192. }
  193. }
  194. /*
  195. function mobile_ad_tag() { ?>
  196. <div id="mobile-ad-top"></div>
  197. <script type="text/javascript">
  198. if (window.matchMedia && window.matchMedia('(max-device-width: 480px)').matches) {
  199. window.mopub = [{
  200. ad_unit: "b90d27bd6740472eac8ee888b73651fe",
  201. ad_container_id: "mobile-ad-top",
  202. ad_width: 320,
  203. ad_height: 50,
  204. keywords: "",
  205. } ];
  206.  
  207. (function() {
  208. var mopubjs = document.createElement("script");
  209. mopubjs.async = true;
  210. mopubjs.type = "text/javascript";
  211. mopubjs.src = "//d1zg4cyg8u4pko.cloudfront.net/mweb/mobileweb.min.js";
  212. var node = document.getElementsByTagName("script")[0];
  213. node.parentNode.insertBefore(mopubjs, node);
  214. })();
  215. }
  216. </script>
  217. <? }
  218. */
  219. $top_box_count = 3;
  220.  
  221. $top_box_id[0] = "boards";
  222. $top_box_button[0] = '<div id="filter-btn" data-cmd="filter">filter ▼</div>';
  223. function top_box_title_0() {
  224. ?>Boards<?
  225. }
  226.  
  227. $info = array();
  228. include 'data/boards.php';
  229.  
  230. function top_box_content_0() {
  231. global $info, $options;
  232. global $boards;
  233.  
  234. $catalog = $options['use_catalog'] ? 'catalog' : '';
  235.  
  236. foreach($boards['img'] as $board) {
  237. $info[$board['dir']] = array(
  238. 'path' => '//' . $board['domain'] . '.' . L::d($board['dir']) . '/' . $board['dir'] . '/' . $catalog,
  239. 'title' => $board['name'],
  240. 'domain' => $board['domain'],
  241. 'nws' => $board['nws']
  242. );
  243. }
  244.  
  245. foreach($boards['upload'] as $board) {
  246. $info[$board['dir']] = array(
  247. 'path' => '//' . $board['domain'] . '.' . L::d($board['dir']) . '/' . $board['dir'] . '/',
  248. 'title' => $board['name'],
  249. 'domain' => $board['domain'],
  250. 'nws' => $board['nws']
  251. );
  252. }
  253.  
  254. if($options['filter_boards'] == 'allc') {
  255. $board_categories = array(
  256. "Image Boards" => array("3", "a", "aco", "adv", "an", "asp", "b", "bant", "biz", "c", "cgl", "ck", "cm", "co", "d"),
  257. "Image Boards+" => array("diy", "e", "fa", "fit", "g", "gd", "gif", "h", "hc", "hm", "hr", "i", "ic", "his", "int", "jp"),
  258. "Image Boards++" => array("k", "lit", "lgbt", "m", "mlp", "mu", 'news', "p", "po", "pol", "pw", "qst", "r", "r9k", "s4s", "s"),
  259. "Image Boards+++" => array("sci", "soc", "sp", "t", "tg", "toy", 'trash', "trv", "tv", "n", "news", "o", "out", "u", "v"),
  260. "Image Boards++++" => array("vg", "vm", "vmg", "vip", "vp", "vr", "vrpg", "vst", "vt", "w", "wg", "wsg", 'wsr', "x", "xs", "y"),
  261. "Upload Boards" => array("f")
  262. );
  263. $column_numbers = array(
  264. "Image Boards" => 1,
  265. "Image Boards+" => 2,
  266. "Image Boards++" => 3,
  267. "Image Boards+++" => 4,
  268. "Image Boards++++" => 5,
  269. "Upload Boards" => 5
  270. );
  271. }
  272. else {
  273. $board_categories = array(
  274. "Japanese Culture" => array("a", "c", "w", "m", "cgl", "cm", "f", "n", "jp", "vt"),
  275. "Video Games" => array('v', 'vg', 'vm', 'vmg', 'vp', 'vr', 'vrpg', 'vst'),
  276. "Interests" => array("co", "g", "tv", "k", "o", "an", "tg", "sp", "xs", "pw", "sci", "his", "int", "out", "toy"),
  277. "Creative" => array("i", "po", "p", "ck", "ic", "wg", "lit", "mu", "fa", "3", "gd", "diy", "wsg", "qst"),
  278. "Adult(NSFW)" => array("s", "hc", "hm", "h", "e", "u", "d", "y", "t", "hr", "gif", "aco", "r"),
  279. "Other" => array("biz", "trv", "fit", "x", "adv", "lgbt", "mlp", "news", 'wsr', 'vip'),
  280. "Misc.(NSFW)" => array("b", "r9k", "pol", "bant", "soc", "s4s")
  281. );
  282.  
  283. $column_numbers = array(
  284. "Japanese Culture" => 0,
  285. 'Video Games' => 0,
  286. "Interests" => 1,
  287. "Creative" => 2,
  288. "Other" => 3,
  289. "Misc.(NSFW)" => 3,
  290. "Adult(NSFW)" => 4
  291. );
  292. }
  293.  
  294. $sfw_only = ($options['filter_boards'] == 'ws');
  295. $nsfw_only = ($options['filter_boards'] == 'nws');
  296.  
  297. $columns = array();
  298. foreach($column_numbers as $cat=>$col) {
  299. if(!isset($columns[$col]))
  300. $columns[$col] = array();
  301. $columns[$col][] = $cat;
  302. }
  303. foreach($columns as $categories) {
  304. $any_categories_printed = false;
  305.  
  306. foreach($categories as $category) {
  307.  
  308. $display_category = $category;
  309. $display_category = preg_replace("#[+]+$#"," (cont.)", $display_category);
  310. $display_category = str_replace("(NSFW)","</h3> <h3 style=\"display: inline;\"><span class=\"warning\" title=\"Not Safe For Work\"><sup style=\"vertical-align: text-bottom;\">(NSFW)</sup></span>",$display_category);
  311.  
  312. $any_boards_printed = false;
  313. foreach($board_categories[$category] as $board) {
  314. if (isset($info[$board]['text']) && $options['filter_text'] == 'hide') {
  315. continue;
  316. }
  317.  
  318. if ($sfw_only && $info[$board]['nws']) {
  319. continue;
  320. }
  321.  
  322. if ($nsfw_only && !$info[$board]['nws']) {
  323. continue;
  324. }
  325.  
  326. if(!$any_categories_printed) {
  327. $any_categories_printed = true;
  328. ?>
  329. <div class="column">
  330. <?
  331. }
  332. if(!$any_boards_printed) {
  333. $any_boards_printed = true;
  334. ?>
  335. <h3 style="text-decoration: underline; display: inline;"><?=$display_category?></h3>
  336. <ul>
  337. <?
  338. }
  339. ?>
  340. <li><a href="<?=$info[$board]['path']?>" class="boardlink"><?=htmlspecialchars($info[$board]['title'])?></a></li>
  341. <?
  342. }
  343. if($any_boards_printed) {
  344. ?>
  345. </ul>
  346. <?
  347. }
  348. }
  349. if($any_categories_printed) {
  350. ?>
  351. </div>
  352. <?
  353. }
  354. }
  355. ?>
  356. <br class="clear-bug"/>
  357. <?
  358. }
  359.  
  360. function wordwrap2( $str, $cols, $cut )
  361. {
  362. // if there's no runs of $cols non-space characters, wordwrap is a no-op
  363. if( mb_strlen( $str ) < $cols || !preg_match( '/[^ <>]{' . $cols . '}/', $str ) ) {
  364. return $str;
  365. }
  366. $sections = preg_split( '/[<>]/', $str );
  367. $str = '';
  368. for( $i = 0; $i < count( $sections ); $i++ ) {
  369. if( $i % 2 ) { // inside a tag
  370. $str .= '<' . $sections[$i] . '>';
  371. } else { // outside a tag
  372. $words = explode( ' ', $sections[$i] );
  373. $exclude = array(
  374. 'http://',
  375. 'https://',
  376. 'www.'
  377. );
  378.  
  379. foreach( $words as &$word ) {
  380. foreach( $exclude as $match ) {
  381. if (stripos($word, $match) === 0 && (stripos($word, '4chan.org') !== false || stripos($word, '4channel.org') !== false)) continue 2;
  382. }
  383.  
  384. $word = htmlspecialchars_decode( $word, ENT_QUOTES );
  385. $word = utf8_wordwrap( $word, $cols, $cut, true );
  386. $word = htmlspecialchars( $word, ENT_QUOTES );
  387.  
  388. }
  389.  
  390. $str .= implode( ' ', $words );
  391. }
  392. }
  393.  
  394. return $str;
  395. }
  396. /*
  397. function utf8_wordwrap( $string, $width = 75, $break = "\n", $cut = false )
  398. {
  399. if( $cut ) {
  400. // Cut lines that are too long by hand, even if they aren't official break opportunities
  401. $search = '/(.{' . $width . '})/uS';
  402. $replace = '$1$2' . $break;
  403. }
  404.  
  405. return preg_replace( $search, $replace, $string );
  406. }
  407. */
  408.  
  409. function render_tooltip_contents($post) {
  410. global $info;
  411. $fsize = (int)($post['fsize']/1024);
  412. $thumburl = '//i.4cdn.org/' . $post['board'] . '/' . $post['tim'] . 's.jpg';
  413. $post['com'] = wordwrap2($post['com'], 50, "<br />");
  414. $com = explode("<br />", $post['com']);
  415. if(count($com) > 7) {
  416. $com = array_slice($com, 0, 7);
  417. $com[] = "...";
  418. }
  419. $com = implode("<br />", $com);
  420.  
  421. // quote lines
  422. $com = preg_replace("!(^|>)(&gt;[^<]*)!", "\\1<span class=\"unkfunc\">\\2</span>", $com);
  423. // quote links
  424. $com = preg_replace("!((&gt;)?&gt;&gt;(/?\w+/)?\d+)!",'<a href="#">$1</a>', $com);
  425.  
  426.  
  427.  
  428. $title = "/{$post['board']}/ - " . htmlspecialchars( $info[$post['board']]['title'] );
  429.  
  430. $html = "";
  431.  
  432. $FORCED_ANON_ARR = array(
  433. 'b',
  434. 'soc'
  435. );
  436.  
  437. $META_BOARD_ARR = array(
  438. 'q'
  439. );
  440.  
  441. $board = $post['board'];
  442.  
  443. if( in_array( $board, $FORCED_ANON_ARR ) || in_array( $board, $META_BOARD_ARR ) ) {
  444. $post['name'] = 'Anonymous';
  445. }
  446.  
  447. if( in_array( $board, $FORCED_ANON_ARR ) ) {
  448. $post['sub'] = '';
  449. }
  450.  
  451. $html .= <<<EOHTML
  452. <h2>$title</h2>
  453. <div class="post">
  454. EOHTML;
  455. $wh = ($post['tn_w'] > 1) ? "width={$post['tn_w']} height={$post['tn_h']}" : "";
  456. if($post['fsize'])
  457. $html .= <<<EOHTML
  458. <span class="p_filesize">File: <a href="#">{$post['time']}{$post['ext']}</a>-($fsize KB, {$post['w']}x{$post['h']}, {$post['filename']}{$post['ext']})</span><br>
  459. <img src="$thumburl" align=left $wh hspace=20 alt="Thumbnail unavailable">
  460. EOHTML;
  461. $html .= <<<EOHTML
  462. <span class="p_filetitle">{$post['sub']}</span>
  463. <span class="p_postername">{$post['name']}</span>
  464. {$post['now']}
  465. No.{$post['no']}<blockquote>$com</blockquote>
  466. </div>
  467. EOHTML;
  468. echo htmlspecialchars($html);
  469. }
  470.  
  471. function format_comment($str) {
  472. // remove sjis
  473. /*
  474. if (SJIS_TAGS && strpos($str, '<span class="sjis"') !== false) {
  475. $str = preg_replace('/<span class="sjis".+?<\/span>/', '[SJIS]', $str);
  476. }
  477. */
  478.  
  479. $str = preg_replace('/(<br>)+/', "\n", $str);
  480.  
  481. // remove html tags
  482. $str = preg_replace('/<[^>]*(>|$)/', '', $str);
  483.  
  484. $len = mb_strlen($str);
  485.  
  486. $length = 100;
  487.  
  488. if ($len <= $length) {
  489. return $str;
  490. }
  491.  
  492. $str = mb_substr($str, 0, $length);
  493.  
  494. // remove truncated html entities
  495. $str = preg_replace('/&[^;]*$/', '', $str);
  496.  
  497. $str .= '...';
  498.  
  499. return $str;
  500. }
  501.  
  502. function summarize($post) {
  503. if($post['sub']) {
  504. $com = $post['sub'];
  505. }
  506. else {
  507. $com = $post['com'];
  508. // strip out URLs...
  509. $com = preg_replace('{//[\S"\'<]+}','',$com);
  510. // remove linebreaks
  511. $com = preg_replace('{<br ?/?>}',"\n",$com);
  512. // take the first sentence that's longer than 6 letters...
  513. $sentences = preg_split('{[\n.]+}',$com);
  514. $com = '';
  515. foreach($sentences as $sent) {
  516. if(strlen($sent) > 6 && strpos($sent,"&gt;")!==0 && strpos($sent,"EXIF data")!==0 && strpos($sent,"Oekaki post")!==0) {
  517. $com = $sent;
  518. break;
  519. }
  520. }
  521. }
  522. // unescape html entities
  523. $com = htmlspecialchars_decode($com, ENT_QUOTES);
  524.  
  525. // replace nonsensical escaped commas
  526. $com = str_replace("&#44;", ",", $com);
  527.  
  528. // and get the first X chars of it, making sure that words don't get cut off
  529. // all-caps subjects are wider
  530. if ($com == strtoupper($com)) {
  531. $com = preg_replace('{^(.{20,}?)(?:[\s\n.]|$).*}','$1',$com);
  532.  
  533. if (strlen($com) >= 20) {
  534. $com .= '...';
  535. }
  536. }
  537. else {
  538. $com = preg_replace('{^(.{30,}?)(?:[\s\n.]|$).*}','$1',$com);
  539.  
  540. if (strlen($com) >= 30) {
  541. $com .= '...';
  542. }
  543. }
  544. // defeat superlong words
  545. if (mb_strlen($com) > 43) {
  546. $com = mb_substr($com, 0, 40) . "...";
  547. }
  548.  
  549. // escape html entities
  550. if ($com) {
  551. $com = strip_tags($com);
  552. return htmlspecialchars($com, ENT_QUOTES);
  553. }
  554.  
  555. if ($post['name'] && mb_strlen($post['name'] < 40)) {
  556. return strip_tags("No.{$post['no']} by {$post['name']}");
  557. }
  558.  
  559. return "No.{$post['no']}";
  560. }
  561.  
  562. function calc_thumbnail_size($post, $max_size = 150) {
  563. $w = $post['tn_w'];
  564. $h = $post['tn_h'];
  565.  
  566. if ($w > $max_size) {
  567. $ratio = $max_size / (float)$w;
  568. $w = $max_size;
  569. $h = round($h * $ratio);
  570. }
  571.  
  572. if ($h > $max_size) {
  573. $ratio = $max_size / (float)$h;
  574. $h = $max_size;
  575. $w = round($w * $ratio);
  576. }
  577.  
  578. return array($w, $h);
  579. }
  580.  
  581. $top_box_id[1] = 'popular-threads';
  582.  
  583. if (IS_4CHANNEL) {
  584. $top_box_button[1] = '';
  585. }
  586. else {
  587. $top_box_button[1] = '<div id="opts-btn" data-cmd="opts">options ▼</div>';
  588. }
  589.  
  590. function top_box_title_1() {
  591. ?>Popular Threads<?
  592. }
  593.  
  594. function top_box_content_1($async = false) {
  595. global $info, $options, $boards_flat;
  596. $posts = unserialize(file_get_contents('data/.popular_threads.cgi'));
  597. shuffle($posts);
  598.  
  599. $total = 0;
  600. $max_threads = 8;
  601. $count = count($posts);
  602.  
  603. $dup_boards = array();
  604.  
  605. echo '<div id="c-threads">';
  606.  
  607. for ($i = 0; $i < $count && $total < $max_threads; $i++) {
  608. $posts[$i]['domain'] = $info[$posts[$i]['board']]['domain'];
  609. $ws = $boards_flat[$posts[$i]['board']]['nws'] ? 'nws' : 'ws';
  610.  
  611. if ($options['content'] != $ws && $options['content'] != 'all') {
  612. continue;
  613. }
  614.  
  615. $picky = ($count - $i) > ($max_threads - $total);
  616.  
  617. if ($picky && isset($dup_boards[$posts[$i]['board']])) {
  618. continue;
  619. }
  620.  
  621. $dup_boards[$posts[$i]['board']] = true;
  622.  
  623. $url = '//' . $posts[$i]['domain'] . '.' . L::d($posts[$i]['board']) . '/'
  624. . $posts[$i]['board'] . '/thread/' . $posts[$i]['no'];
  625.  
  626. $thumb = '//i.4cdn.org/' . $posts[$i]['board'] . '/' . $posts[$i]['tim'] . 's.jpg';
  627.  
  628. $teaser = '';
  629.  
  630. if ($posts[$i]['sub'] !== '') {
  631. $teaser .= '<b>' . $posts[$i]['sub'] . '</b>';
  632. }
  633.  
  634. if ($posts[$i]['com'] !== '') {
  635. if ($teaser !== '') {
  636. $teaser .= ': ';
  637. }
  638.  
  639. $teaser .= format_comment($posts[$i]['com']);
  640. }
  641.  
  642. list($w, $h) = calc_thumbnail_size($posts[$i]);
  643.  
  644. ?>
  645. <div class="c-thread"><div class="c-board"><?php echo htmlspecialchars($info[$posts[$i]['board']]['title']) ?></div><a href="<?php echo $url; ?>" class="boardlink"><img alt="" class="c-thumb" src="<?php echo $thumb ?>" width="<?php echo $w ?>" height="<?php echo $h ?>"></a><div class="c-teaser"><?php echo $teaser ?></div></div>
  646. <?
  647. $total++;
  648. $posts[$i]['type'] = $ws;
  649. }
  650.  
  651. echo '</div>';
  652. }
  653.  
  654. $top_box_id[2] = 'site-stats';
  655.  
  656. function top_box_title_2() {
  657. ?>Stats<?
  658. }
  659.  
  660. function top_box_content_2($async = false) {
  661. $stats = unserialize(file_get_contents('data/.stats.cgi'));
  662. ?>
  663. <div class="stat-cell"><b>Total Posts:</b> <?php echo number_format($stats['post_total']) ?></div>
  664. <div class="stat-cell"><b>Current Users:</b> <?php echo number_format($stats['ips_total']) ?></div>
  665. <div class="stat-cell"><b>Active Content:</b> <?php echo (int)($stats['size_total']/1024/1024/1024) ?> GB</div>
  666.  
  667. <?
  668. }
  669.  
  670. function bottom_ad_728x90() { /*
  671. ?>
  672. <script type="text/javascript">
  673. atOptions = {
  674. 'key' : '460b6aa5e0f6699fc014b783299dad5a',
  675. 'format' : 'iframe',
  676. 'height' : 90,
  677. 'width' : 728,
  678. 'params' : {}
  679. };
  680. document.write('<scr' + 'ipt type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://www.bnhtml.com/invoke.js"></scr' + 'ipt>');
  681. </script><? */
  682. }
  683.  
  684. $include_yui = false;
  685. function external_script() {
  686. ?>//s.4cdn.org/js/frontpage.min.7.js<?
  687. }
  688.  
  689. function inline_script() {
  690. global $show_announce, $options;
  691.  
  692. // these have to match the order of the menu items (which could be different from the valid_options at the top
  693.  
  694. $opts_json = array();
  695. if (isset($options['filter_boards'])) {
  696. $opts_json['fpb'] = $options['filter_boards'];
  697. }
  698. else {
  699. $opts_json['fpb'] = 'all';
  700. }
  701.  
  702. if (isset($options['filter_boards'])) {
  703. $opts_json['fpc'] = $options['content'];
  704. }
  705. else {
  706. $opts_json['fpc'] = 'ws';
  707. }
  708. if ($options['4chan_frames']) {
  709. $opts_json['4chan_frames'] = 1;
  710. }
  711. if ($options['use_catalog']) {
  712. $opts_json['fpcat'] = 1;
  713. }
  714.  
  715. echo "var Opts = " . json_encode($opts_json) . ";";
  716.  
  717. }
  718.  
  719. if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
  720. ob_start();
  721. top_box_content_0();
  722. $boardlist = str_replace("\n"," ", addslashes(ob_get_contents()));
  723. ob_end_clean();
  724. ob_start();
  725. top_box_content_1(true);
  726. $popularthreads = str_replace("\n"," ", addslashes(ob_get_contents()));
  727. ob_end_clean();
  728. header('Cache-Control: no-cache');
  729.  
  730. if($_GET['filter_boards']) {
  731. echo 'YAHOO.util.Dom.getElementsByClassName("boxcontent","div","boards")[0].innerHTML="';
  732. echo ($boardlist);
  733. echo '";';
  734. }
  735. else if($_GET['content']) {
  736. echo 'YAHOO.util.Dom.getElementsByClassName("boxcontent","div","popular-threads")[0].innerHTML="';
  737. echo ($popularthreads);
  738. echo '";';
  739. }
  740. die('');
  741. }
  742. include 'frontpage_template.php';
Tags: php 4chan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement