function threads_create($threads, $copy_files, $create_files, $run_files, $implode_files = array()) { $cfs = array(); foreach ($create_files as $fname => $content) { if (!is_array($content)) { $content = file2array($fname); } else { } $cfs[$fname] = array_rand_slice($content, $threads); } $bat = "#!/bin/bash\n"; $tdir = 'threads-' . randstr(5); mkdir($tdir); chdir($tdir); for ($i = 0; $i < $threads; $i++) { $dir = 'thread' . $i; mkdir($dir); $bat .= $i ? "cd ../{$dir}\n" : "cd {$dir}\n"; foreach ($copy_files as $fname_from => $fname) { if (!is_string($fname_from)) { $fname_from = $fname; } copy('../' . $fname_from, $dir . '/' . $fname); } foreach (array_keys($cfs) as $fname) { file_put_contents($dir . '/' . $fname, str_replace("\n\n", "\n", implode("\n", $cfs[$fname][$i]))); } foreach ($run_files as $fname => $params) { $bat .= "php {$fname} {$params} & \n"; } } file_put_contents('run.sh', $bat); chmod('run.sh', 0777); /* exec('./run.sh'); unlink('run.sh'); foreach( $implode_files as $if ) { $contents = array(); for( $i = 0; $i < $threads; $i++ ) { $contents []= trim( file_get_contents( 'thread' . $i . "/" . $if ) ); } file_put_contents( "../$if", implode( "\n", $contents ), FILE_APPEND ); } for( $i = 0; $i < $threads; $i++ ) { $dir = 'thread' . $i; foreach( array_merge( array_keys( $cfs ), array_keys( $copy_files ) ) as $fname ) unlink( $dir . '/' . $fname ); rmdir( $dir ); } rmdir( $tdir );*/ }
// $charsets['UTF-8'] = $lang->phrase('admin_charset_utf8'); $charsets['cp1252'] = $lang->phrase('admin_charset_cp1252'); if (version_compare(PHP_VERSION, '4.3.2', '>=')) { $charsets['cp866'] = $lang->phrase('admin_charset_cp866'); $charsets['cp1251'] = $lang->phrase('admin_charset_cp1251'); $charsets['KOI8-R'] = $lang->phrase('admin_charset_koi8r'); } $charsets['BIG5'] = $lang->phrase('admin_charset_big5'); $charsets['GB2312'] = $lang->phrase('admin_charset_gb2312'); $charsets['BIG5-HKSCS'] = $lang->phrase('admin_charset_big5hkscs'); $charsets['Shift_JIS'] = $lang->phrase('admin_charset_shiftjis'); $charsets['EUC-JP'] = $lang->phrase('admin_charset_eucjp'); $settings['charset'] = isset($settings['charset']) ? $settings['charset'] : $config['asia_charset']; $rss = file2array('admin/data/rss.txt'); $languages = file2array('admin/data/iso639.txt'); $country = file2array('admin/data/iso3166.txt'); ?> <script language="JavaScript"> <!-- function errordefault(box) { alert($lang->phrase('admin_lang_cannot_unpublish_until_defined_other_lang')); box.checked = true; return false; } --> </script> <form name="form" method="post" action="admin.php?action=language&job=lang_settings2&id=<?php echo $id; ?> "> <table class="border" border="0" cellspacing="0" cellpadding="4">
if (!file_exists($path)) { error('admin.php?action=language&job=lang_emails&id=' . $id, "The specified file does not exist: {$path}"); } $tpl = $gpc->get('tpl', none); $title = $gpc->get('title', none); $xml = "<mail>\n\t<title>{$title}</title>\n\t<comment>{$tpl}</comment>\n</mail>"; $filesystem->file_put_contents($path, $xml); ok('admin.php?action=language&job=lang_emails&id=' . $id); } elseif ($job == 'lang_emails') { echo head(); $id = $gpc->get('id', int); $path = "language/{$id}/mails/"; if (!is_dir($path)) { $filesystem->mkdir($path, 0777); } $help = file2array('admin/data/lang_email.php', "\t"); ?> <table class="border" border="0" cellspacing="0" cellpadding="4" align="center"> <tr> <td class="obox">Edit language file » e-mail-texts</td> </tr> <tr> <td class="mbox"> <ul> <?php $i = 0; $result = opendir($path); while (($file = readdir($result)) !== false) { $info = pathinfo($path . $file); if ($info['extension'] == 'php') { $n = substr($info['basename'], 0, -(strlen($info['extension']) + ($info['extension'] == '' ? 0 : 1)));
function Update_RuCenter_City_IP() { global $DB; set_time_limit(0); /*CONFIG*/ /*remote*/ $ip_file_name = 'geo_files.tar.gz'; $ip_file_path = 'http://ipgeobase.ru/files/db/Main'; $ip_file_url = $ip_file_path.'/'.$ip_file_name; $ip_file_encode = "UTF-8"; //!important /*local*/ $ipgeobase_path = $_SERVER["DOCUMENT_ROOT"].'/upload/ipgeobase'; $tmp_path = $ipgeobase_path.'/tmp'; global $log_path; $log_path = $ipgeobase_path.'/log'; $tmp_tar_file = $tmp_path.'/'.$ip_file_name; $ip_tmp_file = $tmp_path.'/cidr_optim.txt'; $mysql_ranges_table = 'rucenter_ranges'; /*LOGIC*/ MyAddMessage2Log('Script started', true); //wget - will overwrite original file if the size or timestamp change MyAddMessage2Log('Trying to wget '.$ip_file_url); system('wget -N -P '.$tmp_path.' '.$ip_file_url.' -o '.$log_path.'/wget.log'); $wget_log = file($log_path.'/wget.log'); $success_download = false; foreach($wget_log as $row) { if(strpos($row, "SUCCESS")!==false || strpos($row, "saved")!==false) { $success_download = true; MyAddMessage2Log("Wget was succesefull!"); } } //parse & import to mysql if($success_download) { MyAddMessage2Log("Begin to untar ".$tmp_tar_file.' to '.$tmp_path); system('tar -C '.$tmp_path.' -xzvf '.$tmp_tar_file.' > '.$log_path.'/tar.log'); //untar if(file_exists($ip_tmp_file)) { //parse IP's from file to array $arIP = file2array($ip_tmp_file, $ip_file_encode); if(is_array($arIP) && count($arIP)) { MyAddMessage2Log('IP range file parse to array - OK. Begin import to MySQL'); $DB->Query("TRUNCATE TABLE ".$mysql_ranges_table); //delete old data foreach($arIP as $arItem) { $query = " INSERT INTO ".$mysql_ranges_table."( IP_INT_FROM, IP_INT_TO, IP_RANGE, COUNTRY_ID, CITY_ID ) VALUES( '".trim($arItem[0])."', '".trim($arItem[1])."', '".trim($arItem[2])."', '".trim($arItem[3])."', '".(intval(trim($arItem[4])) > 0 ? $arItem[4] : "")."' ) "; $DB->Query($query); } MyAddMessage2Log('IP ranges MySQL import - OK.'); unset($arIP); unlink($ip_tmp_file); } else { MyAddMessage2Log('Couldn\'t parse array from '.$ip_tmp_file); } } else { MyAddMessage2Log($ip_tmp_file.' doesnt exist. Check '.$tmp_tar_file); } } else { MyAddMessage2Log('Wget failed or file didnt changed. See '.$log_path.'/wget.log for details.'); } MyAddMessage2Log('Done!'); }
<?php /** * [Amu!] * * 版权所有 违者必究 * * $Id: cost.inc.php 2010年10月10日 20:14:41 amu $ */ if (!defined('IN_DISCUZ')) { exit('Access Denied'); } $file = './data/plugindata/dsu_amusign.data.php'; $daysarray = array(); if (file_exists($file)) { $data_f2a = file2array($file); $data_f2a = dstripslashes($data_f2a); //print_r($data_f2a); foreach ($data_f2a as $id => $result) { $price_php[$result['days']] = $price_htm[$id] = intval($result['days'] * $result['daycost']); $daysarray[] = $result['days']; } } //折扣设置 //入库数据的预处理 $_G['gp_uid'] = $getuid = intval($_G['gp_uid']); $_G['gp_days'] = intval($_G['gp_days']); $_G['gp_time'] = intval($_G['timestamp']); //获取语言包 require './data/plugindata/dsu_amusign.lang.php'; //获取购买积分