home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / mainfile.php < prev    next >
PHP Script  |  2004-10-13  |  47KB  |  1,225 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Advanced Content Management System                         */
  5. /* ============================================                         */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* This program is free software. You can redistribute it and/or modify */
  11. /* it under the terms of the GNU General Public License as published by */
  12. /* the Free Software Foundation; either version 2 of the License.       */
  13. /************************************************************************/
  14.  
  15. //Union Tap Code (UTC)
  16. //Copyright Zhen-Xjell 2004 http://nukecops.com
  17. //Beta 4 Code to prevent UNION SQL Injections
  18. unset($matches);
  19. unset($loc);
  20. $loc=rawurldecode($_SERVER["QUERY_STRING"]);
  21. //This if block catches C-like comment code within all SQL Injections, not just Union.
  22. //White paper available here: http://www.securiteam.com/securityreviews/5FP0O0KCKM.html
  23. if (strstr($loc,"*")) {
  24.     die("YOU ARE SLAPPED BY <a href=\"http://nukecops.com\">NUKECOPS</a> BY USING '".htmlentities($loc)."'.");
  25. }
  26. //This catches plaintext and base64 version of the Union SQL Injection code.
  27. if (preg_match("/([OdWo5NIbpuU4V2iJT0n]{5}) /", $loc, $matches)) {
  28.     die("YOU ARE SLAPPED BY <a href=\"http://nukecops.com\">NUKECOPS</a> BY USING '$matches[1]' INSIDE '".htmlentities($loc)."'.");
  29. }
  30.  
  31. //Union Tap
  32. //Copyright Zhen-Xjell 2004 http://nukecops.com
  33. //Beta 3 Code to prevent UNION SQL Injections
  34. unset($matches);
  35. unset($loc);
  36. if (preg_match("/([OdWo5NIbpuU4V2iJT0n]{5}) /", rawurldecode($loc=$_SERVER["QUERY_STRING"]), $matches)) {
  37.     exit();
  38. }
  39.  
  40. $queryString = strtolower($_SERVER['QUERY_STRING']);
  41. if (stripos_clone($queryString,'%20union%20') OR stripos_clone($queryString,'/*') OR stripos_clone($queryString,'*/union/*') OR stripos_clone($queryString,'c2nyaxb0')) {
  42. header("Location: index.php"); 
  43. exit(); 
  44.  
  45. $phpver = phpversion();
  46. if ($phpver >= '4.0.4pl1' && strstr($HTTP_SERVER_VARS['HTTP_USER_AGENT'],'compatible')) {
  47.     if (extension_loaded('zlib')) {
  48.     ob_end_clean();
  49.     ob_start('ob_gzhandler');
  50.     }
  51. } else if ($phpver > '4.0') {
  52.     if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) {
  53.     if (extension_loaded('zlib')) {
  54.         $do_gzip_compress = TRUE;
  55.         ob_start();
  56.         ob_implicit_flush(0);
  57.         //header('Content-Encoding: gzip');
  58.     }
  59.     }
  60. }
  61.  
  62. $phpver = explode(".", $phpver);
  63. $phpver = "$phpver[0]$phpver[1]";
  64. if ($phpver >= 41) {
  65.     $PHP_SELF = $_SERVER['PHP_SELF'];
  66. }
  67.  
  68. if (!ini_get("register_globals")) {
  69.     import_request_variables('GPC');
  70. }
  71.  
  72. #############################################################
  73. #--------------- Base64 sanitize by Waraxe -----------------
  74. if(isset($admin))
  75. {
  76.    $admin = base64_decode($admin);
  77.    $admin = addslashes($admin);
  78.    $admin = base64_encode($admin);
  79. }
  80.  
  81. if(isset($user))
  82. {
  83.    $user = base64_decode($user);
  84.    $user = addslashes($user);
  85.    $user = base64_encode($user);
  86. }
  87. #############################################################
  88.  
  89. if (phpversion() < "4.1.0") {
  90.     $_GET = $HTTP_GET_VARS;
  91.     $_POST = $HTTP_POST_VARS;
  92.     $_SERVER = $HTTP_SERVER_VARS;
  93. }
  94.  
  95. if($PHP_SELF != "admin.php") {
  96. foreach ($_GET as $sec_key => $secvalue) {
  97.     if ((eregi("<[^>]*script*\"?[^>]*>", $secvalue)) ||
  98.     (eregi("<[^>]*object*\"?[^>]*>", $secvalue)) ||
  99.     (eregi("<[^>]*iframe*\"?[^>]*>", $secvalue)) ||
  100.     (eregi("<[^>]*applet*\"?[^>]*>", $secvalue)) ||
  101.     (eregi("<[^>]*meta*\"?[^>]*>", $secvalue)) ||
  102.     (eregi("<[^>]*style*\"?[^>]*>", $secvalue)) ||
  103.     (eregi("<[^>]*form*\"?[^>]*>", $secvalue)) ||
  104.     (eregi("<[^>]*img*\"?[^>]*>", $secvalue)) ||
  105.     (eregi("\([^>]*\"?[^)]*\)", $secvalue)) ||
  106.     (eregi("\"", $secvalue)) ||
  107.     (eregi("forum_admin", $sec_key)) || 
  108.     (eregi("inside_mod", $sec_key))) {
  109.     include("language/lang-".$lang.".php");
  110.     die(""._HTMLTAGSNOTALLOWEDPROTECT."");
  111.     }
  112. }
  113. }
  114. //nasledujici uprava (if s $op) je pro umozneni vkladani javascriptu apod.
  115. //pri posilani clanku
  116. //pri nahledu clanku
  117. //pri editaci clanku
  118. //pri editaci naplanovaneho clanku
  119. //pri zmenene hlavniho nastaveni v administraci
  120. //pri vytvareni bloku
  121. //pri uprave bloku
  122. if($PHP_SELF != "admin.php") {
  123.   if($op != "PostAdminStory" AND $op != "PreviewAdminStory" AND $op != "ChangeStory" AND $op != "autoSaveEdit" AND $op != "ConfigSave" AND $op != "BlocksAdd" AND $op != "BlocksEditSave" AND $op != "PreviewAgain" AND $op != "PostStory" AND $op != "EditStory") {
  124.     foreach ($_POST as $secvalue) {
  125.       if ((eregi("<[^>]*onmouseover*\"?[^>]*>", $secvalue)) ||    (eregi("<[^>]*script*\"?[^>]*>", $secvalue)) ||    (eregi("<[^>]*style*\"?[^>]*>", $secvalue))) {
  126.     include("language/lang-".$lang.".php");
  127.         die(""._HTMLTAGSNOTALLOWEDPROTECT."");
  128.       }
  129.     }
  130.   }
  131. }
  132. if (eregi("mainfile.php", $_SERVER['SCRIPT_NAME'])) {
  133.     Header("Location: index.php");
  134.     die();
  135. }
  136.  
  137. if ($forum_admin == 1) {
  138.     require_once("../../../config.php");
  139.     require_once("../../../db/db.php");
  140. } elseif ($inside_mod == 1) {
  141.     require_once("../../config.php");
  142.     require_once("../../db/db.php");
  143. } else {
  144.     require_once("config.php");
  145.     require_once("db/db.php");
  146.     /* FOLLOWING TWO LINES ARE DEPRECATED BUT ARE HERE FOR OLD MODULES COMPATIBILITY */
  147.     /* PLEASE START USING THE NEW SQL ABSTRACTION LAYER. SEE MODULES DOC FOR DETAILS */
  148.     require_once("includes/sql_layer.php");
  149.     $dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);
  150. }
  151.  
  152. $mainfile = 1;
  153. $sql = "SELECT sitename, nukeurl, site_logo, slogan, startdate, adminmail, anonpost, Default_Theme, foot1, foot2, foot3, commentlimit, anonymous, minpass, pollcomm, articlecomm, broadcast_msg, my_headlines, top, storyhome, user_news, oldnum, ultramode, banners, backend_title, backend_language, language, locale, multilingual, useflags, notify, notify_email, notify_subject, notify_message, notify_from, footermsgtxt, email_send, attachmentdir, attachments, attachments_view, download_dir, defaultpopserver, singleaccount, singleaccountname, numaccounts, imgpath, filter_forward, moderate, admingraphic, httpref, httprefmax, CensorMode, CensorReplace, copyright, Version_Num FROM ".$prefix."_config";
  154. $result = $db->sql_query($sql);
  155. $row = $db->sql_fetchrow($result);
  156. $sitename = $row['sitename'];
  157. $nukeurl = $row['nukeurl'];
  158. $site_logo = $row['site_logo'];
  159. $slogan = $row['slogan'];
  160. $startdate = $row['startdate'];
  161. $adminmail = stripslashes($row['adminmail']);
  162. $anonpost = $row['anonpost'];
  163. $Default_Theme = $row['Default_Theme'];
  164. $foot1 = $row['foot1'];
  165. $foot2 = $row['foot2'];
  166. $foot3 = $row['foot3'];
  167. $commentlimit = intval($row['commentlimit']);
  168. $anonymous = $row['anonymous'];
  169. $minpass = intval($row['minpass']);
  170. $pollcomm = intval($row['pollcomm']);
  171. $articlecomm = intval($row['articlecomm']);
  172. $broadcast_msg = intval($row['broadcast_msg']);
  173. $my_headlines = intval($row['my_headlines']);
  174. $top = intval($row['top']);
  175. $storyhome = intval($row['storyhome']);
  176. $user_news = intval($row['user_news']);
  177. $oldnum = intval($row['oldnum']);
  178. $ultramode = intval($row['ultramode']);
  179. $banners = intval($row['banners']);
  180. $backend_title = $row['backend_title'];
  181. $backend_language = $row['backend_language'];
  182. $language = $row['language'];
  183. $locale = $row['locale'];
  184. $multilingual = intval($row['multilingual']);
  185. $useflags = intval($row['useflags']);
  186. $notify = intval($row['notify']);
  187. $notify_email = $row['notify_email'];
  188. $notify_subject = $row['notify_subject'];
  189. $notify_message = $row['notify_message'];
  190. $notify_from = $row['notify_from'];
  191. $footermsgtxt = $row['footermsgtxt'];
  192. $email_send = intval($row['email_send']);
  193. $attachmentdir = $row['attachmentdir'];
  194. $attachments = intval($row['attachments']);
  195. $attachments_view = intval($row['attachments_view']);
  196. $download_dir = $row['download_dir'];
  197. $defaultpopserver = $row['defaultpopserver'];
  198. $singleaccount = intval($row['singleaccount']);
  199. $singleaccountname = $row['singleaccountname'];
  200. $numaccounts = $row['numaccounts'];
  201. $imgpath = $row['imgpath'];
  202. $filter_forward = intval($row['filter_forward']);
  203. $moderate = intval($row['moderate']);
  204. $admingraphic = intval($row['admingraphic']);
  205. $httpref = intval($row['httpref']);
  206. $httprefmax = intval($row['httprefmax']);
  207. $CensorMode = intval($row['CensorMode']);
  208. $CensorReplace = $row['CensorReplace'];
  209. $copyright = $row['copyright'];
  210. $Version_Num = $row['Version_Num'];
  211. $domain = eregi_replace("http://", "", $nukeurl);
  212. $tipath = "images/topics/";
  213. $mtime = microtime();
  214. $mtime = explode(" ",$mtime);
  215. $mtime = $mtime[1] + $mtime[0];
  216. $start_time = $mtime;
  217.  
  218. if ($forum_admin != 1) {
  219.     if (isset($newlang) AND !eregi("\.","$newlang")) {
  220.     if (file_exists("language/lang-".$newlang.".php")) {
  221.         setcookie("lang",$newlang,time()+31536000);
  222.         include("language/lang-".$newlang.".php");
  223.         $currentlang = $newlang;
  224.     } else {
  225.         setcookie("lang",$language,time()+31536000);
  226.         include("language/lang-".$language.".php");
  227.         $currentlang = $language;
  228.     }
  229.     } elseif (isset($lang)) {
  230.     include("language/lang-".$lang.".php");
  231.     $currentlang = $lang;
  232.     } else {
  233.     setcookie("lang",$language,time()+31536000);
  234.     include("language/lang-".$language.".php");
  235.     $currentlang = $language;
  236.     }
  237. }
  238.  
  239. function get_lang($module) {
  240.     global $currentlang, $language;
  241.     if (file_exists("modules/$module/language/lang-".$currentlang.".php")) {
  242.     if ($module == admin) {
  243.         include_once("admin/language/lang-".$currentlang.".php");
  244.     } else {
  245.         include_once("modules/$module/language/lang-".$currentlang.".php");
  246.     }
  247.     } else {
  248.     if ($module == admin) {
  249.         include_once("admin/language/lang-".$currentlang.".php");
  250.     } else {
  251.         include_once("modules/$module/language/lang-".$language.".php");
  252.     }
  253.     }
  254. }
  255.  
  256. function is_admin($admin) {
  257.     global $prefix, $db;
  258.     if(!is_array($admin)) {
  259.         $admin = addslashes($admin);
  260.     $admin = base64_decode($admin);
  261.     $admin = addslashes($admin);
  262.     $admin = explode(":", $admin);
  263.         $aid = addslashes("$admin[0]");
  264.     $pwd = "$admin[1]";
  265.     } else {
  266.         $aid = addslashes("$admin[0]");
  267.     $pwd = "$admin[1]";
  268.     }
  269.     if ($aid != "" AND $pwd != "") {
  270.     $sql = "SELECT pwd FROM ".$prefix."_authors WHERE aid='$aid'";
  271.     $result = $db->sql_query($sql);
  272.     $row = $db->sql_fetchrow($result);
  273.     $pass = $row['pwd'];
  274.     if($pass == $pwd && $pass != "") {
  275.         return 1;
  276.     }
  277.     }
  278.     return 0;
  279. }
  280.  
  281. function is_user($user) {
  282.     global $prefix, $db, $user_prefix;
  283.     if(!is_array($user)) {
  284.         $user = addslashes($user);
  285.     $user = base64_decode($user);
  286.     $user = addslashes($user);
  287.     $user = explode(":", $user);
  288.         $uid = "$user[0]";
  289.     $pwd = "$user[2]";
  290.     } else {
  291.         $uid = "$user[0]";
  292.     $pwd = "$user[2]";
  293.     }
  294.     $uid = addslashes(intval($uid));
  295.     if ($uid != "" AND $pwd != "") {
  296.         $uid = intval($uid);
  297.     $sql = "SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'";
  298.     $result = $db->sql_query($sql);
  299.     $row = $db->sql_fetchrow($result);
  300.     $pass = $row['user_password'];
  301.     if($pass == $pwd && $pass != "") {
  302.         return 1;
  303.     }
  304.     }
  305.     return 0;
  306. }
  307.  
  308.  
  309. function title($text) {
  310.     OpenTable();
  311.     echo "<center><font class=\"title\"><b>$text</b></font></center>";
  312.     CloseTable();
  313.     echo "<br>";
  314. }
  315.  
  316. function is_active($module) {
  317.     global $prefix, $db;
  318.     $module = trim($module);
  319.     $sql = "SELECT active FROM ".$prefix."_modules WHERE title='$module'";
  320.     $result = $db->sql_query($sql);
  321.     $row = $db->sql_fetchrow($result);
  322.     $act = $row[active];
  323.     $act = intval($row['active']);
  324.     if (!$result OR $act == 0) {
  325.     return 0;
  326.     } else {
  327.     return 1;
  328.     }
  329. }
  330.  
  331. function render_blocks($side, $blockfile, $title, $content, $bid, $url) {
  332.     if ($url == "") {
  333.     if ($blockfile == "") {
  334.         if ($side == "c") {
  335.         themecenterbox($title, $content);
  336.         } elseif ($side == "d") {
  337.         themecenterbox($title, $content);
  338.         } else {
  339.         themesidebox($title, $content);
  340.         }
  341.     } else {
  342.         if ($side == "c") {
  343.         blockfileinc($title, $blockfile, 1);
  344.         } elseif ($side == "d") {
  345.         blockfileinc($title, $blockfile, 1);
  346.         } else {
  347.         blockfileinc($title, $blockfile);
  348.         }
  349.     }
  350.     } else {
  351.     if ($side == "c" OR $side == "d") {
  352.         headlines($bid,1);
  353.     } else {
  354.             headlines($bid);
  355.     }
  356.     }
  357. }
  358.  
  359. function blocks($side) {
  360.     global $storynum, $prefix, $multilingual, $currentlang, $db, $admin, $user;
  361.     if ($multilingual == 1) {
  362.         $querylang = "AND (blanguage='$currentlang' OR blanguage='')";
  363.     } else {
  364.         $querylang = "";
  365.     }
  366.     if (strtolower($side[0]) == "l") {
  367.     $pos = "l";
  368.     } elseif (strtolower($side[0]) == "r") {
  369.     $pos = "r";
  370.     }  elseif (strtolower($side[0]) == "c") {
  371.     $pos = "c";
  372.     } elseif  (strtolower($side[0]) == "d") {
  373.     $pos = "d";
  374.     }
  375.     $side = $pos;
  376.     $sql = "SELECT bid, bkey, title, content, url, blockfile, view FROM ".$prefix."_blocks WHERE bposition='$pos' AND active='1' $querylang ORDER BY weight ASC";
  377.     $result = $db->sql_query($sql);
  378.     while($row = $db->sql_fetchrow($result)) {
  379.     $bid = intval($row['bid']);
  380.     $bkey = $row['bkey'];
  381.     $title = stripslashes(check_html($row['title'], "nohtml"));
  382.     $content = stripslashes($row['content']);
  383.     $url = stripslashes($row['url']);
  384.     $blockfile = $row['blockfile'];
  385.     $view = intval($row['view']);
  386.     if ($bkey == admin) {
  387.         adminblock();
  388.     } elseif ($bkey == userbox) {
  389.         userblock();
  390.     } elseif ($bkey == "") {
  391.         if ($view == 0) {
  392.         render_blocks($side, $blockfile, $title, $content, $bid, $url);
  393.         } elseif ($view == 1 AND is_user($user) || is_admin($admin)) {
  394.         render_blocks($side, $blockfile, $title, $content, $bid, $url);
  395.         } elseif ($view == 2 AND is_admin($admin)) {
  396.         render_blocks($side, $blockfile, $title, $content, $bid, $url);
  397.         } elseif ($view == 3 AND !is_user($user) || is_admin($admin)) {
  398.         render_blocks($side, $blockfile, $title, $content, $bid, $url);
  399.         }
  400.     }
  401.     }
  402. }
  403.  
  404. function message_box() {
  405.     global $bgcolor1, $bgcolor2, $user, $admin, $cookie, $textcolor2, $prefix, $multilingual, $currentlang, $db;
  406.     if ($multilingual == 1) {
  407.     $querylang = "AND (mlanguage='$currentlang' OR mlanguage='')";
  408.     } else {
  409.     $querylang = "";
  410.     }
  411.     $sql = "SELECT mid, title, content, date, expire, view FROM ".$prefix."_message WHERE active='1' $querylang";
  412.     $result = $db->sql_query($sql);
  413.     if ($numrows = $db->sql_numrows($result) == 0) {
  414.     return;
  415.     } else {
  416.     while ($row = $db->sql_fetchrow($result)) {
  417.         $mid = intval($row['mid']);
  418.         $title = stripslashes(check_html($row['title'], "nohtml"));
  419.         $content = stripslashes($row['content']);
  420.         $mdate = $row['date'];
  421.         $expire = intval($row['expire']);
  422.         $view = intval($row['view']);
  423.     if ($title != "" && $content != "") {
  424.         if ($expire == 0) {
  425.         $remain = _UNLIMITED;
  426.         } else {
  427.         $etime = (($mdate+$expire)-time())/3600;
  428.         $etime = (int)$etime;
  429.         if ($etime < 1) {
  430.             $remain = _EXPIRELESSHOUR;
  431.         } else {
  432.             $remain = ""._EXPIREIN." $etime "._HOURS."";
  433.         }
  434.         }
  435.         if ($view == 4 AND is_admin($admin)) {
  436.                 OpenTable();
  437.                 echo "<center><font class=\"option\" color=\"$textcolor2\"><b>$title</b></font></center><br>\n"
  438.             ."<font class=\"content\">$content</font>"
  439.             ."<br><br><center><font class=\"content\">[ "._MVIEWADMIN." - $remain - <a href=\"admin.php?op=editmsg&mid=$mid\">"._EDIT."</a> ]</font></center>";
  440.         CloseTable();
  441.         echo "<br>";
  442.         } elseif ($view == 3 AND is_user($user) || is_admin($admin)) {
  443.                 OpenTable();
  444.                 echo "<center><font class=\"option\" color=\"$textcolor2\"><b>$title</b></font></center><br>\n"
  445.             ."<font class=\"content\">$content</font>";
  446.         if (is_admin($admin)) {
  447.             echo "<br><br><center><font class=\"content\">[ "._MVIEWUSERS." - $remain - <a href=\"admin.php?op=editmsg&mid=$mid\">"._EDIT."</a> ]</font></center>";
  448.         }
  449.             CloseTable();
  450.         echo "<br>";
  451.         } elseif ($view == 2 AND !is_user($user) || is_admin($admin)) {
  452.                 OpenTable();
  453.                 echo "<center><font class=\"option\" color=\"$textcolor2\"><b>$title</b></font></center><br>\n"
  454.             ."<font class=\"content\">$content</font>";
  455.         if (is_admin($admin)) {
  456.             echo "<br><br><center><font class=\"content\">[ "._MVIEWANON." - $remain - <a href=\"admin.php?op=editmsg&mid=$mid\">"._EDIT."</a> ]</font></center>";
  457.         }
  458.         CloseTable();
  459.         echo "<br>";
  460.         } elseif ($view == 1) {
  461.                 OpenTable();
  462.                 echo "<center><font class=\"option\" color=\"$textcolor2\"><b>$title</b></font></center><br>\n"
  463.             ."<font class=\"content\">$content</font>";
  464.         if (is_admin($admin)) {
  465.             echo "<br><br><center><font class=\"content\">[ "._MVIEWALL." - $remain - <a href=\"admin.php?op=editmsg&mid=$mid\">"._EDIT."</a> ]</font></center>";
  466.         }
  467.         CloseTable();
  468.         echo "<br>";
  469.         }
  470.         if ($expire != 0) {
  471.             $past = time()-$expire;
  472.         if ($mdate < $past) {
  473.             $db->sql_query("UPDATE ".$prefix."_message SET active='0' WHERE mid='$mid'");
  474.         }
  475.         }
  476.         }
  477.     }
  478.     }
  479. }
  480.  
  481. function online() {
  482.     global $user, $cookie, $prefix, $db;
  483.     cookiedecode($user);
  484.     $ip = $_SERVER["REMOTE_ADDR"];
  485.     $uname = $cookie[1];
  486.     if (!isset($uname)) {
  487.         $uname = "$ip";
  488.         $guest = 1;
  489.     }
  490.     $past = time()-1800;
  491.     $sql = "DELETE FROM ".$prefix."_session WHERE time < '$past'";
  492.     $db->sql_query($sql);
  493.     $sql = "SELECT time FROM ".$prefix."_session WHERE uname='$uname'";
  494.     $result = $db->sql_query($sql);
  495.     $ctime = time();
  496.     if ($row = $db->sql_fetchrow($result)) {
  497.     $sql = "UPDATE ".$prefix."_session SET uname='$uname', time='$ctime', host_addr='$ip', guest='$guest' WHERE uname='$uname'";
  498.     $db->sql_query($sql);
  499.     } else {
  500.     $sql = "INSERT INTO ".$prefix."_session (uname, time, host_addr, guest) VALUES ('$uname', '$ctime', '$ip', '$guest')";
  501.     $db->sql_query($sql);
  502.     }
  503. }
  504.  
  505. function blockfileinc($title, $blockfile, $side=0) {
  506.     $blockfiletitle = $title;
  507.     $file = @file("blocks/".$blockfile."");
  508.     if (!$file) {
  509.     $content = _BLOCKPROBLEM;
  510.     } else {
  511.     include("blocks/".$blockfile."");
  512.     }
  513.     if ($content == "") {
  514.     $content = _BLOCKPROBLEM2;
  515.     }
  516.     if ($side == 1) {
  517.     themecenterbox($blockfiletitle, $content);
  518.     } elseif ($side == 2) {
  519.     themecenterbox($blockfiletitle, $content);
  520.     } else {
  521.     themesidebox($blockfiletitle, $content);
  522.     }
  523. }
  524.  
  525. function selectlanguage() {
  526.     global $useflags, $currentlang;
  527.     if ($useflags == 1) {
  528.     $title = _SELECTLANGUAGE;
  529.     $content = "<center><font class=\"content\">"._SELECTGUILANG."<br><br>";
  530.     $langdir = dir("language");
  531.     while($func=$langdir->read()) {
  532.     if(substr($func, 0, 5) == "lang-") {
  533.             $menulist .= "$func ";
  534.     }
  535.     }
  536.     closedir($langdir->handle);
  537.     $menulist = explode(" ", $menulist);
  538.     sort($menulist);
  539.     for ($i=0; $i < sizeof($menulist); $i++) {
  540.         if($menulist[$i]!="") {
  541.         $tl = ereg_replace("lang-","",$menulist[$i]);
  542.         $tl = ereg_replace(".php","",$tl);
  543.         $altlang = ucfirst($tl);
  544.         $content .= "<a href=\"index.php?newlang=$tl\"><img src=\"images/language/flag-$tl.png\" border=\"0\" alt=\"$altlang\" title=\"$altlang\" hspace=\"3\" vspace=\"3\"></a> ";
  545.     }
  546.     }
  547.     $content .= "</font></center>";
  548.     themesidebox($title, $content);
  549.     } else {
  550.     $title = _SELECTLANGUAGE;
  551.     $content = "<center><font class=\"content\">"._SELECTGUILANG."<br><br></font>";
  552.     $content .= "<form action=\"index.php\" method=\"get\"><select name=\"newlanguage\" onChange=\"top.location.href=this.options[this.selectedIndex].value\">";
  553.         $handle=opendir('language');
  554.         while ($file = readdir($handle)) {
  555.         if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  556.                 $langFound = $matches[1];
  557.                 $languageslist .= "$langFound ";
  558.             }
  559.         }
  560.         closedir($handle);
  561.         $languageslist = explode(" ", $languageslist);
  562.         sort($languageslist);
  563.         for ($i=0; $i < sizeof($languageslist); $i++) {
  564.         if($languageslist[$i]!="") {
  565.     $content .= "<option value=\"index.php?newlang=$languageslist[$i]\" ";
  566.         if($languageslist[$i]==$currentlang) $content .= " selected";
  567.     $content .= ">".ucfirst($languageslist[$i])."</option>\n";
  568.         }
  569.     }
  570.     $content .= "</select></form></center>";
  571.     themesidebox($title, $content);
  572.     }
  573. }
  574.  
  575. function ultramode() {
  576.     global $prefix, $db;
  577.     $ultra = "ultramode.txt";
  578.     $file = fopen("$ultra", "w");
  579.     fwrite($file, "General purpose self-explanatory file with news headlines\n");
  580.     $sql = "SELECT sid, aid, title, time, comments, topic FROM ".$prefix."_stories ORDER BY time DESC LIMIT 0,10";
  581.     $result = $db->sql_query($sql);
  582.     while ($row = $db->sql_fetchrow($result)) {
  583.     $rsid = intval($row['sid']);
  584.     $raid = $row['aid'];
  585.     $rtitle = stripslashes(check_html($row['title'], "nohtml"));
  586.     $rtime = $row['time'];
  587.     $rcomments = stripslashes($row['comments']);
  588.     $rtopic = intval($row['topic']);
  589.     $row2 = $db->sql_fetchrow($db->sql_query("select topictext, topicimage from ".$prefix."_topics where topicid='$rtopic'"));
  590.     $topictext = stripslashes(check_html($row2['topictext'], "nohtml"));
  591.     $topicimage = $row2['topicimage'];
  592.     $content = "%%\n$rtitle\n/modules.php?name=News&file=article&sid=$rsid\n$rtime\n$raid\n$topictext\n$rcomments\n$topicimage\n";
  593.     fwrite($file, $content);
  594.     }
  595.     fclose($file);
  596. }
  597.  
  598. function cookiedecode($user) {
  599.     global $cookie, $prefix, $db, $user_prefix;
  600.     $user = addslashes($user);
  601.     $user = base64_decode($user);
  602.     $user = addslashes($user);
  603.     $user = htmlentities($user, ENT_QUOTES);
  604.     $cookie = explode(":", $user);
  605.     $sql = "SELECT user_password FROM ".$user_prefix."_users WHERE username='$cookie[1]'";
  606.     $result = $db->sql_query($sql);
  607.     $row = $db->sql_fetchrow($result);
  608.     $pass = $row['user_password'];
  609.     if ($cookie[2] == $pass && $pass != "") {
  610.     return $cookie;
  611.     } else {
  612.     unset($user);
  613.     unset($cookie);
  614.     }
  615. }
  616.  
  617. function getusrinfo($user) {
  618.     global $userinfo, $user_prefix, $db;
  619.     $user = addslashes($user);
  620.     $user2 = base64_decode($user);
  621.     $user2 = addslashes($user2);
  622.     $user3 = explode(":", $user2);
  623.     $sql = "SELECT * FROM ".$user_prefix."_users WHERE username='$user3[1]' AND user_password='$user3[2]'";
  624.     $result = $db->sql_query($sql);
  625.     if ($db->sql_numrows($result) == 1) {
  626.         $userinfo = $db->sql_fetchrow($result);
  627.     }
  628.     return $userinfo;
  629. }
  630.  
  631. function FixQuotes ($what = "") {
  632.     $what = ereg_replace("'","''",$what);
  633.     while (eregi("\\\\'", $what)) {
  634.     $what = ereg_replace("\\\\'","'",$what);
  635.     }
  636.     return $what;
  637. }
  638.  
  639. /*********************************************************/
  640. /* text filter                                           */
  641. /*********************************************************/
  642.  
  643. function check_words($Message) {
  644.     global $EditedMessage;
  645.     include("config.php");
  646.     $EditedMessage = $Message;
  647.     if ($CensorMode != 0) {
  648.     if (is_array($CensorList)) {
  649.         $Replace = $CensorReplace;
  650.         if ($CensorMode == 1) {
  651.         for ($i = 0; $i < count($CensorList); $i++) {
  652.             $EditedMessage = eregi_replace("$CensorList[$i]([^a-zA-Z0-9])","$Replace\\1",$EditedMessage);
  653.         }
  654.         } elseif ($CensorMode == 2) {
  655.         for ($i = 0; $i < count($CensorList); $i++) {
  656.             $EditedMessage = eregi_replace("(^|[^[:alnum:]])$CensorList[$i]","\\1$Replace",$EditedMessage);
  657.         }
  658.         } elseif ($CensorMode == 3) {
  659.         for ($i = 0; $i < count($CensorList); $i++) {
  660.             $EditedMessage = eregi_replace("$CensorList[$i]","$Replace",$EditedMessage);
  661.         }
  662.         }
  663.     }
  664.     }
  665.     return ($EditedMessage);
  666. }
  667.  
  668. function delQuotes($string){
  669.     /* no recursive function to add quote to an HTML tag if needed */
  670.     /* and delete duplicate spaces between attribs. */
  671.     $tmp="";    # string buffer
  672.     $result=""; # result string
  673.     $i=0;
  674.     $attrib=-1; # Are us in an HTML attrib ?   -1: no attrib   0: name of the attrib   1: value of the atrib
  675.     $quote=0;   # Is a string quote delimited opened ? 0=no, 1=yes
  676.     $len = strlen($string);
  677.     while ($i<$len) {
  678.     switch($string[$i]) { # What car is it in the buffer ?
  679.         case "\"": #"       # a quote.
  680.         if ($quote==0) {
  681.             $quote=1;
  682.         } else {
  683.             $quote=0;
  684.             if (($attrib>0) && ($tmp != "")) { $result .= "=\"$tmp\""; }
  685.             $tmp="";
  686.             $attrib=-1;
  687.         }
  688.         break;
  689.         case "=":           # an equal - attrib delimiter
  690.         if ($quote==0) {  # Is it found in a string ?
  691.             $attrib=1;
  692.             if ($tmp!="") $result.=" $tmp";
  693.             $tmp="";
  694.         } else $tmp .= '=';
  695.         break;
  696.         case " ":           # a blank ?
  697.         if ($attrib>0) {  # add it to the string, if one opened.
  698.             $tmp .= $string[$i];
  699.         }
  700.         break;
  701.         default:            # Other
  702.         if ($attrib<0)    # If we weren't in an attrib, set attrib to 0
  703.         $attrib=0;
  704.         $tmp .= $string[$i];
  705.         break;
  706.     }
  707.     $i++;
  708.     }
  709.     if (($quote!=0) && ($tmp != "")) {
  710.     if ($attrib==1) $result .= "=";
  711.     /* If it is the value of an atrib, add the '=' */
  712.     $result .= "\"$tmp\"";  /* Add quote if needed (the reason of the function ;-) */
  713.     }
  714.     return $result;
  715. }
  716.  
  717. function check_html ($str, $strip="") {
  718.     /* The core of this code has been lifted from phpslash */
  719.     /* which is licenced under the GPL. */
  720.     include("config.php");
  721.     if ($strip == "nohtml")
  722.         $AllowableHTML=array('');
  723.     $str = stripslashes($str);
  724.     $str = eregi_replace("<[[:space:]]*([^>]*)[[:space:]]*>",
  725.                          '<\\1>', $str);
  726.                // Delete all spaces from html tags .
  727.     $str = eregi_replace("<a[^>]*href[[:space:]]*=[[:space:]]*\"?[[:space:]]*([^\" >]*)[[:space:]]*\"?[^>]*>",
  728.                          '<a href="\\1">', $str); # "
  729.                // Delete all attribs from Anchor, except an href, double quoted.
  730.     $str = eregi_replace("<[[:space:]]* img[[:space:]]*([^>]*)[[:space:]]*>", '', $str);
  731.            // Delete all img tags
  732.     $tmp = "";
  733.     while (ereg("<(/?[[:alpha:]]*)[[:space:]]*([^>]*)>",$str,$reg)) {
  734.         $i = strpos($str,$reg[0]);
  735.         $l = strlen($reg[0]);
  736.         if ($reg[1][0] == "/") $tag = strtolower(substr($reg[1],1));
  737.         else $tag = strtolower($reg[1]);
  738.         if ($a = $AllowableHTML[$tag])
  739.             if ($reg[1][0] == "/") $tag = "</$tag>";
  740.             elseif (($a == 1) || ($reg[2] == "")) $tag = "<$tag>";
  741.             else {
  742.               # Place here the double quote fix function.
  743.               $attrb_list=delQuotes($reg[2]);
  744.               // A VER
  745.               $attrb_list = ereg_replace("&","&",$attrb_list);
  746.               $tag = "<$tag" . $attrb_list . ">";
  747.             } # Attribs in tag allowed
  748.         else $tag = "";
  749.         $tmp .= substr($str,0,$i) . $tag;
  750.         $str = substr($str,$i+$l);
  751.     }
  752.     $str = $tmp . $str;
  753.     return $str;
  754.     exit;
  755.     /* Squash PHP tags unconditionally */
  756.     $str = ereg_replace("<\?","",$str);
  757.     return $str;
  758. }
  759.  
  760. function filter_text($Message, $strip="") {
  761.     global $EditedMessage;
  762.     check_words($Message);
  763.     $EditedMessage=check_html($EditedMessage, $strip);
  764.     return ($EditedMessage);
  765. }
  766.  
  767. /*********************************************************/
  768. /* formatting stories                                    */
  769. /*********************************************************/
  770.  
  771. function formatTimestamp($time) {
  772.     global $datetime, $locale;
  773.     setlocale (LC_TIME, $locale);
  774.     ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
  775.     $datetime = strftime(""._DATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  776.     $datetime = ucfirst($datetime);
  777.     return($datetime);
  778. }
  779.  
  780. function formatAidHeader($aid) {
  781.     global $prefix, $db;
  782.     $sql = "SELECT url, email FROM ".$prefix."_authors WHERE aid='$aid'";
  783.     $result = $db->sql_query($sql);
  784.     $row = $db->sql_fetchrow($result);
  785.     $url = $row['url'];
  786.     $email = stripslashes($row['email']);
  787.     if (isset($email)) {
  788.     $aid = "<a href=\"mailto:$email\">$aid</a>";
  789.     } elseif (isset($url)) {
  790.     $aid = "<a href=\"$url\">$aid</a>";
  791.     } else {
  792.     $aid = $aid;
  793.     }
  794.     echo "$aid";
  795. }
  796.  
  797. function get_author($aid) {
  798.     global $prefix, $db;
  799.     $sql = "SELECT url, email FROM ".$prefix."_authors WHERE aid='$aid'";
  800.     $result = $db->sql_query($sql);
  801.     $row = $db->sql_fetchrow($result);
  802.     $url = stripslashes($row['url']);
  803.     $email = stripslashes($row['email']);
  804.     if (isset($url)) {
  805.     $aid = "<a href=\"$url\">$aid</a>";
  806.     } elseif (isset($email)) {
  807.     $aid = "<a href=\"mailto:$email\">$aid</a>";
  808.     } else {
  809.     $aid = $aid;
  810.     }
  811.     return($aid);
  812. }
  813.  
  814. function themepreview($title, $hometext, $bodytext="", $notes="") {
  815.     echo "<b>$title</b><br><br>$hometext";
  816.     if ($bodytext != "") {
  817.     echo "<br><br>$bodytext";
  818.     }
  819.     if ($notes != "") {
  820.     echo "<br><br><b>"._NOTE."</b> <i>$notes</i>";
  821.     }
  822. }
  823.  
  824. function adminblock() {
  825.     global $admin, $prefix, $db;
  826.     if (is_admin($admin)) {
  827.     $sql = "SELECT title, content FROM ".$prefix."_blocks WHERE bkey='admin'";
  828.     $result = $db->sql_query($sql);
  829.     while ($row = $db->sql_fetchrow($result)) {
  830.         $row_title = $row['title'];
  831.         $row_content = $row['content'];
  832.         $content = "<font class=\"content\">$row_content</font>";
  833.         themesidebox($row_title, $row_content);
  834.     }
  835.     $title = ""._WAITINGCONT."";
  836.     $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_queue"));
  837.     $content = "<font class=\"content\">";
  838.     $content .= "<strong><big>·</big></strong> <a href=\"admin.php?op=submissions\">"._SUBMISSIONS."</a>: $num<br>";
  839.     $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_reviews_add"));
  840.     $content .= "<strong><big>·</big></strong> <a href=\"admin.php?op=reviews\">"._WREVIEWS."</a>: $num<br>";
  841.     $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_links_newlink"));
  842.     $brokenl = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_links_modrequest WHERE brokenlink='1'"));
  843.     $modreql = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_links_modrequest WHERE brokenlink='0'"));
  844.     $content .= "<strong><big>·</big></strong> <a href=\"admin.php?op=Links\">"._WLINKS."</a>: $num<br>";
  845.     $content .= "<strong><big>·</big></strong> <a href=\"admin.php?op=LinksListModRequests\">"._MODREQLINKS."</a>: $modreql<br>";
  846.     $content .= "<strong><big>·</big></strong> <a href=\"admin.php?op=LinksListBrokenLinks\">"._BROKENLINKS."</a>: $brokenl<br>";
  847.     $num = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_newdownload"));
  848.     $brokend = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_modrequest WHERE brokendownload='1'"));
  849.     $modreqd = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_modrequest WHERE brokendownload='0'"));
  850.     $content .= "<strong><big>·</big></strong> <a href=\"admin.php?op=downloads\">"._UDOWNLOADS."</a>: $num<br>";
  851.     $content .= "<strong><big>·</big></strong> <a href=\"admin.php?op=DownloadsListModRequests\">"._MODREQDOWN."</a>: $modreqd<br>";
  852.     $content .= "<strong><big>·</big></strong> <a href=\"admin.php?op=DownloadsListBrokenDownloads\">"._BROKENDOWN."</a>: $brokend<br></font>";
  853.     themesidebox($title, $content);
  854.     }
  855. }
  856.  
  857. function loginbox() {
  858.     global $user;
  859.     if (!is_user($user)) {
  860.     $title = _LOGIN;
  861.     $boxstuff = "<form action=\"modules.php?name=Your_Account\" method=\"post\">";
  862.     $boxstuff .= "<center><font class=\"content\">"._NICKNAME."<br>";
  863.     $boxstuff .= "<input type=\"text\" name=\"username\" size=\"8\" maxlength=\"25\"><br>";
  864.     $boxstuff .= ""._PASSWORD."<br>";
  865.     $boxstuff .= "<input type=\"password\" name=\"user_password\" size=\"8\" maxlength=\"20\"><br>";
  866.     $boxstuff .= "<input type=\"hidden\" name=\"op\" value=\"login\">";
  867.     $boxstuff .= "<input type=\"submit\" value=\""._LOGIN."\"></font></center></form>";
  868.     $boxstuff .= "<center><font class=\"content\">"._ASREGISTERED."</font></center>";
  869.     themesidebox($title, $boxstuff);
  870.     }
  871. }
  872.  
  873. function userblock() {
  874.     global $user, $cookie, $db, $user_prefix;
  875.     if((is_user($user)) AND ($cookie[8])) {
  876.     $sql = "SELECT ublock FROM ".$user_prefix."_users WHERE user_id='$cookie[0]'";
  877.     $result = $db->sql_query($sql);
  878.     $row = $db->sql_fetchrow($result);
  879.     $title = ""._MENUFOR." $cookie[1]";
  880.     $ublock = $row['ublock'];
  881.     themesidebox($title, $ublock);
  882.     }
  883. }
  884.  
  885. function getTopics($s_sid) {
  886.     global $topicname, $topicimage, $topictext, $prefix, $db;
  887.     $sid = intval($s_sid);
  888.     $sql = "SELECT topic FROM ".$prefix."_stories WHERE sid='$sid'";
  889.     $result = $db->sql_query($sql);
  890.     $row = $db->sql_fetchrow($result);
  891.     $rtopic = $row['topic'];
  892.     $sql2 = "SELECT topicid, topicname, topicimage, topictext FROM ".$prefix."_topics WHERE topicid='$rtopic'";
  893.     $result2 = $db->sql_query($sql2);
  894.     $row2 = $db->sql_fetchrow($result2);
  895.     $topicid = intval($row2['topicid']);
  896.     $topicname = $row2['topicname'];
  897.     $topicimage = $row2['topicimage'];
  898.     $topictext = stripslashes(check_html($row2['topictext'], "nohtml"));
  899. }
  900.  
  901. function headlines($bid, $cenbox=0) {
  902.     global $prefix, $db;
  903.     $bid = intval($bid);
  904.     $sql = "SELECT title, content, url, refresh, time FROM ".$prefix."_blocks WHERE bid='$bid'";
  905.     $result = $db->sql_query($sql);
  906.     $row = $db->sql_fetchrow($result);
  907.     $title = stripslashes(check_html($row['title'], "nohtml"));
  908.     $content = stripslashes($row['content']);
  909.     $url = $row['url'];
  910.     $refresh = intval($row['refresh']);
  911.     $otime = $row['time'];
  912.     $past = time()-$refresh;
  913.     if ($otime < $past) {
  914.     $btime = time();
  915.     $rdf = parse_url($url);
  916.     $fp = @fsockopen($rdf['host'], 80, $errno, $errstr, 15);
  917.     if (!$fp) {
  918.         $content = "";
  919.         $sql = "UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'";
  920.         $db->sql_query($sql);
  921.         $cont = 0;
  922.         if ($cenbox == 0) {
  923.             $content = ""._RSSPROBLEM."";
  924.         themesidebox($title, $content);
  925.         } else {
  926.             $content = ""._RSSPROBLEM."";
  927.         themecenterbox($title, $content);
  928.         }
  929.         return;
  930.     }
  931.     if ($fp) {
  932.         fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0\r\n");
  933.         fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
  934.         $string    = "";
  935.         while(!feof($fp)) {
  936.             $pagetext = fgets($fp,300);
  937.             $string .= chop($pagetext);
  938.         }
  939.         fputs($fp,"Connection: close\r\n\r\n");
  940.         fclose($fp);
  941.  
  942.         //uprava pro element image - start
  943.         $imagesindex = eregi("<image>(.*)</image>",$string,$imagearray);
  944.             $image = $imagearray[1];      //uloZena cast s datY o obraZku
  945.         $imagetitle = eregi("<title>(.*)</title>",$image,$titlea);
  946.         $imgtitle = $titlea[1];                //title image
  947.         $imageurl = eregi("<url>(.*)</url>",$image,$urlimage);
  948.         $imagesrc = $urlimage[1];      //src na obrazek
  949.             $imagedescription = eregi("<description>(.*)</description>",$image,$description);
  950.         $imagealt = $description[1];
  951.  
  952.         $imagewidth = eregi("<width>(.*)</width>",$image,$width);
  953.         $imagew = $width[1];
  954.         $imageheight = eregi("<height>(.*)</height>",$image,$height);
  955.             $imageh = $height[1];
  956.  
  957.         if ($imagesrc != "") {
  958.         $imageformat = "<center><img src=\"$imagesrc\" border=\"0\" alt=\"$imagealt\" width=\"$imagew\" height=\"$imageh\"></center><br>";
  959.         }
  960.         //uprava pro element image - konec
  961.  
  962.         $items = explode("</item>",$string);
  963.         $content = "$imageformat<font class=\"content\">";
  964.         for ($i=0;$i<10;$i++) {
  965.         $link = ereg_replace(".*<link>","",$items[$i]);
  966.         $link = ereg_replace("</link>.*","",$link);
  967.         $title2 = ereg_replace(".*<title>","",$items[$i]);
  968.         $title2 = ereg_replace("</title>.*","",$title2);
  969.         $title2 = stripslashes($title2);
  970.         if ($items[$i] == "" AND $cont != 1) {
  971.             $content = "";
  972.             $sql = "UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'";
  973.             $db->sql_query($sql);
  974.             $cont = 0;
  975.             if ($cenbox == 0) {
  976.             themesidebox($title, $content);
  977.             } else {
  978.             themecenterbox($title, $content);
  979.             }
  980.             return;
  981.         } else {
  982.             if (strcmp($link,$title2) AND $items[$i] != "") {
  983.             $cont = 1;
  984.             $content .= "<strong><big>·</big></strong><a href=\"$link\" target=\"new\">$title2</a><br>\n";
  985.             }
  986.         }
  987.         }
  988.  
  989.     }
  990.     $sql = "UPDATE ".$prefix."_blocks SET content='$content', time='$btime' WHERE bid='$bid'";
  991.     $db->sql_query($sql);
  992.     }
  993.     $siteurl = ereg_replace("http://","",$url);
  994.     $siteurl = explode("/",$siteurl);
  995.     if (($cont == 1) OR ($content != "")) {
  996.     $content .= "<br><a href=\"http://$siteurl[0]\" target=\"blank\"><b>"._HREADMORE."</b></a></font>";
  997.     } elseif (($cont == 0) OR ($content == "")) {
  998.     $content = "<font class=\"content\">"._RSSPROBLEM."</font>";
  999.     }
  1000.     if ($cenbox == 0) {
  1001.     themesidebox($title, $content);
  1002.     } else {
  1003.     themecenterbox($title, $content);
  1004.     }
  1005. }
  1006.  
  1007. function automated_news() {
  1008.     global $prefix, $multilingual, $currentlang, $db;
  1009.     if ($multilingual == 1) {
  1010.     $querylang = "WHERE (alanguage='$currentlang' OR alanguage='')"; /* the OR is needed to display stories who are posted to ALL languages */
  1011.     } else {
  1012.     $querylang = "";
  1013.     }
  1014.     $today = getdate();
  1015.     $day = $today['mday'];
  1016.     if ($day < 10) {
  1017.     $day = "0$day";
  1018.     }
  1019.     $month = $today['mon'];
  1020.     if ($month < 10) {
  1021.     $month = "0$month";
  1022.     }
  1023.     $year = $today['year'];
  1024.     $hour = $today['hours'];
  1025.     $min = $today['minutes'];
  1026.     $sec = "00";
  1027.     $sql = "SELECT anid, time FROM ".$prefix."_autonews $querylang";
  1028.     $result = $db->sql_query($sql);
  1029.     while ($row = $db->sql_fetchrow($result)) {
  1030.     $anid = $row['anid'];
  1031.     $time = $row['time'];
  1032.     ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $date);
  1033.     if (($date[1] <= $year) AND ($date[2] <= $month) AND ($date[3] <= $day)) {
  1034.         if (($date[4] < $hour) AND ($date[5] >= $min) OR ($date[4] <= $hour) AND ($date[5] <= $min)) {
  1035.         $sql2 = "SELECT * FROM ".$prefix."_autonews WHERE anid='$anid'";
  1036.         $result2 = $db->sql_query($sql2);
  1037.         while ($row2 = $db->sql_fetchrow($result2)) {
  1038.             $title = stripslashes(FixQuotes($row2['title']));
  1039.             $hometext = stripslashes(FixQuotes($row2['hometext']));
  1040.             $bodytext = stripslashes(FixQuotes($row2['bodytext']));
  1041.             $notes = stripslashes(FixQuotes($row2['notes']));
  1042.             $catid2 = intval($row2['catid']);
  1043.             $aid2 = $row2['aid'];
  1044.             $time2 = $row2['time'];
  1045.             $topic2 = $row2['topic'];
  1046.             $informant2 = $row2['informant'];
  1047.             $ihome2 = intval($row2['ihome']);
  1048.             $alanguage2 = $row2['alanguage'];
  1049.             $acomm2 = intval($row2['acomm']);
  1050.             $associated2 = $row2['associated'];
  1051.             $sql = "INSERT INTO ".$prefix."_stories VALUES (NULL, '$catid2', '$aid2', '$title', '$time2', '$hometext', '$bodytext', '0', '0', '$topic2', '$informant2', '$notes', '$ihome2', '$alanguage2', '$acomm2', '0', '0', '0', '0', '$associated2')";
  1052.             $db->sql_query($sql);
  1053.             $sql = "DELETE FROM ".$prefix."_autonews WHERE anid='$anid'";
  1054.             $db->sql_query($sql);
  1055.         }
  1056.         }
  1057.     }
  1058.     }
  1059. }
  1060.  
  1061. function themecenterbox($title, $content) {
  1062.     OpenTable();
  1063.     echo "<center><font class=\"option\"><b>$title</b></font></center><br>"
  1064.     ."$content";
  1065.     CloseTable();
  1066.     echo "<br>";
  1067. }
  1068.  
  1069. function public_message() {
  1070.     global $prefix, $user_prefix, $db, $user, $admin, $p_msg, $cookie, $broadcast_msg;
  1071.     if ($broadcast_msg == 1) {
  1072.     if (is_user($user)) {
  1073.         cookiedecode($user);
  1074.     $sql = "SELECT broadcast FROM ".$user_prefix."_users WHERE username='$cookie[1]'";
  1075.     $result = $db->sql_query($sql);
  1076.     $row = $db->sql_fetchrow($result);
  1077.     $upref = $row['broadcast'];
  1078.     if ($upref == 1) {
  1079.         $t_off = "<br><p align=\"right\">[ <a href=\"modules.php?name=Your_Account&op=edithome\"><font color=\"FFFFFF\" size=\"2\">"._TURNOFFMSG."</font></a> ]</font>";
  1080.         $pm_show = 1;
  1081.     } else {
  1082.         $pm_show = 0;
  1083.     }
  1084.     } else {
  1085.     $t_off = "";
  1086.     }
  1087.     if (!is_user($user) OR (is_user($user) AND ($pm_show == 1))) {
  1088.     $c_mid = base64_decode($p_msg);
  1089.     $c_mid = addslashes($c_mid);
  1090.     $c_mid = intval($c_mid);
  1091.     $sql2 = "SELECT mid, content, date, who FROM ".$prefix."_public_messages WHERE mid > '$c_mid' ORDER BY date ASC LIMIT 1";
  1092.     $result2 = $db->sql_query($sql2);
  1093.     $row2 = $db->sql_fetchrow($result2);
  1094.     $mid = intval($row2['mid']);
  1095.     $content = $row2['content'];
  1096.     $tdate = $row2['date'];
  1097.     $who = $row2['who'];
  1098.     if ((!isset($c_mid)) OR ($c_mid = $mid)) {
  1099.             $public_msg = "<br><table width=\"90%\" border=\"1\" cellspacing=\"2\" cellpadding=\"0\" bgcolor=\"FFFFFF\" align=\"center\"><tr><td>\n";
  1100.             $public_msg .= "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"FF0000\"><tr><td>\n";
  1101.             $public_msg .= "<font color=\"FFFFFF\" size=\"3\"><b>"._BROADCASTFROM." <a href=\"modules.php?name=Your_Account&op=userinfo&username=$who\"><font color=\"FFFFFF\" size=\"3\">$who</font></a>: \"$content\"</b>";
  1102.         $public_msg .= "$t_off";
  1103.         $public_msg .= "</td></tr></table>";
  1104.             $public_msg .= "</td></tr></table>";
  1105.         $ref_date = $tdate+600;
  1106.         $actual_date = time();
  1107.         if ($actual_date >= $ref_date) {
  1108.         $public_msg = "";
  1109.         $numrows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_public_messages"));
  1110.         if ($numrows == 1) {
  1111.             $db->sql_query("DELETE FROM ".$prefix."_public_messages");
  1112.             $mid = 0;
  1113.         } else {
  1114.             $db->sql_query("DELETE FROM ".$prefix."_public_messages WHERE mid='$mid'");
  1115.         }
  1116.         }
  1117.         if ($mid == 0 OR $mid == "") {
  1118.         setcookie("p_msg");
  1119.         } else {
  1120.             $mid = base64_encode($mid);
  1121.         $mid = addslashes($mid);
  1122.         setcookie("p_msg",$mid,time()+600);
  1123.         }
  1124.     }
  1125.     }
  1126.     } else {
  1127.     $public_msg = "";
  1128.     }
  1129.     return($public_msg);
  1130. }
  1131.  
  1132. function get_theme() {
  1133.     global $user, $cookie, $Default_Theme;
  1134.     if(is_user($user)) {
  1135.     $user2 = base64_decode($user);
  1136.     $user2 = addslashes($user2);
  1137.     $t_cookie = explode(":", $user2);
  1138.     if($t_cookie[9]=="") $t_cookie[9]=$Default_Theme;
  1139.     if(isset($theme)) $t_cookie[9]=$theme;
  1140.     if(!$tfile=@opendir("themes/$t_cookie[9]")) {
  1141.         $ThemeSel = $Default_Theme;
  1142.     } else {
  1143.         $ThemeSel = $t_cookie[9];
  1144.     }
  1145.     } else {
  1146.     $ThemeSel = $Default_Theme;
  1147.     }
  1148.     return($ThemeSel);
  1149. }
  1150.  
  1151. function removecrlf($str) {
  1152.     // Function for Security Fix by Ulf Harnhammar, VSU Security 2002
  1153.     // Looks like I don't have so bad track record of security reports as Ulf believes
  1154.     // He decided to not contact me, but I'm always here, digging on the net
  1155.     return strtr($str, "\015\012", ' ');
  1156. }
  1157.  
  1158. function stripos_clone($haystack, $needle, $offset=0) {
  1159.   return strpos(strtoupper($haystack), strtoupper($needle), $offset);
  1160. }
  1161.  
  1162. function un_update_system_alert(){
  1163. global $prefix, $db, $adminmail, $sitename, $nukeurl, $language;
  1164.  
  1165.   if (file_exists("verstamps/system.ver.php") AND file_exists("verstamps/update.ver.php")) { //je-li system jiz ready :)
  1166.   
  1167.   //nacteme konfiguraci a data
  1168.   $row_config_data_result = $db->sql_query("SELECT * FROM ".$prefix."_un_update_system");
  1169.   while ($row_config_data = $db->sql_fetchrow($row_config_data_result)) {
  1170.   $name = $row_config_data['config_name'];
  1171.   $value = $row_config_data['config_value'];
  1172.   define("$name", "$value");
  1173.   }
  1174.   
  1175.   $checktime = UN_UPDATE_LASTDOWNLOAD + UN_UPDATE_DOWNLOAD_INTERVAL;
  1176.   $now = time();
  1177.     if($checktime < $now) { //aktualizovat udaje v DB
  1178.       if (($un_xml_file = @file_get_contents(UN_UPDATE_SERVER . UN_UPDATE_SOURCEFILE)) == TRUE) {
  1179.       include("verstamps/system.ver.php");
  1180.       include("verstamps/update.ver.php");
  1181.       eregi("<required-update-system>(.*)</required-update-system>", $un_xml_file, $update_system_ver);
  1182.       eregi("<united-nuke version=\"".SYSTEM_SERIES."\">(.*)</united-nuke>", $un_xml_file, $unitednuke_series);
  1183.       eregi("<main-tips>(.*)</main-tips>", $unitednuke_series[1], $main_tips);
  1184.       $update_system_ver[1] = str_replace(".", "", $update_system_ver[1]);
  1185.       $update_system_installedver = str_replace(".", "", UPDATE_SYSTEM_VERSION);
  1186.       if ($update_system_ver[1] > $update_system_installedver) {
  1187.       $new_update_system = "1";
  1188.       } else {
  1189.       $new_update_system = "0";
  1190.       }
  1191.       $updatedversion = explode("</updated-version>", $unitednuke_series[1]);
  1192.       array_pop($updatedversion); //odstranit posledni polozku pole
  1193.       for ($i=0; $i < (sizeof($updatedversion)); $i++) {
  1194.       eregi("<version>(.*)</version>", $updatedversion[$i], $version);
  1195.       $version_int = str_replace(".", "", $version[1]);    
  1196.         if ($version_int > $lastversion) {
  1197.         $lastversion = $version_int;
  1198.     $lastversion_print = $version[1];
  1199.         }      
  1200.       }
  1201.       
  1202.       $installed_system_version_cache = str_replace(".", "", UN_UPDATE_CACHE_LASTVERSION);
  1203.       if ($lastversion > $installed_system_version_cache AND $installed_system_version_cache != "" AND $lastversion > str_replace(".", "", SYSTEM_VERSION_INT)) {
  1204.       include("admin/modules/language/updatemail-".$language.".php");
  1205.       $subject = ""._UPDATEMAIL_SUBJECT." $lastversion_print";
  1206.       $msg = ""._UPDATEMAIL_MSG1." $sitename ($nukeurl). "._UPDATEMAIL_MSG2." ($lastversion_print). "._UPDATEMAIL_MSG3." $nukeurl/admin.php?op=SystemUpdate.\n\n"._UPDATEMAIL_MSG4."\n--\n"._UPDATEMAIL_MSG5."";
  1207.       $mailheaders = "From: "._UPDATEMAIL_FROM." <$adminmail>\n";
  1208.       $mailheaders .= "Content-Type: text/plain; charset=\""._CHARSET."\"\n\n"; // Mime type
  1209.       mail($adminmail, $subject, $msg, $mailheaders);
  1210.       }      
  1211.       $db->sql_query("UPDATE ".$prefix."_un_update_system SET config_value='$new_update_system' WHERE config_name='UN_UPDATE_CACHE_NEWUPDATESYSTEM'");
  1212.       $db->sql_query("UPDATE ".$prefix."_un_update_system SET config_value='$main_tips[1]' WHERE config_name='UN_UPDATE_CACHE_TIPS'");
  1213.       $db->sql_query("UPDATE ".$prefix."_un_update_system SET config_value='$lastversion_print' WHERE config_name='UN_UPDATE_CACHE_LASTVERSION'");      
  1214.       $db->sql_query("UPDATE ".$prefix."_un_update_system SET config_value='".time()."' WHERE config_name='UN_UPDATE_LASTDOWNLOAD'");
  1215.       $db->sql_query("UPDATE ".$prefix."_un_update_system SET config_value='0' WHERE config_name='UN_UPDATE_CACHE_FAILCOUNT'");
  1216.       } else {
  1217.       $db->sql_query("UPDATE ".$prefix."_un_update_system SET config_value=config_value+1 WHERE config_name='UN_UPDATE_CACHE_FAILCOUNT'");    
  1218.       }
  1219.     }
  1220.   }
  1221. }
  1222.  
  1223. ?>
  1224.