30){ $limit = 30; } if($max_days=="today"){ $date = date("Y-m-d"); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00'"; } if($max_days=="week"){ $date = date("Y-m-d",strtotime("-7 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00'"; } if($max_days=="month"){ $date = date("Y-m-d",strtotime("-30 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00'"; } if($max_days=="all"){ $filter = "WHERE online = '1' AND added <= NOW() AND added >= '0'"; } if($sort_by=="random"){ $sort = "RAND()"; $select = "*"; $type = "Random Videos"; } if($sort_by=="latest" || empty($sort_by)){ $sort = "added DESC"; $select = "*"; $type = "Latest Videos"; } if($sort_by=="most_viewed"){ $sort = "views DESC"; $select = "*"; $type = "Most Viewed Videos"; } if($sort_by=="most_discussed"){ $sort = "cnum DESC"; $select = "*,v.id, v.title, v.thumb_url, v.saved_thmb, v.thmb_wdth, v.thmb_hght, v.thmb_filename, COUNT(c.id) cnum"; $ext = "v LEFT JOIN comments c ON (v.id=c.video)"; $group = "GROUP BY v.id "; $type = "Most Discussed Videos"; } if($sort_by=="highest_rated"){ $sort = "rating DESC"; $select = "*,(rating_total / num_ratings) as rating"; $filter.= " AND num_ratings >= '$set[min_num_highest_rated]'"; $type = "Highest Rated Videos"; } //search if(strlen($q)>0){ if($max_days=="today"){ $date = date("Y-m-d"); $filter = "WHERE online = '1' AND added <= NOW() AND added > '$date 00:00:00' AND (title LIKE '%$q%' OR description LIKE '%$q%' OR tags LIKE '%$q%' OR performers LIKE '%$q%')"; } if($max_days=="week"){ $date = date("Y-m-d",strtotime("-7 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added > '$date 00:00:00' AND (title LIKE '%$q%' OR description LIKE '%$q%' OR tags LIKE '%$q%' OR performers LIKE '%$q%')"; } if($max_days=="month"){ $date = date("Y-m-d",strtotime("-30 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added > '$date 00:00:00' AND (title LIKE '%$q%' OR description LIKE '%$q%' OR tags LIKE '%$q%' OR performers LIKE '%$q%')"; } if($max_days=="all"){ $filter = "WHERE online = '1' AND added <= NOW() AND (title LIKE '%$q%' OR description LIKE '%$q%' OR tags LIKE '%$q%' OR performers LIKE '%$q%')"; } $type = "Search Results for '$q'"; } //tags if(strlen($tag)>0){ if($max_days=="today"){ $date = date("Y-m-d"); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00' AND (title LIKE '%$tag%' OR description LIKE '%$tag%' OR tags LIKE '%$tag%' OR performers LIKE '%$tag%')"; } if($max_days=="week"){ $date = date("Y-m-d",strtotime("-7 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00' AND (title LIKE '%$tag%' OR description LIKE '%$tag%' OR tags LIKE '%$tag%' OR performers LIKE '%$tag%')"; } if($max_days=="month"){ $date = date("Y-m-d",strtotime("-30 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00' AND (title LIKE '%$tag%' OR description LIKE '%$tag%' OR tags LIKE '%$tag%' OR performers LIKE '%$tag%')"; } if($max_days=="all"){ $filter = "WHERE online = '1' AND added <= NOW() AND (title LIKE '%$tag%' OR description LIKE '%$tag%' OR tags LIKE '%$tag%' OR performers LIKE '%$tag%')"; } $type = "Tag Results for '$tag'"; } //site if(strlen($site)>0){ if($max_days=="today"){ $date = date("Y-m-d"); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00' AND site = '$site'"; } if($max_days=="week"){ $date = date("Y-m-d",strtotime("-7 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00' AND site = '$site'"; } if($max_days=="month"){ $date = date("Y-m-d",strtotime("-30 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00' AND site = '$site'"; } if($max_days=="all"){ $filter = "WHERE online = '1' AND added <= NOW() AND site='$site'"; } $type = "Site Results for '$site'"; } //channel if(strlen($channel)>0){ if($max_days=="today"){ $date = date("Y-m-d"); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00' AND channels LIKE '%;$channel;%'"; } if($max_days=="week"){ $date = date("Y-m-d",strtotime("-7 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00' AND channels LIKE '%;$channel;%'"; } if($max_days=="month"){ $date = date("Y-m-d",strtotime("-30 days")); $filter = "WHERE online = '1' AND added <= NOW() AND added >= '$date 00:00:00' AND channels LIKE '%;$channel;%'"; } if($max_days=="all"){ $filter = "WHERE online = '1' AND added <= NOW() AND channels LIKE '%;$channel;%'"; } $sqlch = mysql_query("SELECT * FROM channels WHERE id = '$channel'", $conn); $ch = mysql_fetch_array( $sqlch, MYSQL_ASSOC ); $type = "$ch[name] Channel"; } $sql = "SELECT $select FROM videos $ext $filter $group"; $sql = "$sql ORDER BY $sort LIMIT $start, $limit"; print"\n"; print"\n"; print"$set[site_title] $type\n"; print"$set[home_url]\n"; print"$set[site_title] $type\n"; print"en-us\n"; $sqlvi = mysql_query("$sql", $conn); while($res = mysql_fetch_array( $sqlvi, MYSQL_ASSOC )){ print"\n"; $title = htmlentities($res['title']); print"$title\n"; //pubdate $breakup = $res[added]; list($date, $hours) = split(' ', $breakup); list($year,$month,$day) = split('-',$date); list($hour,$min,$sec) = split(':',$hours); $date = date(r,mktime($hour, $min, $sec, $month, $day, $year)); $date = str_replace("+0200","-0500", $date); print"$date\n"; print"".get_video_url($res[title],$res[id])."\n"; print"".get_video_url($res[title],$res[id])."\n"; print"=1){ $thumb_url = "$set[thumb_dir_url]/$sub_path/".$res[id]."_".$res[def_thumb].$res[thmb_filename]; } else { $thumb_url = $res[thumb_url]; } print"$res[title]
"; print"\"$res[title]\"

"; //description $description = htmlentities($res['description']); print"Description: $description
"; //added print"Added: ".dateTimeDiff($res[added])."
"; //views print"Views: $res[views]
"; //duration print"Duration: ".sec2hms($res[duration])."
"; //submitted by if($res[user]=="anonymous"){ print"Submitted By: anonymous
"; } elseif($res[user]=="admin"){ print"Submitted By: admin
"; } else { $sqlus = mysql_query("SELECT * FROM users WHERE id = '$res[user]'", $conn); $us = mysql_fetch_array( $sqlus, MYSQL_ASSOC ); print"Submitted By: $us[username]
"; } //rating if($res[num_ratings]>0){ $rating = number_format(($res[rating_total] / $res[num_ratings]),2); } print"Rating: $rating / $res[num_ratings] total ratings
"; //channels unset($channelstr); $channels = explode(";", trim($res[channels],";")); foreach($channels as $val) { $sqlch = mysql_query("SELECT * FROM channels WHERE id = '$val'", $conn); $ch = mysql_fetch_array( $sqlch, MYSQL_ASSOC ); $channelstr.= "$ch[name], "; } $channels = rtrim($channelstr,", "); print"Channel: $channels
"; //tags unset($tagstr); $tags= explode(",", trim($res[tags])); foreach($tags as $val) { $val = trim($val); $urlval = str_replace(" ","+", $val); $tagstr.= "$val, "; } $tags = rtrim($tagstr,", "); print"Tags: $tags
"; //performers unset($performerstr); $performers= explode(",", trim($res[performers])); foreach($performers as $val) { $val = trim($val); $urlval = str_replace(" ","+", $val); $performerstr.= "$val, "; } $performers = rtrim($performerstr,", "); print"Performers: $performers
"; print"]]>
\n"; print"
\n"; } print"
"; print"
"; mysql_close(); ?>