home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / admin / modules / blocks.php < prev    next >
PHP Script  |  2004-02-14  |  41KB  |  1,023 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal 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. if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
  16. global $prefix, $db;
  17. $aid = substr(trim($aid), 0,25);
  18. $row = $db->sql_fetchrow($db->sql_query("SELECT radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
  19. if ($row['radminsuper'] == 1) {
  20.  
  21. /*********************************************************/
  22. /* Blocks Functions                                      */
  23. /*********************************************************/
  24.  
  25. function BlocksAdmin() {
  26.     global $bgcolor2, $bgcolor4, $prefix, $db, $currentlang, $multilingual;
  27.     include("header.php");
  28.     GraphicAdmin();
  29.     OpenTable();
  30.     echo "<center><font class=\"title\"><b>"._BLOCKSADMIN."</b></font></center>";
  31.     CloseTable();
  32.     echo "<br>";
  33.     OpenTable();
  34.     echo "<br><table border=\"1\" width=\"100%\"><tr>"
  35.         ."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._TITLE."</b></td>"
  36.         ."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._POSITION."</b></td>"
  37.         ."<td align=\"center\" bgcolor=\"$bgcolor2\" colspan=\"2\"><b>"._WEIGHT."</b></td>"
  38.         ."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._TYPE."</b></td>"
  39.         ."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._STATUS."</b></td>"
  40.         ."<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._VIEW."</b></td>";
  41.     if ($multilingual == 1) {
  42.         echo "<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._LANGUAGE."</b></td>";
  43.     }
  44.     echo "<td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._FUNCTIONS."</b></tr>";
  45.     $result = $db->sql_query("SELECT bid, bkey, title, url, bposition, weight, active, blanguage, blockfile, view from " . $prefix . "_blocks order by bposition, weight");
  46.     while ($row = $db->sql_fetchrow($result)) {
  47.     $bid = intval($row['bid']);
  48.     $bkey = $row['bkey'];
  49.     $title = $row['title'];
  50.     $url = $row['url'];
  51.     $bposition = $row['bposition'];
  52.     $weight = intval($row['weight']);
  53.     $active = intval($row['active']);
  54.     $blanguage = $row['blanguage'];
  55.     $blockfile = $row['blockfile'];
  56.     $view = intval($row['view']);
  57.         $weight1 = $weight - 1;
  58.         $weight3 = $weight + 1;
  59.         $row_res = $db->sql_fetchrow($db->sql_query("SELECT bid from ".$prefix."_blocks where weight='$weight1' AND bposition='$bposition'"));
  60.         $bid1 = intval($row_res['bid']);
  61.         $con1 = "$bid1";
  62.         $row_res2 = $db->sql_fetchrow($db->sql_query("SELECT bid from ".$prefix."_blocks where weight='$weight3' AND bposition='$bposition'"));
  63.         $bid2 = intval($row_res2['bid']);
  64.         $con2 = "$bid2";
  65.         echo "<tr>"
  66.         ."<td align=\"center\">$title</td>";
  67.         if ($bposition == "l") {
  68.         $bposition = "<img src=\"images/center_r.gif\" border=\"0\" alt=\""._LEFTBLOCK."\" title=\""._LEFTBLOCK."\" hspace=\"5\"> "._LEFT."";
  69.         } elseif ($bposition == "r") {
  70.         $bposition = ""._RIGHT." <img src=\"images/center_l.gif\" border=\"0\" alt=\""._RIGHTBLOCK."\" title=\""._RIGHTBLOCK."\" hspace=\"5\">";
  71.         } elseif ($bposition == "c") {
  72.         $bposition = "<img src=\"images/center_l.gif\" border=\"0\" alt=\""._CENTERBLOCK."\" title=\""._CENTERBLOCK."\"> "._CENTERUP." <img src=\"images/center_r.gif\" border=\"0\" alt=\""._CENTERBLOCK."\" title=\""._CENTERBLOCK."\">";
  73.         } elseif ($bposition == "d") {
  74.         $bposition = "<img src=\"images/center_l.gif\" border=\"0\" alt=\""._CENTERBLOCK."\" title=\""._CENTERBLOCK."\"> "._CENTERDOWN." <img src=\"images/center_r.gif\" border=\"0\" alt=\""._CENTERBLOCK."\" title=\""._CENTERBLOCK."\">";
  75.         }
  76.         echo "<td align=\"center\">$bposition</td>"
  77.         ."<td align=\"center\">"
  78.         ." $weight </td><td align=\"center\">";
  79.         if ($con1) {
  80.         echo "<a href=\"admin.php?op=BlockOrder&weight=$weight&bidori=$bid&weightrep=$weight1&bidrep=$con1\"><img src=\"images/up.gif\" alt=\""._BLOCKUP."\" title=\""._BLOCKUP."\" border=\"0\" hspace=\"3\"></a>";
  81.         }
  82.         if ($con2) {
  83.         echo "<a href=\"admin.php?op=BlockOrder&weight=$weight&bidori=$bid&weightrep=$weight&bidrep=$con2\"><img src=\"images/down.gif\" alt=\""._BLOCKDOWN."\" title=\""._BLOCKDOWN."\" border=\"0\" hspace=\"3\"></a>";
  84.         }
  85.         echo"</td>";
  86.         if ($bkey == "") {
  87.         if ($url == "") {
  88.             $type = "HTML";
  89.         } elseif ($url != "") {
  90.             $type = "RSS/RDF";
  91.         }
  92.         if ($blockfile != "") {
  93.             $type = _BLOCKFILE2;
  94.         }
  95.         } elseif ($bkey != "") {
  96.         $type = _BLOCKSYSTEM;
  97.         }
  98.         echo "<td align=\"center\">$type</td>";
  99.         $block_act = $active;
  100.         if ($active == 1) {
  101.         $active = _ACTIVE;
  102.         $change = _DEACTIVATE;
  103.         } elseif ($active == 0) {
  104.         $active = "<i>"._INACTIVE."</i>";
  105.         $change = _ACTIVATE;
  106.         }
  107.         echo "<td align=\"center\">$active</td>";
  108.         if ($view == 0) {
  109.         $who_view = _MVALL;
  110.         } elseif ($view == 1) {
  111.         $who_view = _MVUSERS;
  112.         } elseif ($view == 2) {
  113.         $who_view = _MVADMIN;
  114.         } elseif ($view == 3) {
  115.         $who_view = _MVANON;
  116.         }
  117.         echo "<td align=\"center\">$who_view</td>";
  118.         if ($multilingual == 1) {
  119.         if ($blanguage == "") {
  120.             $blanguage = _ALL;
  121.         } else {
  122.             $blanguage = ucfirst($blanguage);
  123.         }
  124.         echo "<td align=\"center\">$blanguage</td>";
  125.         }
  126.         echo "<td align=\"center\"><font class=\"content\">[ <a href=\"admin.php?op=BlocksEdit&bid=$bid\">"._EDIT."</a> | <a href=\"admin.php?op=ChangeStatus&bid=$bid\">$change</a> | ";
  127.         if ($bkey == "") {
  128.         echo "<a href=\"admin.php?op=BlocksDelete&bid=$bid\">"._DELETE."</a> | ";
  129.         } elseif ($bkey != "") {
  130.         echo ""._DELETE." | ";
  131.         }
  132.         if ($block_act == 0) {
  133.         echo "<a href=\"admin.php?op=block_show&bid=$bid\">"._SHOW."</a> ]</font></td></tr>";
  134.         } else {
  135.         echo ""._SHOW." ]</font></td></tr>";
  136.         }
  137.     }
  138.     echo "</table>"
  139.         ."<br><br>"
  140.         ."<center>[ <a href=\"admin.php?op=fixweight\">"._FIXBLOCKS."</a> ]</center><br>";
  141.     CloseTable();
  142.     echo "<br>";
  143.     OpenTable();
  144.     echo "<center><font class=\"option\"><b>"._ADDNEWBLOCK."</b></font></center><br><br>"
  145.         ."<form action=\"admin.php\" method=\"post\">"
  146.         ."<table border=\"0\" width=\"100%\">"
  147.         ."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" size=\"30\" maxlength=\"60\"></td></tr>"
  148.         ."<tr><td>"._RSSFILE.":</td><td><input type=\"text\" name=\"url\" size=\"30\" maxlength=\"200\">  "
  149.         ."<select name=\"headline\">"
  150.         ."<option name=\"headline\" value=\"0\" selected>"._CUSTOM."</option>";
  151.     $res3 = $db->sql_query("SELECT hid, sitename from " . $prefix . "_headlines");
  152.     while ($row_res3 = $db->sql_fetchrow($res3)) {
  153.     $hid = intval($row_res3['hid']);
  154.     $htitle = $row_res3['sitename'];
  155.         echo "<option name=\"headline\" value=\"$hid\">$htitle</option>";
  156.     }
  157.     echo "</select> [ <a href=\"admin.php?op=HeadlinesAdmin\">"._HEADADMINRSS."</a> ]<br><font class=\"tiny\">";
  158.     echo ""._SETUPHEADLINES."</font></td></tr>"
  159.         ."<tr><td>"._FILENAME.":</td><td>"
  160.         ."<select name=\"blockfile\">"
  161.         ."<option name=\"blockfile\" value=\"\" selected>"._NONE."</option>";
  162.     $blocksdir = dir("blocks");
  163.     while($func=$blocksdir->read()) {
  164.         if(substr($func, 0, 6) == "block-") {
  165.             $blockslist .= "$func ";
  166.         }
  167.     }
  168.     closedir($blocksdir->handle);
  169.     $blockslist = explode(" ", $blockslist);
  170.     sort($blockslist);
  171.     for ($i=0; $i < sizeof($blockslist); $i++) {
  172.         if($blockslist[$i]!="") {
  173.         $bl = ereg_replace("block-","",$blockslist[$i]);
  174.         $bl = ereg_replace(".php","",$bl);
  175.         $bl = ereg_replace("_"," ",$bl);
  176.         $result2 = $db->sql_query("select * from ".$prefix."_blocks where blockfile='$blockslist[$i]'");
  177.         $numrows = $db->sql_numrows($result2);
  178.         if ($numrows == 0) {
  179.             echo "<option value=\"$blockslist[$i]\">$bl</option>\n";
  180.         }
  181.         }
  182.     }
  183.     echo "</select>  <font class=\"tiny\">"._FILEINCLUDE."</font></td></tr>"
  184.         ."<tr><td>"._CONTENT.":</td><td><textarea name=\"content\" cols=\"50\" rows=\"10\"></textarea><br><font class=\"tiny\">"._IFRSSWARNING."</font></td></tr>"
  185.         ."<tr><td>"._POSITION.":</td><td><select name=\"bposition\"><option name=\"bposition\" value=\"l\">"._LEFT."</option>"
  186.         ."<option name=\"bposition\" value=\"c\">"._CENTERUP."</option>"
  187.         ."<option name=\"bposition\" value=\"d\">"._CENTERDOWN."</option>"
  188.         ."<option name=\"bposition\" value=\"r\">"._RIGHT."</option></select></td></tr>";
  189.     if ($multilingual == 1) {
  190.     echo "<tr><td>"._LANGUAGE.":</td><td>"
  191.         ."<select name=\"blanguage\">";
  192.     $handle=opendir('language');
  193.     while ($file = readdir($handle)) {
  194.         if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  195.             $langFound = $matches[1];
  196.             $languageslist .= "$langFound ";
  197.         }
  198.     }
  199.     closedir($handle);
  200.     $languageslist = explode(" ", $languageslist);
  201.     sort($languageslist);
  202.     for ($i=0; $i < sizeof($languageslist); $i++) {
  203.         if($languageslist[$i]!="") {
  204.             echo "<option value=\"$languageslist[$i]\" ";
  205.         if($languageslist[$i]==$currentlang) echo "selected";
  206.         echo ">".ucfirst($languageslist[$i])."</option>\n";
  207.         }
  208.     }
  209.     echo "<option value=\"\">"._ALL."</option></select></td></tr>";
  210.     } else {
  211.     echo "<input type=\"hidden\" name=\"blanguage\" value=\"\">";
  212.     }
  213.     echo "<tr><td>"._ACTIVATE2."</td><td><input type=\"radio\" name=\"active\" value=\"1\" checked>"._YES."   "
  214.         ."<input type=\"radio\" name=\"active\" value=\"0\">"._NO."</td></tr>"
  215.         ."<tr><td>"._REFRESHTIME.":</td><td><select name=\"refresh\">"
  216.         ."<option name=\"refresh\" value=\"1800\">1/2 "._HOUR."</option>"
  217.         ."<option name=\"refresh\" value=\"3600\" selected>1 "._HOUR."</option>"
  218.         ."<option name=\"refresh\" value=\"18000\">5 "._HOURS."</option>"
  219.         ."<option name=\"refresh\" value=\"36000\">10 "._HOURS."</option>"
  220.         ."<option name=\"refresh\" value=\"86400\">24 "._HOURS."</option></select> <font class=\"tiny\">"._ONLYHEADLINES."</font></td></tr>"
  221.         ."<tr><td>"._VIEWPRIV."</td><td><select name=\"view\">"
  222.         ."<option value=\"0\" >"._MVALL."</option>"
  223.         ."<option value=\"1\" >"._MVUSERS."</option>"
  224.         ."<option value=\"2\" >"._MVADMIN."</option>"
  225.         ."<option value=\"3\" >"._MVANON."</option>"
  226.         ."</select>"
  227.         ."</td></tr></table><br><br>"
  228.         ."<input type=\"hidden\" name=\"op\" value=\"BlocksAdd\">"
  229.         ."<input type=\"submit\" value=\""._CREATEBLOCK."\"></form>";
  230.     CloseTable();
  231.     include("footer.php");
  232. }
  233.  
  234. function block_show($bid) {
  235.     global $prefix, $db;
  236.     include("header.php");
  237.     GraphicAdmin();
  238.     title(""._BLOCKSADMIN."");
  239.     OpenTable2();
  240.     $bid = intval($bid);
  241.     $row = $db->sql_fetchrow($db->sql_query("SELECT bid, bkey, title, content, url, bposition, blockfile from ".$prefix."_blocks where bid='$bid'"));
  242.     $bid = intval($row['bid']);
  243.     $bkey = $row['bkey'];
  244.     $title = $row['title'];
  245.     $content = $row['content'];
  246.     $url = $row['url'];
  247.     $bposition = $row['bposition'];
  248.     $blockfile = $row['blockfile'];
  249.     if ($bkey == main) {
  250.         mainblock();
  251.     } elseif ($bkey == admin) {
  252.         adminblock();
  253.     } elseif ($bkey == modules) {
  254.         modules_block();
  255.     } elseif ($bkey == category) {
  256.         category();
  257.     } elseif ($bkey == userbox) {
  258.         userblock();
  259.     } elseif ($bkey == "") {
  260.         if ($url == "") {
  261.             if ($blockfile == "") {
  262.         if ($bposition == "c") {
  263.             themecenterbox($title, $content);
  264.         } else {
  265.                 themesidebox($title, $content);
  266.         }
  267.         } else {
  268.         if ($bposition == "c") {
  269.             blockfileinc($title, $blockfile, 1);
  270.         } else {
  271.                 blockfileinc($title, $blockfile);
  272.         }
  273.         }
  274.     } else {
  275.         headlines($bid);
  276.     }
  277.     }
  278.     CloseTable2();
  279.     echo "<br>";
  280.     OpenTable();
  281.     echo "<center><font class=\"option\"><b>"._BLOCKSADMIN.": "._FUNCTIONS."</b></font><br><br>"
  282.     ."[ <a href=\"admin.php?op=ChangeStatus&bid=$bid\">"._ACTIVATE."</a> | <a href=\"admin.php?op=BlocksEdit&bid=$bid\">"._EDIT."</a> | ";
  283.     if ($bkey == "") {
  284.     echo "<a href=\"admin.php?op=BlocksDelete&bid=$bid\">"._DELETE."</a> | ";
  285.     } else {
  286.     echo ""._DELETE." | ";
  287.     }
  288.     echo "<a href=\"admin.php?op=BlocksAdmin\">"._BLOCKSADMIN."</a> ]</center>";
  289.     CloseTable();
  290.     include("footer.php");
  291. }
  292.  
  293. function fixweight() {
  294.     global $prefix, $db;
  295.     $leftpos = "l";
  296.     $rightpos = "r";
  297.     $centerpos = "c";
  298.     $result = $db->sql_query("SELECT bid from ".$prefix."_blocks where bposition='$leftpos' order by weight ASC");
  299.     $weight = 0;
  300.     while ($row = $db->sql_fetchrow($result)) {
  301.     $bid = intval($row['bid']);
  302.     $weight++;
  303.     $db->sql_query("update ".$prefix."_blocks set weight='$weight' where bid='$bid'");
  304.     }
  305.     $result2 = $db->sql_query("SELECT bid from ".$prefix."_blocks where bposition='$rightpos' order by weight ASC");
  306.     $weight = 0;
  307.     while ($row2 = $db->sql_fetchrow($result2)) {
  308.     $bid = intval($row2['bid']);
  309.     $weight++;
  310.     $db->sql_query("update ".$prefix."_blocks set weight='$weight' where bid='$bid'");
  311.     }
  312.     $result3 = $db->sql_query("SELECT bid from ".$prefix."_blocks where bposition='$centerpos' order by weight ASC");
  313.     $weight = 0;
  314.     while ($row3 = $db->sql_fetchrow($result3)) {
  315.     $bid = intval($row3['bid']);
  316.     $weight++;
  317.     $db->sql_query("update ".$prefix."_blocks set weight='$weight' where bid='$bid'");
  318.     }
  319.     Header("Location: admin.php?op=BlocksAdmin");
  320. }
  321.  
  322. function BlockOrder ($weightrep,$weight,$bidrep,$bidori) {
  323.     global $prefix, $db;
  324.     $bidrep = intval($bidrep);
  325.     $bidori = intval($bidori);
  326.     $result = $db->sql_query("update ".$prefix."_blocks set weight='$weight' where bid='$bidrep'");
  327.     $result2 = $db->sql_query("update ".$prefix."_blocks set weight='$weightrep' where bid='$bidori'");
  328.     Header("Location: admin.php?op=BlocksAdmin");
  329. }
  330.  
  331. function rssfail() {
  332.     include("header.php");
  333.     GraphicAdmin();
  334.     OpenTable();
  335.     echo "<center><font class=\"title\"><b>"._BLOCKSADMIN."</b></font></center>";
  336.     CloseTable();
  337.     echo "<br>";
  338.     OpenTable();
  339.     echo "<center><b>"._RSSFAIL."</b><br><br>"
  340.     .""._RSSTRYAGAIN."<br><br>"
  341.     .""._GOBACK."</center>";
  342.     CloseTable();
  343.     include("footer.php");
  344.     die;
  345. }
  346.  
  347. function BlocksAdd($title, $content, $url, $bposition, $active, $refresh, $headline, $blanguage, $blockfile, $view) {
  348.     global $prefix, $db;
  349.     if ($headline != 0) {
  350.     $row = $db->sql_fetchrow($db->sql_query("SELECT sitename, headlinesurl from ".$prefix."_headlines where hid='$headline'"));
  351.         $title = $row['sitename'];
  352.         $url = $row['headlinesurl'];
  353.     }
  354.     $row2 = $db->sql_fetchrow($db->sql_query("SELECT weight FROM ".$prefix."_blocks WHERE bposition='$bposition' ORDER BY weight DESC"));
  355.     $weight = intval($row2['weight']);
  356.     $weight++;
  357.     $title = stripslashes(FixQuotes($title));
  358.     $content = stripslashes(FixQuotes($content));
  359.     $bkey = "";
  360.     $btime = "";
  361.     if ($blockfile != "") {
  362.     $url = "";
  363.     if ($title == "") {
  364.         $title = ereg_replace("block-","",$blockfile);
  365.         $title = ereg_replace(".php","",$title);
  366.         $title = ereg_replace("_"," ",$title);
  367.     }
  368.     }
  369.     if ($url != "") {
  370.     $btime = time();
  371.     if (!ereg("http://",$url)) {
  372.         $url = "http://$url";
  373.     }
  374.     $rdf = parse_url($url);
  375.     $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
  376.     if (!$fp) {
  377.         rssfail();
  378.         exit;
  379.     }
  380.     if ($fp) {
  381.         fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0\r\n");
  382.         fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
  383.         $string = "";
  384.         while(!feof($fp)) {
  385.             $pagetext = fgets($fp,228);
  386.             $string .= chop($pagetext);
  387.         }
  388.         fputs($fp,"Connection: close\r\n\r\n");
  389.         fclose($fp);
  390.  
  391.         //uprava pro element image - start
  392.         $imagesindex = eregi("<image>(.*)</image>",$string,$imagearray);
  393.             $image = $imagearray[1];      //uloZena cast s datY o obraZku
  394.         $imagetitle = eregi("<title>(.*)</title>",$image,$titlea);
  395.         $imgtitle = $titlea[1];                //title image
  396.         $imageurl = eregi("<url>(.*)</url>",$image,$urlimage);
  397.         $imagesrc = $urlimage[1];      //src na obrazek
  398.             $imagedescription = eregi("<description>(.*)</description>",$image,$description);
  399.         $imagealt = $description[1];
  400.  
  401.         $imagewidth = eregi("<width>(.*)</width>",$image,$width);
  402.         $imagew = $width[1];
  403.         $imageheight = eregi("<height>(.*)</height>",$image,$height);
  404.             $imageh = $height[1];
  405.  
  406.         if ($imagesrc != "") {
  407.         $imageformat = "<center><img src=\"$imagesrc\" border=\"0\" alt=\"$imagealt\" width=\"$imagew\" height=\"$imageh\"></center><br>";
  408.         }
  409.         //uprava pro element image - konec
  410.  
  411.         $items = explode("</item>",$string);
  412.         $content = "$imageformat<font class=\"content\">";
  413.         for ($i=0;$i<10;$i++) {
  414.         $link = ereg_replace(".*<link>","",$items[$i]);
  415.         $link = ereg_replace("</link>.*","",$link);
  416.         $title2 = ereg_replace(".*<title>","",$items[$i]);
  417.         $title2 = ereg_replace("</title>.*","",$title2);
  418.         if ($items[$i] == "" AND $cont != 1) {
  419.             $content = "";
  420.         } else {
  421.             if (strcmp($link,$title2) AND $items[$i] != "") {
  422.             $cont = 1;
  423.             $content .= "<strong><big>·</big></strong> <a href=\"$link\" target=\"new\">$title2</a><br>\n";
  424.             }
  425.         }
  426.         }
  427.     }
  428.     }
  429.     $content = FixQuotes($content);
  430.     if (($content == "") AND ($blockfile == "")) {
  431.     rssfail();
  432.     } else {
  433.     $db->sql_query("insert into ".$prefix."_blocks values (NULL, '$bkey', '$title', '$content', '$url', '$bposition', '$weight', '$active', '$refresh', '$btime', '$blanguage', '$blockfile', '$view')");
  434.     Header("Location: admin.php?op=BlocksAdmin");
  435.     }
  436. }
  437.  
  438. function BlocksEdit($bid) {
  439.     global $bgcolor2, $bgcolor4, $prefix, $db, $multilingual;
  440.     include("header.php");
  441.     GraphicAdmin();
  442.     OpenTable();
  443.     echo "<center><font class=\"title\"><b>"._EDITBLOCK."</b></font></center>";
  444.     CloseTable();
  445.     echo "<br>";
  446.     $bid = intval($bid);
  447.     $row = $db->sql_fetchrow($db->sql_query("SELECT bkey, title, content, url, bposition, weight, active, refresh, blanguage, blockfile, view from ".$prefix."_blocks where bid='$bid'"));
  448.     $bkey = $row['bkey'];
  449.     $title = $row['title'];
  450.     $content = $row['content'];
  451.     $url = $row['url'];
  452.     $bposition = $row['bposition'];
  453.     $weight = intval($row['weight']);
  454.     $active = intval($row['active']);
  455.     $refresh = intval($row['refresh']);
  456.     $blanguage = $row['blanguage'];
  457.     $blockfile = $row['blockfile'];
  458.     $view = intval($row['view']);
  459.     if ($url != "") {
  460.     $type = _RSSCONTENT;
  461.     } elseif ($blockfile != "") {
  462.     $type = _BLOCKFILE;
  463.     }
  464.     OpenTable();
  465.     echo "<center><font class=\"option\"><b>"._BLOCK.": $title $type</b></font></center><br><br>"
  466.         ."<form action=\"admin.php\" method=\"post\">"
  467.         ."<table border=\"0\" width=\"100%\">"
  468.         ."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" size=\"30\" maxlength=\"60\" value=\"$title\"></td></tr>";
  469.     if ($blockfile != "") {
  470.     echo "<tr><td>"._FILENAME.":</td><td>"
  471.         ."<select name=\"blockfile\">";
  472.     $blocksdir = dir("blocks");
  473.     while($func=$blocksdir->read()) {
  474.         if(substr($func, 0, 6) == "block-") {
  475.             $blockslist .= "$func ";
  476.         }
  477.     }
  478.     closedir($blocksdir->handle);
  479.     $blockslist = explode(" ", $blockslist);
  480.     sort($blockslist);
  481.     for ($i=0; $i < sizeof($blockslist); $i++) {
  482.         if($blockslist[$i]!="") {
  483.         $bl = ereg_replace("block-","",$blockslist[$i]);
  484.         $bl = ereg_replace(".php","",$bl);
  485.         $bl = ereg_replace("_"," ",$bl);
  486.         echo "<option value=\"$blockslist[$i]\" ";
  487.         if ($blockfile == $blockslist[$i]) { echo "selected"; }
  488.         echo ">$bl</option>\n";
  489.         }
  490.     }
  491.     echo "</select>  <font class=\"tiny\">"._FILEINCLUDE."</font></td></tr>";
  492.     } else {
  493.     if ($url != "") {
  494.         echo "<tr><td>"._RSSFILE.":</td><td><input type=\"text\" name=\"url\" size=\"30\" maxlength=\"200\" value=\"$url\">  <font class=\"tiny\">"._ONLYHEADLINES."</font></td></tr>";
  495.     } else {
  496.         echo "<tr><td>"._CONTENT.":</td><td><textarea name=\"content\" cols=\"50\" rows=\"10\">$content</textarea></td></tr>";
  497.     }
  498.     }
  499.     $oldposition = $bposition;
  500.     echo "<input type=\"hidden\" name=\"oldposition\" value=\"$oldposition\">";
  501.     if ($bposition == "l") {
  502.     $sel1 = "selected";
  503.     $sel2 = "";
  504.     $sel3 = "";
  505.     $sel4 = "";
  506.     } elseif ($bposition == "c") {
  507.     $sel1 = "";
  508.     $sel2 = "selected";
  509.     $sel3 = "";
  510.     $sel4 = "";
  511.     } elseif ($bposition == "r") {
  512.     $sel1 = "";
  513.     $sel2 = "";
  514.     $sel3 = "selected";
  515.     $sel4 = "";
  516.     } elseif ($bposition == "d") {
  517.     $sel1 = "";
  518.     $sel2 = "";
  519.     $sel3 = "";
  520.     $sel4 = "selected";
  521.     }
  522.     echo "<tr><td>"._POSITION.":</td><td><select name=\"bposition\">"
  523.     ."<option name=\"bposition\" value=\"l\" $sel1>"._LEFT."</option>"
  524.     ."<option name=\"bposition\" value=\"c\" $sel2>"._CENTERUP."</option>"
  525.     ."<option name=\"bposition\" value=\"d\" $sel4>"._CENTERDOWN."</option>"
  526.     ."<option name=\"bposition\" value=\"r\" $sel3>"._RIGHT."</option></select></td></tr>";
  527.     if ($multilingual == 1) {
  528.     echo "<tr><td>"._LANGUAGE.":</td><td>"
  529.         ."<select name=\"blanguage\">";
  530.     $handle=opendir('language');
  531.     while ($file = readdir($handle)) {
  532.         if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  533.             $langFound = $matches[1];
  534.             $languageslist .= "$langFound ";
  535.         }
  536.     }
  537.     closedir($handle);
  538.     $languageslist = explode(" ", $languageslist);
  539.     sort($languageslist);
  540.     for ($i=0; $i < sizeof($languageslist); $i++) {
  541.         if($languageslist[$i]!="") {
  542.         echo "<option value=\"$languageslist[$i]\" ";
  543.         if($languageslist[$i]==$blanguage) echo "selected";
  544.         echo ">".ucfirst($languageslist[$i])."</option>\n";
  545.         }
  546.     }
  547.     if ($blanguage != "") {
  548.         $sel3 = "";
  549.     } else {
  550.         $sel3 = "selected";
  551.     }
  552.     echo "<option value=\"\" $sel3>"._ALL."</option></select></td></tr>";
  553.     } else {
  554.     echo "<input type=\"hidden\" name=\"blanguage\" value=\"\">";
  555.     }
  556.     if ($active == 1) {
  557.     $sel1 = "checked";
  558.     $sel2 = "";
  559.     } elseif ($active == 0) {
  560.     $sel1 = "";
  561.     $sel2 = "checked";
  562.     }
  563.     echo "<tr><td>"._ACTIVATE2."</td><td><input type=\"radio\" name=\"active\" value=\"1\" $sel1>"._YES."   "
  564.         ."<input type=\"radio\" name=\"active\" value=\"0\" $sel2>"._NO."</td></tr>";
  565.     if ($url != "") {
  566.     if ($refresh == 1800) {
  567.     $sel1 = "selected";
  568.     $sel2 = "";
  569.     $sel3 = "";
  570.     $sel4 = "";
  571.     $sel5 = "";
  572.     } elseif ($refresh == 3600) {
  573.     $sel1 = "";
  574.     $sel2 = "selected";
  575.     $sel3 = "";
  576.     $sel4 = "";
  577.     $sel5 = "";
  578.     } elseif ($refresh == 18000) {
  579.     $sel1 = "";
  580.     $sel2 = "";
  581.     $sel3 = "selected";
  582.     $sel4 = "";
  583.     $sel5 = "";
  584.     } elseif ($refresh == 36000) {
  585.     $sel1 = "";
  586.     $sel2 = "";
  587.     $sel3 = "";
  588.     $sel4 = "selected";
  589.     $sel5 = "";
  590.     } elseif ($refresh == 86400) {
  591.     $sel1 = "";
  592.     $sel2 = "";
  593.     $sel3 = "";
  594.     $sel4 = "";
  595.     $sel5 = "selected";
  596.     }
  597.     echo "<tr><td>"._REFRESHTIME.":</td><td><select name=\"refresh\"><option name=\"refresh\" value=\"1800\" $sel1>1/2 "._HOUR."</option>"
  598.         ."<option name=\"refresh\" value=\"3600\" $sel2>1 "._HOUR."</option>"
  599.         ."<option name=\"refresh\" value=\"18000\" $sel3>5 "._HOURS."</option>"
  600.         ."<option name=\"refresh\" value=\"36000\" $sel4>10 "._HOURS."</option>"
  601.         ."<option name=\"refresh\" value=\"86400\" $sel5>24 "._HOURS."</option></select> <font class=\"tiny\">"._ONLYHEADLINES."</font>";
  602.     }
  603.     if ($view == 0) {
  604.     $sel1 = "selected";
  605.     $sel2 = "";
  606.     $sel3 = "";
  607.     $sel4 = "";
  608.     } elseif ($view == 1) {
  609.     $sel1 = "";
  610.     $sel2 = "selected";
  611.     $sel3 = "";
  612.     $sel4 = "";
  613.     } elseif ($view == 2) {
  614.     $sel1 = "";
  615.     $sel2 = "";
  616.     $sel3 = "selected";
  617.     $sel4 = "";    
  618.     } elseif ($view == 3) {
  619.     $sel1 = "";
  620.     $sel2 = "";
  621.     $sel3 = "";
  622.     $sel4 = "selected";    
  623.     }
  624.     echo "</td></tr><tr><td>"._VIEWPRIV."</td><td><select name=\"view\">"
  625.         ."<option value=\"0\" $sel1>"._MVALL."</option>"
  626.         ."<option value=\"1\" $sel2>"._MVUSERS."</option>"
  627.         ."<option value=\"2\" $sel3>"._MVADMIN."</option>"
  628.         ."<option value=\"3\" $sel4>"._MVANON."</option>"
  629.         ."</select>"
  630.     ."</td></tr></table><br><br>"
  631.     ."<input type=\"hidden\" name=\"bid\" value=\"$bid\">"
  632.     ."<input type=\"hidden\" name=\"bkey\" value=\"$bkey\">"
  633.     ."<input type=\"hidden\" name=\"weight\" value=\"$weight\">"
  634.         ."<input type=\"hidden\" name=\"op\" value=\"BlocksEditSave\">"
  635.         ."<input type=\"submit\" value=\""._SAVEBLOCK."\"></form>";
  636.     CloseTable();
  637.     include("footer.php");
  638. }
  639.  
  640. function SortWeight($bposition) {
  641.     global $prefix, $db;
  642.     $numbers = 1;
  643.     $number_two = 1;
  644.     $result = $db->sql_query("SELECT bid,weight FROM ".$prefix."_blocks WHERE bposition='$bposition' ORDER BY weight");
  645.     while ($row = $db->sql_fetchrow($result)) {
  646.     $bid = intval($row['bid']);
  647.     $weight = intval($row['weight']);
  648.     $result2 = $db->sql_query("update ".$prefix."_blocks set weight='$numbers' where bid='$bid'");
  649.     $numbers++;
  650.     }
  651.     if ($bposition == l) {
  652.     $position_two = "r";
  653.     } else {
  654.     $position_two = "l";
  655.     }
  656.     $result_two = $db->sql_query("SELECT bid,weight FROM ".$prefix."_blocks WHERE bposition='$position_two' ORDER BY weight");
  657.     while ($row_two = $db->sql_fetchrow($result_two)) {
  658.     $bid2 = intval($row_two['bid']);
  659.     $weight = $row_two['weight'];
  660.     $result_two2 = $db->sql_query("update ".$prefix."_blocks set weight='$number_two' where bid='$bid2'");
  661.     $number_two++;
  662.     }
  663.     return $numbers;
  664. }
  665.  
  666. function BlocksEditSave($bid, $bkey, $title, $content, $url, $oldposition, $bposition, $active, $refresh, $weight, $blanguage, $blockfile, $view) {
  667.     global $prefix, $db;
  668.     if ($url != "") {
  669.     $bkey = "";
  670.     $btime = time();
  671.     if (!ereg("http://",$url)) {
  672.         $url = "http://$url";
  673.     }
  674.     $rdf = parse_url($url);
  675.     $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
  676.     if (!$fp) {
  677.             rssfail();
  678.             exit;
  679.     }
  680.     if ($fp) {
  681.             fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0\r\n");
  682.             fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
  683.             $string    = "";
  684.             while(!feof($fp)) {
  685.             $pagetext = fgets($fp,300);
  686.         $string .= chop($pagetext);
  687.         }
  688.         fputs($fp,"Connection: close\r\n\r\n");
  689.         fclose($fp);
  690.  
  691.         //uprava pro element image - start
  692.         $imagesindex = eregi("<image>(.*)</image>",$string,$imagearray);
  693.             $image = $imagearray[1];      //uloZena cast s datY o obraZku
  694.         $imagetitle = eregi("<title>(.*)</title>",$image,$titlea);
  695.         $imgtitle = $titlea[1];                //title image
  696.         $imageurl = eregi("<url>(.*)</url>",$image,$urlimage);
  697.         $imagesrc = $urlimage[1];      //src na obrazek
  698.             $imagedescription = eregi("<description>(.*)</description>",$image,$description);
  699.         $imagealt = $description[1];
  700.  
  701.         $imagewidth = eregi("<width>(.*)</width>",$image,$width);
  702.         $imagew = $width[1];
  703.         $imageheight = eregi("<height>(.*)</height>",$image,$height);
  704.             $imageh = $height[1];
  705.  
  706.         if ($imagesrc != "") {
  707.         $imageformat = "<center><img src=\"$imagesrc\" border=\"0\" alt=\"$imagealt\" width=\"$imagew\" height=\"$imageh\"></center><br>";
  708.         }
  709.         //uprava pro element image - konec
  710.  
  711.         $items = explode("</item>",$string);
  712.         $content = "$imageformat<font class=\"content\">";
  713.         for ($i=0;$i<10;$i++) {
  714.         $link = ereg_replace(".*<link>","",$items[$i]);
  715.         $link = ereg_replace("</link>.*","",$link);
  716.         $title2 = ereg_replace(".*<title>","",$items[$i]);
  717.         $title2 = ereg_replace("</title>.*","",$title2);
  718.         if ($items[$i] == "" AND $cont != 1) {
  719.             $content = "";
  720.         } else {
  721.             if (strcmp($link,$title2) AND $items[$i] != "") {
  722.             $cont = 1;
  723.             $content .= "<strong><big>·</big></strong> <a href=\"$link\" target=\"new\">$title2</a><br>\n";
  724.             }
  725.         }
  726.         }
  727.     }
  728.     if ($oldposition != $bposition) {
  729.         $result = $db->sql_query("SELECT bid from ".$prefix."_blocks where weight>='$weight' AND bposition='$bposition'");
  730.         $fweight = $weight;
  731.         $oweight = $weight;
  732.             while ($row = $db->sql_fetchrow($result)) {
  733.         $nbid = intval($row['bid']);
  734.         $weight++;
  735.         $db->sql_query("update ".$prefix."_blocks set weight='$weight' where bid='$nbid'");
  736.         }
  737.             $result2 = $db->sql_query("SELECT bid from " . $prefix . "_blocks where weight>'$oweight' AND bposition='$oldposition'");
  738.             while ($row2 = $db->sql_fetchrow($result2)) {
  739.         $obid = intval($row2['bid']);
  740.         $db->sql_query("update ".$prefix."_blocks set weight='$oweight' where bid='$obid'");
  741.         $oweight++;
  742.         }
  743.             $row3 = $db->sql_fetchrow($db->sql_query("SELECT weight from ".$prefix."_blocks where bposition='$bposition' order by weight DESC limit 0,1"));
  744.             $lastw = $row3['weight'];
  745.         if ($lastw <= $fweight) {
  746.         $lastw++;
  747.         $db->sql_query("update ".$prefix."_blocks set title='$title', content='$content', bposition='$bposition', weight='$lastw', active='$active', refresh='$refresh', blanguage='$blanguage', blockfile='$blockfile', view='$view' where bid='$bid'");
  748.         } else {
  749.         $db->sql_query("update ".$prefix."_blocks set title='$title', content='$content', bposition='$bposition', weight='$fweight', active='$active', refresh='$refresh', blanguage='$blanguage', blockfile='$blockfile', view='$view' where bid='$bid'");
  750.         }
  751.     } else {
  752.         $result4 = $db->sql_query("update ".$prefix."_blocks set bkey='$bkey', title='$title', content='$content', url='$url', bposition='$bposition', weight='$weight', active='$active', refresh='$refresh', blanguage='$blanguage', blockfile='$blockfile', view='$view' where bid='$bid'");
  753.     }
  754.     Header("Location: admin.php?op=BlocksAdmin");
  755.     } else {
  756.     $title = stripslashes(FixQuotes($title));
  757.     $content = stripslashes(FixQuotes($content));
  758.     if ($oldposition != $bposition) {
  759.             $result5 = $db->sql_query("SELECT bid from ".$prefix."_blocks where weight>='$weight' AND bposition='$bposition'");
  760.         $fweight = $weight;
  761.         $oweight = $weight;
  762.             while ($row5 = $db->sql_fetchrow($result5)) {
  763.         $nbid = intval($row5['bid']);
  764.         $weight++;
  765.         $db->sql_query("update ".$prefix."_blocks set weight='$weight' where bid='$nbid'");
  766.         }
  767.                 $result6 = $db->sql_query("SELECT bid from " . $prefix . "_blocks where weight>'$oweight' AND bposition='$oldposition'");
  768.                 while ($row6 = $db->sql_fetchrow($result6)) {
  769.             $obid = intval($row6['bid']);
  770.         $db->sql_query("update ".$prefix."_blocks set weight='$oweight' where bid='$obid'");
  771.         $oweight++;
  772.         }
  773.             $row7 = $db->sql_fetchrow($db->sql_query("SELECT weight from ".$prefix."_blocks where bposition='$bposition' order by weight DESC limit 0,1"));
  774.             $lastw = $row7['weight'];
  775.         if ($lastw <= $fweight) {
  776.         $lastw++;
  777.         $db->sql_query("update ".$prefix."_blocks set title='$title', content='$content', bposition='$bposition', weight='$lastw', active='$active', refresh='$refresh', blanguage='$blanguage', blockfile='$blockfile', view='$view' where bid='$bid'");
  778.         } else {
  779.         $db->sql_query("update ".$prefix."_blocks set title='$title', content='$content', bposition='$bposition', weight='$fweight', active='$active', refresh='$refresh', blanguage='$blanguage', blockfile='$blockfile', view='$view' where bid='$bid'");
  780.         }
  781.     } else {
  782.         $result8 = $db->sql_query("update ".$prefix."_blocks set bkey='$bkey', title='$title', content='$content', url='$url', bposition='$bposition', weight='$weight', active='$active', refresh='$refresh', blanguage='$blanguage', blockfile='$blockfile', view='$view' where bid='$bid'");
  783.     }
  784.     Header("Location: admin.php?op=BlocksAdmin");
  785.     }
  786. }
  787.  
  788. function ChangeStatus($bid, $ok=0) {
  789.     global $prefix, $db;
  790.     $bid = intval($bid);
  791.     $row = $db->sql_fetchrow($db->sql_query("SELECT active from ".$prefix."_blocks where bid='$bid'"));
  792.     $active = intval($row['active']);
  793.     if (($ok) OR ($active == 1)) {
  794.     if ($active == 0) {
  795.         $active = 1;
  796.     } elseif ($active == 1) {
  797.         $active = 0;
  798.     }
  799.     $result2 = $db->sql_query("update ".$prefix."_blocks set active='$active' where bid='$bid'");
  800.     Header("Location: admin.php?op=BlocksAdmin");
  801.     } else {
  802.     $row3 = $db->sql_fetchrow($db->sql_query("SELECT title, content from ".$prefix."_blocks where bid='$bid'"));
  803.     $title = $row3['title'];
  804.     $content = $row3['content'];
  805.     include("header.php");
  806.     GraphicAdmin();
  807.     echo "<br>";
  808.     OpenTable();
  809.     echo "<center><font class=\"option\"><b>"._BLOCKACTIVATION."</b></font></center>";
  810.     CloseTable();
  811.     echo "<br>";
  812.     OpenTable();
  813.     if ($content != "") {
  814.         echo "<center>"._BLOCKPREVIEW." <i>$title</i><br><br>";
  815.         themesidebox($title, $content);
  816.     } else {
  817.         echo "<center><i>$title</i><br><br>";
  818.     }
  819.     echo "<br>"._WANT2ACTIVATE."<br><br>"
  820.         ."[ <a href=\"admin.php?op=BlocksAdmin\">"._NO."</a> | <a href=\"admin.php?op=ChangeStatus&bid=$bid&ok=1\">"._YES."</a> ]"
  821.         ."</center>";
  822.     CloseTable();
  823.     include("footer.php");
  824.     }
  825. }
  826.  
  827. function BlocksDelete($bid, $ok=0) {
  828.     global $prefix, $db;
  829.         $bid = intval($bid);
  830.     if ($ok) {
  831.     $row = $db->sql_fetchrow($db->sql_query("SELECT bposition, weight from ".$prefix."_blocks where bid='$bid'"));
  832.     $bposition = $row['bposition'];
  833.     $weight = intval($row['weight']);
  834.     $result2 = $db->sql_query("SELECT bid from " . $prefix . "_blocks where weight>'$weight' AND bposition='$bposition'");
  835.     while ($row2 = $db->sql_fetchrow($result2)) {
  836.     $nbid = intval($row2['bid']);
  837.         $db->sql_query("update ".$prefix."_blocks set weight='$weight' where bid='$nbid'");
  838.         $weight++;
  839.     }
  840.     $db->sql_query("delete from ".$prefix."_blocks where bid='$bid'");
  841.     Header("Location: admin.php?op=BlocksAdmin");
  842.     } else {
  843.         $row3 = $db->sql_fetchrow($db->sql_query("SELECT title from ".$prefix."_blocks where bid='$bid'"));
  844.         $title = $row3['title'];
  845.     include("header.php");
  846.     GraphicAdmin();
  847.     OpenTable();
  848.     echo "<center><font class=\"title\"><b>"._BLOCKSADMIN."</b></font></center>";
  849.     CloseTable();
  850.     echo "<br>";
  851.     OpenTable();
  852.     echo "<center>"._ARESUREDELBLOCK." <i>$title</i>?";
  853.     echo "<br><br>[ <a href=\"admin.php?op=BlocksAdmin\">"._NO."</a> | <a href=\"admin.php?op=BlocksDelete&bid=$bid&ok=1\">"._YES."</a> ]</center>";
  854.     CloseTable();
  855.     include("footer.php");
  856.     }
  857. }
  858.  
  859. function HeadlinesAdmin() {
  860.     global $bgcolor1, $bgcolor2, $prefix, $db;
  861.     include ("header.php");
  862.     GraphicAdmin();
  863.     OpenTable();
  864.     echo "<center><font class=\"title\"><b>"._HEADLINESADMIN."</b></font></center>";
  865.     CloseTable();
  866.     echo "<br>";
  867.     OpenTable();
  868.     echo "<form action=\"admin.php\" method=\"post\">"
  869.     ."<table border=\"1\" width=\"100%\" align=\"center\"><tr>"
  870.     ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._SITENAME."</b></td>"
  871.     ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._URL."</b></td>"
  872.     ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._FUNCTIONS."</b></td><tr>";
  873.     $result = $db->sql_query("SELECT hid, sitename, headlinesurl from " . $prefix . "_headlines order by hid");
  874.     while ($row = $db->sql_fetchrow($result)) {
  875.     $hid = intval($row['hid']);
  876.     $sitename = $row['sitename'];
  877.     $headlinesurl = $row['headlinesurl'];
  878.     echo "<td bgcolor=\"$bgcolor1\" align=\"center\">$sitename</td>"
  879.         ."<td bgcolor=\"$bgcolor1\" align=\"center\"><a href=\"$headlinesurl\" target=\"new\">$headlinesurl</a></td>"
  880.         ."<td bgcolor=\"$bgcolor1\" align=\"center\">[ <a href=\"admin.php?op=HeadlinesEdit&hid=$hid\">"._EDIT."</a> | <a href=\"admin.php?op=HeadlinesDel&hid=$hid&ok=0\">"._DELETE."</a> ]</td><tr>";
  881.     }
  882.     echo "</form></td></tr></table>";
  883.     CloseTable();
  884.     echo "<br>";
  885.     OpenTable();
  886.     echo "<font class=\"option\"><b>"._ADDHEADLINE."</b></font><br><br>"
  887.     ."<font class=\"content\">"
  888.     ."<form action=\"admin.php\" method=\"post\">"
  889.     ."<table border=\"0\" width=\"100%\"><tr><td>"
  890.     .""._SITENAME.":</td><td><input type=\"text\" name=\"xsitename\" size=\"31\" maxlength=\"30\"></td></tr><tr><td>"
  891.     .""._RSSFILE.":</td><td><input type=\"text\" name=\"headlinesurl\" size=\"50\" maxlength=\"200\"></td></tr><tr><td>"
  892.     ."</td></tr></table>"
  893.     ."<input type=\"hidden\" name=\"op\" value=\"HeadlinesAdd\">"
  894.     ."<input type=\"submit\" value=\""._ADD."\">"
  895.     ."</form>";
  896.     CloseTable();
  897.     include("footer.php");
  898. }
  899.  
  900. function HeadlinesEdit($hid) {
  901.     global $prefix, $db;
  902.     include ("header.php");
  903.     GraphicAdmin();
  904.     OpenTable();
  905.     echo "<center><font class=\"title\"><b>"._HEADLINESADMIN."</b></font></center>";
  906.     CloseTable();
  907.     echo "<br>";
  908.     $row = $db->sql_fetchrow($db->sql_query("SELECT sitename, headlinesurl from ".$prefix."_headlines where hid='$hid'"));
  909.     $xsitename = $row['sitename'];
  910.     $headlinesurl = $row['headlinesurl'];
  911.     OpenTable();
  912.     echo "<center><font class=\"option\"><b>"._EDITHEADLINE."</b></font></center>
  913.     <form action=\"admin.php\" method=\"post\">
  914.     <input type=\"hidden\" name=\"hid\" value=\"$hid\">
  915.     <table border=\"0\" width=\"100%\"><tr><td>
  916.     "._SITENAME.":</td><td><input type=\"text\" name=\"xsitename\" size=\"31\" maxlength=\"30\" value=\"$xsitename\"></td></tr><tr><td>
  917.     "._RSSFILE.":</td><td><input type=\"text\" name=\"headlinesurl\" size=\"50\" maxlength=\"200\" value=\"$headlinesurl\"></td></tr><tr><td>
  918.     </select></td></tr></table>
  919.     <input type=\"hidden\" name=\"op\" value=\"HeadlinesSave\">
  920.     <input type=\"submit\" value=\""._SAVECHANGES."\">
  921.     </form>";
  922.     CloseTable();
  923.     include("footer.php");
  924. }
  925.  
  926. function HeadlinesSave($hid, $xsitename, $headlinesurl) {
  927.     global $prefix, $db;
  928.     $xsitename = ereg_replace(" ", "", $xsitename);
  929.     $db->sql_query("update ".$prefix."_headlines set sitename='$xsitename', headlinesurl='$headlinesurl' where hid='$hid'");
  930.     Header("Location: admin.php?op=HeadlinesAdmin");
  931. }
  932.  
  933. function HeadlinesAdd($xsitename, $headlinesurl) {
  934.     global $prefix, $db;
  935.     $xsitename = ereg_replace(" ", "", $xsitename);
  936.     $db->sql_query("insert into ".$prefix."_headlines values (NULL, '$xsitename', '$headlinesurl')");
  937.     Header("Location: admin.php?op=HeadlinesAdmin");
  938. }
  939.  
  940. function HeadlinesDel($hid, $ok=0) {
  941.     global $prefix, $db;
  942.     if($ok==1) {
  943.     $db->sql_query("delete from ".$prefix."_headlines where hid='$hid'");
  944.     Header("Location: admin.php?op=HeadlinesAdmin");
  945.     } else {
  946.     include("header.php");
  947.     GraphicAdmin();
  948.     OpenTable();
  949.     echo "<center><br>";
  950.     echo "<font class=\"option\">";
  951.     echo "<b>"._SURE2DELHEADLINE."</b></font><br><br>";
  952.     }
  953.     echo "[ <a href=\"admin.php?op=HeadlinesDel&hid=$hid&ok=1\">"._YES."</a> | <a href=\"admin.php?op=HeadlinesAdmin\">"._NO."</a> ]<br><br>";
  954.     CloseTable();
  955.     include("footer.php");
  956. }
  957.  
  958. switch($op) {
  959.  
  960.     case "BlocksAdmin":
  961.     BlocksAdmin();
  962.     break;
  963.  
  964.     case "BlocksAdd":
  965.     BlocksAdd($title, $content, $url, $bposition, $active, $refresh, $headline, $blanguage, $blockfile, $view);
  966.     break;
  967.  
  968.     case "BlocksEdit":
  969.     BlocksEdit($bid);
  970.     break;
  971.  
  972.     case "BlocksEditSave":
  973.     BlocksEditSave($bid, $bkey, $title, $content, $url, $oldposition, $bposition, $active, $refresh, $weight, $blanguage, $blockfile, $view);
  974.     break;
  975.  
  976.     case "ChangeStatus":
  977.     ChangeStatus($bid, $ok, $de);
  978.     break;
  979.  
  980.     case "BlocksDelete":
  981.     BlocksDelete($bid, $ok);
  982.     break;
  983.  
  984.     case "BlockOrder":
  985.     BlockOrder ($weightrep,$weight,$bidrep,$bidori);
  986.     break;
  987.  
  988.     case "HeadlinesDel":
  989.     HeadlinesDel($hid, $ok);
  990.     break;
  991.  
  992.     case "HeadlinesAdd":
  993.     HeadlinesAdd($xsitename, $headlinesurl);
  994.     break;
  995.  
  996.     case "HeadlinesSave":
  997.     HeadlinesSave($hid, $xsitename, $headlinesurl);
  998.     break;
  999.  
  1000.     case "HeadlinesAdmin":
  1001.     HeadlinesAdmin();
  1002.     break;
  1003.  
  1004.     case "HeadlinesEdit":
  1005.     HeadlinesEdit($hid);
  1006.     break;
  1007.  
  1008.     case "fixweight":
  1009.     fixweight();
  1010.     break;
  1011.  
  1012.     case "block_show":
  1013.     block_show($bid);
  1014.     break;
  1015.  
  1016. }
  1017.  
  1018. } else {
  1019.     echo "Access Denied";
  1020. }
  1021.  
  1022. ?>
  1023.