Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------ mysql_connect.php -------------
- <?php
- function ConectToDB() {
- $MyConnection = mysql_connect(server, user, password);
- mysql_select_db(database);
- return $MyConnection;
- }
- ?>
- ------------ mysql_connect.php -------------
- ------------ update_streams.php ------------
- <?php
- require_once('mysql_connect.php');
- ConectToDB();
- $now = time();
- mysql_query("update site_tasks_helper set streams_last_verified='$now'");
- $query = mysql_query("select * from streams");
- $aux = 0;
- while ($aux < mysql_num_rows($query)) {
- $rs = mysql_fetch_array($query);
- $id = $rs["id_stream"];
- $url = $rs["url"];
- $site = $rs["site"];
- switch ($site) {
- case "twitch":
- $url = "http://api.justin.tv/api/stream/list.xml?channel=$url";
- $xml = simplexml_load_file($url);
- $title = $xml->stream->title;
- $meta_game = $xml->stream->meta_game;
- $channel_count = $xml->stream->channel_count;
- if ($channel_count < 1) {
- mysql_query("update streams set title='', game='', viewers=0, online=0 where id_stream=$id");
- } else {
- mysql_query("update streams set title='$title', game='$meta_game', viewers=$channel_count, online=1 where id_stream=$id");
- }
- break;
- }
- $aux++;
- }
- mysql_close();
- ?>
- ------------ update_streams.php ------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement