Closed

I have a working mirror script that mirrors 100% what other donor site is.

I have a working mirror script that mirrors 100% what other donor site is.

But some problems exist when sub domain are used.

For example if donor site = [url removed, login to view]

and mirror site is [url removed, login to view]

when [url removed, login to view] uses sub domains like [url removed, login to view]

then [url removed, login to view] is not able to reproduce them,

problem is in parsing input + that my Nginx is configured

So task is to fix sub domain issue

adapt script to this nginx config

if ($host ~* ^(.*\..*)$) {

set $sub "";

set $domain $host;

}

if ($host ~* ^(.*)\.(.*\..*)$) {

set $sub $1;

set $domain $2;

}

if ($host ~* ^www\.(.*\..*)$) {

set $sub "";

set $domain $1;

}

server_name _;

server_name_in_redirect off;

#root /home/web/data/$domain/$sub;

root /home/web/data/$domain/;

location /

{

chunked_transfer_encoding off;

#root /home/web/data/$domain/$sub;

root /home/web/data/$domain/;

index [url removed, login to view];

#try_files $uri $uri/ @fallback;

if (!-e $request_filename)

{

rewrite ^(.*)$ /[url removed, login to view]$1 last;

break;

}

location ~ \.php$

{

chunked_transfer_encoding off;

if (!-e $request_filename)

{

rewrite ^(.*)$ /[url removed, login to view]$1 last;

break;

}

here is example of mirror script

[url removed, login to view]

<?php

/*

* ?„???????†???? ?·?°???????·???? ???‚???°?????†?‹

*/

function load($url)

{

global $loader;

return $loader($url);

}

[url removed, login to view]

<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '[url removed, login to view]';

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '[url removed, login to view]';

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '[url removed, login to view]';

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '[url removed, login to view]';

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '[url removed, login to view]';

define('projectName', 'cache');

define('cacheFolder', '/home/web/');

define('cachePath', cacheFolder . projectName . DIRECTORY_SEPARATOR);

function cache_hash($url)

{

return md5($url);

}

function cache_save($url, $body)

{

$fsize=strlen($body);

if ($fsize > 0){

file_put_contents(cachePath . cache_hash($url), $body);

}

}

function cache_load($url)

{

if (cache_exists($url))

{

return file_get_contents(cachePath . cache_hash($url));

}

else

{

throw new RuntimeException('cache not exists');

}

}

function cache_exists($url)

{

$fexists=FALSE;

$fexists=file_exists(cachePath . cache_hash($url));

$fsize=filesize(cachePath . cache_hash($url));

$fsizeok=FALSE;

if ($fsize > 0){ $fsizeok=TRUE; }

$cacheok = ($fexists && $fsizeok);

return $cacheok;

}

function mirror_load()

{

global $query;

$url = url_site($query);

if (cache_exists($url))

{

//return cache_load($url)."<!-- cache -->";

return cache_load($url);

}

else

{

$contents = load($url);

cache_save($url, $contents);

$contents .= "<!-- ".time()." not cache; url=$url -->";

return $contents;

}

}

function mirror_replace($contents)

{

global $site, $mirror;

return str_replace($site, $mirror, $contents);

}

function mirror_echo($contents)

{

global $query;

header('Content-type: ' . mime_guess($query));

echo $contents;

}

[url removed, login to view]

<?php

/*

* ???»???±?°?»?????‹?? ???°???????? ???°???€?????µ?????? ?„?°???»????

* ???°???‹: (???°???€?????µ?????µ => ?????µ???‚???„?????°?‚???? mime ?‚?????°)

*/

$extension = Array(

'txt' => 'text',

'html' => 'html',

'htm' => 'html',

'css' => 'css',

'js' => 'javascript',

'jpg' => 'jpeg',

'jpeg' => 'jpeg',

'png' => 'png',

'gif' => 'gif'

);

/*

* ?„???????†???? ???»?? ?????????µ?????? ???°???€?????µ?????? ?„?°???»?°-?·?°?????????°

*/

function extension_check($extension, $subject)

{

return preg_match('/.*\.' . $extension . '.*/', $subject);

}

/*

* ?„???????†???? ???»?? ???·???»?µ?‡?µ?????? ???°???€?????µ?????? ?„?°???»?° ???· ?·?°?????????°

*/

function extension_guess($subject)

{

global $extension;

foreach ($extension as $ext => $mime)

{

if (extension_check($ext, $subject))

{

return $ext;

}

}

return 'html';

}

Skills: PHP

See more: php script mirror site cache script, txt 2 jpg, png to txt, parsing input, my working, javascript jpeg, gif to txt, what if, this site is, text parsing, rewrite script, nginx configuration, mirror, md5, js script, data loader, php text array, fix root, php script last, php parsing text, javascript array com, nginx problem, php html parsing, nginx url rewrite url, nginx rewrite url

About the Employer:
( 1 review ) dfhgkh, United Kingdom

Project ID: #2544517

3 freelancers are bidding on average $17/hour for this job

perfectsuccessor

plz check your PMB

$15 USD / hour
(18 Reviews)
5.0
bestpro126

Dear sir. I can help you. I can do this as you want, and everything is ready. Best and kind regards.

$15 USD / hour
(13 Reviews)
3.4
jonez734

I could easily do something like this using 'wget' or perhaps 'curl'. does your current 'mirror' script run from cron?

$20 USD / hour
(0 Reviews)
0.0