Skip to content

Commit

Permalink
url_mode=0 is now working
Browse files Browse the repository at this point in the history
  • Loading branch information
Athlon1600 committed Jun 18, 2016
1 parent 0cdd23c commit b0a31d5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 39 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "athlon1600/php-proxy",
"type": "library",
"version": "4.0.1",
"version": "4.0.2",
"keywords": ["php proxy", "proxy script", "php web proxy", "web proxy"],
"homepage": "https://www.php-proxy.com/",
"require": {
Expand Down
60 changes: 22 additions & 38 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,15 @@

// strip away extra parameters text/html; charset=UTF-8
function clean_content_type($content_type){
return preg_replace('@;.*@', '', $content_type);
return trim(preg_replace('@;.*@', '', $content_type));
}

function is_html($content_type){

$content_type = clean_content_type($content_type);

$text = array(
//'text/cmd',
//'text/css',
//'text/csv',
//'text/example',
'text/html'
//'text/javascript',
//'text/plain',
//'text/rtf',
//'text/vcard',
//'text/vnd.abc',
//'text/xml'
);

return in_array($content_type, $text);
return clean_content_type($content_type) == 'text/html';
}

function base64_url_encode($input){
// = at the end is just padding to make the length of the str divisible by 4
return rtrim(strtr(base64_encode($input), '+/', '-_'), '=');
}

function base64_url_decode($input){
return base64_decode(str_pad(strtr($input, '-_', '+/'), strlen($input) % 4, '=', STR_PAD_RIGHT));
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}

function in_arrayi($needle, $haystack){
Expand Down Expand Up @@ -130,32 +108,37 @@ function time_ms(){
return round(microtime(true) * 1000);
}

function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
function base64_url_encode($input){
// = at the end is just padding to make the length of the str divisible by 4
return rtrim(strtr(base64_encode($input), '+/', '-_'), '=');
}

function base64_encrypt($data, $key = false){
function base64_url_decode($input){
return base64_decode(str_pad(strtr($input, '-_', '+/'), strlen($input) % 4, '=', STR_PAD_RIGHT));
}

function url_encrypt($url, $key = false){

if($key){
$data = str_rot_pass($data, $key);
$url = str_rot_pass($url, $key);
} else if(Config::get('encryption_key')){
$data = str_rot_pass($data, Config::get('encryption_key'));
$url = str_rot_pass($url, Config::get('encryption_key'));
}

return base64_url_encode($data);
return Config::get('url_mode') ? base64_url_encode($url) : rawurlencode($url);
}

function base64_decrypt($data, $key = false){
function url_decrypt($url, $key = false){

$data = base64_url_decode($data);
$url = Config::get('url_mode') ? base64_url_decode($url) : rawurldecode($url);

if($key){
$data = str_rot_pass($data, $key, true);
$url = str_rot_pass($url, $key, true);
} else if(Config::get('encryption_key')){
$data = str_rot_pass($data, Config::get('encryption_key'), true);
$url = str_rot_pass($url, Config::get('encryption_key'), true);
}

return $data;
return $url;
}

// www.youtube.com TO proxy-app.com/index.php?q=encrypt_url(www.youtube.com)
Expand All @@ -164,10 +147,11 @@ function proxify_url($url, $base_url = ''){
$url = htmlspecialchars_decode($url);

if($base_url){
$base_url = add_http($base_url);
$url = rel2abs($url, $base_url);
}

return app_url().'?q='.base64_encrypt($url);
return app_url().'?q='.url_encrypt($url);
}

function vid_player($url, $width, $height, $extension = false){
Expand Down

0 comments on commit b0a31d5

Please sign in to comment.