本文整理汇总了PHP中hg_file_write函数的典型用法代码示例。如果您正苦于以下问题:PHP hg_file_write函数的具体用法?PHP hg_file_write怎么用?PHP hg_file_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hg_file_write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log2file
function log2file($user, $level, $message, $input, $output = array())
{
if (!LOG_LEVEL) {
return;
}
if (LOG_FOR_USER != 'ALL' && $user['user_name'] != LOG_FOR_USER) {
return;
}
$level = strtoupper($level);
$log_level = array('ERROR' => 1, 'DEBUG' => 2, 'ALL' => 3);
if ($log_level[$level] > LOG_LEVEL) {
return;
}
$log_path = CUR_CONF_PATH . 'data/log/' . date('Y') . '/' . date('m') . '/';
if (!is_dir($log_path)) {
hg_mkdir($log_path);
}
$input = json_encode($input);
$output = json_encode($output);
$time = date('Y-m-d H:i');
$user = @json_encode($user);
$log_message_tpl = <<<LC
Level : {$level}
Message : {$message}
Input : {$input}
Ouput : {$output}
Date\t: {$time}
User\t: {$user}
LC;
hg_file_write($log_path . 'log-' . date('Y-m-d') . '.php', $log_message_tpl, 'a+');
}
示例2: get_server_config
/**
* 生成缓存文件
* Enter description here ...
*/
private function get_server_config()
{
$alive_filename = $this->settings['alive_filename'] ? $this->settings['alive_filename'] : 'alive';
$filename = $alive_filename . '.php';
if (is_file(CACHE_DIR . $filename)) {
include CACHE_DIR . $filename;
} else {
$this->db = hg_ConnectDB();
$sql = "SELECT id, host, output_dir, input_port, type FROM " . DB_PREFIX . "server_config ";
$sql .= " WHERE status = 1 ORDER BY id DESC ";
$q = $this->db->query($sql);
$return = array();
while ($row = $this->db->fetch_array($q)) {
$row['host'] = $row['host'] . ':' . $row['input_port'];
$return[] = $row;
}
$content = '<?php
if (!IS_READ)
{
exit();
}
$return = ' . var_export($return, 1) . ';
?>';
hg_file_write(CACHE_DIR . $filename, $content);
}
return $return;
}
示例3: hg_debug_tofile
function hg_debug_tofile($str, $is_arr = 0, $dir = '', $op_type = 'a+', $tofile = false)
{
if ($is_arr) {
$str = var_export($str, true);
}
if ($op_type == "a" || $op_type == "a+") {
$str .= "<br />";
}
$tmp_info = debug_backtrace();
$debug_tree = "";
$max = count($tmp_info);
$i = 1;
foreach ($tmp_info as $debug_info) {
$space = str_repeat(' ', $max - $i);
$debug_tree = "<br />" . $space . $debug_info['file'] . " on line " . $debug_info['line'] . ":" . $debug_tree;
$i++;
}
$str = "<br />" . '[' . date('Y-m-d H:i:s') . ']' . $debug_tree . $str;
if ($tofile) {
$filename = $dir ? $dir : LOG_DIR . "log.txt";
hg_file_write($filename, $str, $op_type);
} else {
echo $str;
}
}
示例4: hg_debug_tofile
function hg_debug_tofile($str = '', $is_arr = 0, $dir = '', $filename = 'log.txt', $op_type = 'a+', $tofile = true)
{
if ($is_arr) {
$str = var_export($str, true);
}
if ($op_type == "a" || $op_type == "a+") {
if ($tofile) {
$entersplit = "\r\n";
} else {
$entersplit = "<br />";
}
}
$tmp_info = debug_backtrace();
$str .= $entersplit;
$debug_tree = "";
$max = count($tmp_info);
$i = 1;
foreach ($tmp_info as $debug_info) {
$space = str_repeat(' ', $max - $i);
$debug_tree = $entersplit . $space . $debug_info['file'] . " on line " . $debug_info['line'] . ":" . $debug_tree;
$i++;
}
$str = $entersplit . '[' . date('Y-m-d H:i:s') . ']' . $debug_tree . $str;
if ($tofile) {
$filename = $filename ? $filename : "log.txt";
$filenamedir = explode('/', $filename);
unset($filenamedir[count($filenamedir) - 1]);
hg_mkdir(LOG_DIR . $dir . implode('/', $filenamedir));
hg_file_write(LOG_DIR . $dir . $filename, $str, $op_type);
} else {
echo $str;
}
}
示例5: buildCache
function buildCache($filename, $content)
{
if ($this->menableCache) {
$this->deleteCache($filename);
$filename = $this->mcacheDir . md5($filename) . $this->msuffix;
return hg_file_write($filename, $content);
} else {
return false;
//缓存被禁用
}
}
示例6: recache
function recache($cache_name, $cache_dir = CACHE_DIR)
{
if (empty($cache_name)) {
return false;
}
$material_type = $this->get_material_type();
hg_mkdir($cache_dir);
$cache_file = $cache_dir . $cache_name;
hg_file_write($cache_file, serialize($material_type));
return $material_type;
}
示例7: settings_process
function settings_process()
{
$basic_settings = $this->input['param']['cloudvideo_basic_set'];
if (!is_array($basic_settings)) {
$basic_settings = array();
}
$content = '<?php
return $basic_settings = ' . var_export($basic_settings, 1) . ';
?>';
hg_file_write(DATA_DIR . 'settings.php', $content);
}
示例8: ParseTemplate
/**
* 解析模板,生成模板缓存
* @param $FileName
* @return String
*/
public function ParseTemplate($FileName = '')
{
$file = $this->mTemplateDir . $FileName;
if (!is_file($file)) {
return false;
}
$content = file_get_contents($file);
$content = $this->ParseNestTemplate($content);
$cache_file = $this->mTemplateCacheDir . md5($FileName . realpath($this->mTemplateDir)) . '.php';
hg_file_write($cache_file, $content);
return $cache_file;
}
示例9: update_cache
function update_cache($v = array(), $cache_dir = CACHE_DIR)
{
if (is_string($v) && !empty($v)) {
$v['name'] = $v;
}
if ($v['name']) {
if (empty($v['value'])) {
$v['value'] = $this->cache[$v['name']];
} else {
$this->cache[$v['name']] = $v['value'];
}
$cache_file = $cache_dir . $this->convert_cache_name($v['name'], true) . '.php';
if ($v['value'] === false) {
$v['value'] = 0;
}
if (!defined('CACHE_INCLUDE')) {
$content = '<' . '?php exit; ?' . '>' . serialize($v['value']);
} else {
$content = '<' . "?php\n\$gCache['{$v['name']}'] = " . var_export($v['value'], true) . ";\n?" . '>';
}
hg_file_write($cache_file, $content);
}
}
示例10: error_output
$rename = @rename($mp4, $source_file);
if (!$rename) {
error_output('005', '视频权限限制,无法编辑视频');
}
$mediainfo = new mediainfo($source_file);
$source_file_data = $mediainfo->getMeidaInfo();
$source = array();
foreach ($svodid as $k => $vid) {
$video_dir = hg_num2dir($vid);
$targerdir = TARGET_DIR . $video_dir . $vid . '.ssm/';
if ($vid == $vodid) {
$sourcef = $source_file;
$data = $source_file_data;
} else {
$sourcef = $targerdir . $vid . '.mp4';
if (!is_file($sourcef)) {
error_output('006', '指定片段视频不存在');
}
$mediainfo->setFile($sourcef);
$data = $mediainfo->getMeidaInfo();
}
$source[] = array('source' => $sourcef, 'start' => intval($start[$k]), 'duration' => intval($duration[$k]), 'mediainfo' => $data);
}
$curl = new curl($gVodApi['host'], $gVodApi['dir'], $gVodApi['token']);
$curl->initPostData();
$conf = $curl->request('vod_config.php');
$gTransApi['filename'] = 'getVideoInfo.php';
$trans_info = array('sourceFile' => $source, 'id' => $video_id, 'vodid' => $vodid, 'targetDir' => $targerdir, 'config' => $conf[0], 'callback' => $gTransApi);
hg_file_write(UPLOAD_DIR . FILE_QUEUE . $vodid, json_encode($trans_info));
$data = array('id' => $video_id, 'vodid' => $vodid, 'trans_info' => $trans_info);
output($data);
示例11: hg_update_role_prms
function hg_update_role_prms($role_ids = '')
{
$complex = array();
global $gDB;
//获取节点和发布栏目的权限
$sql = 'SELECT * FROM ' . DB_PREFIX . 'role_prms WHERE admin_role_id IN(' . $role_ids . ')';
$query = $gDB->query($sql);
while ($row = $gDB->fetch_array($query)) {
$temp = array();
$temp['action'] = trim($row['func_prms']) ? explode(',', $row['func_prms']) : array();
$temp['nodes'] = strlen($row['node_prms']) ? explode(',', $row['node_prms']) : array();
$temp['setting'] = $row['setting_prms'];
$temp['is_complete'] = $row['is_complete'];
$complex[$row['admin_role_id']]['app_prms'][$row['app_uniqueid']] = $temp;
}
//栏目节点
$sql = 'SELECT publish_prms,extend_prms,id,site_prms FROM ' . DB_PREFIX . 'admin_role WHERE id IN(' . $role_ids . ')';
$query = $gDB->query($sql);
while ($publish_prms = $gDB->fetch_array($query)) {
$complex[$publish_prms['id']]['site_prms'] = $publish_prms['site_prms'] ? explode(',', $publish_prms['site_prms']) : array();
$complex[$publish_prms['id']]['publish_prms'] = $publish_prms['publish_prms'] ? explode(',', $publish_prms['publish_prms']) : array();
$complex[$publish_prms['id']]['default_setting'] = $publish_prms['extend_prms'] ? unserialize($publish_prms['extend_prms']) : array();
}
if ($complex) {
foreach ($complex as $role_id => $prms) {
if (!write_role_prms_to_redis($role_id, json_encode($prms))) {
$cache_dir = get_prms_cache_dir();
if (!is_dir($cache_dir)) {
hg_mkdir($cache_dir);
}
$role_prms_file = get_prms_cache_dir($role_id);
//$prms = hg_merger_show_node($prms);
$content = '<?php
/*
权限测试注意事项
1、授权和测试在同一服务器上 因为读取是缓存文件
2、确定自己应用的主模块的标识符号
3、辅助模块 即除了主模块以外的 都是通过settings这个选项判定是否具有增删改查的权限
4、app_prms 存储的是应用标志 主要用于主模块的操作和节点控制
5、site_prms 全站栏目授权
6、publish_prms 控制发布权限 有栏目即即有发布操作权限
7、default_setting 控制其他选项 同之前版本
*/
return ' . var_export($prms, 1) . ';?>';
hg_file_write($role_prms_file, $content);
}
}
}
return $complex;
}
示例12: cache
public function cache()
{
$sql = 'SELECT sort.id as catalog_sort_id,sort.catalog_sort,
sort.catalog_sort_name,field.id,field.catalog_field,field.remark,
field.catalog_default,field.selected,field.bak,field.batch,field.required,
field.zh_name,style.formhtml AS style,style.type FROM ' . DB_PREFIX . 'field AS field
LEFT JOIN ' . DB_PREFIX . 'style AS style ON field.form_style=style.id
LEFT JOIN ' . DB_PREFIX . 'field_sort AS sort ON sort.id=field.catalog_sort_id WHERE 1 AND field.switch = 1';
$sql .= " ORDER BY sort.order_id DESC,field.order_id DESC";
$q = $this->db->query($sql);
while ($data = $this->db->fetch_array($q)) {
$data['catalog_field'] = catalog_prefix($data['catalog_field']);
$default = $data['catalog_default'] = $data['catalog_default'] ? explode(',', $data['catalog_default']) : NULL;
$data['selected'] = maybe_unserialize($data['selected']);
if (is_string($data['selected']) && !empty($data['selected'])) {
$data['selected'] = $this->content_change($data['type'], $data['selected']);
}
$datas[$data['catalog_sort']]['catalog_sort_id'] = $data['catalog_sort_id'];
$datas[$data['catalog_sort']]['catalog_sort_name'] = $data['catalog_sort_name'];
$datas[$data['catalog_sort']]['catalog_sort'] = $data['catalog_sort'];
if ($data['type'] == 'text' || $data['type'] == 'textarea') {
$data['style'] = str_replace(REPLACE_NAME, $data['catalog_field'], $data['style']);
} elseif ($data['type'] == 'radio') {
$style = str_replace(REPLACE_NAME, $data['catalog_field'], $data['style']);
unset($data['style']);
foreach ($default as $defaults) {
$data['style'] .= str_replace(REPLACE_DATA, $defaults, $style);
}
} elseif ($data['type'] == 'checkbox') {
$style = str_replace(REPLACE_NAME, $data['catalog_field'] . '[]', $data['style']);
unset($data['style']);
foreach ($default as $defaults) {
$data['style'] .= str_replace(REPLACE_DATA, $defaults, $style);
}
} elseif ($data['type'] == 'option') {
$style = $data['style'];
unset($data['style']);
foreach ($default as $defaults) {
$data['style'] .= str_replace(REPLACE_DATA, $defaults, $style);
}
$data['style'] = '<select name=' . $data['catalog_field'] . '><option value>请选择' . $data['zh_name'] . '</option>' . $data['style'] . '</select>';
} elseif ($data['type'] == 'img') {
if ($data['batch']) {
$data['style'] = str_replace(REPLACE_NAME, $data['catalog_field'] . '[]', $data['style']);
} else {
$data['style'] = str_replace(REPLACE_NAME, $data['catalog_field'], $data['style']);
}
} else {
continue;
}
$html = array('catalog_id' => $data['id'], 'zh_name' => $data['zh_name'], 'catalog_field' => $data['catalog_field'], 'remark' => $data['remark'], 'catalog_default' => $data['catalog_default'], 'selected' => $data['selected'], 'bak' => $data['bak'], 'batch' => $data['batch'], 'required' => $data['required'], 'type' => $data['type'], 'style' => $data['style']);
$datas[$data['catalog_sort']]['html'][$data['catalog_field']] = $html;
$datas[$data['catalog_sort']]['html'][$data['catalog_field']]['data'] = NULL;
}
$text = '<?php $cache=' . var_export($datas, true) . ';?>';
hg_file_write(CACHE_SORT, $text);
}
示例13: _changeCss
private function _changeCss($dir, $root = false)
{
if (!$root) {
$root = $dir;
}
if (is_dir($dir) && ($dh = opendir($dir))) {
while (false !== ($file = readdir($dh))) {
if ($file != '.' && $file != '..') {
if (is_dir($dir . $file . '/')) {
$this->_changeCss($dir . $file . '/', $root);
} else {
if (preg_match('/.css$/', $file)) {
$content = file_get_contents($dir . $file);
$content = preg_replace("/{\\\$[a-zA-Z0-9_\\[\\]\\-\\'\\>]+}/", RESOURCE_URL, $content);
hg_file_write($dir . $file, $content);
}
}
}
}
closedir($dh);
}
}
示例14: show
function show()
{
$hg_ad_js = ADV_DATA_DIR . 'script/hg_ad.js';
if (!file_exists($hg_ad_js) || $this->input['forcejs']) {
if (!is_dir(ADV_DATA_DIR . 'script/')) {
hg_mkdir(ADV_DATA_DIR . 'script/');
}
$adjs = file_get_contents('./core/ad.js');
hg_file_write($hg_ad_js, str_replace('{$addomain}', AD_DOMAIN, $adjs));
}
$para = array();
$para['offset'] = $this->input['offset'] ? intval($this->input['offset']) : 0;
$para['count'] = $this->input['count'] ? intval($this->input['count']) : 100;
$para['where'] = urldecode($this->get_condition());
$para['arcinfo'] = json_decode(urldecode($this->input['vinfo']), true);
$para['colid'] = hg_filter_ids($this->input['colid']);
$para['colid'] = $para['colid'] == -1 ? 0 : $para['colid'];
$dostatistic = true;
if ($this->input['preview']) {
$dostatistic = false;
}
$ad = new adv();
$ads = $ad->getAdDatas($para, $dostatistic);
if ($ads) {
$outputjs = '';
foreach ($ads as $k => $r) {
$_ad = $r;
if (!is_array($r[0])) {
//不存在广告位多个广告
$_ad = array(0 => $r);
unset($r);
}
$_ad_tpl = '';
foreach ($_ad as $r) {
if ($r['mtype'] != 'javascript') {
$is_js = 0;
} else {
$is_js = 1;
}
$r['param'] = array_merge((array) $r['param']['pos'], (array) $r['param']['ani']);
$r['param']['title'] = $r['title'];
$r['param']['content'] = build_ad_tpl($r['url'], $r['mtype'], $r['param']);
foreach ($r as $k => $v) {
if (is_array($v)) {
foreach ($v as $kk => $vv) {
${$kk} = $vv;
}
} else {
${$k} = $v;
}
}
if (!$tpl) {
$tpl = '{$content}';
}
$ad_tpl = stripslashes(preg_replace("/{(\\\$[a-zA-Z0-9_\\[\\]\\-\\'\"\$\\>\\.]+)}/ies", '${1}', $tpl));
$ad_tpl = preg_replace("/[\n]+/is", '', $ad_tpl);
//通过API进行统计
if ($link) {
if ($r['mtype'] != 'javascript') {
$_ad_tpl .= '<a href="' . AD_DOMAIN . 'click.php?a=doclick&url=' . urlencode($link) . '&pubid=' . $pubid . '" target="_blank">' . $ad_tpl . '</a>';
}
} else {
$_ad_tpl .= $ad_tpl;
}
if (!$ad_js_para) {
$ad_js_para = stripslashes(preg_replace("/{\\\$([a-zA-Z0-9_\\[\\]\\-\\'\"\$\\>\\.]+)}/ies", '${1} . ":\\"" . $${1} . "\\""', str_replace("\r\n", '', $js_para)));
}
}
$outputjs .= 'hg_AD_AddHtml({para:{' . $ad_js_para . '}, html:"' . addslashes($_ad_tpl) . '",box:"ad_' . $id . '",loadjs:"' . $include_js . '",loadurl:"' . ADV_DATA_URL . 'script/",isjs:' . $is_js . '});';
}
header('Content-Type:application/x-javascript');
echo $outputjs;
}
}
示例15: unset_logindb_cache
public function unset_logindb_cache()
{
$id = $this->input['id'];
if (!$id) {
$this->errorOutput("无效的数据库服务器");
}
if ($id) {
//禁用的数据库
$sql = 'UPDATE ' . DB_PREFIX . 'login_server SET status = 0 WHERE id IN(' . $id . ')';
$this->db->query($sql);
}
$sql = 'SELECT host,port,user,pass,`database`,`charset`,`pconnect` FROM ' . DB_PREFIX . 'login_server WHERE status=1 ORDER BY id DESC';
//$this->errorOutput($sql);
$query = $this->db->query($sql);
$cache = array();
while ($row = $this->db->fetch_array($query)) {
$cache[] = $row;
}
hg_file_write(CACHE_DIR . 'loginserv.php', "<?php\n \$servers = " . var_export($cache, 1) . "\n?>");
$this->addItem(explode(',', $id));
$this->output();
}