473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Trying to see Youtube through this proxy script

290 100+
Hi,

As I am in Turkey at present, I can not see vidoes on
youtube. So I have tried a few proxies but keep finding them slow or
not working.

So I have installed myphpProxy on my server under the
domain name www.blog-start.com

Unfortuantely it is not not working correctly
- whenever I try to watch a video (any video),
the screen displays the message:
"We're sorry, this video is no longer available".

Any ideas what may be wrong ?

(you can try it yourself - no password on the site yet )

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. /*
  4.  phpMyProxy is a free php proxy script programmed by eProxies.info Team.
  5.  Website: http://www.phpmyproxy.com
  6.  Support: http://www.eproxies.info/support/
  7.  Proxy Directory: http://www.eproxies.info/
  8.  
  9.  Created: Thursday, December 13, 2007 09:49:28 PM
  10.  Modified: Saturday, January 13, 2008
  11. */
  12.  
  13. error_reporting(E_ALL);
  14. session_start();
  15. //@set_time_limit(0);
  16.  
  17. define('_PROXY_VERSION', '1.0.3');
  18. define('_CWD', dirname(__FILE__));
  19. //define('_SAFE_MODE', (bool)@ini_get('safe_mode'));
  20. //define('_OPEN_BASEDIR', (bool)@ini_get('open_basedir'));
  21.  
  22. if(get_magic_quotes_gpc()) {
  23.     if(@ini_get('magic_quotes_sybase')) {
  24.         $_GET = _strip_single_quotes($_GET);
  25.         $_POST = _strip_single_quotes($_POST);
  26.         $_COOKIE = _strip_single_quotes($_COOKIE);
  27.     } else {
  28.         $_GET = _stripslashes($_GET);
  29.         $_POST = _stripslashes($_POST);
  30.         $_COOKIE = _stripslashes($_COOKIE);
  31.     }
  32. }
  33.  
  34. // Require configurations
  35. require './proxy.config.php';
  36.  
  37. // Get required language
  38. $_langfile = './lang/' . $_lang . '.php';
  39. if(!file_exists($_langfile)) {
  40.     $_langfile = './lang/english.php';
  41. }
  42. include $_langfile;
  43.  
  44. // Get theme directory
  45. $_theme_dir = './themes/' . $_theme;
  46. if(!file_exists($_theme_dir)) {
  47.     $_theme_dir = './themes/default';
  48. }
  49. define('_THEME_DIR', $_theme_dir);
  50. unset($_langfile, $_theme_dir);
  51.  
  52.  
  53. if(!function_exists('http_build_query')) { // PHP4 doesn't have this function, we have to create one like PHP5.
  54.     function http_build_query($formdata, $prefix = '', $first = true) {
  55.         static $data = array();
  56.         static $size = false;
  57.         static $count = 0;
  58.         if(is_object($formdata)) {
  59.             $formdata = unserialize(serialize($formdata));
  60.         }
  61.         if($size == false) $size = count($formdata);
  62.         foreach($formdata as $key => $value) {
  63.             $key = urlencode($key);
  64.             if(is_object($value)) {
  65.                 $value = unserialize(serialize($value));
  66.             }
  67.             if($first) $count++;
  68.             if(is_array($value)) {
  69.                 http_build_query($value, (($first and !is_numeric($key)) ? '' : $prefix) . $key . ($first ? '' : ']') . '[', false);
  70.             } else {
  71.                 $data[] = (($first and !is_numeric($key)) ? '' : $prefix) . $key . ($first ? '' : ']') . '=' . urlencode($value);
  72.             }
  73.         }
  74.  
  75.         if($count == $size and $first) return ($data) ? implode('&', $data) : '';
  76.     }
  77. }
  78.  
  79.  
  80. // Do something
  81. $_SERVER['REQUEST_METHOD'] = strtoupper($_SERVER['REQUEST_METHOD']);
  82. $_referer = (isset($_SERVER['HTTP_REFERER']) ? trim($_SERVER['HTTP_REFERER']) : false);
  83.  
  84. // Get available protocols
  85. $_protocols = array('http', 'ftp');
  86. $_curl_version = curl_version();
  87. $_https = ((is_array($_curl_version) and in_array('https', $_curl_version['protocols'])) or (is_string($_curl_version) and strpos($_curl_version, 'OpenSSL/') !== false)) ? true : false;
  88. if($_https) {
  89.     $_protocols[] = 'https';
  90. }
  91. unset($_curl_version);
  92.  
  93. // Setup options and take relevant action
  94. if(!isset($_SESSION['_options']) or !is_array($_SESSION['_options'])) {
  95.     $_SESSION['_options'] = array();
  96. }
  97. if(isset($_POST[$_config['url_var_name']]) and !isset($_GET[$_config['url_var_name']])) {
  98.     if(!isset($_POST['options']) or !is_array($_POST['options'])) {
  99.         $_POST['options'] = array();
  100.     }
  101.     foreach($_options as $_option => $_value) {
  102.         $_SESSION['_options'][$_option] = (!$_frozen_options[$_option] ? (isset($_POST['options'][$_option]) ? $_POST['options'][$_option] : 0) : $_value);
  103.     }
  104.  
  105.     $_url = trim($_POST[$_config['url_var_name']]);
  106. } elseif(isset($_GET[$_config['url_var_name']])) {
  107.     foreach($_options as $_option => $_value) {
  108.         $_SESSION['_options'][$_option] = ((isset($_SESSION['_options'][$_option]) and !$_frozen_options[$_option]) ? $_SESSION['_options'][$_option] : $_value);
  109.     }
  110.  
  111.     $_url = _decode_url(trim($_GET[$_config['url_var_name']]));
  112.     if((count($_GET) > 1 and !isset($_GET['_x_fin_x_'])) or (count($_GET) > 2 and isset($_GET['_x_fin_x_']))) {
  113.         unset($_GET[$_config['url_var_name']], $_GET['_x_fin_x_']);
  114.         $_url .= ($_GET) ? '?' . http_build_query($_GET) : '';
  115.         _redirect(_rewrite_url($_url));
  116.     }
  117. } else {
  118.     foreach($_options as $_option => $_value) {
  119.         $_SESSION['_options'][$_option] = ((isset($_SESSION['_options'][$_option]) and !$_frozen_options[$_option]) ? $_SESSION['_options'][$_option] : $_value);
  120.     }
  121.     _report();
  122. }
  123.  
  124. // Validate user input
  125. if($_url == '') {
  126.     _report(array('error' => 'empty_url'));
  127. }
  128. if(!in_array($_SERVER['REQUEST_METHOD'], array('HEAD', 'GET', 'POST'))) {
  129.     _report(array('error' => 'unsupported_method'));
  130. }
  131.  
  132. if(strpos($_url, ':') === false) {
  133.     $_url = 'http://' . $_url;
  134. }
  135. $_url = preg_replace('#:/{3,}#i', '://', $_url);
  136.  
  137. $_url_com = @parse_url($_url);
  138. $_url_com['scheme'] = strtolower($_url_com['scheme']);
  139. if(empty($_url_com) or !isset($_url_com['host'])) {
  140.     _report(array('error' => 'incorrect_url'));
  141. }
  142. if(preg_match('/^127\.|192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[01])\./i', $_url_com['host']) or strpos($_url_com['host'], '.') === false) {
  143.     _report(array('error' => 'denied_url'));
  144. }
  145. foreach($_disallowed_hosts as $_disallowed_host) {
  146.     if($_url_com['host'] == $_disallowed_host or $_url_com['host'] == 'www.' . $_disallowed_host) {
  147.         _report(array('error' => 'denied_url'));
  148.     }
  149. }
  150. if(!in_array($_url_com['scheme'], $_protocols)) {
  151.     _report(array('error' => 'unsupported_protocol'));
  152. }
  153.  
  154.  
  155. // Prevent HotLinking
  156. if(!$_config['allow_hotlinking']) {
  157.     $_hotlink = true;
  158.     if($_referer) {
  159.         $_hotlink_domains[] = $_SERVER['HTTP_HOST'];
  160.         $_referer_com = @parse_url($_referer);
  161.         foreach($_hotlink_domains as $_hotlink_domain) {
  162.             if($_hotlink_domain == $_referer_com['host'] or $_hotlink_domain == 'www.' . $_referer_com['host'] or 'www.' . $_hotlink_domain == $_referer_com['host']) {
  163.                 $_hotlink = false;
  164.                 break;
  165.             }
  166.         }
  167.     } elseif (!$_config['nonreferer_hotlink'] and !$_referer) {
  168.         $_hotlink = false;
  169.     }
  170.  
  171.     if($_hotlink) {
  172.         switch($_config['upon_hotlink']) {
  173.             case 1:
  174.                 _report(array('error' => 'hotlinking'));
  175.             break;
  176.  
  177.             case 2:
  178.                 header('HTTP/1.0 404 Not Found');
  179.                 exit;
  180.             break;
  181.  
  182.             default:
  183.                 _redirect($_config['upon_hotlink']);
  184.         }
  185.     }
  186. } // End of hotlinking prevention
  187.  
  188. // Save username and password to the session
  189. if(!isset($_SESSION['_authorization'])) {
  190.     $_SESSION['_authorization'] = array();
  191. }
  192. if(isset($_POST[$_config['url_var_name']]) and (isset($_POST['username']) or isset($_POST['password']))) {
  193.     $_SESSION['_authorization'][$_url_com['host']] = (isset($_POST['username']) ? $_POST['username'] : '') . ':' . (isset($_POST['password']) ? $_POST['password'] : '');
  194. } else {
  195.     $_SESSION['_authorization'][$_url_com['host']] = (isset($_SESSION['_authorization'][$_url_com['host']]) ? $_SESSION['_authorization'][$_url_com['host']] : '');
  196. }
  197.  
  198. // Complete URL
  199. $_url = $_url_com['scheme'] . '://';
  200. $_base = array('scheme' => $_url_com['scheme']);
  201. if(isset($_url_com['user']) or isset($_url_com['pass'])) {
  202.     $_url .= $_url_com['user'];
  203.     if(isset($_url_com['pass'])) {
  204.         $_url .= ':' . $_url_com['pass'];
  205.     }
  206.     $_url .= '@';
  207. }
  208. $_url .= $_url_com['host'];
  209. if(isset($_url_com['port'])) {
  210.     $_url .= ':' . $_url_com['port'];
  211. }
  212. $_base['webroot'] = $_url;
  213. if(isset($_url_com['path'])) {
  214.     $_url .= $_url_com['path'];
  215. }
  216. $_base['path'] = isset($_url_com['path']) ? $_url_com['path'] : '/';
  217. $_base['webpath'] = $_url;
  218. if(isset($_url_com['query'])) {
  219.     $_url_com['query'] = str_replace('&amp;', '&', $_url_com['query']);
  220.     parse_str($_url_com['query'], $_query_pairs);
  221.     $_url .= '?' . http_build_query($_query_pairs);
  222.     unset($_query_pairs);
  223. }
  224. $_base['url'] = $_url;
  225. //echo $_url;exit;
  226.  
  227.  
  228. // Redirect if neccessary
  229. if(isset($_POST[$_config['url_var_name']]) and !isset($_GET[$_config['url_var_name']])) {
  230.     _redirect('?' . $_config['url_var_name'] . '=' . _encode_url($_url) . (isset($_url_com['fragment']) ? '#' . $_url_com['fragment'] : ''));
  231. }
  232.  
  233. // Setup options
  234. $_curl_options = array();
  235. $_uploaded_files = array();
  236. if($_SERVER['REQUEST_METHOD'] != 'GET') {
  237.     $_curl_options[CURLOPT_CUSTOMREQUEST] = $_SERVER['REQUEST_METHOD'];
  238.     if(!isset($_POST[$_config['url_var_name']]) and $_SERVER['REQUEST_METHOD'] == 'POST') {
  239.         $_postfields = $_POST;
  240.         if(@ini_get('file_uploads') and $_FILES) {
  241.             foreach($_FILES as $_key => $_value) {
  242.                 if(is_array($_value['tmp_name'])) {
  243.                     foreach($_value['tmp_name'] as $_k => $_v) {
  244.                         $_new_name = dirname($_v) . '/' . $_value['name'][$_k];
  245.                         @unlink($_new_name);
  246.                         if(!@rename($_v, $_new_name)) {
  247.                             $_new_name = $_v;
  248.                         }
  249.                         $_postfields[$_key . '[' . $_k . ']'] = '@' . $_new_name;
  250.                     }
  251.                 } else {
  252.                     $_new_name = dirname($_value['tmp_name']) . '/' . $_value['name'];
  253.                     @unlink($_new_name);
  254.                     if(!@rename($_value['tmp_name'], $_new_name)) {
  255.                         $_new_name = $_value['tmp_name'];
  256.                     }
  257.                     $_postfields[$_key] = '@' . $_new_name;
  258.                 }
  259.             }
  260.         }
  261.         $_curl_options[CURLOPT_POSTFIELDS] = $_postfields;
  262.         unset($_postfields, $_new_name);
  263.     }
  264. }
  265. if($_url_com['scheme'] == 'https') {
  266.     $_curl_options[CURLOPT_SSL_VERIFYPEER] = false;
  267.     $_curl_options[CURLOPT_SSL_VERIFYHOST] = false;
  268. }
  269.  
  270. // Pass headers
  271. $_passible_headers = array(
  272.     'HTTP_ACCEPT' => 'Accept',
  273.     'HTTP_ACCEPT_CHARSET' => 'Accept-Charset',
  274.     'HTTP_ACCEPT_LANGUAGE' => 'Accept-Language',
  275.     'HTTP_USER_AGENT' => 'User-Agent',
  276.     'HTTP_CACHE_CONTROL' => 'Cache-Control',
  277. );
  278. $_headers = array();
  279. foreach($_passible_headers as $_header_key => $_header_name) {
  280.     if(isset($_SERVER[$_header_key])) $_headers[] = $_header_name . ': ' . $_SERVER[$_header_key];
  281. }
  282.  
  283. // Remove referers
  284. if($_SESSION['_options']['remove_referers']) {
  285.     $_headers[] = 'Referer: ';
  286. } else {
  287.     if($_referer) {
  288.         $_referer_com = @parse_url($_referer);
  289.         if($_url_com['host'] == $_referer_com['host'] or $_url_com['host'] == 'www.' . $_referer_com['host'] or 'www.' . $_url_com['host'] == $_referer_com['host']) {
  290.             $_headers[] = 'Referer: ' . $_referer;
  291.         } else if($_referer_com['host'] == $_SERVER['HTTP_HOST'] or $_referer_com['host'] == 'www.' . $_SERVER['HTTP_HOST'] or 'www.' . $_referer_com['host'] == $_SERVER['HTTP_HOST']) {
  292.             if(isset($_referer_com['query'])) {
  293.                 $_referer_vars = array();
  294.                 parse_str($_referer_com['query'], $_referer_vars);
  295.                 $_internal_referer = _decode_url($_referer_vars[$_config['url_var_name']]);
  296.                 $_headers[] = 'Referer: ' . (($_internal_referer) ? $_internal_referer : $_url);
  297.             } else {
  298.                 $_headers[] = 'Referer: ' . $_url;
  299.             }
  300.         } else {
  301.             $_headers[] = 'Referer: ' . $_url;
  302.         }
  303.     }
  304. }
  305.  
  306.  
  307. // Get content
  308. $_r = array('headers' => array());
  309. $_p = curl_init($_url);
  310. if($_SESSION['_options']['accept_cookies']) {
  311.     $_cookie_file = _CWD . '/cookies/' . session_id() . '.txt';
  312.     if(!file_exists($_cookie_file)) {
  313.         $_cookie = @fopen($_cookie_file, 'wb');
  314.         @fclose($_cookie);
  315.     }
  316.     curl_setopt($_p, CURLOPT_COOKIEJAR, $_cookie_file);
  317.     curl_setopt($_p, CURLOPT_COOKIEFILE, $_cookie_file);
  318. }
  319. curl_setopt($_p, CURLOPT_REFERER, false);
  320. curl_setopt($_p, CURLOPT_FAILONERROR, true);
  321. curl_setopt($_p, CURLOPT_FORBID_REUSE, false);
  322. curl_setopt($_p, CURLOPT_FRESH_CONNECT, false);
  323. curl_setopt($_p, CURLOPT_TIMEOUT, 60);
  324. curl_setopt($_p, CURLOPT_MAXREDIRS, 10);
  325. curl_setopt($_p, CURLOPT_FILETIME, true);
  326. curl_setopt($_p, CURLOPT_RETURNTRANSFER, true);
  327. curl_setopt($_p, CURLOPT_HTTPHEADER, $_headers);
  328. curl_setopt($_p, CURLOPT_HEADERFUNCTION, '_headerfunction');
  329. if(defined('CURLOPT_AUTOREFERER')) curl_setopt($_p, CURLOPT_AUTOREFERER, false);
  330.  
  331. if($_SESSION['_authorization'][$_url_com['host']]) curl_setopt($_p, CURLOPT_USERPWD, $_SESSION['_authorization'][$_url_com['host']]);
  332. foreach($_curl_options as $_option => $_value) {
  333.     curl_setopt($_p, $_option, $_value);
  334. }
  335.  
  336. if(defined('_DEVELOPMENT_MODE')) {
  337.     $_curl_log = fopen('./curl_log.txt', 'ab');
  338.     fwrite($_curl_log, "[ " . date('Y-m-d H:i:s') . " ]\r\n");
  339.     flock($_curl_log, LOCK_EX);
  340.     curl_setopt($_p, CURLOPT_VERBOSE, true);
  341.     curl_setopt($_p, CURLOPT_STDERR, $_curl_log);
  342. }
  343.  
  344. $_r['content'] = curl_exec($_p);
  345. $_r['info'] = curl_getinfo($_p);
  346. $_r['errno'] = curl_errno($_p);
  347. $_r['error'] = curl_error($_p);
  348. curl_close($_p);
  349.  
  350. if(defined('_DEVELOPMENT_MODE')) {
  351.     fwrite($_curl_log, "=> Error Code: {$_r['errno']}\r\n=> Error Message: {$_r['error']}\r\n\r\n\r\n");
  352.     flock($_curl_log, LOCK_UN);
  353.     fclose($_curl_log);
  354. }
  355.  
  356. // Delete uploaded files if did
  357. foreach($_uploaded_files as $_uploaded_file) {
  358.     @unlink($_uploaded_file);
  359. }
  360. unset($_p, $_uploaded_files, $_uploaded_file, $_curl_options);
  361.  
  362. // Handle errors or redirection returned by the distination
  363. if($_r['errno'] == 28 or $_r['errno'] == 6) {
  364.     _report(array('error' => 'server_not_found'));
  365. }
  366. //if($_r['info']['url'] != $_url) {
  367. //    _redirect('?' . $_config['url_var_name'] . '=' . _encode_url($_r['info']['url']));
  368. //}
  369. if($_r['info']['http_code'] == 401) { // Authorization Required
  370.     sscanf($_r['headers']['www-authenticate'][0], 'Basic realm=%s', $_realm);
  371.     $_realm = array();
  372.     preg_match('#basic realm=(?:\'|\")(.*?)(?:\'|\")#si', $_r['headers']['www-authenticate'][0], $_realm);
  373.     $_realm = $_realm ? $_realm[1] : '';
  374.     $_lang['enter_username_password'] = sprintf($_lang['enter_username_password'], trim($_realm, '"\''), $_base['webroot']);
  375.     unset($_realm);
  376.     _report(array('error' => 'authorization_required', 'username' => '', 'password' => ''));
  377. }
  378. if($_r['info']['http_code'] == 404) { // File not found
  379.     _report(array('error' => 'error_404'));
  380. }
  381. if($_config['max_file_size'] > 0 and $_r['info']['download_content_length'] > $_config['max_file_size']) {
  382.     $_lang['file_too_large'] = sprintf($_lang['file_too_large'], _number_format($_config['max_file_size'] / 1048576), _number_format($_r['info']['download_content_length'] / 1048576));
  383.     _report(array('error' => 'file_too_large'));
  384. }
  385.  
  386. // Try to detect Content-Type
  387. if(!isset($_r['headers']['content-type']) and function_exists('mime_content_type')) {
  388.     $_r['headers']['content-type'] = array(mime_content_type($_url));
  389. }
  390. if(isset($_r['headers']['content-type'])) {
  391.     $_content_type = explode(';', $_r['headers']['content-type'][0]);
  392.     $_content_type = array_map('trim', $_content_type);
  393. } else {
  394.     $_content_type = array('text/html');
  395. }
  396.  
  397. // Use compress output or not?
  398. if($_config['compress_output'] and (in_array($_content_type[0], $_proxify) and $_content_type[0] != 'text/css') and !(bool)@ini_get('zlib.output_compression') and extension_loaded('zlib')) ob_start('ob_gzhandler');
  399.  
  400. // Out content don't need to be proxified
  401. if(!in_array($_content_type[0], $_proxify)) {
  402.     _out(false, $_content_type[0]);
  403. }
  404.  
  405. // Try to find <base> tag out and re-setup $_base
  406. if(preg_match('#(<base[^>]*\bhref\s*=\s*[\(\'\"]+)(.*?)([\'\"\)]+[^>]*>)#si', $_r['content'], $match)) {
  407.     $_base_com = @parse_url($match[2]);
  408.     if($_base_com) {
  409.         $_base_url = $_base_com['scheme'] . '://';
  410.         $_base_com['scheme'] = strtolower($_base_com['scheme']);
  411.         $_base = array('scheme' => $_base_com['scheme']);
  412.         if(isset($_base_com['user']) or isset($_base_com['pass'])) {
  413.             $_base_url .= $_base_com['user'];
  414.             if(isset($_base_com['pass'])) {
  415.                 $_base_url .= ':' . $_base_com['pass'];
  416.             }
  417.             $_base_url .= '@';
  418.         }
  419.         $_base_url .= $_base_com['host'];
  420.         if(isset($_base_com['port'])) {
  421.             $_base_url .= ':' . $_base_com['port'];
  422.         }
  423.         $_base['webroot'] = $_base_url;
  424.         if(isset($_base_com['path'])) {
  425.             $_base_url .= $_base_com['path'];
  426.         }
  427.         $_base['path'] = isset($_base_com['path']) ? $_base_com['path'] : '/';
  428.         $_base['webpath'] = $_base_url;
  429.         if(isset($_base_com['query'])) {
  430.             $_base_com['query'] = str_replace('&amp;', '&', $_base_com['query']);
  431.             parse_str($_base_com['query'], $_query_pairs);
  432.             $_base_url .= '?' . http_build_query($_query_pairs);
  433.             unset($_query_pairs);
  434.         }
  435.         $_base['url'] = $_base_url;
  436.         unset($_base_url);
  437.     }
  438.     unset($_base_com);
  439.  
  440.     $_r['content'] = str_replace($match[0], '', $_r['content']);
  441. }
  442.  
  443. // Remove Images
  444. if($_SESSION['_options']['remove_images']) {
  445.     $_r['content'] = preg_replace('#<img[^>]*>#si', '', $_r['content']);
  446.     $_r['content'] = preg_replace('#(\Wbackground(?:\-image|)?\s*:\s*?.*?)url\s*\(.*?\)(\s)*(;)?#Ssi', '\\1none\\2\\3', $_r['content']);
  447. }
  448.  
  449. // Out if it's CSS file
  450. if($_content_type[0] == 'text/css') {
  451.     $_r['content'] = _rewrite_css($_r['content']);
  452.     _out();
  453. }
  454.  
  455. // Handle Options
  456. if($_SESSION['_options']['remove_title']) { // Remove Page Title
  457.     $_r['content'] = preg_replace('#<title\s*>[^<]*</\s*title\s*>#si', '<title></title>', $_r['content']);
  458. }
  459. $_scripts = array();
  460. if($_SESSION['_options']['remove_scripts']) { // Remove scripts
  461.     $_r['content'] = preg_replace('#<script[^>]*>.*?</\s*script\s*>#si', '', $_r['content']);
  462.     $_r['content'] = preg_replace('#\Won[a-z]+\s*=\s*(?:\"[^\"]*\"|\'[^\']*\'|[^\s\>]*)#si', '', $_r['content']);
  463.     $_r['content'] = preg_replace('#<noscript[^>]*>(.*?)</\s*noscript\s*>#si', '\\1', $_r['content']);
  464. } else {
  465.     // Handle scripts #1
  466.     _rewrite_tags(array('script' => array('src')));
  467.     preg_match_all('#<script[^>]*>.*?</\s*script\s*>#si', $_r['content'], $_scripts);
  468.     $_scripts = $_scripts[0];
  469.     foreach($_scripts as $_key => $_script) {
  470.         $_scripts['@-@-@-script-' . $_key . '-@-@-@'] = $_script;
  471.         unset($_scripts[$_key]);
  472.     }
  473.     $_r['content'] = str_replace($_scripts, array_keys($_scripts), $_r['content']);
  474. }
  475. if($_SESSION['_options']['remove_meta']) { // Remove meta tags
  476.     $_r['content'] = preg_replace('#<meta[^>]*\bname\s*=\s*(?:\"[^\"]*\"|\'[^\']*\'|[^\s\>]*)[^>]*>#si', '', $_r['content']);
  477. }
  478.  
  479. // Rewrite URLs
  480. _rewrite_tags(array(
  481.     'a' => array('href'),
  482.     'img' => array('src', 'longdesc'),
  483.     'image' => array('src', 'longdesc'),
  484.     'body' => array('background'),
  485.     'base' => array('href'),
  486.     'frame' => array('src', 'longdesc'),
  487.     'iframe' => array('src', 'longdesc'),
  488.     'head' => array('profile'),
  489.     'layer' => array('src'),
  490.     'input' => array('src', 'usemap'),
  491.     'form' => array('action'),
  492.     'area' => array('href'),
  493.     'link' => array('href', 'src', 'urn'),
  494.     'meta' => array('content'),
  495.     'param' => array('value'),
  496.     'applet' => array('codebase', 'code', 'object', 'archive'),
  497.     'object' => array('usermap', 'codebase', 'classid', 'archive', 'data'),
  498.     'select' => array('src'),
  499.     'hr' => array('src'),
  500.     'table' => array('background'),
  501.     'tr' => array('background'),
  502.     'th' => array('background'),
  503.     'td' => array('background'),
  504.     'bgsound' => array('src'),
  505.     'blockquote' => array('cite'),
  506.     'del' => array('cite'),
  507.     'embed' => array('src'),
  508.     'fig' => array('src', 'imagemap'),
  509.     'ilayer' => array('src'),
  510.     'ins' => array('cite'),
  511.     'note' => array('src'),
  512.     'overlay' => array('src', 'imagemap'),
  513.     'q' => array('cite'),
  514.     'ul' => array('src')
  515. ));
  516.  
  517. // Handle scripts #2
  518. if(!$_SESSION['_options']['remove_scripts']) {
  519.     $_r['content'] = str_replace(array_keys($_scripts), $_scripts, $_r['content']);
  520. }
  521. unset($_scripts);
  522.  
  523. // Rewrite Inline CSS
  524. $_r['content'] = preg_replace('#(<[a-z]+\s*[^>]*url\s*\([\'\"]?)(.*?)([\'\"]?\)[^>]*>)#Sesi', 'stripslashes("\\1") . _rewrite_url("\\2") . stripslashes("\\3")', $_r['content']);
  525.  
  526. // Rewrite CSS
  527. if(preg_match_all('#<style[^>]*>.*?</\s*style\s*>#Ssi', $_r['content'], $_matches)) {
  528.     $_newinx = count($_matches);
  529.     $_matches[$_newinx] = array();
  530.     foreach($_matches[0] as $_key => $_match) {
  531.         $_matches[$_newinx][] = _rewrite_css($_match);
  532.     }
  533.     $_r['content'] = str_replace($_matches[0], $_matches[$_newinx], $_r['content']);
  534.     unset($_matches, $_newinx, $_key, $_match);
  535. }
  536.  
  537. // Include mini form
  538. if($_SESSION['_options']['include_form'] and (!isset($_GET['_x_fin_x_']) or $_GET['_x_fin_x_'] != '1')) {
  539.     include _THEME_DIR . '/mini_form.php';
  540.     $_r['content'] = preg_replace('#(<body(?:\s*[a-z]+\s*=\s*(?:\"[^\"]*\"|\'[^\']*\'|[^\s\>]*))*.*?>)#si', '\\1' . $_form, $_r['content'], 1);
  541.     //end of if
  542. }
  543.  
  544. // Out proxified content
  545. _out();
  546.  
  547.  
  548.  
  549. // Functions
  550. function _redirect($_url) {
  551.     header('Location: ' . $_url);
  552.     exit;
  553. }
  554.  
  555. function _stripslashes($input) {
  556.     return (is_array($input) ? array_map('_stripslashes', $input) : (is_string($input) ? stripslashes($input) : $input));
  557. }
  558.  
  559. function _strip_single_quotes($input) {
  560.     return (is_array($input) ? array_map('_strip_single_quotes', $input) : (is_string($input) ? str_replace('\'\'', '\'', $input) : $input));
  561. }
  562.  
  563. function _number_format($_number, $_num_dec_places = 2) {
  564.     global $_config, $_lang;
  565.  
  566.     return number_format($_number, $_num_dec_places, $_lang['decimal_separator'], $_lang['thousands_separator']);
  567. }
  568.  
  569. function _report($_data = array()) {
  570.     global $_url, $_lang, $_config, $_options, $_frozen_options;
  571.  
  572.     if(!isset($_data['url'])) $_data['url'] = $_url;
  573.     $_data['url'] = htmlentities($_data['url'], ENT_QUOTES, 'UTF-8');
  574.     require _THEME_DIR . '/main_form.php';
  575.     exit;
  576. }
  577.  
  578. function _headerfunction(&$curl, $header) {
  579.     global $_r;
  580.  
  581.     if($_value = explode(':', $header, 2) and count($_value) > 1) {
  582.         $_value = array_map('trim', $_value);
  583.         if($_value[0] == '' or $_value[1] == '') {
  584.             unset($_r['headers'][$_key]);
  585.             continue;
  586.         }
  587.  
  588.         $_value[0] = strtolower($_value[0]);
  589.         switch($_value[0]) {
  590.             case 'location':
  591.                 _redirect(_rewrite_url($_value[1]));
  592.             break;
  593.  
  594.             case 'uri':
  595.             case 'content-location':
  596.                 $_value[1] = _rewrite_url($_value[1]);
  597.             break;
  598.  
  599.             case 'p3p':
  600.                 if(preg_match('#policyref\s*=\s*(\"[^\"]*\"|\'[^\']*\'|[^\s]*)#si', $_value[1], $_matches)) {
  601.                     $_value[1] = str_replace($_matches[1], '"' . _rewrite_url(trim($_matches[1], '"\'')) . '"', $_value[1]);
  602.                 }
  603.             break;
  604.  
  605.             case 'refresh':
  606.                 if(preg_match('#(\s*\d+\s*;\s*url\s*=\s*)([^\"\'\s]*)#si', $_value[1], $_matches)) {
  607.                     $_value[1] = str_replace($_matches[0], $_matches[1] . _rewrite_url($_matches[2]), $_value[1]);
  608.                 }
  609.             break;
  610.         }
  611.  
  612.         if(isset($_r['headers'][$_value[0]])) {
  613.             $_r['headers'][$_value[0]][] = $_value[1];
  614.         } else {
  615.             $_r['headers'][$_value[0]] = array($_value[1]);
  616.         }
  617.     }
  618.  
  619.     return strlen($header);
  620. }
  621.  
  622. function _out($_proxify = true, $_content_type = '') {
  623.     global $_r, $_url;
  624.  
  625.     $_nopass_headers = array('cookie', 'set-cookie', 'connection', 'keep-alive', 'transfer-encoding');
  626.     $_r['headers']['content-length'] = array(strlen($_r['content']));
  627.     if(!$_proxify and !isset($_r['headers']['content-disposition'])) $_r['headers']['content-disposition'] = array(($_content_type == 'application/octet_stream' ? 'attachment' : 'inline') . '; filename="' . basename($_url) . '"');
  628.     foreach($_r['headers'] as $_key => $_value) {
  629.         if(in_array($_key, $_nopass_headers)) continue;
  630.         $_key = ucwords($_key);
  631.         foreach($_value as $_k => $_v) {
  632.             header("$_key: $_v");
  633.         }
  634.     }
  635.  
  636.     session_write_close();
  637.     echo $_r['content'];
  638.     exit;
  639. }
  640.  
  641. function _rewrite_css($_content) {
  642.     return preg_replace('#((?:import\s*url|import|url)\s*[\(\'\"]+)(.*?)([\'\"\)]+)#Sesi', 'stripslashes("\\1") . _rewrite_url("\\2") . stripslashes("\\3")', $_content);
  643. }
  644.  
  645. function _rewrite_tags($_tags) {
  646.     global $_url, $_r, $_config;
  647.  
  648.     if(preg_match_all('#<(' . implode('|', array_keys($_tags)) . ')((?:\s*[a-z\-]+\s*=\s*(?:\"[^\"]*\"|\'[^\']*\'|[^\s\>]*)|\s*[a-z\-]+)+)+.*?>#si', $_r['content'], $_matches)) {
  649.         $_newinx = count($_matches);
  650.         $_matches[$_newinx] = array();
  651.         foreach($_matches[0] as $_key => $_match) {
  652.             $_tag = strtolower($_matches[1][$_key]);
  653.             if(!isset($_tags[$_tag])) {
  654.                 unset($_matches[0][$_key], $_matches[1][$_key], $_matches[2][$_key]);
  655.                 continue;
  656.             }
  657.             $get = false;
  658.             if($_tag == 'form') {
  659.                 $get = !preg_match('#method\s*=\s*(?:\"post\"|\'post\'|post)#si', $_matches[2][$_key]);
  660.             }
  661.             $_action = '';
  662.             $_pairs = array();
  663.             if(preg_match_all('#\s*(' . implode('|', $_tags[$_tag]) . ')\s*=\s*(\"[^\"]*\"|\'[^\']*\'|[^\s\>]*)#si', $_matches[2][$_key], $_ms)) {
  664.                 foreach($_ms[2] as $_k => $_m) {
  665.                     $_wrapper = '';
  666.                     if($_m{0} == '"' and $_m{strlen($_m) - 1} == '"') {
  667.                         $_wrapper = '"';
  668.                         $_m = trim($_m, '"');
  669.                     } else if($_m{0} == '\'' and $_m{strlen($_m) - 1} == '\'') {
  670.                         $_wrapper = '\'';
  671.                         $_m = trim($_m, '\'');
  672.                     }
  673.  
  674.                     $_attribute = strtolower($_ms[1][$_k]);
  675.                     //Process <meta http-equiv="refresh" content="00;URL=http://somewhere.com">
  676.                     if($_tag == 'meta') {
  677.                         if($_attribute == 'content') {
  678.                             if($_refresh = preg_match('#(\s*\d+\s*;\s*url\s*=\s*)([^\"\'\s]*)#si', $_m, $_mh)) {
  679.                                 $_m = $_mh[1] . _rewrite_url($_mh[2]);
  680.                             }
  681.                         }
  682.                     } elseif($_tag == 'form' and $get and $_attribute == 'action') {
  683.                         $_action = _rewrite_url($_m, false);
  684.                         $_m = '';
  685.                     } elseif(($_tag == 'frame' or $_tag == 'iframe') and $_attribute == 'src') {
  686.                         if($_m == '') {
  687.                             $_m = _rewrite_url($_url) . '&_x_fin_x_=1';
  688.                         } else {
  689.                             $_m = _rewrite_url($_m) . '&_x_fin_x_=1';
  690.                         }
  691.                     } else {
  692.                         $_m = _rewrite_url($_m);
  693.                     }
  694.                 }
  695.                 $_pairs[] = ' ' . $_ms[1][$_k] . '=' . $_wrapper . $_m . $_wrapper;
  696.             }
  697.             $_matches[$_newinx][$_key] = str_replace($_ms[0], $_pairs, $_matches[0][$_key]) . ($get ? '<input type="hidden" name="' . $_config['url_var_name'] . '" value="' . $_action . '" />' : '');
  698.         }
  699.         $_r['content'] = str_replace($_matches[0], $_matches[$_newinx], $_r['content']);
  700.     }
  701.     //end of if
  702. }
  703.  
  704. function _rewrite_url($_url, $_proxify = true) {
  705.     global $_base, $_url_com, $_config, $_protocols;
  706.  
  707.     $_url = trim($_url);
  708.     if($_url == '') return '';
  709.     switch(strtolower($_url{0})) {
  710.         case '#':
  711.             return $_url;
  712.         break;
  713.  
  714.         case '?':
  715.             $_url = $_base['webpath'] . $_url;
  716.         break;
  717.  
  718.         case '/':
  719.             if(substr($_url, 1, 1) == '/') {
  720.                 $_url = $_base['scheme'] . '://' . substr($_url, 2);
  721.                 break;
  722.             }
  723.             $_url = $_base['webroot'] . $_url;
  724.         break;
  725.  
  726.         default:
  727.             // Try to detect an another protocol
  728.             $_inx = strpos($_url, '://');
  729.             if($_inx !== false and $_inx > 0) {
  730.                 $_prefix = substr($_url, 0, $_inx);
  731.                 $_is_protocol = (preg_replace('#\W#i', '', $_prefix) == $_prefix);
  732.                 if($_is_protocol) {
  733.                     // If it's a supported protocol, break and proxify it, if not leave it intact.
  734.                     if(in_array($_prefix, $_protocols)) {
  735.                         break;
  736.                     } else {
  737.                         return $_url;
  738.                     }
  739.                 }
  740.             }
  741.             $_url = $_base['webroot'] . _realpath($_base['path'], $_url);
  742.     }
  743.  
  744.     $_url = ($_proxify ? ($_SERVER['SCRIPT_NAME'] . '?' . $_config['url_var_name'] . '=') : '') . _encode_url($_url, $_proxify) . ((isset($_url_com['fragment']) and $_proxify) ? ('#' . $_url_com['fragment']) : '');
  745.  
  746.     return $_url;
  747. }
  748.  
  749.  
  750. function _realpath($_cwd, $_cd) {
  751.     $_cwd = trim($_cwd, '/');
  752.     $_cwd_dirs = ($_cd and $_cd{0} == '/') ? array() : (($_cwd and $_cwd != '/') ? explode('/', $_cwd) : array());
  753.     $_cd_dirs = ($_cd ? explode('/', $_cd) : array());
  754.     $_last_dir = array_pop($_cwd_dirs);
  755.     if($_last_dir and strpos($_last_dir, '.') === false) {
  756.         $_cwd_dirs[] = $_last_dir;
  757.     }
  758.     $_cd_len = count($_cd_dirs);
  759.     $_i = 0;
  760.     foreach($_cd_dirs as $_cd_dir) {
  761.         $_i++;
  762.         if($_cd_dir == '.' or $_cd_dir == '') {
  763.             continue;
  764.         } else if($_cd_dir == '..') {
  765.             array_pop($_cwd_dirs);
  766.         } else {
  767.             $_cwd_dirs[] = (strpos($_cd_dir, '.') !== false and $_i == $_cd_len) ? $_cd_dir : rawurlencode(rawurldecode($_cd_dir));
  768.         }
  769.     }
  770.  
  771.     return '/' . implode('/', $_cwd_dirs);
  772. }
  773.  
  774.  
  775. function _encode_url($_url, $_url_encode = true) {
  776.     return ($_url_encode ? rawurlencode(base64_encode($_url)) : base64_encode($_url));
  777. }
  778.  
  779.  
  780. function _decode_url($_encoded_url) {
  781.     return base64_decode($_encoded_url);
  782. }
  783.  
  784. ?>
Really appreciate any help :)
Apr 11 '09 #1
7 16067
i face this problem also ..

and the solution is simple for me

i just press F5, i refresh the page and then it works :D

i hope this will work for you also
Apr 12 '09 #2
jeddiki
290 100+
Thanks for your reply,

I tried the F5 button and refresh but I still get a
black screen and the message:
"We're sorry, this video is no longer available" on every video :(

Something must be wrong somewhere.

Please try it yourself and see what happens.

www.blog-start.com

Then just type inwww.youtube.com into the box

Please let me know if you can see videos

Thanks
Apr 13 '09 #3
jeddiki
290 100+
I have now put another proxy script on my server
this time it is called "glype proxy"

This one also does not let me play the videos
it gives this error:

Hello, you either have JavaScript turned off or an old version of Adobe's Flash Player. Get the latest Flash player.
You can see it working at this address:

My Personal Proxy

I know that my browser has up-to-date adobe because I can see youtube vides when I use other peoples public proxies that are running glybe.

I have tried all the configurations of cookies/no cookies scripts/no scripts
etc but I can not get it working :(

I am thinking that there is something wrong on my server ?

Any ideas ?
Apr 16 '09 #4
Markus
6,050 Expert 4TB
Most likely nothing is wrong with your server, but the proxy script is causing these errors.

By the looks of it, they're (the proxies) are all based off the same proxy script.

Proxies are slow, regardless of whose server it is on.

- mark.
Apr 17 '09 #5
Hey i have a simmilar problem , but not with the turkish government but with my turkish network admin XD.

Instead i wrote a few simple php scripts that use the youtube API. One uses the API to get search results and then passes the video ID to another script which grabs the details and has a JW player on it, the JW player grabs the video from another script that gets the youtube video ID via GET , then reads the file and echo's it on the page which then becomes a video file of the JW player.

it works but is a bit slow, ill post it up when i get back home tonight, also i appologize if this response did not make alot of structual sense i blame it on lack off sleep ( 2 days ) lol.

Take Care
GhOsT
Apr 23 '09 #6
jeddiki
290 100+
The problem that I have is that I often spend time in Turkey
which has banned youtube.

Now when I am in the UK that is no problem, but when I travel to Turkey,
this silly ban disrupts my work. Other sites like Metecafe are no problem, but so many people use youtube to host their videos that I need to have access.

Now I thought that I could just use a public proxy, but I always get this message:

Quote:
Hello, you either have JavaScript turned off or an old version of Adobe's Flash Player. Get the latest Flash player.
Obvously I have the latest flash player, so I don't know why I get that error and no video.

To by pass this problem I thought that I would use my leased server. I lease a server in Arizona, USA so in theory I should be able to use that server to look at youtube and bounce the results over to my browser here in Turkey without any problem.

To do this I have downloaded two scripts:

phpMyProxy 1.3

and

Glype Proxy Script

Both are supposed to be good.

Actually this is a better solution because my server is much faster than a public one and there are no adverts ( of course ).

Unfortunately - both of them also give the same massage:

Hello, you either have JavaScript turned off or an old version of Adobe's Flash Player. Get the latest Flash player.

Does anyone have any idea how I can get this working ?

Actually - could someone please chack to see if you can watch a you tube video on my proxy server ?
just to check it out ?

Finally - is it worth just writing my own proxy script ?
But maybe I will just get the same result

my proxy is located here:

http://www.blog-start.com/prox/

Just enter www.youtube.com into the box and pick any video to try it out.

Probably it will work for you - but maybe because I am in Turkey, I get this error ?

Please let me know you thoughts.

Thanks.
Jun 2 '09 #7
bnashenas1984
258 100+
Hi everyone
I think I know why this happens.
When you use a PHP proxy , It simply gets the result from the target website and sends it to you which means : It seems that your just contacting the PHP proxy server not the target website ..

BUT the problem is that:
Flash player (Action Script) is a client side scripting language and gets the request directly from the target website (in this case YOUTUBE) .
So you are geting the whole HTML page and it's components from the proxy server but as soon as the flash file (.swf) runs it directly contacts the target website to download the FLV file which is not possible (because of filtering).

I think there is only one way to solve this and it's to use an IP based proxy.

Hope this helps
Jul 8 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: jasonbrown1999 | last post by:
Someone told me the following script could be used to run harmful commands on the server, by passing commands into the script. What the script does is encode an affiliate URL, create two frames,...
7
by: ckb2102 | last post by:
Hi there, I am new to this so I apologize in advance if I am not following the right etiquette or something... I am working on a project for school. My partner has written a short program in...
1
by: Ellie | last post by:
Hi, I need to find out how to use a proxy-script to submit a form to one server, have it act as client and send the form to another server, which collects data, and then submits that data back...
1
by: pdc | last post by:
I have two web servers that I use, one is the primary and the other is a backup for when the server is down. I use a third, central server which redirects a browser's initial link to one of my...
0
by: deepak | last post by:
Hi All, i m develpoing a .net Window application which has 4 texboxes(tbxURLmfor URL in URL Frame,tbxAddress for address in Proxy server frame,tbxPort for port in proxy server...
2
by: jonathan184 | last post by:
Hi I am trying to make a script to login a website and after login > click on a link >click on another link Choose a date/time range and click a submit button. Now if there are no results...
20
by: Pete Marsh | last post by:
Wondering if anyone can see an error with this script. I get a server configuration error. THat could mean a module is not being loaded, but maybe there's a syntax error here, can anyone spot it?...
1
by: alexxxprog | last post by:
Thank you very much for who can solve this bash script: "Create on the filesystem a bash proceedure createdata that creates collections that that will have to contain a variable, a random number,...
7
by: amrat | last post by:
Can anyone help me produce a On This Day script, where i can customise the list that appears. I think this is a 2 stage process, which include building some sort of database?? Anyone know how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.