Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 17.54 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3.  * This file is part of kusaba.
  4.  *
  5.  * kusaba is free software; you can redistribute it and/or modify it under the
  6.  * terms of the GNU General Public License as published by the Free Software
  7.  * Foundation; either version 2 of the License, or (at your option) any later
  8.  * version.
  9.  *
  10.  * kusaba is distributed in the hope that it will be useful, but WITHOUT ANY
  11.  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12.  * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License along with
  15.  * kusaba; if not, write to the Free Software Foundation, Inc.,
  16.  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  17.  */
  18. /**
  19.  * Script configuration
  20.  *
  21.  * Tells the script what to call itself, where the database and other things are
  22.  * located, along with define what features to enable.
  23.  *
  24.  * @package kusaba
  25.  */
  26. /*
  27. To enable a feature, change the value to true:
  28.         define('KU_INSTANTREDIRECT', true);
  29. To disable a feature, change the value to false:
  30.         define('KU_INSTANTREDIRECT', false;
  31.  
  32. To change the text value of a configuration, edit the text in the single quotes:
  33.         define('KU_NAME', 'kusaba');
  34. Becomes:
  35.         define('KU_NAME', 'Mychan');
  36. Warning: Do not insert single quotes in the value yourself, or else you will cause problems.  To overcome this, you use what is called escaping, which is the process of adding a backslash before the single quote, to show it is part of the string:
  37.         define('KU_NAME', 'Jason\'s chan');
  38.  
  39. */
  40. // Sets error reporting to hide notices.
  41. error_reporting(E_ALL ^ E_NOTICE);
  42. if (!headers_sent()) {
  43.         header('Content-Type: text/html; charset=utf-8');
  44. }
  45.  
  46. $cf = array();
  47.  
  48. // Caching (this needs to be set at the start because if enabled, it skips the rest of the configuration process)
  49.         $cf['KU_APC'] = false;
  50.  
  51. $cache_loaded = false;
  52. if ($cf['KU_APC']) {
  53.         if (apc_load_constants('config')) {
  54.                 $cache_loaded = true;
  55.         }
  56. }
  57.  
  58. if (!$cache_loaded) {
  59.         // Database
  60.                 $cf['KU_DBTYPE']          = 'mysqli';   // Database type. Valid values are mysql and mysqli (reccomended for mysql).
  61.                                                         // PostgreSQL is also supported. Supported values are postgres64, postgres7 and postgres8. Only postgres8 is tested.
  62.                                                         // SQLite is also supported. Set to sqlite to use. SQLite will not use any database software, only a single file.
  63.                 $cf['KU_DBHOST']          = 'localhost'; // Database hostname. On SQLite this has no effect.
  64.                 $cf['KU_DBDATABASE']      = 'anonymo2_newchan'; // Database... database. On SQLite this will be the path to your database file. Secure this file.
  65.                 $cf['KU_DBUSERNAME']      = 'anonymo2_newchan'; // Database username. On SQLite this has no effect.
  66.                 $cf['KU_DBPASSWORD']      = '6768543'; // Database password. On SQLite this has no effect.
  67.                 $cf['KU_DBPREFIX']        = ''; // Database table prefix
  68.                 $cf['KU_DBUSEPERSISTENT'] = false; // Use persistent connection to database
  69.  
  70.         // Imageboard info
  71.                 $cf['KU_NAME']      = 'AnonChan'; // The name of your site
  72.                 $cf['KU_SLOGAN']    = '<em>Made from the blood of tigers</em>'; // Site slogan, set to nothing to disable its display
  73.                 $cf['KU_HEADERURL'] = ''; // Full URL to the header image (or rotation script) to be displayed, can be left blank for no image
  74.                 $cf['KU_IRC']       = ''; // IRC info, which will be displayed in the menu.  Leave blank to remove it
  75.                 $cf['KU_BANREASON']     = ''; // This is the default ban reason that will automatically fill in the ban reason box
  76.  
  77.         // Paths and URLs
  78.                 // Main installation directory
  79.                         $cf['KU_ROOTDIR']   = realpath(dirname(__FILE__))."/"; // Full system path of the folder containing kusaba.php, with trailing slash. The default value set here should be OK.. If you need to change it, you should already know what the full path is anyway.
  80.                         $cf['KU_WEBFOLDER'] = '/'; // The path from the domain of the board to the folder which kusaba is in, including the trailing slash.  Example: "http://www.yoursite.com/misc/kusaba/" would have a $cf['KU_WEBFOLDER'] of "/misc/kusaba/"
  81.                         $cf['KU_WEBPATH']   = 'http://4chan.co.cc'; // The path to the index folder of kusaba, without trailing slash. Example: http://www.yoursite.com
  82.                         $cf['KU_DOMAIN']    = 'http://4chan.co.cc'; // Used in cookies for the domain parameter.  Should be a period and then the top level domain, which will allow the cookies to be set for all subdomains.  For http://www.randomchan.org, the domain would be .randomchan.org; http://zachchan.freehost.com would be zach.freehost.com
  83.  
  84.                 // Board subdomain/alternate directory (optional, change to enable)
  85.                         // DO NOT CHANGE THESE IF YOU DO NOT KNOW WHAT YOU ARE DOING!!
  86.                         $cf['KU_BOARDSDIR']    = $cf['KU_ROOTDIR'];
  87.                         $cf['KU_BOARDSFOLDER'] = $cf['KU_WEBFOLDER'];
  88.                         $cf['KU_BOARDSPATH']   = $cf['KU_WEBPATH'];
  89.  
  90.                 // CGI subdomain/alternate directory (optional, change to enable)
  91.                         // DO NOT CHANGE THESE IF YOU DO NOT KNOW WHAT YOU ARE DOING!!
  92.                         $cf['KU_CGIDIR']    = $cf['KU_BOARDSDIR'];
  93.                         $cf['KU_CGIFOLDER'] = $cf['KU_BOARDSFOLDER'];
  94.                         $cf['KU_CGIPATH']   = $cf['KU_BOARDSPATH'];
  95.  
  96.                 // Coralized URLs (optional, change to enable)
  97.                         $cf['KU_WEBCORAL']    = ''; // Set to the coralized version of your webpath to enable.  If not set to '', URLs which can safely be cached will be coralized, and will use the Coral Content Distribution Network.  Example: http://www.kusaba.org becomes http://www.kusaba.org.nyud.net, http://www.crapchan.org/kusaba becomes http://www.crapchan.org.nyud.net/kusaba
  98.                         $cf['KU_BOARDSCORAL'] = '';
  99.  
  100.         // Templates
  101.                 $cf['KU_TEMPLATEDIR']       = $cf['KU_ROOTDIR'] . 'dwoo/templates'; // Dwoo templates directory
  102.                 $cf['KU_CACHEDTEMPLATEDIR'] = $cf['KU_ROOTDIR'] . 'dwoo/templates_c'; // Dwoo compiled templates directory.  This folder MUST be writable (you may need to chmod it to 755).  Set to '' to disable template caching
  103.  
  104.         // CSS styles
  105.                 $cf['KU_STYLES']        = 'burichan:futaba'; // Styles which are available to be used for the boards, separated by colons, in lower case.  These will be displayed next to [Home] [Manage] if KU_STYLESWIKUHER is set to true
  106.                 $cf['KU_DEFAULTSTYLE']  = 'futaba'; // If Default is selected in the style list in board options, it will use this style.  Should be lower case
  107.                 $cf['KU_STYLESWITCHER'] = true; // Whether or not to display the different styles in a clickable switcher at the top of the board
  108.                 $cf['KU_DROPSWITCHER']  = false; // Whether or not to use a dropdown style switcher. False is use plaintext switcher, true is dropdown.
  109.  
  110.                 $cf['KU_TXTSTYLES']        = 'futatxt:buritxt'; // Styles which are available to be used for the boards, separated by colons, in lower case
  111.                 $cf['KU_DEFAULTTXTSTYLE']  = 'futatxt'; // If Default is selected in the style list in board options, it will use this style.  Should be lower case
  112.                 $cf['KU_TXTSTYLESWITCHER'] = true; // Whether or not to display the different styles in a clickable switcher at the top of the board
  113.  
  114.                 $cf['KU_MENUTYPE']          = 'normal'; // Type of display for the menu.  normal will add the menu styles and such as it normally would, plain will not use the styles, and will look rather boring
  115.                 $cf['KU_MENUSTYLES']        = 'futaba:burichan'; // Menu styles
  116.                 $cf['KU_DEFAULTMENUSTYLE']  = 'futaba'; // Default menu style
  117.                 $cf['KU_MENUSTYLESWITCHER'] = true; // Whether or not to display the different styles in a clickable switcher in the menu
  118.  
  119.         // Limitations
  120.                 $cf['KU_NEWTHREADDELAY'] = 30; // Minimum time in seconds a user must wait before posting a new thread again
  121.                 $cf['KU_REPLYDELAY']     = 7; // Minimum time in seconds a user must wait before posting a reply again
  122.                 $cf['KU_LINELENGTH']     = 150; // Used when cutting long post messages on pages and placing the message too long notification
  123.  
  124.         // Image handling
  125.                 $cf['KU_THUMBWIDTH']       = 200; // Maximum thumbnail width
  126.                 $cf['KU_THUMBHEIGHT']      = 200; // Maximum thumbnail height
  127.                 $cf['KU_REPLYTHUMBWIDTH']  = 125; // Maximum thumbnail width (reply)
  128.                 $cf['KU_REPLYTHUMBHEIGHT'] = 125; // Maximum thumbnail height (reply)
  129.                 $cf['KU_CATTHUMBWIDTH']    = 50; // Maximum thumbnail width (catalog)
  130.                 $cf['KU_CATTHUMBHEIGHT']   = 50; // Maximum thumbnail height (catalog)
  131.                 $cf['KU_THUMBMETHOD']      = 'gd'; // Method to use when thumbnailing images in jpg, gif, or png format.  Options available: gd, imagemagick
  132.                 $cf['KU_ANIMATEDTHUMBS']   = true; // Whether or not to allow animated thumbnails (only applies if using imagemagick)
  133.  
  134.         // Post handling
  135.                 $cf['KU_NEWWINDOW']       = true; // When a user clicks a thumbnail, whether to open the link in a new window or not
  136.                 $cf['KU_MAKELINKS']       = true; // Whether or not to turn http:// links into clickable links
  137.                 $cf['KU_NOMESSAGETHREAD'] = ''; // Text to set a message to if a thread is made with no text
  138.                 $cf['KU_NOMESSAGEREPLY']  = ''; // Text to set a message to if a reply is made with no text
  139.  
  140.         // Post display
  141.                 $cf['KU_THREADS']         = 10; // Number of threads to display on a board page
  142.                 $cf['KU_THREADSTXT']      = 15; // Number of threads to display on a text board front page
  143.                 $cf['KU_REPLIES']         = 3; // Number of replies to display on a board page
  144.                 $cf['KU_REPLIESSTICKY']   = 1; // Number of replies to display on a board page when a thread is stickied
  145.                 $cf['KU_THUMBMSG']        = false; // Whether or not to display the "Thumbnail displayed, click image for full size." message on posts with images
  146.                 $cf['KU_BANMSG']          = '<br /><font color="#FF0000"><b>(USER WAS BANNED FOR THIS POST)</b></font>'; // The text to add at the end of a post if a ban is placed and "Add ban message" is checked
  147.                 $cf['KU_TRADITIONALREAD'] = false; // Whether or not to use the traditional style for multi-quote urls.  Traditional: read.php/board/thread/posts, Non-traditional: read.php?b=board&t=thread&p=posts
  148.                 $cf['KU_YOUTUBEWIDTH']    = 200; // Width to display embedded YouTube videos
  149.                 $cf['KU_YOUTUBEHEIGHT']   = 164; // Height to display embedded YouTube videos
  150.  
  151.         // Pages
  152.                 $cf['KU_FIRSTPAGE'] = 'board.html'; // Filename of the first page of a board.  Only change this if you are willing to maintain the .htaccess files for each board directory (they are created with a DirectoryIndex board.html, change them if you change this)
  153.                 $cf['KU_DIRTITLE']  = false; // Whether or not to place the board directory in the board's title and at the top of the page.  true would render as "/b/ - Random", false would render as "Random"
  154.  
  155.         // File tagging
  156.                 $cf['KU_TAGS'] = array('Japanese' => 'J',
  157.                                        'Anime'    => 'A',
  158.                                        'Game'     => 'G',
  159.                                        'Loop'     => 'L',
  160.                                        'Other'    => '*'); // Used only in Upload imageboards.  These are the tags which a user may choose to use as they are posting a file.  If you wish to disable tagging on Upload imageboards, set this to ''
  161.  
  162.         // Special Tripcodes
  163.                 $cf['KU_TRIPS'] = array('#Test'  => 'test',
  164.                                         '#temp' => 'temp'); // Special tripcodes which can have a predefined output.  Do not include the initial ! in the output.  Maximum length for the output is 30 characters.  Set to array(); to disable
  165.  
  166.         // Extra features
  167.                 $cf['KU_RSS']             = true; // Whether or not to enable the generation of rss for each board and modlog
  168.                 $cf['KU_EXPAND']          = true; // Whether or not to add the expand button to threads viewed on board pages
  169.                 $cf['KU_QUICKREPLY']      = true; // Whether or not to add quick reply links on posts
  170.                 $cf['KU_WATCHTHREADS']    = true; // Whether or not to add thread watching capabilities
  171.                 $cf['KU_FIRSTLAST']       = true; // Whether or not to generate extra files for the first 100 posts/last 50 posts
  172.                 $cf['KU_BLOTTER']         = true; // Whether or not to enable the blotter feature
  173.                 $cf['KU_SITEMAP']         = false; // Whether or not to enable automatic sitemap generation (you will still need to link the search engine sites to the sitemap.xml file)
  174.                 $cf['KU_APPEAL']          = false; // Whether or not to enable the appeals system
  175.  
  176.         // Misc config
  177.                 $cf['KU_MODLOGDAYS']        = 7; // Days to keep modlog entries before removing them
  178.                 $cf['KU_RANDOMSEED']        = '2asd2a13s2d13as2d1aa3s2dasd'; // Type a bunch of random letters/numbers here, any large amount (35+ characters) will do
  179.                 $cf['KU_STATICMENU']        = false; // Whether or not to generate the menu files as static files, instead of linking to menu.php.  Enabling this will reduce load, however some users have had trouble with getting the files to generate
  180.                 $cf['KU_GENERATEBOARDLIST'] = true; // Set to true to automatically make the board list which is displayed ad the top and bottom of the board pages, or false to use the boards.html file
  181.  
  182.         // Language / timezone / encoding
  183.                 $cf['KU_LOCALE']  = 'en'; // The locale of kusaba you would like to use.  Locales available: en, de, et, es, fi, pl, nl, nb, ro, ru, it, ja
  184.                 $cf['KU_CHARSET'] = 'UTF-8'; // The character encoding to mark the pages as.  This must be the same in the .htaccess file (AddCharset charsethere .html and AddCharset charsethere .php) to function properly.  Only UTF-8 and Shift_JIS have been tested
  185.                 putenv('TZ=US/Pacific'); // The time zone which the server resides in
  186.                 $cf['KU_DATEFORMAT'] = 'd/m/y(D)H:i';
  187.  
  188.         // Debug
  189.                 $cf['KU_DEBUG'] = false; // When enabled, debug information will be printed (Warning: all queries will be shown publicly)
  190.  
  191.         // Post-configuration actions, don't modify these
  192.                 $cf['KU_VERSION']    = '0.9.3';
  193.                 $cf['KU_TAGS']       = serialize($cf['KU_TAGS']);
  194.                 $cf['KU_TRIPS']      = serialize($cf['KU_TRIPS']);
  195.                 $cf['KU_LINELENGTH'] = $cf['KU_LINELENGTH'] * 15;
  196.  
  197.                 if (substr($cf['KU_WEBFOLDER'], -2) == '//') { $cf['KU_WEBFOLDER'] = substr($cf['KU_WEBFOLDER'], 0, -1); }
  198.                 if (substr($cf['KU_BOARDSFOLDER'], -2) == '//') { $cf['KU_BOARDSFOLDER'] = substr($cf['KU_BOARDSFOLDER'], 0, -1); }
  199.                 if (substr($cf['KU_CGIFOLDER'], -2) == '//') { $cf['KU_CGIFOLDER'] = substr($cf['KU_CGIFOLDER'], 0, -1); }
  200.  
  201.                 $cf['KU_WEBPATH'] = trim($cf['KU_WEBPATH'], '/');
  202.                 $cf['KU_BOARDSPATH'] = trim($cf['KU_BOARDSPATH'], '/');
  203.                 $cf['KU_CGIPATH'] = trim($cf['KU_CGIPATH'], '/');
  204.  
  205.                 if ($cf['KU_APC']) {
  206.                         apc_define_constants('config', $cf);
  207.                 }
  208.                 while (list($key, $value) = each($cf)) {
  209.                         define($key, $value);
  210.                 }
  211.                 unset($cf);
  212. }
  213.  
  214. // DO NOT MODIFY BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING OR ELSE BAD THINGS MAY HAPPEN
  215. $modules_loaded = array();
  216. $required = array(KU_ROOTDIR, KU_WEBFOLDER, KU_WEBPATH);
  217. if (in_array('CHANGEME', $required) || in_array('', $required)){
  218.         echo 'You must set KU_ROOTDIR, KU_WEBFOLDER, and KU_WEBPATH before installation will finish!';
  219.         die();
  220. }
  221. require KU_ROOTDIR . 'lib/gettext/gettext.inc.php';
  222. require KU_ROOTDIR . 'lib/adodb/adodb.inc.php';
  223.  
  224. // Gettext
  225. _textdomain('kusaba');
  226. _setlocale(LC_ALL, KU_LOCALE);
  227. _bindtextdomain('kusaba', KU_ROOTDIR . 'inc/lang');
  228. _bind_textdomain_codeset('kusaba', KU_CHARSET);
  229.  
  230. // SQL  database
  231. if (!isset($tc_db) && !isset($preconfig_db_unnecessary)) {
  232.         $tc_db = &NewADOConnection(KU_DBTYPE);
  233.         if (KU_DBUSEPERSISTENT) {
  234.                 $tc_db->PConnect(KU_DBHOST, KU_DBUSERNAME, KU_DBPASSWORD, KU_DBDATABASE) or die('SQL database connection error: ' . $tc_db->ErrorMsg());
  235.         } else {
  236.                 $tc_db->Connect(KU_DBHOST, KU_DBUSERNAME, KU_DBPASSWORD, KU_DBDATABASE) or die('SQL database connection error: ' . $tc_db->ErrorMsg());
  237.         }
  238.  
  239.         // SQL debug
  240.         if (KU_DEBUG) {
  241.                 $tc_db->debug = true;
  242.         }
  243.  
  244.         $results_events = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "events` WHERE `at` <= " . time());
  245.         if (count($results_events) > 0) {
  246.                 if ($tc_db->ErrorMsg() == '') {
  247.                         foreach($results_events AS $line_events) {
  248.                                 if ($line_events['name'] == 'sitemap') {
  249.                                         $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "events` SET `at` = " . (time() + 21600) . " WHERE `name` = 'sitemap'");
  250.                                         if (KU_SITEMAP) {
  251.                                                 $sitemap = '<?xml version="1.0" encoding="UTF-8"?' . '>' . "\n" .
  252.                                                 '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n" . "\n";
  253.  
  254.                                                 $results = $tc_db->GetAll("SELECT `name`, `id` FROM `" . KU_DBPREFIX . "boards` ORDER BY `name` ASC");
  255.                                                 if (count($results) > 0) {
  256.                                                         foreach($results AS $line) {
  257.                                                                 $sitemap .= '   <url>' . "\n" .
  258.                                                                 '               <loc>' . KU_BOARDSPATH . '/' . $line['name'] . '/</loc>' . "\n" .
  259.                                                                 '               <lastmod>' . date('Y-m-d') . '</lastmod>' . "\n" .
  260.                                                                 '               <changefreq>hourly</changefreq>' . "\n" .
  261.                                                                 '       </url>' . "\n";
  262.  
  263.                                                                 $results2 = $tc_db->GetAll("SELECT `id`, `bumped` FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $line['id'] . " AND `parentid` = 0 AND `IS_DELETED` = 0 ORDER BY `bumped` DESC");
  264.                                                                 if (count($results2) > 0) {
  265.                                                                         foreach($results2 AS $line2) {
  266.                                                                                 $sitemap .= '   <url>' . "\n" .
  267.                                                                                 '               <loc>' . KU_BOARDSPATH . '/' . $line['name'] . '/res/' . $line2['id'] . '.html</loc>' . "\n" .
  268.                                                                                 '               <lastmod>' . date('Y-m-d', $line2['bumped']) . '</lastmod>' . "\n" .
  269.                                                                                 '               <changefreq>hourly</changefreq>' . "\n" .
  270.                                                                                 '       </url>' . "\n";
  271.                                                                         }
  272.                                                                 }
  273.                                                         }
  274.                                                 }
  275.  
  276.                                                 $sitemap .= '</urlset>';
  277.  
  278.                                                 $fp = fopen(KU_BOARDSDIR . 'sitemap.xml', 'w');
  279.                                                 fwrite($fp, $sitemap);
  280.                                                 fclose($fp);
  281.  
  282.                                                 unset($sitemap, $fp);
  283.                                         }
  284.                                 }
  285.                         }
  286.                 }
  287.  
  288.                 unset($results_events, $line_events);
  289.         }
  290. }
  291.  
  292.  
  293. function stripslashes_deep($value)
  294. {
  295.         $value = is_array($value) ?
  296.                 array_map('stripslashes_deep', $value) :
  297.                 stripslashes($value);
  298.         return $value;
  299. }
  300.  
  301. // Thanks Z
  302. if (get_magic_quotes_gpc()) {
  303.         $_POST = array_map('stripslashes_deep', $_POST);
  304.         $_GET = array_map('stripslashes_deep', $_GET);
  305.         $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
  306. }
  307. if (get_magic_quotes_runtime()) {
  308.         set_magic_quotes_runtime(0);
  309. }
  310.  
  311. ?>