Warning: Use of undefined constant userClick - assumed 'userClick' (this will throw an Error in a future version of PHP) in /srv/www.tvmad.com/htdocs/share.php on line 18

Warning: Use of undefined constant DOCUMENT_ROOT - assumed 'DOCUMENT_ROOT' (this will throw an Error in a future version of PHP) in /srv/www.tvmad.com/htdocs/share.php on line 35

Warning: Use of undefined constant DOCUMENT_ROOT - assumed 'DOCUMENT_ROOT' (this will throw an Error in a future version of PHP) in /srv/www.tvmad.com/htdocs/share.php on line 36

Warning: Use of undefined constant DOCUMENT_ROOT - assumed 'DOCUMENT_ROOT' (this will throw an Error in a future version of PHP) in /srv/www.tvmad.com/htdocs/share.php on line 37
login_type == 'tw'){ $user[login_type] = 'tw'; $user[id] = $usr -> id; $name = explode(" ", $usr -> name); $cnt = count($name); if($cnt > 1){ $user[last_name] = array_pop($name); $user[first_name] = implode(" ", $name); }else{ $user[first_name] = $usr -> name; } $user[nickname] = $usr -> screen_name; $user[location][name] = $usr -> location; }else{ $user = $usr; if (!$user['nickname']) $user['nickname'] = $user['first_name']; } if($user[intrested_in][female]) $intrested_in = 'f'; elseif($user[intrested_in][male]) $intrested_in = 'm'; else $intrested_in = ''; $q = mysql_query("SELECT id FROM tvmad_user WHERE login_type = '".$user[login_type]."' AND login_id = '".$user[id]."'"); if(mysql_num_rows($q) == 0){ $username = createUsername($user['first_name']); mysql_query(sprintf("INSERT INTO tvmad_user (username, first_name, last_name, nickname, email, birthday, gender, hometown, location, interested_in, meeting_for, relationship_status, religion, political, login_type, login_id, login_time) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '".substr($user[gender],0,1)."', '%s', '%s', '".$intrested_in."', '%s', '%s', '%s', '%s', '".$user[login_type]."', '%s', NOW())", $username, $user[first_name], $user[last_name], $user[nickname], $user[email], $user[birthday], $user[hometown][name], $user[location][name], $user[meeting_for], substr($user[relationship_status], 0, 1), $user[religion], $user[political], $user[id])) or die(mysql_error()); $_SESSION[user][id] = mysql_result(mysql_query("SELECT LAST_INSERT_ID() AS id"), 0, "id"); }else{ mysql_query(sprintf("UPDATE tvmad_user SET first_name = '%s', last_name = '%s', nickname = '%s', email = '%s', birthday = '%s', hometown = '%s', location = '%s', interested_in = '".$intrested_in."', meeting_for = '%s', relationship_status = '%s', religion = '%s', political = '%s', notice='0' WHERE login_type = '".$user[login_type]."' AND login_id = '".$user[id]."'", $user[first_name], $user[last_name], $user[nickname], $user[email], $user[birthday], $user[hometown][name], $user[location][name], $user[meeting_for], substr($user[relationship_status], 0, 1), $user[religion], $user[political])); $_SESSION[user][id] = mysql_result($q, 0, "id"); } $_SESSION[user][login_type] = $user[login_type]; $_SESSION[user][login_id] = $user[id]; $_SESSION[user][firstname] = $user[first_name]; $_SESSION[user][lastname] = $user[last_name]; $_SESSION[user][nickname] = $user[first_name]; $_SESSION[user][email] = $user[email]; if($user[login_type] == 'fb'){ mysql_query("DELETE FROM tvmad_user_interest WHERE user_id = '".$_SESSION[user][id]."'"); foreach($user[data] as $k => $v){ if($v[name] != ''){ $q = mysql_query(sprintf("SELECT id FROM tvmad_interest WHERE name = '%s'", mysql_real_escape_string($v[name]))); if(mysql_num_rows($q) > 0){ $r = mysql_fetch_assoc($q); mysql_query("INSERT INTO tvmad_user_interest (user_id, interest_id) VALUES ('".$_SESSION[user][id]."', '".$r[id]."')"); }else{ mysql_query(sprintf("INSERT INTO tvmad_interest (name) VALUES ('%s')", mysql_real_escape_string($v[name]))); $interest_id = mysql_result(mysql_query("SELECT LAST_INSERT_ID() AS id"), 0, "id"); mysql_query("INSERT INTO tvmad_user_interest (user_id, interest_id) VALUES ('".$_SESSION[user][id]."', '".$interest_id."')"); } } } } return $_SESSION[user]; } function make_file_code($str){ $title=strtolower($str); $file_n=str_replace(' ',' ',$title); $file_n=str_replace(' - ','-',$title); $file_n=str_replace(' ','-',$file_n); $file_n=str_replace('ä','a',$file_n); $file_n=str_replace('ü','u',$file_n); $file_n=str_replace('õ','o',$file_n); $file_n=str_replace('ö','o',$file_n); $file_n=preg_replace("/([^a-z0-9\-]+)/i","",$file_n); $file_n=preg_replace('/--/','-',$file_n,-1); $file_n=preg_replace('/--/','-',$file_n,-1); $file_n=preg_replace('/--/','-',$file_n,-1); if(substr($file_n,0,1)=='-') $file_n=substr($file_n,1); if(substr($file_n,-1)=='-') $file_n=substr($file_n,0,-1); return $file_n; } function get_user_ip(){ if(getenv('HTTP_X_FORWARDED_FOR') != '' ){ $client_ip = $_SERVER['REMOTE_ADDR']; $entries = explode(',', getenv('HTTP_X_FORWARDED_FOR')); reset($entries); while (list(, $entry) = each($entries)) { $entry = trim($entry); if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $entry, $ip_list) ){ $private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/', '/^10\..*/', '/^224\..*/', '/^240\..*/'); $found_ip = preg_replace($private_ip, $client_ip, $ip_list[1]); if ($client_ip != $found_ip){ $client_ip = $found_ip; break; } } } } else{ $client_ip = $_SERVER['REMOTE_ADDR']; } return $client_ip; } $start = $_GET['start']*1; $limit = 20; $max = 20; function pageNums($count, $max=0, $start=0, $limit=0, $ajax='', $ajaxElem='') { if (!$start) $start = $GLOBALS['start']*1; if (!$limit) $limit = $GLOBALS['limit']*1; if (!$max) $max = $GLOBALS['max']*1; if (!$max) $max = 20; if ($limit < $count || $limit == "ajax" && 10 < $count) { if (!$start) {$start = $GLOBALS['start'];} if (!$limit) {$limit = $GLOBALS['limit'];} $piale = str_replace(array('&start=' . $start, '?start=' . $start), array('', '?'), getenv('REQUEST_URI')); //if (!stristr($piale, '?')) $piale .= '/?'; $previus_link = ""; $prev_id = 0; if ($start > 0) {$prev_id = $start-$limit;} if ($prev_id < 0) {$prev_id = 0;} if ($start) { if ($ajax) { $previus_link = "«« « "; } else { $previus_link = "«« « "; } } $next_link = ''; $next_id = $start+$limit; if ($next_id < $count) { $last_page = $count-($count%$limit); if ($last_page+1 > $count) { $last_page = $count-$limit; } if ($ajax) { $next_link = "» »» "; } else { $next_link = "» »» "; } } $page_count = @round(($count+0.49*$limit)/$limit, 0); $page_first = 0; $page_last = $page_count; if ($page_count > $max) { $half = @round($max/2-0.01, 0); $leht_praegu = @round($start/$limit, 0); $page_first = $leht_praegu-$half; if ($page_first <= 0) {$page_first = 0;} $page_last = $page_first+$max; if ($page_last >= $page_count) {$page_last = $page_count; $page_first = $page_last-$max;} } $page_numbers = ""; for ($i=$page_first;$i<$page_last;$i++) { $i2 = $i+1; $page_start = $i*$limit; if ($page_start < $count) { if ($page_start == $start) { if ($ajax) { $page_numbers .= "$i2 "; } else { $page_numbers .= "$i2 "; } } else { if ($ajax) { $page_numbers .= "$i2 "; } else { $page_numbers .= "$i2 "; } } } } $r .= "
$previus_link $page_numbers $next_link
"; } return $r; } function picThumb($from, $to, $width = 0, $height = 0) { global $imagickPath; $img_size=getimagesize($from); if (!$width && !$height || $img_size[0] < $width && $width && !$height || $img_size[1] < $height && $height && !$width || $img_size[0] < $width && $img_size[1] < $height && $width && $height) { // PILDI MÕÕTMED JÄÄVAD SAMAKS copy($from, $to); return true; } else if ($width && !$height) { // MUUDETAKSE SUURUST VASTAVALT LAIUSELE $str = $imagickPath . 'convert -quality 90 -resize ' . $width . 'x ' . $from . ' ' . $to . ' 2>&1'; exec($str); return true; } else if ($width && !$height) { // MUUDETAKSE SUURUST VASTAVALT KÕRGUSELE $str = $imagickPath . 'convert -quality 90 -resize x' . $height . ' ' . $from . ' ' . $to . ' 2>&1'; exec($str); return true; } else { // MUUDETAKSE VASTAVALT LAIUSELE JA KÕRGUSELE $res_w = $img_size[0]/$width; $res_h = $img_size[1]/$height; $x_pos = 0; $y_pos = 0; if ($res_w <= $res_h) { //$y_pos = ($res_h-$res_w)*$height/2; $str = $imagickPath . 'convert -quality 90 -resize ' . $width . 'x ' . $from . ' ' . $to . ' 2>&1'; exec($str); } else { $x_pos = ($res_w-$res_h)*$width/2/$res_w; $str = $imagickPath . 'convert -quality 90 -resize x' . $height . ' ' . $from . ' ' . $to . ' 2>&1'; exec($str); } $str = $imagickPath . 'convert -quality 90 -crop ' . $width . 'x' . $height . '+' . $x_pos . '+' . $y_pos . ' ' . $to . ' ' . $to . ' 2>&1'; exec($str); return true; } } function curl($url, $post = '', $un = '', $pw = '', $follow=1, $header=0, $cookies = array()) { if ($un && $pw) { $url = str_replace('//', '//' . $un . ':' . $pw . '@', $url); } $urlcode = 'a' . md5($url . $post . $un . $pw . $follow . $header); if ($_SESSION['curl'][$urlcode] && strlen($_SESSION['curl'][$urlcode]) > 10) return $_SESSION['curl'][$urlcode]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, $header); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.0) Gecko/20090623 SUSE/3.5.0-6.1 Firefox/3.5"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $follow); if ($post) { curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } $cook = ''; if ($cookies) { foreach($cookies AS $key => $cookie) { $cook .= $key . '=' . $cookie . ';'; } } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:', 'User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.0) Gecko/20090623 SUSE/3.5.0-6.1 Firefox/3.5', 'Cookie:' . $cook)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); $page = curl_exec($ch); curl_close($ch); if (count($_SESSION['curl']) > 20) unset($_SESSION['curl']); $_SESSION['curl'][$urlcode] = $page; return $page; } function hint($message, $code='', $w=0) { if (!$w) $w = 300; if (!$code) $code = 'h' . md5($message) . rand(10000000, 99999999); $r = ''; return $r; } $outerUrls = array( 'youtube' => 'http://www.youtube.com/watch?v=', 'vimeo' => 'http://vimeo.com/', 'dailymotion' => 'http://www.dailymotion.com/video/', 'metacafe' => 'http://www.metacafe.com/watch/', ); function getMedia($type, $ytkey, $retry = false) { global $safeThumb; $r = array(); if ($type == 'youtube') { $rawData = file_get_contents('http://gdata.youtube.com/feeds/api/videos/' . $ytkey . '?v=2'); if ($rawData == 'Private video') return false; if (strlen($rawData) < 50) { if ($retry) { return false; } else { return getMedia($type, $ytkey, true); } } $data = new SimpleXMLElement(tidy_repair_string($rawData, array('input-xml' => true,'output-xml' => true))); if (!$data->title) { if ($retry) { return false; } else { return getMedia($type, $ytkey, true); } } $yt = $data->children('http://gdata.youtube.com/schemas/2007'); if ($yt->noembed) return 'noembed'; $r['length'] = 0; $r['title'] = $data->title . ''; $r['realurl'] = $ytkey; $media = $data->children('http://search.yahoo.com/mrss/'); $yt = $media->children('http://gdata.youtube.com/schemas/2007'); $r['tags'] = $media->group->keywords . ', '; $keywords .= $r['tags']; if (!$yt->duration) return false; $attrs = $yt->duration->attributes(); $r['length'] = $attrs['seconds']*1; if (!$r['length']) return false; if (!$safeThumb) { $attrs = $media->group->thumbnail[0]->attributes(); $safeThumb = $attrs['url']; } if (!$r['realurl']) return false; $r['length'] = $r['length']+2; return $r; } else if ($type == 'vimeo') { $rawData = curl('http://vimeo.com/api/v2/video/' . $ytkey . '.json'); $data = json_decode($rawData); $r['length'] = $data[0]->duration; $r['title'] = $data[0]->title; $r['realurl'] = $ytkey; $r['tags'] = $data[0]->tags; if (!$safeThumb) { $safeThumb = $data[0]->thumbnail_medium; } $r['length'] = $r['length']+2; return $r; } else if ($type == 'dailymotion') { $rawData = curl('http://www.dailymotion.com/video/' . $ytkey); list(,$title) = explode('&format=json" title="', $rawData); list($r['title']) = explode('"', $title, 2); list(,$dmduration) = explode('DMDURATION=', $rawData); list($r['length']) = explode('&', $dmduration, 2); $r['tags'] = ''; if (!$safeThumb) { list(,$thumb) = explode('og:image" content="', $rawData); list($safeThumb) = explode('"', $thumb, 2); } $r['realurl'] = $ytkey; $r['length'] = $r['length']+2; return $r; } else if ($type == 'metacafe') { $rawData = file_get_contents('http://www.metacafe.com/watch/' . $ytkey); list(,$title) = explode('', $title, 2); list($r['title']) = explode('', $title, 2); $r['title'] = trim(str_replace(array(' ', ' ', ' ', ' ', ' '), ' ', strip_tags($r['title']))); list(,$dmduration) = explode('&duration=', $rawData); list($r['length']) = explode('&', $dmduration, 2); list(,$dmduration) = explode('name="keywords" content="', $rawData); list($r['tags']) = explode('"', $dmduration, 2); if (!$safeThumb) { list(,$thumb) = explode('rel="image_src" href="', $rawData); list($safeThumb) = explode('"', $thumb, 2); } $r['length'] = $r['length']+2; $r['realurl'] = $ytkey; return $r; } } function passHack($password) { $len = abs(round(strlen($password)-5*strlen($password)/2, 0)); $extra_letter = 'jklghzxcvbn90qwerasdfzxcvbnm123tyuiopasdfghjklqwertyuiop4567890m12345678'; $password = md5($extra_letter[$len] . $password . '_tv' . $len); return $password; } function passRand($length) { $letters = 'qqwertyupasdfghjkzxcvbnmQWERTYUOPASDFGHJKZXCVBNM2345689'; $password = ''; for ($i=0;$i<$length;$i++) { $def_mark = rand(1, strlen($letters)-2); $password .= $letters[$def_mark]; } return strtolower($password); } $badge_explain = array( 'newbie' => 'Congrats! Newbie status is just the beginning, it`s all uphill from here.', 'judge' => 'You have given a rating to 5 channels already!', 'intelligent' => 'Nice, Your ratings to more than 10 channels seem to be quite fair.', 'positive charger' => 'Thanks for being a positive role model, this is for giving the high ratings.', 'well connected' => 'Connections count- keep sharing the channels.', 'major influencer' => 'Wow. You seem to have a great influence on your friends. People like the things you share in TVmad.', 'trend setter' => 'You have shared TVmad content 10 times already- a true trend setter.', 'distributor' => 'You have embedded a channel, good work.', 'pr boss' => 'People like what you have to say! Keep chatting.', 'reporter' => 'We like curious people. This badge is for creating a poll.', 'chat jedi' => 'You are not afraid to speak up, 5000 chat lines and counting.', 'surfer' => 'A true channelsurfer- more than 10 cool channels have cought your eye already.', 'couch potato' => 'You are one of the most dedicated users here. 10 hours of quality content.', 'movie fan' => 'Movie fans are the greatest! You have watched 5 hours of great motion pictures.', 'entertainer' => 'A dedicated broadcaster, your webcam has been online for an hour. ', 'anchor' => 'A hardcore broadcaster, 10 hours of live time is quite an achievement.', 'star' => 'You are the star of TVmad. Already 1000 channel views and 10 hours of live time.', 'tubenator' => 'Your Video playlist is one of the most comprehensive ones in TVmad. Congrats!', 'producer' => 'You are on your way to becoming the Super Producer- the first minutes of live content has been set up.', 'super producer' => 'Big boss of the TV world- 5 channels and 10000 views altogether.', 'seasoned' => 'Thanks for visiting us again and again. 10 sign-ins in TVmad already.', 'fan' => 'Cool! You are one of the most loyal users of TVmad, thanks for sticking around!', 'superfan' => 'No explanation needed- 100 sign-ins in TVmad and we love you for it.', 'good samaritian' => 'You are not greedy- this is for enabling p2p and helping to keep the bandwidth up.', 'scientist' => 'Quality matters, and you have set up a really educational science channel.', 'maker' => '1st place winner- your channel has been the no1 most viewed.', 'emmy winner' => 'Congrats! Your channel has been awarded with a place in the Featured list.', 'most gossiped' => 'Nice job, spreading your channel has brought you more than 50 viewers.', 'top breaker' => 'Your channels are one of the best ones in TVmad- 5 times in the no1 position.', 'eye candy' => 'People like what you broadcast- avarage rating is over 4 points.', 'media mogul' => 'All your channels are really great- avarage rating is over 4 points.', 'news' => 'Knoledge is Power- thanks for setting up a news channel.', 'explorer' => 'Every channel in TVmad is worth looking into and you have browsed over 50 of them.', 'i love tvmad' => 'This is for sharing the love and favouriting the channels.', 'music fan' => 'Music unites people. This is for creating a cool music channel.', ); $badge_explain2 = array( 'judge' => 'You need to give a rating to at least 5 channels.', 'intelligent' => 'Rate channels more than 10 times. And be honest!', 'positive charger' => 'Give a positive rating to at least 5 channels', 'well connected' => 'You need to share the channel with your friends to get this badge.', 'major influencer' => 'Share different channels more than 10 times.', 'trend setter' => 'To get this badge you need to invite people to watch a channel and share the channels.', 'distributor' => 'Embed a channel to another site to get this one.', 'pr boss' => '', 'reporter' => 'Create a poll to make your channel more attractive and get this badge.', 'chat jedi' => 'Speak your mind- only the busiest chatters get this badge.', 'surfer' => 'Watch different channels on TVmad to earn this badge.', 'couch potato' => 'The biggest fans who watch more than 10 hours can get their hands on this one.', 'movie fan' => 'Getting this one is easy- watch channels in "Movies" category for more than 5 hours.', 'entertainer' => 'Keep your webcam LIVE and earn this badge.', 'anchor' => 'This badge is not for amateurs- you have to broadcast your webcam for more than 10 hours.', 'star' => 'You need to be a real "red carpet material" to get this one- more than 1000 channel views required.', 'tubenator' => 'Set up a video playlist of more than 50 clips and earn the badge.', 'producer' => 'Setting up any channel on TVmad gets you this badge.', 'super producer' => 'Massive quality needed for this badge! Get at least 10 000 views to your channel and the badge is yours.', 'newbie' => 'Thats the easiest one to get- just log in.', 'seasoned' => 'This badge is handed out to the loyal users. Log in to TVmad on more than 10 days.', 'fan' => 'You need to be a true hardcore fan- 50 sign-ins to TVmad!', 'superfan' => 'This is the ultimate gigasuperbadge for a TVmad user. Visit TVmad 100 times and log in when visiting.', 'good samaritian' => 'Enable 2p2 and get the badge.', 'scientist' => 'Educate others and set up a channel in Science and education category.', 'maker' => 'Other users have to like your channel if you want the badge, so keep the content top notch.', 'emmy winner' => 'Get on the front page with your channel on the badge is yours to keep.', 'most gossiped' => 'Spead the word about your channel to earn the badge.', 'top breaker' => 'You channel has to be the best of the week five times.', 'eye candy' => 'Your channel has to get average of 4,5 rating and the badge is yours.', 'media mogul' => 'Set up 5 channels with an average rating of 4.', 'news' => 'To get this badge set up a news channel.', 'explorer' => '', 'i love tvmad' => 'This badge is given to people who favourite at least 5 channels.', 'music fan' => 'Your music channel has to consist of more than 20 clips for this badge.', ); function badge($type, $params='', $user_id=0) { if (!$type || !$_SESSION['user']['id'] && !$user_id) return false; if ($user_id) { $userd = mysql_fetch_assoc(mysql_query("SELECT id, login_type, login_id FROM tvmad_user WHERE id='$user_id'")); $user_code = $userd['login_type'] . $userd['login_id']; $user_id = $userd['id']; } else { $user_code = $_SESSION['user']['login_type'] . $_SESSION['user']['login_id']; $user_id = $_SESSION['user']['id']; } if (!$user_id) return false; $typelist = array(); if (is_array($type)) { $typelist = $type; } else if ($type == 'all') { $typelist = array('newbie', 'judge', 'intelligent', 'positive charger', 'well connected', 'major influencer', 'trend setter', 'distributor', 'pr boss', 'reporter', 'chat jedi', 'surfer', 'couch potato', 'movie fan', 'entertainer', 'anchor', 'star', 'tubenator', 'producer', 'super producer', 'seasoned', 'fan', 'superfan', 'good samaritian', 'scientist', 'maker', 'emmy winner', 'most gossiped', 'top breaker', 'eye candy', 'media mogul', 'news', 'explorer', 'i love tvmad', 'music fan'); } else { $typelist = array($type); } foreach ($typelist AS $type) { $active = 0; $num = 0; $val = ''; $channel_id = ''; //judge - 5 hinnet if ($type == 'judge') { $ratings = @mysql_result(mysql_query("SELECT COUNT(id) FROM tvmad_rate WHERE user_id='$user_code'"), 0)*1; if ($ratings >= 5) $active = 1; $num = $ratings; } //intelligent - kui üle 10 hinde ja usutavad if ($type == 'intelligent') { $ratings = @mysql_result(mysql_query("SELECT COUNT(id) FROM tvmad_rate WHERE user_id='$user_code'"), 0)*1; if ($ratings >= 10) $active = 1; $num = $ratings; } //positive charger - üle 5 hinde, paneb 4 ja 5 if ($type == 'positive charger') { $ratings = mysql_fetch_assoc(mysql_query("SELECT COUNT(id) AS counts, MIN(rate) AS rmin, MAX(rate) AS rmax FROM tvmad_rate WHERE user_id='$user_code'")); if ($ratings['counts'] >= 5 && $ratings['rmin'] == 4 && $ratings['rmax'] == 5) $active = 1; $num = $ratings; } //well connected - kui 3x sharinud if ($type == 'well connected') { $shares = @mysql_result(mysql_query("SELECT num FROM tvmad_badge WHERE user_id='$user_id' AND type='$type'"), 0)*1+1; if ($shares >= 3) $active = 1; $num = $shares; } //major influencer - 10x sharinud ja 3 kutset confirmitud if ($type == 'major influencer') { $shares = @mysql_result(mysql_query("SELECT num FROM tvmad_badge WHERE user_id='$user_id' AND type='$type'"), 0)*1+1; if ($shares >= 10) $active = 1; $num = $shares; } //trend setter - 10 share'i ja üks invite if ($type == 'trend setter') { $shares = mysql_fetch_assoc(mysql_query("SELECT num, val FROM tvmad_badge WHERE user_id='$user_id' AND type='$type'")); if ($params == 'invite') { $shares['val']++; // invaidid } else if ($params == 'share') { $shares['num']++; //sharemises } if ($shares['val'] >= 1 && $shares['num'] >= 10) $active = 1; $num = $shares['num']; $val = $shares['val']; } //distributor - embeddib kanali if ($type == 'distributor') { //$active = 1; } //major distributor - embeddib kanali ja sealt tuleb trafficut if ($type == 'major distributor') { $visitors = @mysql_result(mysql_query("SELECT num FROM tvmad_badge WHERE user_id='$user_id' AND type='$type'"), 0)*1+1; if ($visitors > 25) $active = 1; $num = $visitors; } //PR boss - 100 rida if ($type == 'pr boss') { $lines = @mysql_result(mysql_query("SELECT COUNT(id) FROM tvmad_msg WHERE image='$user_code'"), 0)*1+1; if ($lines >= 100) $active = 1; $num = $lines; } //reporter - polli oled tekitanud if ($type == 'reporter') { $polls = @mysql_result(mysql_query("SELECT COUNT(tvmad_poll.id) FROM tvmad_poll, tvmad_channel WHERE tvmad_channel.id=tvmad_poll.channel_id AND tvmad_channel.owner_id='$user_id'"), 0)*1; if ($polls) $active = 1; $num = $polls; } //chat jedi - 5000 rida if ($type == 'chat jedi') { $lines = @mysql_result(mysql_query("SELECT COUNT(id) FROM tvmad_msg WHERE image='$user_code'"), 0)*1+1; if ($lines >= 5000) $active = 1; $num = $lines; } //surfer - on vaadanud 10 kanalit a 5 minutit if ($type == 'surfer') { $channels = @mysql_result(mysql_query("SELECT COUNT(*) FROM tvmad_channel_peertime WHERE user_id='$user_id' AND UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time)>300"), 0)*1; if ($channels >= 10) $active = 1; $num = $channels; } //couch potato - 10h vaadanud kokku kanaleid if ($type == 'couch potato') { $viewtime = @mysql_result(mysql_query("SELECT SUM(UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time))/60/60 FROM tvmad_channel_peertime WHERE user_id='$user_id'"), 0)*1; if ($viewtime >= 10) $active = 1; $num = $viewtime; } //movie fan - kes on vaadanud 5h movie kanaleid if ($type == 'movie fan') { $movie_channels = array(); $q_channels = mysql_query("SELECT id FROM tvmad_channel WHERE cat_id='25'"); while ($r_channels = mysql_fetch_assoc($q_channels)) { $movie_channels[] = $r_channels['id']; } $viewtime = @mysql_result(mysql_query("SELECT SUM(UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time))/60/60 FROM tvmad_channel_peertime WHERE user_id='$user_id' AND channel_id IN ('" . implode("', '", $movie_channels) . "')"), 0)*1; if ($viewtime >= 5) $active = 1; $num = $viewtime; } //entertainer - broadcastib webcami 1h (naca ümber teha) if ($type == 'entertainer') { $showtime = @mysql_result(mysql_query("SELECT SUM(UNIX_TIMESTAMP(last_time)-UNIX_TIMESTAMP(start_time))/60/60 FROM tvmad_streamer WHERE user_id='$user_id'"), 0)*1; if ($showtime >= 1) $active = 1; $num = $showtime; } //anchor - 10h broadcastib if ($type == 'anchor') { $showtime = @mysql_result(mysql_query("SELECT SUM(UNIX_TIMESTAMP(last_time)-UNIX_TIMESTAMP(start_time))/60/60 FROM tvmad_streamer WHERE user_id='$user_id'"), 0)*1; if ($showtime >= 10) $active = 1; $num = $showtime; } //star - 10h ja channel 1000 views if ($type == 'star') { $showtime = @mysql_result(mysql_query("SELECT SUM(UNIX_TIMESTAMP(last_time)-UNIX_TIMESTAMP(start_time))/60/60 FROM tvmad_streamer WHERE user_id='$user_id'"), 0)*1; $viewers = @mysql_result(mysql_query("SELECT SUM(views) FROM tvmad_streamer WHERE user_id='$user_id' AND stream='flash'"), 0)*1; if ($showtime >= 10 && $viewers >= 1000) $active = 1; $val = $viewers; $num = $showtime; } //Tubenator - kui on 50 urli ladunud eri kanalitesse või ühte if ($type == 'tubenator') { $my_channels = array(); $q_channels = mysql_query("SELECT id FROM tvmad_channel WHERE owner_id='$user_id' AND stream='youtube'"); while ($r_channels = mysql_fetch_assoc($q_channels)) { $my_channels[] = $r_channels['id']; } $urlcount = 0; if ($my_channels) { $urlcount = @mysql_result(mysql_query("SELECT COUNT(id) FROM tvmad_channel_media WHERE channel_id IN ('" . implode("', '", $my_channels) . "')"), 0)*1; } if ($urlcount >= 50) $active = 1; $num = $urlcount; } //producer - 5 minca lives üks kõik, mis kanal if ($type == 'producer') { $chancount = 0; $q_channels = mysql_query("SELECT id, stream FROM tvmad_channel WHERE owner_id='$user_id' ORDER BY id ASC"); while ($r_channels = mysql_fetch_assoc($q_channels)) { if ($r_channels['stream'] != 'flash' || mysql_result(mysql_query("SELECT SUM(UNIX_TIMESTAMP(last_time)-UNIX_TIMESTAMP(start_time))/60 FROM tvmad_streamer WHERE channel_id='$r_channels[id]'"), 0)*1 >= 5) { $chancount++; } } if ($chancount >= 5) $active = 1; $num = $chancount; } //super producer - 5 kanalit ja ja 10000 vaatamist kokku if ($type == 'super producer') { $mychans = mysql_fetch_assoc(mysql_query("SELECT SUM(views) AS views, COUNT(id) AS counts FROM tvmad_channel WHERE owner_id='$user_id'")); if ($mychans['counts'] >= 5 && $mychans['views'] >= 10000) $active = 1; $val = $mychans['counts']; $num = $mychans['views']; } //newbie - logisid sisse if ($type == 'newbie') { $active = 1; } //seasoned - 10 logimist (päeva läheb 1 kirja) if ($type == 'seasoned') { $logins = mysql_num_rows(mysql_query("SELECT user_id FROM tvmad_channel_peertime WHERE user_id='$user_id' GROUP BY (DATE(start_time))")); if ($logins >= 10) $active = 1; $num = $logins; } //fan - 50 logimist if ($type == 'fan') { $logins = mysql_num_rows(mysql_query("SELECT user_id FROM tvmad_channel_peertime WHERE user_id='$user_id' GROUP BY (DATE(start_time))")); if ($logins >= 50) $active = 1; $num = $logins; } //superfan - 100 logimist if ($type == 'superfan') { $logins = mysql_num_rows(mysql_query("SELECT user_id FROM tvmad_channel_peertime WHERE user_id='$user_id' GROUP BY (DATE(start_time))")); if ($logins >= 100) $active = 1; $num = $logins; } //good samaritian - p2p on enableinud if ($type == 'good samaritian') { } /* //eco friendly - nature channeli broadcastija 10h min //?? nature kategooriat ju hetkel polegi! //!! jääb praegu kasutusest välja if ($type == 'eco friendly') { $my_channels = array(); $q_channels = mysql_query("SELECT id FROM tvmad_channel WHERE owner_id='$user_id' AND cat_id=''"); while ($r_channels = mysql_fetch_assoc($q_channels)) { $my_channels[] = $r_channels['id']; } $showtime = @mysql_result(mysql_query("SELECT SUM(UNIX_TIMESTAMP(last_time)-UNIX_TIMESTAMP(start_time))/60/60 FROM tvmad_streamer WHERE user_id='$user_id' AND channel_id IN ('" . implode("', '", $my_channels) . "')"), 0)*1; if ($showtime >= 10) $active = 1; $num = $showtime; } */ //scientist kategooria striimija 10hmin if ($type == 'scientist') { $my_channels = array(); $q_channels = mysql_query("SELECT id FROM tvmad_channel WHERE owner_id='$user_id' AND cat_id='28'"); while ($r_channels = mysql_fetch_assoc($q_channels)) { $my_channels[] = $r_channels['id']; } $showtime = @mysql_result(mysql_query("SELECT SUM(UNIX_TIMESTAMP(last_time)-UNIX_TIMESTAMP(start_time))/60/60 FROM tvmad_streamer WHERE user_id='$user_id' AND channel_id IN ('" . implode("', '", $my_channels) . "')"), 0)*1; if ($showtime >= 10) $active = 1; $num = $showtime; } //maker - top1 kanal nädala lõikes. iga nädala kohta mitu if ($type == 'maker' && date('w') == 0) { $topchannel = @mysql_result(mysql_query("SELECT owner_id, COUNT(tvmad_channel_view.id) AS viewers FROM tvmad_channel_view, tvmad_channel WHERE tvmad_channel.id=tvmad_channel_view.channel_id AND UNIX_TIMESTAMP(tvmad_channel_view.add_time)>UNIX_TIMESTAMP(NOW())-604800 GROUP BY channel_id ORDER BY viewers LIMIT 1"), 0)*1; if ($topchannel == $user_id) { $active = 1; $num = @mysql_result(mysql_query("SELECT num FROM tvmad_badge WHERE type='$type' AND user_id='$user_id'"), 0)*1+1; } } //emmy winner - featured kanal if ($type == 'emmy winner') { $featured = mysql_num_rows(mysql_query("SELECT id FROM tvmad_channel WHERE owner_id='$user_id' AND (featured='1' OR featured2='1')"))*1; if ($featured) $active = 1; $num = $featured; } //most gossiped - kui lingist on üle 50 inimese tulnud if ($type == 'most gossiped') { $onlink = 0; $q_channels = mysql_query("SELECT url FROM tvmad_channel WHERE owner_id='$user_id'"); while ($r_channels = mysql_fetch_assoc($q_channels)) { $onlink += @mysql_result(mysql_query("SELECT COUNT(*) FROM tvmad_session WHERE landing_page='/channel/$r_channels[url]'"), 0)*1; } if ($onlink > 50) $active = 0; $num = $onlink; } //top breaker - kui on 5 esikohta saanud if ($type == 'top breaker') { $num = @mysql_result(mysql_query("SELECT num FROM tvmad_badge WHERE type='maker' AND user_id='$user_id'"), 0)*1; if ($num >= 5) $active = 1; } //eye candy - keskm hinne üle 4.5 if ($type == 'eye candy') { $rating = @mysql_result(mysql_query("SELECT AVG(rate) AS rating FROM tvmad_rate, tvmad_channel WHERE tvmad_rate.channel_id=tvmad_channel.id AND tvmad_channel.owner_id='$user_id' GROUP BY tvmad_rate.channel_id ORDER BY rating DESC LIMIT 1"), 0)*1; if ($rating > 4.5) $active = 1; $num = $rating; } //media mogul - 5 kanalit, mille keskmine hinne üle 4 if ($type == 'media mogul') { $forplus = 0; $q_rating = mysql_query("SELECT AVG(rate) AS rating FROM tvmad_rate, tvmad_channel WHERE tvmad_rate.channel_id=tvmad_channel.id AND tvmad_channel.owner_id='$user_id' GROUP BY tvmad_rate.channel_id ORDER BY rating DESC LIMIT 1"); while ($r_rating = mysql_fetch_assoc($q_rating)) { if ($r_rating['rating'] > 4) $forplus++; } if ($forplus >= 5) $active = 1; $num = $forplus; } //news - kui uudisekanaleid striimib if ($type == 'news') { $newschans = @mysql_result(mysql_query("SELECT COUNT(id) FROM tvmad_channel WHERE owner_id='$user_id' AND cat_id='4'"), 0)*1; if ($newschans) $active = 1; $num = $forplus; } //explorer 2 ver - üle 50 kanali vaadanud 50 kanalit a 5 minutit if ($type == 'explorer') { $viewcount = 0; $q_viewtime = mysql_query("SELECT SUM(UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time))/60 AS chanontime FROM tvmad_channel_peertime WHERE user_id='$user_id' GROUP BY channel_id ORDER BY chanontime DESC"); while ($r_viewtime = mysql_fetch_assoc($q_viewtime)) { if ($r_viewtime['chanontime'] >= 5) $viewcount++; } if ($viewcount > 50) $active = 1; $num = $viewcount; } //i love tvmad - kui on 5 favouritesi if ($type == 'i love tvmad') { $favorites = @mysql_result(mysql_query("SELECT COUNT(id) FROM tvmad_favorite WHERE user_id='$user_id'"), 0)*1; if ($favorites >= 5) $active = 1; $num = $favorites; } //music fan - kui striimib vähemalt 20 urlist muusikakanalit if ($type == 'music fan') { $my_channels = array(); $q_channels = mysql_query("SELECT id FROM tvmad_channel WHERE owner_id='$user_id' AND stream='youtube' AND cat_id='18'"); while ($r_channels = mysql_fetch_assoc($q_channels)) { $my_channels[] = $r_channels['id']; } $urlcount = 0; if ($my_channels) { $urlcount = @mysql_result(mysql_query("SELECT COUNT(id) FROM tvmad_channel_media WHERE channel_id IN ('" . implode("', '", $my_channels) . "')"), 0)*1; } if ($urlcount >= 20) $active = 1; $num = $urlcount; } if (mysql_num_rows(mysql_query("SELECT id FROM tvmad_badge WHERE user_id='$user_id' AND type='$type'"))) { $curractive = mysql_num_rows(mysql_query("SELECT id FROM tvmad_badge WHERE user_id='$user_id' AND type='$type' AND active='1'")); if ($curractive) $active = 1; mysql_query("UPDATE tvmad_badge SET active='$active', num='$num', val='$val', channel_id='$channel_id' WHERE user_id='$user_id' AND type='$type'"); } else { mysql_query("INSERT INTO tvmad_badge(user_id, type, active, num, val, channel_id) VALUES ('$user_id', '$type', '$active', $num, '$val', '$channel_id')"); } } } function createUsername($name) { $name = preg_replace("/([^a-z0-9\-]+)/i", '', strtolower(trim($name))); $toadd = ''; while (mysql_num_rows(mysql_query("SELECT id FROM tvmad_user WHERE username='$name$toadd'"))) { $toadd = $toadd*1+1; } return $name . $toadd; } function timeAgo($dateTime) { $ago = time() - strtotime($dateTime); $r = $dateTime; if (($ago/60/60/24/365) < 1.5) $r = round($ago/60/60/24/365) . ' years ago'; if (($ago/60/60/24/365) < 1.5) $r = '1 year ago'; if (($ago/60/60/24/30.4) < 12) $r = round($ago/60/60/24/30.4) . ' months ago'; if (($ago/60/60/24/30.4) < 1.5) $r = '1 month ago'; if (($ago/60/60/24) < 30) $r = round($ago/60/60/24) . ' days ago'; if (($ago/60/60/24) < 1.5) $r = '1 day ago'; if (($ago/60/60) < 24) $r = round($ago/60/60) . ' hours ago'; if (($ago/60/60) < 1.5) $r = '1 hour ago'; if (($ago/60) < 60) $r = round($ago/60) . ' minutes ago'; if (($ago/60) < 2) $r = 'one minute ago'; if (($ago/60) < 1) $r = 'less than minute ago'; return $r; } ?>
Warning: Use of undefined constant DOCUMENT_ROOT - assumed 'DOCUMENT_ROOT' (this will throw an Error in a future version of PHP) in /srv/www.tvmad.com/htdocs/share.php on line 38
Share
Fatal error: Uncaught Error: Call to undefined function mysql_fetch_assoc() in /srv/www.tvmad.com/htdocs/share.php:59 Stack trace: #0 {main} thrown in /srv/www.tvmad.com/htdocs/share.php on line 59