function showNewsRefresh($id, $time, $path)
 {
     global $objDatabase;
     //delete old #01
     $query = "SELECT link,\n                           filename\n                      FROM " . DBPREFIX . "module_feed_news\n                     WHERE id = '" . $id . "'";
     $objResult = $objDatabase->Execute($query);
     $old_link = $objResult->fields['link'];
     $old_filename = $objResult->fields['filename'];
     if ($old_link != '') {
         $filename = 'feed_' . $time . '_' . \Cx\Lib\FileSystem\FileSystem::replaceCharacters(basename($old_link));
         @copy($old_link, $path . $filename);
         //rss class
         $rss = new \XML_RSS($path . $filename);
         $rss->parse();
         $content = '';
         foreach ($rss->getStructure() as $array) {
             $content .= $array;
         }
     }
     if ($old_link == '') {
         $filename = $old_filename;
     }
     $query = "UPDATE " . DBPREFIX . "module_feed_news\n                       SET filename = '" . $filename . "',\n                           time = '" . $time . "'\n                     WHERE id = '" . $id . "'";
     $objDatabase->Execute($query);
     //delete old #02
     if ($old_link != '') {
         @unlink($path . $old_filename);
     }
 }
 function testGetStructureFromString()
 {
     $rss = file_get_contents(dirname(__FILE__) . '/test.rss');
     $r = new XML_RSS($rss);
     $r->parse();
     $expected = 'a:7:{i:0;a:4:{s:4:"type";s:7:"channel";s:5:"title";s:4:"Test";s:4:"link";s:20:"http://pear.php.net/";s:11:"description";s:34:"This is a test channel for XML_RSS";}i:1;a:4:{s:4:"type";s:5:"image";s:5:"title";s:4:"PEAR";s:3:"url";s:38:"http://pear.php.net/gifs/pearsmall.gif";s:4:"link";s:20:"http://pear.php.net/";}i:2;a:4:{s:4:"type";s:4:"item";s:5:"title";s:12:"PHP homepage";s:4:"link";s:15:"http://php.net/";s:8:"category";a:1:{i:0;s:3:"php";}}i:3;a:4:{s:4:"type";s:4:"item";s:5:"title";s:13:"PEAR homepage";s:4:"link";s:20:"http://pear.php.net/";s:8:"category";a:2:{i:0;s:3:"php";i:1;s:4:"pear";}}i:4;a:4:{s:4:"type";s:4:"item";s:5:"title";s:16:"PHP-GTK homepage";s:4:"link";s:19:"http://gtk.php.net/";s:8:"category";a:2:{i:0;s:3:"php";i:1;s:3:"gtk";}}i:5;a:4:{s:4:"type";s:4:"item";s:5:"title";s:15:"PHP QA homepage";s:4:"link";s:18:"http://qa.php.net/";s:8:"category";a:2:{i:0;s:3:"php";i:1;s:2:"qa";}}i:6;a:5:{s:4:"type";s:9:"textinput";s:5:"title";s:15:"Search Slashdot";s:11:"description";s:23:"Search Slashdot stories";s:4:"name";s:5:"query";s:4:"link";s:29:"http://slashdot.org/search.pl";}}';
     $actual = serialize($r->getStructure());
     $this->assertEquals($expected, $actual);
 }
 /**
  * refresh xml
  *
  * refresh ex. xml
  *
  * @access   public
  * @param    string  $id
  * @return   string  $filename
  * @global   ADONewConnection
  * @global   array
  */
 function refreshXML($id)
 {
     global $objDatabase, $_ARRAYLANG;
     //get filename
     $objResult = $objDatabase->Execute("SELECT  id, rss_link, rss_file FROM " . DBPREFIX . "module_directory_dir WHERE status = '1' AND id = '" . contrexx_addslashes($id) . "'");
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             $filename = $objResult->fields['rss_file'];
             $link = $objResult->fields['rss_link'];
             $objResult->MoveNext();
         }
     }
     //del old
     if (file_exists($this->mediaPath . "ext_feeds/" . $filename)) {
         @unlink($this->mediaPath . "ext_feeds/" . $filename);
     }
     //copy
     if (!copy($link, $this->mediaPath . "ext_feeds/" . $filename)) {
         $this->statusMessage = $_ARRAYLANG['DIRECTORY_NO_NEWS'];
         die;
     }
     //rss class
     $rss = new \XML_RSS($this->mediaPath . "ext_feeds/" . $filename);
     $rss->parse();
     $content = '';
     foreach ($rss->getStructure() as $array) {
         $content .= $array;
     }
     $objResult = $objDatabase->Execute("UPDATE " . DBPREFIX . "module_directory_dir SET xml_refresh='" . mktime(date("G"), date("i"), date("s"), date("m"), date("d"), date("Y")) . "' WHERE id='" . $id . "'");
     if ($content == '') {
         unlink($this->mediaPath . "ext_feeds/" . $filename);
     }
 }
 function showEditSetNew($id, $subid, $name, $link, $filename, $articles, $cache, $time, $image, $status)
 {
     global $objDatabase, $_ARRAYLANG;
     //delete old #01
     $query = "SELECT link,\n                           filename\n                      FROM " . DBPREFIX . "module_feed_news\n                     WHERE id = '" . $id . "'";
     $objResult = $objDatabase->Execute($query);
     $old_link = $objResult->fields['link'];
     $old_filename = $objResult->fields['filename'];
     //new
     $query = "SELECT id\n                      FROM " . DBPREFIX . "module_feed_news\n              WHERE BINARY name = '" . $name . "'\n                       AND id <> '" . $id . "'";
     $objResult = $objDatabase->Execute($query);
     if ($objResult->RecordCount() == 0) {
         if ($link != '') {
             $filename = "feed_" . $time . "_" . basename($link);
             if (!copy($link, $this->feedpath . $filename)) {
                 $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_FEED_MESSAGE_ERROR_NEWS_FEED'];
                 $this->goToReplace('&act=edit&id=' . $id);
                 die;
             }
             //rss class
             $rss = new \XML_RSS($this->feedpath . $filename);
             $rss->parse();
             $content = '';
             foreach ($rss->getStructure() as $array) {
                 $content .= $array;
             }
             if ($content == '') {
                 unlink($this->feedpath . $filename);
                 $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_FEED_MESSAGE_ERROR_NEWS_FEED'];
                 $this->goToReplace('&act=edit&id=' . $id);
                 die;
             }
         }
         $query = "UPDATE " . DBPREFIX . "module_feed_news\n                           SET subid = '" . $subid . "',\n                               name = '" . $name . "',\n                               link = '" . $link . "',\n                               filename = '" . $filename . "',\n                               articles = '" . $articles . "',\n                               cache = '" . $cache . "',\n                               time = '" . $time . "',\n                               image = '" . $image . "',\n                               status = '" . $status . "'\n                         WHERE id = '" . $id . "'";
         $objResult = $objDatabase->Execute($query);
     } else {
         $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_FEED_MESSAGE_ERROR_EXISTING_NEWS'];
         $this->goToReplace('&act=edit&id=' . $id);
         die;
     }
     //delete old #02
     if ($old_link != '') {
         if (!unlink($this->feedpath . $old_filename)) {
             $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_FEED_MESSAGE_ERROR_DELETE'];
             $this->goToReplace('');
             die;
         }
     }
 }