本文整理汇总了PHP中_at函数的典型用法代码示例。如果您正苦于以下问题:PHP _at函数的具体用法?PHP _at怎么用?PHP _at使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_at函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* 执行
*
* @author Garbin
* @param none
* @return void
*/
function execute()
{
//此处的锁定机制可能存在冲突问题
/* 被锁定 */
if ($this->is_lock()) {
return;
}
/* 在运行结束前锁定 */
_at('set_time_limit', 1800);
//半个小时
_at('ignore_user_abort', true);
//忽略用户退出
$this->lock();
$this->_init_tasks();
/* 获取到期的任务列表 */
$due_tasks = $this->get_due_tasks();
/* 没有到期的任务 */
if (empty($due_tasks)) {
$this->unlock();
return;
}
/* 执行任务 */
$this->run_task($due_tasks);
/* 更新任务列表 */
$this->update_tasks($due_tasks);
/* 解锁 */
$this->unlock();
}
示例2: build
/**
* 生成XML文档
*@access public
*@param string $file_name 如果提供了文件名则生成文件,否则返回字符串.
*@return [void|string]
*/
function build($file_name = null)
{
$map = $this->header . "\n";
foreach ($this->items as $item) {
$item->loc = htmlentities($item->loc, ENT_QUOTES);
$map .= "\t\t<url>\n\t\t\t<loc>{$item->loc}</loc>\n";
// lastmod
if (!empty($item->lastmod)) {
$map .= "\t\t\t<lastmod>{$item->lastmod}</lastmod>\n";
}
// changefreq
if (!empty($item->changefreq)) {
$map .= "\t\t\t<changefreq>{$item->changefreq}</changefreq>\n";
}
// priority
if (!empty($item->priority)) {
$map .= "\t\t\t<priority>{$item->priority}</priority>\n";
}
$map .= "\t\t</url>\n\n";
}
$map .= $this->footer . "\n";
if (!is_null($file_name)) {
return _at('file_put_contents', $file_name, $map, LOCK_EX);
} else {
return $map;
}
}
示例3: DbApp
function DbApp()
{
parent::BackendApp();
/* 设置最长执行时间为5分钟 */
_at('set_time_limit', 300);
_at('ini_set', 'memory_limit', '64M');
$this->db =& db();
$this->backup_path = ROOT_PATH . '/' . 'data/' . $this->backup_dir . '/';
}
示例4: clean_file
/**
* 清理垃圾文件
*
* @author Garbin
* @return void
*/
function clean_file()
{
$continue = isset($_GET['continue']);
$isolcated_file = $this->_get_isolated_file();
if (empty($isolcated_file)) {
$this->json_error('no_isocated_file');
return;
}
$file_count = count($isolcated_file);
if (!$continue) {
$this->json_result('', sprintf(Lang::get('isolcated_file_count'), $file_count));
return;
} else {
foreach ($isolcated_file as $f) {
_at('unlink', ROOT_PATH . '/' . $f);
}
$this->json_result('', sprintf('clean_file_successed', $file_count));
}
}
示例5: creathtml
function creathtml()
{
$this->assign('index', 1);
// 标识当前页面是首页,用于设置导航状态
/* 热门搜素 */
$this->assign('hot_keywords', $this->_get_hot_keywords());
$this->assign('page_title', Conf::get('site_title'));
$this->assign('page_description', Conf::get('site_description'));
$this->assign('page_keywords', Conf::get('site_keywords'));
if (file_exists(ROOT_PATH . "/index.html")) {
_at(unlink, ROOT_PATH . "/index.html");
_at(unlink, ROOT_PATH . "/mindex.html");
}
$data = $this->outhtml('index.html');
$file = 'index.html';
$mdata = $this->outhtml('mindex.html');
$mfile = 'mindex.html';
$filesize = file_put_contents($file, $data);
$mfilesize = file_put_contents($mfile, $mdata);
@chmod($file, 0777);
@chmod($mfile, 0777);
$this->json_result("", "生成首页静态文件成功");
}
示例6: get_prop
function get_prop()
{
//参数数组
$paramArr = array('app_key' => $this->_appKey, 'method' => 'taobao.itempropvalues.get', 'format' => 'json', 'v' => '2.0', 'timestamp' => date('Y-m-d H:i:s'), 'fields' => $this->_fields, 'pvs' => $this->_pvs, 'cid' => $this->_cid);
//生成签名
$sign = $this->_createSign($paramArr, $appSecret);
//组织参数
$strParam = $this->_createStrParam($paramArr);
$strParam .= 'sign=' . $sign;
//访问服务
$url = 'http://gw.api.taobao.com/router/rest?' . $strParam;
//vdump('ok',file_get_contents($url));
$result = _at('file_get_contents', $url);
if (!$result) {
$this->_error('api_data_fail');
return false;
}
$result = $this->_getJsonData($result);
if (isset($result['msg'])) {
$this->_error($result['msg']);
return false;
}
return $result['prop_value']['prop_value'];
}
示例7: drop_avatar
/**
* 删除头像
*
* @author Garbin
* @param int $user_id
* @return bool
*/
function drop_avatar($user_id)
{
$model_member =& m('member');
$info = $model_member->get($user_id);
if ($info['portrait']) {
return _at('unlink', ROOT_PATH . '/' . $info['portrait']);
}
return true;
}
示例8: delete
function delete($key)
{
$cache_file = $this->_get_cache_path($key);
return _at(unlink, $cache_file);
}
示例9: remote_image
function remote_image()
{
import('image.func');
import('uploader.lib');
$uploader = new Uploader();
$uploader->allowed_type(IMAGE_FILE_TYPE);
$uploader->allowed_size(SIZE_GOODS_IMAGE);
// 2M
$upload_mod =& m('uploadedfile');
/* 取得剩余空间(单位:字节),false表示不限制 */
$store_mod =& m('store');
$settings = $store_mod->get_settings($this->store_id);
$remain = $settings['space_limit'] > 0 ? $settings['space_limit'] * 1024 * 1024 - $upload_mod->get_file_size($this->store_id) : false;
$uploader->root_dir(ROOT_PATH);
$dirname = '';
$remote_url = trim($_POST['remote_url']);
if (!empty($remote_url)) {
if (preg_match("/^(http:\\/\\/){1,1}.+(gif|png|jpeg|jpg){1,1}\$/i", $remote_url)) {
$result = $this->url_exist($remote_url, 2097152, $remain);
if ($result === 1) {
$this->view_remote();
$res = Lang::get("url_invalid");
echo "<script type='text/javascript'>alert('{$res}');</script>";
return false;
} elseif ($result === 2) {
$this->view_remote();
$res = Lang::get("not_allowed_size");
echo "<script type='text/javascript'>alert('{$res}');</script>";
return false;
} elseif ($result === 3) {
$this->view_remote();
$res = Lang::get("space_limit_arrived");
echo "<script type='text/javascript'>alert('{$res}');</script>";
return false;
}
$img_url = _at('file_get_contents', $remote_url);
$dirname = '';
if ($this->belong == BELONG_GOODS) {
$dirname = 'data/files/store_' . $this->visitor->get('manage_store') . '/goods_' . time() % 200;
} elseif ($this->belong == BELONG_STORE) {
$dirname = 'data/files/store_' . $this->visitor->get('manage_store') . '/other';
} elseif ($this->belong == BELONG_ARTICLE) {
$dirname = 'data/files/mall/store_' . $this->visitor->get('manage_store') . '/article';
}
$filename = $uploader->random_filename();
$new_url = $dirname . '/' . $filename . '.' . substr($remote_url, strrpos($remote_url, '.') + 1);
ecm_mkdir(ROOT_PATH . '/' . $dirname);
$fp = _at('fopen', ROOT_PATH . '/' . $new_url, "w");
_at('fwrite', $fp, $img_url);
_at('fclose', $fp);
if (!file_exists(ROOT_PATH . '/' . $new_url)) {
$this->view_remote();
$res = Lang::get("system_error");
echo "<script type='text/javascript'>alert('{$res}');</script>";
return false;
}
/* 处理文件入库 */
$data = array('store_id' => $this->store_id, 'file_type' => $this->_return_mimetype(ROOT_PATH . '/' . $new_url), 'file_size' => filesize(ROOT_PATH . '/' . $new_url), 'file_name' => substr($remote_url, strrpos($remote_url, '/') + 1), 'file_path' => $new_url, 'belong' => $this->belong, 'item_id' => $this->id, 'add_time' => gmtime());
$file_id = $upload_mod->add($data);
if (!$file_id) {
$this->_error($uf_mod->get_error());
return false;
}
if ($this->instance == 'goods_image') {
/* 生成缩略图 */
$thumbnail = dirname($new_url) . '/small_' . basename($new_url);
make_thumb(ROOT_PATH . '/' . $new_url, ROOT_PATH . '/' . $thumbnail, THUMB_WIDTH, THUMB_HEIGHT, THUMB_QUALITY);
/* 更新商品相册 */
$mod_goods_image =& m('goodsimage');
$goods_image = array('goods_id' => $this->id, 'image_url' => $new_url, 'thumbnail' => $thumbnail, 'sort_order' => 255, 'file_id' => $file_id);
if (!$mod_goods_image->add($goods_image)) {
$this->_error($this->mod_goods_imaged->get_error());
return false;
}
$data['thumbnail'] = $thumbnail;
}
$data['instance'] = $this->instance;
$data['file_id'] = $file_id;
$res = "{";
foreach ($data as $key => $val) {
$res .= "\"{$key}\":\"{$val}\",";
}
$res = substr($res, 0, strrpos($res, ','));
$res .= '}';
$this->view_remote();
echo "<script type='text/javascript'>window.parent.add_uploadedfile({$res});</script>";
} else {
$res = Lang::get('url_invalid');
$this->view_remote();
echo "<script type='text/javascript'>alert('{$res}');</script>";
return false;
}
} else {
$res = Lang::get('remote_empty');
$this->view_remote();
echo "<script type='text/javascript'>alert('{$res}');</script>";
return false;
}
}
示例10: drop_data
/**
* 删除商品相关数据:包括商品图片、商品缩略图,要在删除商品之前调用
*
* @param string $goods_ids 商品id,用逗号隔开
*/
function drop_data($goods_ids)
{
$image_mod =& m('goodsimage');
$images = $image_mod->find(array('conditions' => 'goods_id' . db_create_in($goods_ids), 'fields' => 'image_url, thumbnail'));
foreach ($images as $image) {
if (!empty($image['image_url']) && trim($image['image_url']) && substr($image['image_url'], 0, 4) != 'http' && file_exists(ROOT_PATH . '/' . $image['image_url'])) {
_at(unlink, ROOT_PATH . '/' . $image['image_url']);
}
if (!empty($image['thumbnail']) && trim($image['thumbnail']) && substr($image['thumbnail'], 0, 4) != 'http' && file_exists(ROOT_PATH . '/' . $image['thumbnail'])) {
_at(unlink, ROOT_PATH . '/' . $image['thumbnail']);
}
}
}
示例11: edit
function edit()
{
$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
if (!IS_POST) {
/* 是否存在 */
$gcategory = $this->_gcategory_mod->get_info($id);
if (!$gcategory) {
$this->show_warning('gcategory_empty');
return;
}
$this->assign('gcategory', $gcategory);
/* 导入jQuery的表单验证插件 */
$this->import_resource(array('script' => 'jquery.plugins/jquery.validate.js'));
$this->assign('parents', $this->_get_options($id));
$this->display('gcategory.form.html');
} else {
$data = array('cate_name' => $_POST['cate_name'], 'parent_id' => $_POST['parent_id'], 'sort_order' => $_POST['sort_order'], 'if_show' => $_POST['if_show']);
/* 检查名称是否已存在 */
if (!$this->_gcategory_mod->unique(trim($data['cate_name']), $data['parent_id'], $id)) {
$this->show_warning('name_exist');
return;
}
/* 检查级数 */
$depth = $this->_gcategory_mod->get_depth($id);
$ancestor = $this->_gcategory_mod->get_ancestor($data['parent_id']);
if ($depth + count($ancestor) > MAX_LAYER) {
$this->show_warning('max_layer_error');
return;
}
/* 保存 */
$old_data = $this->_gcategory_mod->get_info($id);
// 保存前的数据
$rows = $this->_gcategory_mod->edit($id, $data);
if ($this->_gcategory_mod->has_error()) {
$this->show_warning($this->_gcategory_mod->get_error());
return;
}
/* 如果改变了上级分类,更新商品表中相应记录的cate_id_1到cate_id_4 */
if ($old_data['parent_id'] != $data['parent_id']) {
// 执行时间可能比较长,所以不限制了
_at(set_time_limit, 0);
// 清除商城商品分类缓存
$cache_server =& cache_server();
$cache_server->delete('goods_category_0');
// 取得当前分类的所有子孙分类(包括自身)
$cids = $this->_gcategory_mod->get_descendant_ids($id, true);
// 找出这些分类中有商品的分类
$mod_goods =& m('goods');
$mod_gcate =& $this->_gcategory_mod;
$sql = "SELECT DISTINCT cate_id FROM {$mod_goods->table} WHERE cate_id " . db_create_in($cids);
$cate_ids = $mod_goods->getCol($sql);
// 循环更新每个分类的cate_id_1到cate_id_4
foreach ($cate_ids as $cate_id) {
$cate_id_n = array(0, 0, 0, 0);
$ancestor = $mod_gcate->get_ancestor($cate_id, true);
for ($i = 0; $i < 4; $i++) {
isset($ancestor[$i]) && ($cate_id_n[$i] = $ancestor[$i]['cate_id']);
}
$sql = "UPDATE {$mod_goods->table} " . "SET cate_id_1 = '{$cate_id_n[0]}', cate_id_2 = '{$cate_id_n[1]}', cate_id_3 = '{$cate_id_n[2]}', cate_id_4 = '{$cate_id_n[3]}' " . "WHERE cate_id = '{$cate_id}'";
$mod_goods->db->query($sql);
}
}
$this->show_message('edit_ok', 'back_list', 'index.php?app=gcategory', 'edit_again', 'index.php?app=gcategory&act=edit&id=' . $id);
}
}
示例12: unlock
/**
* 解锁
*
* @author Garbin
* @return void
*/
function unlock()
{
_at('unlink', $this->_config['lock_file']);
//file_put_contents($this->_config['lock_file'], 0, LOCK_EX);
}