Esempio n. 1
0
 function process_toolsform(&$formdata)
 {
     global $CFG;
     $error_reporting = ini_get('error_reporting');
     $display_errors = ini_get('display_errors');
     ini_set('error_reporting', E_ALL);
     ini_set('display_errors', 'On');
     if (isset($formdata->updatechannels)) {
         include_once $CFG->dirroot . '/mod/podcaster/lib/public.php';
         include_once $CFG->dirroot . '/mod/podcaster/lib/util.php';
         $start = microtime();
         echo '<pre>Clearing cache ...</pre>';
         flush();
         execute_sql('UPDATE ' . $CFG->prefix . 'podcaster_item SET enclosureurl = \'\', enclosurelength = 0, enclosuretype = \'\'');
         execute_sql('UPDATE ' . $CFG->prefix . 'podcaster SET imageurl = \'\', imagewidth = 0, imageheight = 0, imagetype = \'\', imagelength = 0 WHERE ismeta = 0');
         $channels = get_records('podcaster', 'ismeta', '0');
         echo '<pre>Updating all channels ...</pre>';
         flush();
         if ($channels) {
             foreach ($channels as $channel) {
                 echo '<pre>&nbsp;&nbsp;Updating ' . $channel->id . ': ' . htmlspecialchars($channel->name) . '</pre>';
                 flush();
                 $channelstart = microtime();
                 $channelObj = podcaster_channel::create_channel($channel);
                 $channelObj->update_rss();
                 echo '<pre><a href="' . $channelObj->get_rss_link() . '">RSS</a> <a href="' . $CFG->wwwroot . '/mod/podcaster/view.php?channel=' . $channelObj->id . '">HTML</a></pre>';
                 echo '<pre>&nbsp;&nbsp;&nbsp;&nbsp;done in ' . podcaster_util::time_diff($channelstart, microtime()) . '</pre>';
                 flush();
             }
         }
         echo '<pre>done in ' . podcaster_util::time_diff($start, microtime()) . '</pre>';
         die;
     } elseif (isset($formdata->updatemetachannels)) {
         include_once $CFG->dirroot . '/mod/podcaster/lib/public.php';
         include_once $CFG->dirroot . '/mod/podcaster/lib/util.php';
         $start = microtime();
         echo '<pre>Clearing cache ...</pre>';
         execute_sql('UPDATE ' . $CFG->prefix . 'podcaster SET imageurl = \'\', imagewidth = 0, imageheight = 0, imagetype = \'\', imagelength = 0 WHERE ismeta = 1');
         $channels = get_records('podcaster_metachannel');
         echo '<pre>Updating all metachannels ...</pre>';
         flush();
         if ($channels) {
             foreach ($channels as $channel) {
                 echo '<pre>&nbsp;&nbsp;Updating ' . $channel->id . ': ' . htmlspecialchars($channel->name) . '</pre>';
                 flush();
                 $channelstart = microtime();
                 $channelObj = podcaster_channel::create_metachannel($channel);
                 $channelObj->update_rss();
                 echo '<pre><a href="' . $channelObj->get_rss_link() . '">RSS</a> <a href="' . $CFG->wwwroot . '/mod/podcaster/view.php?channel=' . $channelObj->id . '">HTML</a></pre>';
                 echo '<pre>&nbsp;&nbsp;&nbsp;&nbsp;done in ' . podcaster_util::time_diff($channelstart, microtime()) . '</pre>';
                 flush();
             }
         }
         echo '<pre>done in ' . podcaster_util::time_diff($start, microtime()) . '</pre>';
         die;
     }
     ini_set('error_reporting', $error_reporting);
     ini_set('display_errors', $display_errors);
     return PODCASTER_NOERROR;
 }