From 40dfa7d5c0dc8e4cb2c95e403b6b4b2c4bf70644 Mon Sep 17 00:00:00 2001 From: Matthijs Kuiper Date: Sat, 4 Feb 2017 16:05:45 +0100 Subject: Original UTStats beta 4.2.8 --- html/includes/clanbase.php | 90 ++++++ html/includes/config.php | 188 +++++++++++ html/includes/config_pic.php | 239 ++++++++++++++ html/includes/countries.php | 244 +++++++++++++++ html/includes/footer.php | 16 + html/includes/ftp.php | 411 ++++++++++++++++++++++++ html/includes/ftp_class.php | 492 +++++++++++++++++++++++++++++ html/includes/ftp_class_native.php | 142 +++++++++ html/includes/ftp_class_pure.php | 192 ++++++++++++ html/includes/ftp_class_sockets.php | 249 +++++++++++++++ html/includes/ftptimestamp.php | 1 + html/includes/functions.php | 605 ++++++++++++++++++++++++++++++++++++ html/includes/functions_admin.php | 332 ++++++++++++++++++++ html/includes/geoip.inc | 498 +++++++++++++++++++++++++++++ html/includes/header.php | 66 ++++ html/includes/hints.php | 81 +++++ html/includes/index.htm | 0 html/includes/overlib_mini.js | 322 +++++++++++++++++++ html/includes/sidebar.php | 27 ++ html/includes/teamstats.php | 177 +++++++++++ html/includes/weaponstats.php | 216 +++++++++++++ 21 files changed, 4588 insertions(+) create mode 100755 html/includes/clanbase.php create mode 100755 html/includes/config.php create mode 100755 html/includes/config_pic.php create mode 100755 html/includes/countries.php create mode 100755 html/includes/footer.php create mode 100755 html/includes/ftp.php create mode 100755 html/includes/ftp_class.php create mode 100755 html/includes/ftp_class_native.php create mode 100755 html/includes/ftp_class_pure.php create mode 100755 html/includes/ftp_class_sockets.php create mode 100755 html/includes/ftptimestamp.php create mode 100755 html/includes/functions.php create mode 100755 html/includes/functions_admin.php create mode 100755 html/includes/geoip.inc create mode 100755 html/includes/header.php create mode 100755 html/includes/hints.php create mode 100755 html/includes/index.htm create mode 100755 html/includes/overlib_mini.js create mode 100755 html/includes/sidebar.php create mode 100755 html/includes/teamstats.php create mode 100755 html/includes/weaponstats.php (limited to 'html/includes') diff --git a/html/includes/clanbase.php b/html/includes/clanbase.php new file mode 100755 index 0000000..5ad7640 --- /dev/null +++ b/html/includes/clanbase.php @@ -0,0 +1,90 @@ +| )/U", $file, $out, PREG_SET_ORDER); + + + //for each player split the information and put all info in one array + + for ($x=0;$x',$out[$x][1]); + } + + //return the array + + return ($player); + + //All players are listed as: + //$player[0] + //$player[1] + //$player[2] + //etc. + + //the info for each player is listed as: + //$player[0][0] = pid; + //$player[0][1] = name; +} + + +/* + This function is to get the clans from a war. + It will return an array with all the information. +*/ + +function get_clans($wid) { + //Load the page where all players are listed into a var. + + $url = 'http://www.clanbase.com/warinfo.php?wid='.$wid.'&frame=1'; + $file = implode('', file($url)); + + //Use an expression to get the tags from each clan + + preg_match_all("/pagetitle'>Match (.*)vs (.*)<.div>/U", $file, $out, PREG_SET_ORDER); + + //Add the information to one array + + $clan[0][0]=$out[0][1]; + $clan[1][0]=$out[0][2]; + + //Use an expression to get the cid + full name from each clan + + preg_match_all("/claninfo\.php\?cid+=(.*)<.a>/U", $file, $out, PREG_SET_ORDER); + + //Add the information to one array + + $temp = explode('" class="slink">', $out[0][1]); + $clan[0][1]=$temp[0]; + $clan[0][2]=$temp[1]; + + $temp = explode('" class="slink">', $out[1][1]); + $clan[1][1]=$temp[0]; + $clan[1][2]=$temp[1]; + + //return the array + + return ($clan); + + + //The clans are listed as: + //$clan[0] + //$clan[1] + + //the info for each clan is listed as: + //$clan[0][0] = tag + //$clan[0][1] = cid + //$clan[0][2] = full name + +} +?> \ No newline at end of file diff --git a/html/includes/config.php b/html/includes/config.php new file mode 100755 index 0000000..7e9bd6f --- /dev/null +++ b/html/includes/config.php @@ -0,0 +1,188 @@ + \ No newline at end of file diff --git a/html/includes/config_pic.php b/html/includes/config_pic.php new file mode 100755 index 0000000..e70aee5 --- /dev/null +++ b/html/includes/config_pic.php @@ -0,0 +1,239 @@ + 'Player has played a total of 57 Capture the Flag games.' +// +// '%PLAYERNAME%'s overall accuracy this month was %MONTH_ACC% % while it was %LMONTH_ACC% last month!' +// ==> 'Player's overall accuracy this month was 42.22 % while it was 27.52 % last month!' + + +$j=0; +$pic[$i]['process'][$j]['type'] = 'text'; +$pic[$i]['process'][$j]['value'] = '%PLAYERNAME%'; +$pic[$i]['process'][$j]['fontcolor'] = '000000'; +$pic[$i]['process'][$j]['fontsize'] = 18; +$pic[$i]['process'][$j]['x_from'] = 9; +$pic[$i]['process'][$j]['y_from'] = 23; +$j++; +$pic[$i]['process'][$j]['type'] = 'text'; +$pic[$i]['process'][$j]['value'] = '%GAMENAME%'; +$pic[$i]['process'][$j]['fontsize'] = 14; +$pic[$i]['process'][$j]['x_from'] = 9; +$pic[$i]['process'][$j]['y_from'] = 43; +$j++; +$pic[$i]['process'][$j]['type'] = 'text'; +$pic[$i]['process'][$j]['value'] = 'Rank:'; +$pic[$i]['process'][$j]['fontcolor'] = 'DDDD20'; +$pic[$i]['process'][$j]['x_from'] = 9; +$pic[$i]['process'][$j]['y_from'] = 69; +$j++; +$pic[$i]['process'][$j]['type'] = 'text'; +$pic[$i]['process'][$j]['align'] = 'left'; +$pic[$i]['process'][$j]['value'] = '%RT%'; +$pic[$i]['process'][$j]['x_from'] = 65; +$pic[$i]['process'][$j]['y_from'] = 69; +$j++; +$pic[$i]['process'][$j]['type'] = 'text'; +$pic[$i]['process'][$j]['value'] = 'Hours:'; +$pic[$i]['process'][$j]['fontcolor'] = '000000'; +$pic[$i]['process'][$j]['x_from'] = 9; +$pic[$i]['process'][$j]['y_from'] = 91; +$j++; +$pic[$i]['process'][$j]['type'] = 'text'; +$pic[$i]['process'][$j]['align'] = 'left'; +$pic[$i]['process'][$j]['value'] = '%TOTAL_GAMETIME%'; +$pic[$i]['process'][$j]['x_from'] = 75; +$pic[$i]['process'][$j]['y_from'] = 91; +$j++; + + + + + + + + +// The next picture + +$i++; +$pic[$i]['enabled'] = false; +$pic[$i]['gidrequired'] = false; +$pic[$i]['load']['template'] = 'basic.png'; +$pic[$i]['load']['recreate'] = true; +$pic[$i]['load']['bgcolor'] = 'AAAAAA'; +$pic[$i]['load']['bgtransparent'] = false; + +$pic[$i]['output']['type'] = 'png'; + +$pic[$i]['default']['align'] = 'left'; +$pic[$i]['default']['angle'] = 0; +$pic[$i]['default']['font'] = 'microsbe.ttf'; +$pic[$i]['default']['fontcolor'] = 'FFFFFF'; +$pic[$i]['default']['fontsize'] = 10; + +$j=0; +$pic[$i]['process'][$j]['type'] = 'text'; +$pic[$i]['process'][$j]['value'] = '%PLAYERNAME% sucks!'; +$pic[$i]['process'][$j]['x_from'] = 9; +$pic[$i]['process'][$j]['y_from'] = 23; +$j++; +$pic[$i]['process'][$j]['type'] = 'text'; +$pic[$i]['process'][$j]['value'] = 'in %GAMENAME% games that is...'; +$pic[$i]['process'][$j]['x_from'] = 9; +$pic[$i]['process'][$j]['y_from'] = 43; +$j++; + + + +?> \ No newline at end of file diff --git a/html/includes/countries.php b/html/includes/countries.php new file mode 100755 index 0000000..4de8dde --- /dev/null +++ b/html/includes/countries.php @@ -0,0 +1,244 @@ + 'Afghanistan', + 'al' => 'Albania, People\'s Socialist Republic of', + 'dz' => 'Algeria, People\'s Democratic Republic of', + 'as' => 'American Samoa', + 'ad' => 'Andorra, Principality of', + 'ao' => 'Angola, Republic of', + 'ai' => 'Anguilla', + 'aq' => 'Antarctica (the territory South of 60 deg S)', + 'ag' => 'Antigua and Barbuda', + 'ar' => 'Argentina, Argentine Republic', + 'am' => 'Armenia', + 'aw' => 'Aruba', + 'au' => 'Australia, Commonwealth of', + 'at' => 'Austria, Republic of', + 'az' => 'Azerbaijan, Republic of', + 'bs' => 'Bahamas, Commonwealth of the', + 'bh' => 'Bahrain, Kingdom of', + 'bd' => 'Bangladesh, People\'s Republic of', + 'bb' => 'Barbados', + 'by' => 'Belarus', + 'be' => 'Belgium, Kingdom of', + 'bz' => 'Belize', + 'bj' => 'Benin, People\'s Republic of', + 'bm' => 'Bermuda', + 'bt' => 'Bhutan, Kingdom of', + 'bo' => 'Bolivia, Republic of', + 'ba' => 'Bosnia and Herzegovina', + 'bw' => 'Botswana, Republic of', + 'bv' => 'Bouvet Island (Bouvetoya)', + 'br' => 'Brazil, Federative Republic of', + 'io' => 'British Indian Ocean Territory (Chagos Archipelago)', + 'vg' => 'British Virgin Islands', + 'bn' => 'Brunei Darussalam', + 'bg' => 'Bulgaria, People\'s Republic of', + 'bf' => 'Burkina Faso', + 'bi' => 'Burundi, Republic of', + 'kh' => 'Cambodia, Kingdom of', + 'cm' => 'Cameroon, United Republic of', + 'ca' => 'Canada', + 'cv' => 'Cape Verde, Republic of', + 'ky' => 'Cayman Islands', + 'cf' => 'Central African Republic', + 'td' => 'Chad, Republic of', + 'cl' => 'Chile, Republic of', + 'cn' => 'China, People\'s Republic of', + 'cx' => 'Christmas Island', + 'cc' => 'Cocos (Keeling) Islands', + 'co' => 'Colombia, Republic of', + 'km' => 'Comoros, Federal and Islamic Republic of', + 'cd' => 'Congo, Democratic Republic of', + 'cg' => 'Congo, People\'s Republic of', + 'ck' => 'Cook Islands', + 'cr' => 'Costa Rica, Republic of', + 'ci' => 'Cote D\'Ivoire, Ivory Coast, Republic of the', + 'cu' => 'Cuba, Republic of', + 'cy' => 'Cyprus, Republic of', + 'cz' => 'Czech Republic', + 'dk' => 'Denmark, Kingdom of', + 'dj' => 'Djibouti, Republic of', + 'dm' => 'Dominica, Commonwealth of', + 'do' => 'Dominican Republic', + 'tl' => 'Timor-Leste', + 'ec' => 'Ecuador, Republic of', + 'eg' => 'Egypt, Arab Republic of', + 'sv' => 'El Salvador, Republic of', + 'gq' => 'Equatorial Guinea, Republic of', + 'er' => 'Eritrea', + 'ee' => 'Estonia', + 'et' => 'Ethiopia', + 'fo' => 'Faeroe Islands', + 'fk' => 'Falkland Islands (Malvinas)', + 'fj' => 'Fiji, Republic of the Fiji Islands', + 'fi' => 'Finland, Republic of', + 'fr' => 'France, French Republic', + 'gf' => 'French Guiana', + 'pf' => 'French Polynesia', + 'tf' => 'French Southern Territories', + 'ga' => 'Gabon, Gabonese Republic', + 'gm' => 'Gambia, Republic of the', + 'ge' => 'Georgia', + 'de' => 'Germany', + 'gh' => 'Ghana, Republic of', + 'gi' => 'Gibraltar', + 'gr' => 'Greece, Hellenic Republic', + 'gl' => 'Greenland', + 'gd' => 'Grenada', + 'gp' => 'Guadaloupe', + 'gu' => 'Guam', + 'gt' => 'Guatemala, Republic of', + 'gn' => 'Guinea, Revolutionary People\'s Rep\'c of', + 'gw' => 'Guinea-Bissau, Republic of', + 'gy' => 'Guyana, Republic of', + 'ht' => 'Haiti, Republic of', + 'hm' => 'Heard and McDonald Islands', + 'va' => 'Holy See (Vatican City State)', + 'hn' => 'Honduras, Republic of', + 'hk' => 'Hong Kong, Special Administrative Region of China', + 'hr' => 'Hrvatska (Croatia)', + 'hu' => 'Hungary, Hungarian People\'s Republic', + 'is' => 'Iceland, Republic of', + 'in' => 'India, Republic of', + 'id' => 'Indonesia, Republic of', + 'ir' => 'Iran, Islamic Republic of', + 'iq' => 'Iraq, Republic of', + 'ie' => 'Ireland', + 'il' => 'Israel, State of', + 'it' => 'Italy, Italian Republic', + 'jm' => 'Jamaica', + 'jp' => 'Japan', + 'jo' => 'Jordan, Hashemite Kingdom of', + 'kz' => 'Kazakhstan, Republic of', + 'ke' => 'Kenya, Republic of', + 'ki' => 'Kiribati, Republic of', + 'kp' => 'Korea, Democratic People\'s Republic of', + 'kr' => 'Korea, Republic of', + 'kw' => 'Kuwait, State of', + 'kg' => 'Kyrgyz Republic', + 'la' => 'Lao People\'s Democratic Republic', + 'lv' => 'Latvia', + 'lb' => 'Lebanon, Lebanese Republic', + 'ls' => 'Lesotho, Kingdom of', + 'lr' => 'Liberia, Republic of', + 'ly' => 'Libyan Arab Jamahiriya', + 'li' => 'Liechtenstein, Principality of', + 'lt' => 'Lithuania', + 'lu' => 'Luxembourg, Grand Duchy of', + 'mo' => 'Macao, Special Administrative Region of China', + 'mk' => 'Macedonia, the former Yugoslav Republic of', + 'mg' => 'Madagascar, Republic of', + 'mw' => 'Malawi, Republic of', + 'my' => 'Malaysia', + 'mv' => 'Maldives, Republic of', + 'ml' => 'Mali, Republic of', + 'mt' => 'Malta, Republic of', + 'mh' => 'Marshall Islands', + 'mq' => 'Martinique', + 'mr' => 'Mauritania, Islamic Republic of', + 'mu' => 'Mauritius', + 'yt' => 'Mayotte', + 'mx' => 'Mexico, United Mexican States', + 'fm' => 'Micronesia, Federated States of', + 'md' => 'Moldova, Republic of', + 'mc' => 'Monaco, Principality of', + 'mn' => 'Mongolia, Mongolian People\'s Republic', + 'ms' => 'Montserrat', + 'ma' => 'Morocco, Kingdom of', + 'mz' => 'Mozambique, People\'s Republic of', + 'mm' => 'Myanmar', + 'na' => 'Namibia', + 'nr' => 'Nauru, Republic of', + 'np' => 'Nepal, Kingdom of', + 'an' => 'Netherlands Antilles', + 'nl' => 'Netherlands, Kingdom of the', + 'nc' => 'New Caledonia', + 'nz' => 'New Zealand', + 'ni' => 'Nicaragua, Republic of', + 'ne' => 'Niger, Republic of the', + 'ng' => 'Nigeria, Federal Republic of', + 'nu' => 'Niue, Republic of', + 'nf' => 'Norfolk Island', + 'mp' => 'Northern Mariana Islands', + 'no' => 'Norway, Kingdom of', + 'om' => 'Oman, Sultanate of', + 'pk' => 'Pakistan, Islamic Republic of', + 'pw' => 'Palau', + 'ps' => 'Palestinian Territory, Occupied', + 'pa' => 'Panama, Republic of', + 'pg' => 'Papua New Guinea', + 'py' => 'Paraguay, Republic of', + 'pe' => 'Peru, Republic of', + 'ph' => 'Philippines, Republic of the', + 'pn' => 'Pitcairn Island', + 'pl' => 'Poland, Polish People\'s Republic', + 'pt' => 'Portugal, Portuguese Republic', + 'pr' => 'Puerto Rico', + 'qa' => 'Qatar, State of', + 're' => 'Reunion', + 'ro' => 'Romania, Socialist Republic of', + 'ru' => 'Russian Federation', + 'rw' => 'Rwanda, Rwandese Republic', + 'sh' => 'St. Helena', + 'kn' => 'St. Kitts and Nevis', + 'lc' => 'St. Lucia', + 'pm' => 'St. Pierre and Miquelon', + 'vc' => 'St. Vincent and the Grenadines', + 'ws' => 'Samoa, Independent State of', + 'sm' => 'San Marino, Republic of', + 'st' => 'Sao Tome and Principe, Democratic Republic of', + 'sa' => 'Saudi Arabia, Kingdom of', + 'sn' => 'Senegal, Republic of', + 'sc' => 'Seychelles, Republic of', + 'sl' => 'Sierra Leone, Republic of', + 'sg' => 'Singapore, Republic of', + 'sk' => 'Slovakia (Slovak Republic)', + 'si' => 'Slovenia', + 'sb' => 'Solomon Islands', + 'so' => 'Somalia, Somali Republic', + 'za' => 'South Africa, Republic of', + 'gs' => 'South Georgia and the South Sandwich Islands', + 'es' => 'Spain, Spanish State', + 'lk' => 'Sri Lanka, Democratic Socialist Republic of', + 'sd' => 'Sudan, Democratic Republic of the', + 'sr' => 'Suriname, Republic of', + 'sg' => 'Svalbard & Jan Mayen Islands', + 'sz' => 'Swaziland, Kingdom of', + 'se' => 'Sweden, Kingdom of', + 'ch' => 'Switzerland, Swiss Confederation', + 'sy' => 'Syrian Arab Republic', + 'tw' => 'Taiwan, Province of China', + 'tj' => 'Tajikistan', + 'tz' => 'Tanzania, United Republic of', + 'th' => 'Thailand, Kingdom of', + 'tg' => 'Togo, Togolese Republic', + 'tk' => 'Tokelau (Tokelau Islands)', + 'to' => 'Tonga, Kingdom of', + 'tt' => 'Trinidad and Tobago, Republic of', + 'tn' => 'Tunisia, Republic of', + 'tr' => 'Turkey, Republic of', + 'tm' => 'Turkmenistan', + 'tc' => 'Turks and Caicos Islands', + 'tv' => 'Tuvalu', + 'vi' => 'US Virgin Islands', + 'ug' => 'Uganda, Republic of', + 'ua' => 'Ukraine', + 'ae' => 'United Arab Emirates', + 'gb' => 'United Kingdom of Great Britain & N. Ireland', + 'um' => 'United States Minor Outlying Islands', + 'us' => 'United States of America', + 'uy' => 'Uruguay, Eastern Republic of', + 'uz' => 'Uzbekistan', + 'vu' => 'Vanuatu', + 've' => 'Venezuela, Bolivarian Republic of', + 'vn' => 'Viet Nam, Socialist Republic of', + 'wf' => 'Wallis and Futuna Islands', + 'eh' => 'Western Sahara', + 'ye' => 'Yemen', + 'yu' => 'Yugoslavia, Socialist Federal Republic of', + 'zm' => 'Zambia, Republic of', + 'zw' => 'Zimbabwe', + 'xx' => 'Unknown country' + ); +?> \ No newline at end of file diff --git a/html/includes/footer.php b/html/includes/footer.php new file mode 100755 index 0000000..0fd4f3f --- /dev/null +++ b/html/includes/footer.php @@ -0,0 +1,16 @@ +

+'; + +// Please leave this bit in, its the least you can do with all the work we have done :) + + echo' + + +
+ UTStats Beta 4.2.8 © 2005 azazel, AnthraX and toa
+ + +'; + +ob_end_flush(); \ No newline at end of file diff --git a/html/includes/ftp.php b/html/includes/ftp.php new file mode 100755 index 0000000..7e058a3 --- /dev/null +++ b/html/includes/ftp.php @@ -0,0 +1,411 @@ +PopError()) !== false) { + + $fctname = $err['fctname']; + + $msg = $err['msg']; + + $desc = $err['desc']; + + if($desc) $tmp=' ('.$desc.')'; else $tmp=''; + + if (strpos($msg, 'socket set') === 0) { + + $tmp .= "\nTry disabling the usage of sockets (set \$ftp_type = 'pure'; in config.php)"; + + } + + tablerow('Error details:', $fctname.': '.$msg.$tmp, true); + + } + + + +} + + + +function tablerow($left, $right, $error=false) { + + global $html, $ftp_debug; + + if ($ftp_debug) return; + + $space = ($html) ? ' ' : ' '; + + $left = (empty($left)) ? $space : (($html) ? htmlentities($left) : $left); + + $right = (empty($right)) ? $space : (($html) ? nl2br(htmlentities($right)) : $right); + + $style = ($error) ? 'style="background-color: red;"' : ''; + + if ($html) { + + echo ''; + + echo ''. $left .''; + + echo ''. $right .''; + + echo ''; + + } else { + + if (strlen($left) < 30) $left .= str_repeat(" ", 30 - strlen($left)); + + echo "$left $right\n"; + + } + + flush(); + +} + + + +function ftpupdate() + +{ + + global $html, $ftp, $ftp_uname, $ftp_upass, $ftp_hostname, $ftp_port, $g_ftp_error, $ftp_debug, + + $ftp_delete, $ftp_movedir, $ftp_dir, $ftp_passive, $import_log_start, $import_log_extension, + + $import_utdc_download_enable, $import_utdc_log_start, $import_utdc_log_extension, $import_utdc_screenshot_start, $import_utdc_screenshot_extension, + $import_ac_download_enable, $import_ac_log_start, $import_ac_log_extension, + $import_ace_download_enable, $import_ace_log_start, $import_ace_log_extension, $import_ace_screenshot_start, $import_ace_screenshot_extension; + + + + if (!$ftp_debug) { + + if ($html) echo''; + + } + + + + // Update, from here on were going to be doing multiple FTP sessions. + + for ($i = 0; $i < count($ftp_hostname); $i++) { + + if ($i != 0) { + + if ($html and !$ftp_debug) echo ''; + + echo "\n"; + + } + + + + tablerow('Connecting to server:', $ftp_hostname[$i] .':'. $ftp_port[$i]); + + if (!$ftp->SetServer($ftp_hostname[$i], $ftp_port[$i])) { + + ftp_error("Unable to set server: ". $ftp->lastmsg); $ftp->quit(true); continue; + + } + + if (!$ftp->connect()) { + + ftp_error("Unable to connect to server: ". $ftp->lastmsg); $ftp->quit(true); continue; + + } + + + + tablerow('', "Connected, now logging in..."); + + if (!$ftp->login($ftp_uname[$i], $ftp_upass[$i])) { + + ftp_error("Login failed!\nBad username/password?"); $ftp->quit(true); continue; + + } + + tablerow('', "Logged in!"); + + + + if (!$ftp->SetType(FTP_BINARY)) { + + ftp_error("Could not set type: ". $ftp->lastmsg); $ftp->quit(true); continue; + + } + + if (!isset($ftp_passive[$i]) or $ftp_passive[$i]) { + + tablerow("", "Setting passive mode"); + + if(!$ftp->Passive(true)) { + + ftp_error("Could not set passive mode: ". $ftp->lastmsg); $ftp->quit(true); continue; + + } + + } else { + + tablerow("", "Setting active mode"); + + if(!$ftp->Passive(false)) { + + ftp_error("Could not set active mode: ". $ftp->lastmsg); $ftp->quit(true); continue; + + } + + } + + if (($pwd = $ftp->pwd()) === false) { + + ftp_error("Unable to retrieve current working directory"); $ftp->quit(true); continue; + + } + + tablerow("Current directory is:", $pwd); + + + + $dl_start = time(); + + $dl_files = 0; + + $dl_bytes = 0; + + $error = false; + + foreach($ftp_dir[$i] as $dir) { + + if (!empty($dir)) { + + if (!$ftp->chdir($dir)) { + + ftp_error("Unable to change directory to: $dir"); $ftp->quit(true); continue; + + } + + tablerow('', "Changing directory to: $dir"); + + if (($pwd = $ftp->pwd()) === false) { + + ftp_error("Unable to retrieve current working directory"); $ftp->quit(true); continue; + + } + + tablerow("New directory is:", $pwd); + + } + + + + if (($filelist = $ftp->nlist()) === false) { + + ftp_error("Unable to retrieve file list"); continue; + + } + + + + tablerow("Directory contains:", count($filelist) ." ". ((count($filelist) == 1) ? 'file' : 'files')); + + if (count($filelist) == 0) { + + continue; + + } + + foreach ($filelist as $filename) { + + if (((substr($filename, 0, strlen($import_log_start)) == $import_log_start) and (substr($filename, strlen($filename) - strlen($import_log_extension)) == $import_log_extension)) + + or ($import_utdc_download_enable and (substr($filename, 0, strlen($import_utdc_log_start)) == $import_utdc_log_start) and (substr($filename, strlen($filename) - strlen($import_utdc_log_extension)) == $import_utdc_log_extension)) + + or ($import_utdc_download_enable and (substr($filename, 0, strlen($import_utdc_screenshot_start)) == $import_utdc_screenshot_start) and (substr($filename, strlen($filename) - strlen($import_utdc_screenshot_extension)) == $import_utdc_screenshot_extension)) + + or ($import_ac_download_enable and (substr($filename, 0, strlen($import_ac_log_start)) == $import_ac_log_start) and (substr($filename, strlen($filename) - strlen($import_ac_log_extension)) == $import_ac_log_extension)) + + or ($import_ace_download_enable and (substr($filename, 0, strlen($import_ace_log_start)) == $import_ace_log_start) and (substr($filename, strlen($filename) - strlen($import_ace_log_extension)) == $import_ace_log_extension)) + + or ($import_ace_download_enable and (substr($filename, 0, strlen($import_ace_screenshot_start)) == $import_ace_screenshot_start) and (substr($filename, strlen($filename) - strlen($import_ace_screenshot_extension)) == $import_ace_screenshot_extension))) { + } else { + continue; + } + + $size = $ftp->get($filename, 'logs/' . $filename); + + if ($size === FALSE) { + + $result = 'ERROR!'; + + $error = true; + + if (file_exists('logs/' . $filename)) { + unlink('logs/' . $filename); + } + + } else { + + $result = "OK (". number_format(round(($size / 1024), 0)) ." KB)"; + + $dl_files++; + + $dl_bytes += $size; + + } + + tablerow(($dl_files == 1) ? 'Downloading...' : '', "$filename -> $result"); + + if ((!isset($ftp_delete[$i]) or $ftp_delete[$i]) and !$error) { + $ftp->delete($filename); + } + else { + // rename the file to prevent reimporting + $ftp->rename($filename, "~" . $filename); + } + + } + + } + + $dl_kb = number_format(round(($dl_bytes / 1024), 0)); + + $dl_time = time() - $dl_start; + + tablerow("Downloaded:", "$dl_files ". ((count($filelist) == 1) ? 'file' : 'files') ." ($dl_kb KB) in $dl_time seconds"); + + + + if ($error) { + + ftp_error('There were errors when downoading (some) files!'); + + } + + + + tablerow("Disconnecting...", "done!"); + + $ftp->quit(true); + + } + + if (!$ftp_debug and $html) echo '
'; + + echo "FTP Transferring Log Files...\n"; + + if ($html) echo '

'; + + echo "\n\n"; + + + + //update timestamp + + + + if (!$g_ftp_error) { + + $file = fopen('includes/ftptimestamp.php', 'wb+', 1); + + fwrite($file, time()); + + fclose($file); + + } + +} + + + + + +$fname = 'includes/ftptimestamp.php'; + +$timestamp = 0; + + + +if(file_exists($fname)) + +{ + + $file = fopen($fname, 'rb'); + + $timestamp = trim(my_fgets($file)); + + fclose($file); + +} + + + +if(!$timestamp || (time() - $timestamp) > $ftp_interval*60) { + + if ($timestamp) { + + if ($html) echo '

'; + + echo "Last FTP update more than $ftp_interval minutes ago, starting update ($ftp_type): \n"; + + if ($html) echo '

'; + + } + + if ($ftp_debug) { + + if ($html) echo '
'; + + echo "FTP Debugging Output:\n"; + + if ($html) echo '
';
+
+	}
+
+	$ftp = new ftp($ftp_debug, $ftp_debug);
+
+	ftpupdate();
+
+	if ($ftp_debug and $html) echo '

'; + +} else { + + if ($html) echo '

'; + + echo "Last FTP update was ". round(((time() - $timestamp) / 60), 0) ." minutes ago, no update necessary\n"; + + if ($html) echo '

'; + +} + + + +?> \ No newline at end of file diff --git a/html/includes/ftp_class.php b/html/includes/ftp_class.php new file mode 100755 index 0000000..5281379 --- /dev/null +++ b/html/includes/ftp_class.php @@ -0,0 +1,492 @@ + +// http://www.phpclasses.org/browse/package/1743.html +// License: Free for non-commercial use +// + +if(!defined('CRLF')) define('CRLF',"\r\n"); +if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1); +if(!defined("FTP_BINARY")) define("FTP_BINARY", 1); +if(!defined("FTP_ASCII")) define("FTP_ASCII", 0); +if(!defined('FTP_FORCE')) define('FTP_FORCE', TRUE); +define('FTP_OS_Unix','u'); +define('FTP_OS_Windows','w'); +define('FTP_OS_Mac','m'); + +class ftp_base { + /* Public variables */ + var $LocalEcho=FALSE; + var $Verbose=FALSE; + var $OS_local; + var $lastmsg; + + /* Private variables */ + var $_lastaction=NULL; + var $_errors; + var $_type; + var $_umask; + var $_timeout; + var $_passive; + var $_host; + var $_fullhost; + var $_port; + var $_datahost; + var $_dataport; + var $_ftp_control_sock; + var $_ftp_data_sock; + var $_ftp_temp_sock; + var $_login; + var $_password; + var $_connected; + var $_ready; + var $_code; + var $_message; + var $_can_restore; + var $_port_available; + + var $_error_array=array(); + var $AuthorizedTransferMode=array( + FTP_AUTOASCII, + FTP_ASCII, + FTP_BINARY + ); + var $OS_FullName=array( + FTP_OS_Unix => 'UNIX', + FTP_OS_Windows => 'WINDOWS', + FTP_OS_Mac => 'MACOS' + ); + var $NewLineCode=array( + FTP_OS_Unix => "\n", + FTP_OS_Mac => "\r", + FTP_OS_Windows => "\r\n" + ); + var $AutoAsciiExt=array("ASP","BAT","C","CPP","CSV","H","HTM","HTML","SHTML","INI","LOG","PHP","PHP3","PL","PERL","SH","SQL","TXT"); + + /* Constructor */ + function ftp_base($port_mode=FALSE) { + $this->_port_available=($port_mode==TRUE); + $this->SendMSG("Staring FTP client class with".($this->_port_available?"":"out")." PORT mode support"); + $this->_connected=FALSE; + $this->_ready=FALSE; + $this->_can_restore=FALSE; + $this->_code=0; + $this->_message=""; + $this->SetUmask(0022); + $this->SetType(FTP_AUTOASCII); + $this->SetTimeout(30); + $this->Passive(!$this->_port_available); + $this->_login="anonymous"; + $this->_password="anon@ftp.com"; + $this->OS_local=FTP_OS_Unix; + if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows; + elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac; + } + +// +// +// + function parselisting($list) { +// Parses i line like: "drwxrwx--- 2 owner group 4096 Apr 23 14:57 text" + if(preg_match("/^([-ld])([rwxst-]+)\s+(\d+)\s+(\w+)\s+(\w+)\s+(\d+)\s+(\w{3})\s+(\d+)\s+([\:\d]+)\s+(.+)$/i", $list, $ret)) { + $v=array( + "type" => ($ret[1]=="-"?"f":$ret[1]), + "perms" => 0, + "inode" => $ret[3], + "owner" => $ret[4], + "group" => $ret[5], + "size" => $ret[6], + "date" => $ret[7]." ".$ret[8]." ".$ret[9], + "name" => $ret[10] + ); + $v["perms"]+=00400*(int)($ret[2]{0}=="r"); + $v["perms"]+=00200*(int)($ret[2]{1}=="w"); + $v["perms"]+=00100*(int)in_array($ret[2]{2}, array("x","s")); + $v["perms"]+=00040*(int)($ret[2]{3}=="r"); + $v["perms"]+=00020*(int)($ret[2]{4}=="w"); + $v["perms"]+=00010*(int)in_array($ret[2]{5}, array("x","s")); + $v["perms"]+=00004*(int)($ret[2]{6}=="r"); + $v["perms"]+=00002*(int)($ret[2]{7}=="w"); + $v["perms"]+=00001*(int)in_array($ret[2]{8}, array("x","t")); + $v["perms"]+=04000*(int)in_array($ret[2]{2}, array("S","s")); + $v["perms"]+=02000*(int)in_array($ret[2]{5}, array("S","s")); + $v["perms"]+=01000*(int)in_array($ret[2]{8}, array("T","t")); + } + return $v; + } + + function SendMSG($message = "", $crlf=true) { + $this->lastmsg = $message; + if ($this->Verbose) { + echo $message.($crlf?CRLF:""); + flush(); + } + return TRUE; + } + + function SetType($mode=FTP_AUTOASCII) { + if(!in_array($mode, $this->AuthorizedTransferMode)) { + $this->SendMSG("Wrong type"); + return FALSE; + } + $this->_type=$mode; + $this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) ); + return TRUE; + } + + function Passive($pasv=NULL) { + if(is_null($pasv)) $this->_passive=!$this->_passive; + else $this->_passive=$pasv; + if(!$this->_port_available and !$this->_passive) { + $this->SendMSG("Only passive connections available!"); + $this->_passive=TRUE; + return FALSE; + } + $this->SendMSG("Passive mode ".($this->_passive?"on":"off")); + return TRUE; + } + + function SetServer($host, $port=21, $reconnect=true) { + global $ftp_debug; + if ($ftp_debug) { + $this->verbose=true; + $this->SendMSG("Connect to:
\n- Server: $host
\n- Port: $port
\n"); + $this->verbose=false; + } + $port = intval($port); + if(!is_long($port)) { + $this->verbose=true; + $this->SendMSG("Incorrect port syntax"); + return FALSE; + } else { + $ip=@gethostbyname($host); + $dns=@gethostbyaddr($host); + if(!$ip) $ip=$host; + if(!$dns) $dns=$host; + if(ip2long($ip) === -1) { + $this->SendMSG("Wrong host name/address \"".$host."\""); + return FALSE; + } + $this->_host=$ip; + $this->_fullhost=$dns; + $this->_port=$port; + $this->_dataport=$port-1; + } + $this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\""); + if($reconnect){ + if($this->_connected) { + $this->SendMSG("Reconnecting"); + if(!$this->quit(FTP_FORCE)) return FALSE; + if(!$this->connect()) return FALSE; + } + } + return TRUE; + } + + function SetUmask($umask=0022) { + $this->_umask=$umask; + umask($this->_umask); + $this->SendMSG("UMASK 0".decoct($this->_umask)); + return TRUE; + } + + function SetTimeout($timeout=30) { + $this->_timeout=$timeout; + $this->SendMSG("Timeout ".$this->_timeout); + if($this->_connected) + if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE; + return TRUE; + } + + function connect() { + $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]); + if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) { + $this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\""); + return FALSE; + } + $this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting."); + do { + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + $this->_lastaction=time(); + } while($this->_code<200); + $this->_ready=true; + return TRUE; + } + + function quit($force=false) { + if($this->_ready) { + if(!$this->_exec("QUIT") and !$force) return FALSE; + if(!$this->_checkCode() and !$force) return FALSE; + $this->_ready=false; + $this->SendMSG("Session finished"); + } + $this->_quit(); + return TRUE; + } + + function login($user=NULL, $pass=NULL) { + if(!is_null($user)) $this->_login=$user; + else $this->_login="anonymous"; + if(!is_null($pass)) $this->_password=$pass; + else $this->_password="anon@anon.com"; + if(!$this->_exec("USER ".$this->_login, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code!=230) { + if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } + $this->SendMSG("Authentication succeeded"); + $this->_can_restore=$this->restore(100); + $this->SendMSG("This server can".($this->_can_restore?"":"'t")." resume broken uploads/downloads"); + return TRUE; + } + + function pwd() { + if(!$this->_exec("PWD", "pwd")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return ereg_replace("^[0-9]{3} \"(.+)\" .+".CRLF, "\\1", $this->_message); + } + + function cdup() { + if(!$this->_exec("CDUP", "cdup")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return true; + } + + function chdir($pathname) { + if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rmdir($pathname) { + if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function mkdir($pathname) { + if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function rename($from, $to) { + if(!$this->_exec("RNFR ".$from, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($this->_code==350) { + if(!$this->_exec("RNTO ".$to, "rename")) return FALSE; + if(!$this->_checkCode()) return FALSE; + } else return FALSE; + return TRUE; + } + + function filesize($pathname) { + if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); + } + + function mdtm($pathname) { + if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $mdtm = ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message); + $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d"); + $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]); + return $timestamp; + } + + function systype() { + if(!$this->_exec("SYST", "systype")) return FALSE; + if(!$this->_checkCode()) return FALSE; + $DATA = explode(" ", $this->_message); + return $DATA[1]; + } + + function delete($pathname) { + if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function site($command, $fnction="site") { + if(!$this->_exec("SITE ".$command, $fnction)) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function chmod($pathname, $mode) { + if(!$this->site("CHMOD ".decoct($mode)." ".$pathname, "chmod")) return FALSE; + return TRUE; + } + + function restore($from) { + if(!$this->_exec("REST ".$from, "resore")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return TRUE; + } + + function features() { + if(!$this->_exec("FEAT", "features")) return FALSE; + if(!$this->_checkCode()) return FALSE; + return preg_split("/[".CRLF."]+/", ereg_replace("[0-9]{3}[ -][^".CRLF."]*".CRLF, "", $this->_message), -1, PREG_SPLIT_NO_EMPTY); + } + + function rawlist($arg="", $pathname="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist"); + } + + function nlist($arg="", $pathname="") { + return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist"); + } + + function is_exists($pathname) + { + if (!($remote_list = $this->nlist("-a", dirname($pathname)))) { + $this->SendMSG("Error : Cannot get remote file list"); + return -1; + } + reset($remote_list); + while (list(,$value) = each($remote_list)) { + if ($value == basename($pathname)) { + $this->SendMSG("Remote file ".$pathname." exists"); + return TRUE; + } + } + $this->SendMSG("Remote file ".$pathname." does not exist"); + return FALSE; + } + + function get($remotefile, $localfile=NULL) { + if(is_null($localfile)) $localfile=$remotefile; + if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten"); + $fp = @fopen($localfile, "w"); + if (!$fp) { + $this->PushError("get","can't open local file", "Cannot create \"".$localfile."\""); + return FALSE; + } + $pi=pathinfo($remotefile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore) $this->restore(0); + if(!$this->_exec("RETR ".$remotefile, "get")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $out=$this->_data_read($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $out; + } + + function put($localfile, $remotefile=NULL) { + if(is_null($remotefile)) $remotefile=$localfile; + if (!@file_exists($localfile)) { + $this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\""); + return FALSE; + } + $fp = @fopen($localfile, "r"); + if (!$fp) { + $this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\""); + return FALSE; + } + $pi=pathinfo($localfile); + if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII; + else $mode=FTP_BINARY; + if(!$this->_data_prepare($mode)) { + fclose($fp); + return FALSE; + } + if($this->_can_restore) $this->restore(0); + if(!$this->_exec("STOR ".$remotefile, "put")) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + if(!$this->_checkCode()) { + $this->_data_close(); + fclose($fp); + return FALSE; + } + $ret=$this->_data_write($mode, $fp); + fclose($fp); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + return $ret; + } + +// +// +// + function _checkCode() { + return ($this->_code<400 and $this->_code>0); + } + + function _list($arg="", $cmd="LIST", $fnction="_list") { + if(!$this->_data_prepare()) return FALSE; + if(!$this->_exec($cmd.$arg, $fnction)) { + $this->_data_close(); + return FALSE; + } + if($this->_code == 450 and $cmd == "NLST") return(array()); + if(!$this->_checkCode()) { + $this->_data_close(); + return FALSE; + } + $out=$this->_data_read(); + $this->_data_close(); + if(!$this->_readmsg()) return FALSE; + if(!$this->_checkCode()) return FALSE; + if($out === FALSE ) return FALSE; + $out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY); + $this->SendMSG(implode($this->NewLineCode[$this->OS_local], $out)); + return $out; + } + +// +// +// +// G�n�re une erreur pour traitement externe � la classe + function PushError($fctname,$msg,$desc=false){ + $error=array(); + $error['time']=time(); + $error['fctname']=$fctname; + $error['msg']=$msg; + $error['desc']=$desc; + if($desc) $tmp=' ('.$desc.')'; else $tmp=''; + $this->SendMSG($fctname.': '.$msg.$tmp); + return(array_push($this->_error_array,$error)); + } + +// R�cup�re une erreur externe + function PopError(){ + if(count($this->_error_array)) return(array_pop($this->_error_array)); + else return(false); + } +} + +if (isset($ftp_type) and $ftp_type == 'pure') { + require_once "ftp_class_pure.php"; +} else { + $mod_sockets=TRUE; + if (!extension_loaded('sockets')) { + $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : ''; + if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE; + } + require_once "ftp_class_".($mod_sockets?"sockets":"pure").".php"; +} +?> \ No newline at end of file diff --git a/html/includes/ftp_class_native.php b/html/includes/ftp_class_native.php new file mode 100755 index 0000000..4f7f1df --- /dev/null +++ b/html/includes/ftp_class_native.php @@ -0,0 +1,142 @@ +lastmsg = "Incorrect port syntax"; + return(false); + } else { + $ip=@gethostbyname($host); + $dns=@gethostbyaddr($host); + if(!$ip) $ip = $host; + if(!$dns) $dns = $host; + if(ip2long($ip) === -1) { + $this->lastmsg("Wrong host name/address \"".$host."\""); + return(false); + } + $this->host = $ip; + $this->fullhost = $dns; + $this->port = $port; + } + return(true); + } + + function connect() { + $php_erormsg = ''; + if (!check_extension('ftp') or true) { + $this->lastmsg = "No FTP support in this php build!"; + return(false); + } + $this->fp = @ftp_connect($this->host, $this->port, 30); + if (!$this->fp) { + $this->lastmsg = $php_errormsg; + return(false); + } + return(true); + } + + function login($user, $pass) { + $php_errormsg = ''; + if (!@ftp_login($this->fp, $user, $pass)) { + $this->lastmsg = $php_errormsg; + return(false); + } + return(true); + } + + function SetType($transfertype) { + $this->transfertype = $transfertype; + return(true); + } + + function Passive($pasv) { + $php_errormsg = ''; + if (!@ftp_pasv($this->fp, $pasv)) { + $this->lastmsg = $php_errormsg; + return(false); + } + return(true); + } + + function pwd() { + $php_errormsg = ''; + if (!($res = @ftp_pwd($this->fp))) { + $this->lastmsg = $php_errormsg; + return(false); + } + return($res); + } + + function chdir($dir) { + $php_errormsg = ''; + if (!@ftp_chdir($this->fp, $dir)) { + $this->lastmsg = $php_errormsg; + return(false); + } + return(true); + } + + function nlist() { + $php_errormsg = ''; + if (!($res = @ftp_nlist($this->fp, '.'))) { + $this->lastmsg = $php_errormsg; + return(false); + } + return($res); + } + + function get($remotefile, $localfile) { + $php_errormsg = ''; + if (!@ftp_get($this->fp, $localfile, $remotefile, $this->transfertype)) { + $this->lastmsg = $php_errormsg; + $this->PushError('get', "Unable to download $remotefile", $php_errormsg); + return(false); + } + return(filesize($localfile)); + } + + function delete($remotefile) { + $php_errormsg = ''; + if (!@ftp_delete($this->fp, $remotefile)) { + $this->lastmsg = $php_errormsg; + return(false); + } + return(true); + } + + + function quit() { + if ($this->fp) { + ftp_close($this->fp); + $this->fp = NULL; + } + return(true); + } + + + function PushError($fctname, $msg, $desc=false){ + $error=array(); + $error['time']=time(); + $error['fctname']=$fctname; + $error['msg']=$msg; + $error['desc']=$desc; + if($desc) $tmp=' ('.$desc.')'; else $tmp=''; + return(array_push($this->errors,$error)); + } + + function PopError(){ + if(count($this->errors)) return(array_pop($this->_error_array)); + else return(false); + } + + + +} diff --git a/html/includes/ftp_class_pure.php b/html/includes/ftp_class_pure.php new file mode 100755 index 0000000..e7806db --- /dev/null +++ b/html/includes/ftp_class_pure.php @@ -0,0 +1,192 @@ + +// http://www.phpclasses.org/browse/package/1743.html +// License: Free for non-commercial use +// + + +class ftp extends ftp_base { + function ftp($verb=FALSE, $le=FALSE) { + $this->LocalEcho = $le; + $this->Verbose = $verb; + $this->ftp_base(); + } + +// +// +// + + function _settimeout($sock) { + if(!@stream_set_timeout($sock, $this->_timeout)) { + $this->PushError('_settimeout','socket set send timeout'); + $this->_quit(); + return FALSE; + } + return TRUE; + } + + function _connect($host, $port) { + $this->SendMSG("NOT using PHP's socket extension"); + $this->SendMSG("Creating socket"); + $sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); + if (!$sock) { + $this->PushError('_connect','socket connect failed', $errstr." (".$errno.")"); + return FALSE; + } + $this->_connected=true; + return $sock; + } + + function _readmsg($fnction="_readmsg"){ + if(!$this->_connected) { + $this->PushError($fnction, 'Connect first'); + return FALSE; + } + $result=true; + $this->_message=""; + $this->_code=0; + $go=true; + do { + $tmp=@my_fgets($this->_ftp_control_sock, 512); + if($tmp===false) { + $go=$result=false; + $this->PushError($fnction,'Read failed'); + } else { + $this->_message.=$tmp; +// for($i=0; $i_message); $i++) +//