[ Home | HTML; if ($_SESSION[cpaccess]==1) { $content .= " Admin Panel | "; $content .= " Show Dead Links | "; } if (verifyUser()) { $content .= "Logout | "; $content .= "Your Videos | "; $content .= "Submit Videos "; } else { $content .= "Login "; } $content .= " ]\n"; return $content; } // ----------------------------------------------------------------------------- function display_page($content) { global $config; if ($file = fopen($config['header'], "r")) { fpassthru($file); fclose($file); } print << function basicPopup(url) { popupWindow = window.open(url,'popUpWindow','height=500,width=500,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes'); } HTML; echo $content; if ($file = @fopen($config['footer'], "r")) { @fpassthru($file); @fclose($file); } } function display_page_old($content="") { global $config, $mainlink; displayHeader("Pethobbyist.com - Building the world's largest pet community", $config['banner_region'], $config['splashtext_market']); // start main outside table echo "\n"; // display the left_column_include echo "\n"; if ($file = @fopen($config[left_column_include],"r")) { @fpassthru($file); @fclose($file); } // start middle content with description and featured video print <<
Videos
These are videos submitted by staff, volunteers, and users of all the PetHobbyist pet communities. Currently our system supports videos hosted on YouTube, but other video hosts will be added soon. PLEASE NOTE - All videos are reviewed before listing and videos that contain commerical advertising, copyrighted materials, profanity, or are not on topic will not be listed. Submitting a video does not guarantee listing. To have a video listed click here.
HTML; // Get recommended Video if (!$mainlink) { dbConnect(); } get_recommended_video($config[default_market]); print <<
$content HTML; // show the right_column_include echo "\n"; if ($file = @fopen($config[right_column_include],"r")) { @fpassthru($file); @fclose($file); } // close the main table print << HTML; displayFooter(); exit; } function displayHeader($title="", $banner_rotation="", $splashtext_market="kingsnake") { global $config; if ($banner_rotation=="" || $banner_rotation==" ") { $banner_rotation = $config[banner_region]; } if (!$title) { $title = strip_tags($config[title]); } // Capture the header template if ($file = @fopen($config[header_template],"r")) { ob_start(); @fpassthru($file); $page = ob_get_contents(); ob_end_clean(); @fclose($file); } //$page = implode("",(@file('/mnt/shared/headers/top_king_tmpl.html'))); //$page = implode("",(@file('/web/forums/kingsnake/top_king_tmpl.html'))); if ( (!$page) or (empty($page)) ) { die("Sorry, there was a problem building the page."); } // Capture the banner if ($file = @fopen("http://gallery.pethobbyist.com/ssi/get_banner.php?region=$banner_rotation","r")) { ob_start(); @fpassthru($file); $banner = ob_get_contents(); ob_end_clean(); @fclose($file); } // Capture the splashtext if ($file = @fopen("http://www.pethobbyist.com/splashtext/splashtext.php?market=$splashtext_market","r")) { ob_start(); @fpassthru($file); $splash = ob_get_contents(); ob_end_clean(); @fclose($file); } $css = << function NewWindow(mypage, myname, w, h, scroll) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable' win = window.open(mypage, myname, winprops) if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } HTML; $page = ereg_replace("{title}", strip_tags($title), $page); $page = ereg_replace("{css}", $css, $page); $page = ereg_replace("{banner}", $banner, $page); $page = ereg_replace("{splash}", $splash, $page); echo $page; return true; } function displayFooter() { global $config; echo "

\n"; if ($myfile = @fopen($config[footer],'r')) { @fpassthru($myfile); } exit; } function dbConnect() { global $mainlink, $config; $mainlink = @mysql_connect( $config[dbHost], $config[dbUser], $config[dbPasswd] ) or error( "Unable to connect to the database. Please try again later." ); @mysql_select_db( $config[dbName], $mainlink ) or error("Unable to select the database table ($config[dbName]). Please try again later."); } function dbConnectAuth () { global $authlink, $config; $authlink = @mysql_connect( $config[dbAuthHost], $config[dbAuthUser], $config[dbAuthPasswd] ) or error("Unable to connect to the database. Please try again later.", "C3 - Can't connect to Auth database " . mysql_error() ); @mysql_select_db( $config[dbAuthName], $authlink ) or error("Unable to connect to $config[dbAuthName]. Please try again later.", "C4 - Auth database not selected, " . mysql_error() ); } function verifyUser() { global $config; if ( isset($_SESSION["usernamein"]) && isset($_SESSION["userpasswd"]) ) { if ( $_SESSION[pgm_id]==$config[pgm_id] ) { return true; } } return false; } function logit( $details ) { global $config; $mydate = date("Y-m-d H:i:s") . ": "; error_log ("$mydate $error $details\n", 3, $config[logfile]); } function error( $error, $details="" ) { global $config; $content = <<

<Error Page>

Error: $error

Back  |  $config[title]

HTML; $mydate = date("Y-m-d H:i:s") . ": "; error_log ("$mydate $error $details\n", 3, $config[logfile]); display_page($content); exit; } function textFilter( $str ) { global $mainlink; $str = trim($str); $str = eregi_replace(">", ">", $str); $str = eregi_replace("<", "<", $str); //$str = strip_tags($str, "
,"); $str = stripslashes($str); $str = htmlspecialchars($str); return $str; } function displayFormatHTML( $str) { $str = trim($str); $str = stripslashes($str); $str = eregi_replace("\n", "
", $str); $str = eregi_replace("<br>", "
", $str); $str = eregi_replace("&", "&", $str); $str = eregi_replace("<", "<", $str); $str = eregi_replace(""", "\"", $str); $str = eregi_replace(">", ">", $str); return $str; } function displayFormatTEXT( $str) { $str = trim($str); $str = urldecode($str); $str = stripslashes($str); $str = eregi_replace("
", "\n", $str); $str = eregi_replace("
", "", $str); $str = eregi_replace("<br>", "\n", $str); $str = eregi_replace("&quot;", "\"", $str); $str = eregi_replace(""", "\"", $str); $str = eregi_replace(">", ">", $str); $str = eregi_replace("<", "<", $str); $str = eregi_replace("&", "&", $str); $str = stripslashes($str); return $str; } function yn_select($fieldname, $key) { $content = "\n"; return $content; } // ---------------------------------------------------------------------------- function get_recommended_video($market='pet') { global $mainlink, $config; $expire = 60 * 60 * 6; // every 6 hours $expire_time = strftime("%c", time() + $expire); $epoch_expire_time = time() + $expire; $filename = $config['cachedir'] . "/cache_videos_recommended.txt"; if ($data = read($filename, $epoch_expire_time)) { $content .= $data; $content .= "\n"; } else { // hmm. No valid cache file dbConnect(); $sql = "SELECT title,youtubeid,userid,username FROM content WHERE approved='Yes' AND recommend='Yes' AND gun='y' ORDER BY RAND() LIMIT 1"; $result = @mysql_query($sql, $mainlink); if (!$result) return false; $jutjub = new YouTube(); $row = @mysql_fetch_array($result); $title = displayFormatHTML($row['title']); $data = "Featured Video
\n"; $data .= "$title
\n"; $data .= "\n"; $data .= $jutjub->ShowImg($row['youtubeid'],1,$title); $data .= "\n"; $data .= "
posted by $row[username]\n"; if ( write($filename, $epoch_expire_time, $data) ) { $content .= $data; $content .= "\n"; } else { $content .= $data; $content .= "\n"; } } return $content; } function CleanCache($groupid) { global $config; $filename = $config['cachedir'] . "/cache_videos_index_page_*"; @unlink($filename); } function BackColor() { global $config; static $BackColorValue; if ($BackColorValue == $config[table_back_color_alternative]) { $BackColorValue = $config[table_back_color]; } else { $BackColorValue = $config[table_back_color_alternative]; } return($BackColorValue); } //----------------------------------------------------------------------------- function read($filename="", $expires=0) { $success = false; $expires -= 30; ignore_user_abort(true); $fp = @fopen($filename, "r"); if ($fp) { if (@flock($fp, 1)) { clearstatcache(); // because the filesize can be cached by PHP itself... $length = @filesize($filename); $mqr = get_magic_quotes_runtime(); set_magic_quotes_runtime(0); // read in the expire time key $hashControl = @fread($fp, 10); $length = $length - 10; // read in the rest of the contents $data = @fread($fp, $length); set_magic_quotes_runtime($mqr); @flock($fp, 3); $success = true; } @fclose($fp); ignore_user_abort(false); if ($success) { // Compare time to see if this cache file has expired if ($expires >= $hashControl) { @unlink($filename); return false; } return $data; } else { // Well, you'd kinda like it to try again $data = "\n"; return $data; } } @fclose($fp); ignore_user_abort(false); return false; } //----------------------------------------------------------------------------- function write($filename, $epoch_expire_time=0, $data="") { $success = false; ignore_user_abort(true); $fp = @fopen($filename, "w+"); if ($fp) { if (@flock($fp, 2)) { $key = $epoch_expire_time . "\n"; @fwrite($fp, $key, 12); $len = strlen($data); @fwrite($fp, $data, $len); @flock($fp, 3); $success = true; } @fclose($fp); ignore_user_abort(false); if ($success) { return true; } else { return false; } } @fclose($fp); ignore_user_abort(false); return false; } ?>