function rsscache_default_channel() { global $rsscache_link; global $rsscache_time; global $rsscache_logo; global $rsscache_description; $config = config_xml(); $channel = array('title' => rsscache_title(), 'link' => $rsscache_link, 'description' => str_replace(array(' ', "\n"), array(' ', ''), $rsscache_description), 'image' => $rsscache_logo, 'lastBuildDate' => $rsscache_time, 'docs' => $rsscache_link); return $channel; }
function rsscache_sql($c, $q, $f, $v, $start, $num, $v_segments = NULL) { /* $c == category $q == query $f == function $v == video (rsstool_url_crc32) LIMIT $start, $num $table_suffix is optional and set in config.xml */ global $rsscache_sql_db, $rsscache_isnew, $rsscache_root, $rsscache_enable_search, $rsscache_related_search, $rsscache_use_dl_date, $rsscache_max_results, $rsscache_time, $rsscache_item_ttl; global $rsscache_debug_sql; $debug = $rsscache_debug_sql; // $debug = 1; $category0_xml = config_xml(); // DEBUG //echo '<pre><tt>'; //print_r ($category0_xml); //exit; $c = 'c64'; $category_xml = config_xml_by_category($c); $c = $category_xml['category']; // safety // DEBUG //echo '<pre><tt>'; //echo $c; //print_r ($category_xml); //exit; if ($f == 'stats') { return rsscache_sql_stats($rsscache_sql_db, $c); } if ($f == 'extern') { return rsscache_sql_extern($c, $q, $f, $v, $start, $num); } $rsstool_table = rsscache_tablename_by_category('rsstool', $c); $sql_query_s = ''; $sql_query_s .= '' . 'SELECT' . ' rsstool_url,' . ' ' . $rsstool_table . '.rsstool_url_crc32,' . ' rsstool_title,' . ' rsstool_desc,' . ' rsstool_dl_date,' . ' rsstool_date,' . ' tv2_moved,' . ' rsstool_event_start,' . ' rsstool_event_end,' . ' rsstool_media_duration,' . ' rsstool_keywords,' . ' rsstool_user,' . ' rsstool_related_id'; // direct if ($v) { $sql_query_s .= ' FROM ' . $rsstool_table; $sql_query_s .= ' WHERE ( rsstool_url_crc32 = ' . $v . ' )' . ' LIMIT 1'; $d = rsscache_sql_query($sql_query_s); $d = rsscache_sql_normalize($d); return $d; } // related search if ($rsscache_related_search && $f == 'related') { $sql_query_s .= ' FROM ' . $rsstool_table; $a = array(); // category if ($c) { $a[] = 'tv2_moved = \'' . $c . '\''; } // $a[] = 'rsstool_related_id = '.misc_related_string_id ($q); // super fast $a[] = 'rsstool_related_id = ' . sprintf("%u", $q); // super fast // $a[] = 'rsstool_related_id = '.$q; // super fast if (isset($a[0])) { $sql_query_s .= ' WHERE ( ' . implode(' AND ', $a) . ' )'; } // we sort related by title for playlist $sql_query_s .= ' ORDER BY rsstool_title ASC'; // limit $sql_query_s .= ' LIMIT ' . $rsscache_max_results; $d = rsscache_sql_query($sql_query_s); $d = rsscache_sql_normalize($d); return $d; } // keyword search if ($rsscache_enable_search && $q) { if ($v_segments) { if (trim($v_segments) != '') { $q .= ' +part'; } } $b = rsscache_sql_query2boolean($q, $c); $sql_query_s .= ' FROM ' . rsscache_sql_keyword_func($b['any'], $b['require'], $b['exclude'], isset($category_xml['rsscache:table_suffix']) ? $category_xml['rsscache:table_suffix'] : NULL); } else { $sql_query_s .= ' FROM ' . $rsstool_table; } // category if ($c) { $a[] = 'tv2_moved = \'' . $c . '\''; } // functions if ($f == 'new') { $a[] = 'rsstool_dl_date > ' . ($rsscache_time - $rsscache_isnew) . ''; } if ($rsscache_item_ttl > 0) { $a[] = 'rsstool_date > ' . ($rsscache_time - $rsscache_item_ttl); } if ($f == '0_5min') { $a[] = 'rsstool_media_duration BETWEEN 0 AND 301'; } else { if ($f == '5_10min') { $a[] = 'rsstool_media_duration BETWEEN 299 AND 601'; } else { if ($f == '10_30min') { $a[] = 'rsstool_media_duration BETWEEN 599 AND 1801'; } else { if ($f == '30_60_min') { $a[] = 'rsstool_media_duration BETWEEN 1799 AND 3601'; } else { if ($f == '60_min' || $f == '1_h') { $a[] = 'rsstool_media_duration > 3599'; } } } } } if (isset($a[0])) { $sql_query_s .= ' WHERE ( ' . implode(' AND ', $a) . ' )'; } // sort // if ($f == 'score') // $sql_query_s .= ' ORDER BY tv2_score ASC'; // else if ($f == 'new' || $rsscache_use_dl_date) { $sql_query_s .= ' ORDER BY rsstool_dl_date DESC'; } else { $sql_query_s .= ' ORDER BY rsstool_date DESC'; } // limit $sql_query_s .= ' LIMIT ' . $start . ',' . min($num, $rsscache_max_results); $d = rsscache_sql_query($sql_query_s); $d = rsscache_sql_normalize($d); return $d; }
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ //phpinfo (); //error_reporting(E_ALL | E_STRICT); require_once '../htdocs/rsscache/default.php'; require_once '../htdocs/config.php'; require_once '../htdocs/misc/misc.php'; require_once '../htdocs/misc/sql.php'; require_once '../htdocs/misc/rss.php'; require_once '../htdocs/misc/youtube.php'; require_once '../htdocs/rsscache/rsscache_sql.php'; require_once '../htdocs/rsscache/rsscache_misc.php'; // main () // unlimited execution time //ini_set('max_execution_time', '3600'); set_time_limit(0); rsscache_sql_open(); $config = config_xml(); echo misc_exec('/etc/init.d/tor restart'); // DEBUG echo 'database: ' . $rsscache_dbname . ' (' . $rsscache_dbuser . ')' . "\n"; for ($i = 0; isset($config['item'][$i]); $i++) { if (isset($config['item'][$i]['category'])) { print_r($config['item'][$i]); rsscache_download_feeds_by_category($config['item'][$i]['category']); } } rsscache_sql_close(); exit;