function __construct($prefix) { if (!is_dir(DATA_DIR . '/kvstore/')) { utils::mkdir_p(DATA_DIR . '/kvstore/'); } $this->rs = dba_popen(DATA_DIR . '/kvstore/dba.db', 'c'); }
private function _get_prev_pathname() { if (!is_dir(TMP_DIR)) { utils::mkdir_p(TMP_DIR); } return TMP_DIR . '/' . $this->get_prev_key() . '.chdb'; }
function __construct() { $this->dir = ROOT_DIR . '/data/search/zend/lucene/'; if (!is_dir($this->dir)) { utils::mkdir_p($this->dir, 0777, true); } }
function save($project) { if (!is_dir(DATA_DIR . '/projects')) { utils::mkdir_p(DATA_DIR . '/projects'); } file_put_contents(DATA_DIR . '/projects/' . $project['createtime'] . '.php', '<?php $project = ' . var_export($project, 1) . ';'); }
function __construct() { $workat = DATA_DIR . '/cache'; if (!is_dir($workat)) { utils::mkdir_p($workat); } $this->workat($workat . '/filecache'); }
function __construct() { $workat = DATA_DIR . '/cache'; $this->secache_size = config::get('cache.base_cache_secache.size', '15M'); if (!is_dir($workat)) { utils::mkdir_p($workat); } $this->workat($workat . '/secache'); }
function __construct() { $workat = DATA_DIR . '/cache'; if (!is_dir($workat)) { utils::mkdir_p($workat); } $this->workat($workat . '/secache'); $this->check_vary_list(); }
function export($app_id, $path) { if (!file_exists(ROOT_DIR . "/app/{$app_id}/app.xml")) { return; } utils::mkdir_p("{$path}/refs"); $this->update_index($app_id, $path); $this->update_appinfo($app_id, $path); $this->update_servicelib($app_id, $path); $this->update_dbschema($app_id, $path); }
public function post_install() { logger::info('Initial ectools'); kernel::single('base_initial', 'ectools')->init(); logger::info('Initial Regions'); kernel::single('ectools_regions_mainland')->install(); if (!is_dir(DATA_DIR . '/misc')) { utils::mkdir_p(DATA_DIR . '/misc'); } utils::cp(app::get('ectools')->res_dir . '/js/region_data.js', DATA_DIR . '/misc/region_data.js'); }
private function write_log($title = '', $class_name = 'b2c_api_callback_app', $request_method_name = 'rpc_request', $data = array()) { if ($data) { $log_file = DATA_DIR . '/logs/b2c/request/{date}/api_request.php'; $logfile = str_replace('{date}', date("Ymd"), $log_file); //$logfile = DATA_DIR.'/logs/b2c/request/api_request.xml'; if (!file_exists($logfile)) { if (!is_dir(dirname($logfile))) { utils::mkdir_p(dirname($logfile)); } $fs = fopen($logfile, 'w'); $str_xml = "<?php exit(0);"; $str_xml .= "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; $str_xml .= "<request>"; $str_xml .= "</request>';"; //error_log(print_r($str_xml,true),3,$logfile); fwrite($fs, $str_xml); fclose($fs); } $arr_data = array('method' => $data[0], 'params' => $data[1], 'rpc_callback' => $data[2]); // 记录api日志 if (filesize($logfile)) { $fs = fopen($logfile, 'a+'); $str_xml = fread($fs, filesize($logfile)); $str_xml = substr($str_xml, 0, strlen($str_xml) - 12); fclose($fs); } $fs = fopen($logfile, 'w'); $str_xml .= "<query>"; $str_xml .= "<method>" . $arr_data['method'] . "</method>"; $str_xml .= "<params>" . print_r($arr_data['params'], true) . "</params>"; $str_xml .= "<rpc_callback>"; foreach ($arr_data['rpc_callback'] as $key => $value) { $str_xml .= "<{$key}>" . $value . "</{$key}>"; } $str_xml .= "</rpc_callback></query>"; $str_xml .= "</request>';"; fwrite($fs, $str_xml); fclose($fs); //error_log(print_r($str_xml,true),3,$logfile); } }
static function extra($file, $dir) { $filename = $dir . '/' . $file['name']; $dirname = dirname($filename); if (!file_exists($dirname)) { utils::mkdir_p($dirname); } if ($file['type'] == '0') { fseek($file['rs'], $file['offset']); $rs = fopen($filename, 'w'); $output = 0; while ($output < $file['size']) { $read = min($file['size'] - $output, 1024); fputs($rs, fread($file['rs'], $read)); $output += $read; } fclose($rs); touch($filename, $file['mtime']); } }
function setting($pkey) { if (!$pkey) { return false; } if ($_POST['setting']) { $this->begin('javascript:finderGroup["' . $_POST['finder_id'] . '"].refresh();'); $payment = new $pkey($this->app); $setting = $payment->setting(); foreach ($setting as $key => $setting_item) { if ($setting_item['type'] == 'pecentage') { $_POST['setting'][$key] = $_POST['setting'][$key] * 0.01; } } $data['setting'] = $_POST['setting']; $data['status'] = $_POST['status']; $data['pay_type'] = $_POST['pay_type']; $data['platform'] = $_POST['platform']; //支付平台 // 是否有文件上传 if ($_FILES) { $pos = strpos($pkey, '_'); $bankName = substr($pkey, $pos + 1); $destination = DATA_DIR . '/cert/' . $bankName; if (!file_exists($destination)) { utils::mkdir_p($destination, 0755); } foreach ($_FILES['setting']['error'] as $evalue) { if ($evalue == UPLOAD_ERR_OK) { foreach ($_FILES['setting']['name'] as $nkey => $nvalue) { $data['setting'][$nkey] = $nvalue; foreach ($_FILES['setting']['tmp_name'] as $tkey => $tvalue) { if (is_uploaded_file($tvalue)) { if ($nkey == $tkey) { $destination = DATA_DIR . '/cert/' . $bankName . '/' . $nvalue; move_uploaded_file($tvalue, $destination); } } } } } } } $this->app->setConf($pkey, serialize($data)); $this->end(true, app::get('ectools')->_('支付方式修改成功!')); } else { $payment = new $pkey($this->app); $setting = $payment->setting(); if ($setting) { $val = $this->app->getConf($pkey); $val = unserialize($val); $render = $this->app->render(); $render->pagedata['admin_info'] = $payment->admin_intro(); $render->pagedata['settings'] = $setting; foreach ($setting as $k => $v) { $render->pagedata['settings'][$k]['value'] = $val['setting'][$k] ? $val['setting'][$k] : $val[$k]; if ($v['type'] == 'pecentage') { $render->pagedata['settings'][$k]['value'] = $render->pagedata['settings'][$k]['value'] * 100; } if (strpos($v['type'], 'cur') !== false) { // 得到所有的货币 $currency_mdl = $this->app->model('currency'); $arr_curs = $currency_mdl->getSysCur(false, '', false); foreach ($arr_curs as &$str_currency) { if (strpos($str_currency, ',') !== false) { $str_currency = substr($str_currency, strpos($str_currency, ',') + 3); } } if ($payment->supportCurrency) { foreach ($payment->supportCurrency as $key => $str_support_cur) { $render->pagedata['settings'][$k]['cur_value'] .= $arr_curs[$key]; } } } } $render->pagedata['classname'] = $pkey; $render->display('payments/cfgs/cfgs.html'); } else { echo '<div class="note">' . app::get("ectools")->_("不需要设置参数") . '</div>'; } } }
public function download($app_id, $force = false) { $download_able = $force; if (!$download_able) { $download_able = !file_exists(APP_DIR . '/' . $app_id . '/app.xml'); if (!$download_able) { $rows = app::get('base')->model('apps')->getList('app_id,local_ver,remote_ver', array('app_id' => $app_id), 0, 1); $download_able = $rows[0]['local_ver'] ? version_compare($rows[0]['remote_ver'], $rows[0]['local_ver'], '>') : true; } } if ($download_able) { $tmpfile = tempnam(TMP_DIR, 'app_'); $tmpdir = tempnam(TMP_DIR, 'app_'); $download_result = kernel::single('base_pget')->dl(sprintf(URL_APP_FETCH, $app_id), $tmpfile); if (!$download_result) { logger::info('Appliction [' . $app_id . '] download failed.'); exit; } $broken = false; logger::info("\nExtra from package."); foreach (base_package::walk($tmpfile) as $file) { if (!$file) { $broken = true; break; } logger::info($file['name']); base_package::extra($file, $tmpdir); } if (!$broken && file_exists($tmpdir . '/app.xml')) { if (!is_dir(DATA_DIR . '/backup')) { utils::mkdir_p(DATA_DIR . '/backup'); } utils::cp(APP_DIR . '/' . $app_id, DATA_DIR . '/backup/app.' . $app_id . '.' . time()); utils::remove_p(APP_DIR . '/' . $app_id); utils::cp($tmpdir, APP_DIR . '/' . $app_id); utils::remove_p($tmpdir); $this->update_local_app_info($app_id); return true; } else { utils::remove_p($tmpdir); return false; } } }
private function check_dir() { if (!is_dir(ROOT_DIR . '/data/kvstore/' . $this->prefix)) { utils::mkdir_p(ROOT_DIR . '/data/kvstore/' . $this->prefix); } }
function __construct($prefix) { if (!is_dir(DATA_DIR . '/kvstore/')) { utils::mkdir_p(DATA_DIR . '/kvstore/'); } }
private function _get_key_filepath($type = 'pub') { $mer_id = $this->getConf('mer_id', __CLASS__); if (!is_dir(TMP_DIR)) { utils::mkdir_p(TMP_DIR); } return TMP_DIR . '/chinapay_cert_' . $mer_id . '_' . $type . '.key'; }
static function log($message, $keepline = false) { if (self::$console_output) { if ($keepline) { echo $message; } else { echo $message = $message . "\n"; } } else { //modify by edwin.lzh@gmail.com 2010/6/10 $message = sprintf("%s\t%s\n", date("Y-m-d H:i:s"), $message); switch (LOG_TYPE) { case 3: if (defined('LOG_FILE')) { $logfile = str_replace('{date}', date("Ymd"), LOG_FILE); $ip = $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1'; $ip = str_replace(array('.', ':'), array('_', '_'), $ip); $logfile = str_replace('{ip}', $ip, $logfile); } else { $logfile = DATA_DIR . '/logs/all.php'; } if (!is_file($logfile)) { if (!is_dir(dirname($logfile))) { utils::mkdir_p(dirname($logfile)); } file_put_contents($logfile, defined(LOG_HEAD_TEXT) ? LOG_HEAD_TEXT : '<' . '?php exit()?' . ">\n"); } @error_log($message, 3, $logfile); break; case 0: default: @error_log($message, 0); } //End Switch } }
public static function log($message, $log_level = LOG_SYS_INFO) { self::__init(); if (kernel::$console_output) { if ($log_level < LOG_SYS_DEBUG) { echo $message = $message . "\n"; } } if ($log_level <= self::$__log_level) { $message = sprintf("%s\t%s\t%s\n", date("Y-m-d H:i:s"), self::$__log_levels[$log_level], $message); switch (LOG_TYPE) { case 3: if (defined('LOG_FILE')) { $logfile = str_replace('{date}', date("Ymd"), LOG_FILE); $ip = $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1'; $ip = str_replace(array('.', ':'), array('_', '_'), $ip); $logfile = str_replace('{ip}', $ip, $logfile); } else { $logfile = DATA_DIR . '/logs/all.php'; } if (!file_exists($logfile)) { if (!is_dir(dirname($logfile))) { utils::mkdir_p(dirname($logfile)); } file_put_contents($logfile, defined(LOG_HEAD_TEXT) ? LOG_HEAD_TEXT : '<' . '?php exit()?' . ">\n"); } @error_log($message, 3, $logfile); break; case 2: @error_log($message, 0); case 0: default: @syslog($log_level, $message); } //End Switch } }
public function check_dir() { if (!is_dir(WAP_THEME_DIR)) { utils::mkdir_p(WAP_THEME_DIR); } }
/** * 更新region控件JS数据. * * @reutrn boolean */ public function updateRegionData() { $this->getAllRegions(); $this->regions = (array) $this->regions; $regions = array(); foreach ($this->regions as $v) { $regions[] = $v; } unset($this->regions); // 文件数据 if (!is_dir(DATA_DIR . '/misc')) { utils::mkdir_p(DATA_DIR . '/misc'); } $script = 'var REGION_DATA=' . json_encode($regions) . ';'; $filename = DATA_DIR . '/misc/region_data.js'; $handle = fopen($filename, 'w'); if (!$handle) { fclose($handle); return false; } if (!fwrite($handle, $script)) { fclose($handle); return false; } fclose($handle); return true; }
function setting($pkey) { if (!$pkey) { return false; } if ($_POST['setting']) { $this->begin('javascript:finderGroup["' . $_POST['finder_id'] . '"].refresh();'); $payment = new $pkey($this->app); $setting = $payment->setting(); foreach ($setting as $key => $setting_item) { if ($setting_item['type'] == 'pecentage') { $_POST['setting'][$key] = $_POST['setting'][$key] * 0.01; } } $data['setting'] = $_POST['setting']; $data['status'] = $_POST['status']; $data['pay_type'] = $_POST['pay_type']; $data['platform'] = $_POST['platform']; //支付平台 // 是否有文件上传 if ($_FILES) { $pos = strpos($pkey, '_'); $bankName = substr($pkey, $pos + 1); $destination = DATA_DIR . '/cert/' . $bankName; if (!file_exists($destination)) { utils::mkdir_p($destination, 0755); } foreach ($_FILES['setting']['error'] as $evalue) { if ($evalue == UPLOAD_ERR_OK) { foreach ($_FILES['setting']['name'] as $nkey => $nvalue) { $data['setting'][$nkey] = $nvalue; foreach ($_FILES['setting']['tmp_name'] as $tkey => $tvalue) { if (is_uploaded_file($tvalue)) { if ($nkey == $tkey) { $destination = DATA_DIR . '/cert/' . $bankName . '/' . $nvalue; move_uploaded_file($tvalue, $destination); } } } } } else { $val = app::get('ectools')->getConf($pkey); $val = unserialize($val); foreach ($_FILES['setting']['name'] as $nkey => $nvalue) { $data['setting'][$nkey] = $val['setting'][$nkey]; } } } } $this->app->setConf($pkey, serialize($data)); $this->adminlog("修改支付方式配置[{$data['pay_type']}]", 1); $this->end(true, app::get('ectools')->_('支付方式修改成功!')); } else { $payment = new $pkey($this->app); $setting = $payment->setting(); if ($setting) { $val = $this->app->getConf($pkey); $val = unserialize($val); $pagedata['admin_info'] = $payment->admin_intro(); $pagedata['settings'] = $setting; foreach ($setting as $k => $v) { $pagedata['settings'][$k]['value'] = $val['setting'][$k] ? $val['setting'][$k] : $val[$k]; if ($v['type'] == 'pecentage') { $pagedata['settings'][$k]['value'] = $pagedata['settings'][$k]['value'] * 100; } if (strpos($v['type'], 'cur') !== false) { if ($payment->supportCurrency) { foreach ($payment->supportCurrency as $key => $str_support_cur) { $pagedata['settings'][$k]['cur_value'] .= $arr_curs[$key]; } } } if ($k == 'ConnectType' && $v['extendcontent'][0]['value']) { foreach ($v['extendcontent'][0]['value'] as $keyonebank => $valueonebank) { if (in_array($valueonebank['value'], $val['setting'][$v['extendcontent'][0]['property']['name']])) { $pagedata['settings'][$k]['extendcontent'][0]['value'][$keyonebank]['checked'] = "checked"; } } } } $pagedata['classname'] = $pkey; $pagedata['app_id'] = substr($pkey, 0, strpos($pkey, '_')); $pagedata['payment_id'] = isset($payment->app_rpc_key) && $payment->app_rpc_key ? $payment->app_rpc_key : $payment->app_key; return view::make('ectools/payments/cfgs/cfgs.html', $pagedata); } else { return '<div class="note">' . app::get("ectools")->_("不需要设置参数") . '</div>'; } } }
public static function log($message, $log_level = LOG_SYS_INFO) { self::__init(); if (vmc::$console_output) { if ($log_level < LOG_SYS_DEBUG) { echo $message = $message . "\n"; } } if ($log_level <= self::$__log_level) { //日志格式:时间 日志内容 日志级别标示 $ip = base_request::get_remote_addr(); $message = sprintf("%s\t%s\t%s\t%s\n", $ip, date("Y-m-d H:i:s"), self::$__log_levels[$log_level], $message); switch (LOG_TYPE) { case 3: if (defined('LOG_FILENAME')) { $logfilename = str_replace('{date}', date("Ymd"), LOG_FILENAME); $logfilename = str_replace('{hour}', date("H"), $logfilename); $logfilename = str_replace('{level}', self::$__log_levels[$log_level], $logfilename); } else { $logfilename = date("YmdH") . '.php'; } if (defined('LOG_DIR')) { $logfile = LOG_DIR . '/' . $logfilename; } else { $logfile = DATA_DIR . '/logs/' . $logfilename; } if (!file_exists($logfile)) { if (!is_dir(dirname($logfile))) { utils::mkdir_p(dirname($logfile)); } file_put_contents($logfile, defined(LOG_HEAD_TEXT) ? LOG_HEAD_TEXT : '<' . '?php exit()?' . ">\n"); } @error_log($message, 3, $logfile); break; case 2: @error_log($message, 0); case 0: default: @syslog($log_level, $message); } //End Switch } }
private function check_dir() { if (!is_dir(DATA_DIR . '/kvstore/' . $this->prefix)) { utils::mkdir_p(DATA_DIR . '/kvstore/' . $this->prefix); } }