function page_init($title = '', $keywords = '', $description = '', $album_id = null, $photo_id = null) { $plugin =& loader::lib('plugin'); $head_str = "<title>{$title}</title>\n"; $head_str .= "<meta name=\"keywords\" content=\"{$keywords}\" />\n"; $head_str .= "<meta name=\"description\" content=\"{$description}\" />\n"; $meu_head = $plugin->filter('meu_head', $head_str, $album_id, $photo_id); $meu_head .= "\n" . '<meta name="generator" content="Mei' . 'u' . 'Pic ' . MPIC_VERSION . '" />' . "\n"; $feed_url = $album_id ? site_link('feed', 'index', array('aid' => $album_id)) : site_link('feed'); $feed_title = $this->setting->get_conf('site.title'); $meu_head .= "<link rel=\"alternate\" title=\"{$feed_title}\" href=\"" . $feed_url . "\" type=\"application/rss+xml\" />\n"; $this->output->set('meu_head', $meu_head); if ($this->user->loggedin()) { //更新提示 $this->output->set('update_info', $this->setting->get_conf('update')); } $user_status = loader::view('block/user_status', false); $this->output->set('user_status', $plugin->filter('user_status', $user_status)); $page_head = $plugin->filter('page_head', '', $album_id, $photo_id); $page_foot = $plugin->filter('page_foot', '', $album_id, $photo_id); $this->output->set('page_head', $page_head); $this->output->set('page_foot', $page_foot); $this->output->set('trash_status', has_trash()); $mdl_nav =& Loader::model('nav'); $nav_menu = $mdl_nav->get_enabled_navs(); $this->output->set('nav_menu', $nav_menu); //$plugin->filter('main_menu',$nav_menu,$album_id,$photo_id); }
function fetch($file, $templateid = null, $tpldir = null) { global $base_path; $output =& loader::lib('output'); $params = $output->getAll(); extract($params); if (!$templateid) { $templateid = TEMPLATEID; } $style_path = $base_path . TPLDIR . '/'; $setting =& loader::model('setting'); $theme_config = $setting->get_conf('theme_' . $templateid, array()); if (isset($_config)) { if ($theme_config) { $_config = array_merge($_config, $theme_config); } } else { $_config = $theme_config; } $footer = '<script src="' . $statics_path . 'js/common.js" type="text/javascript"></script>'; if (isset($loggedin) && $loggedin) { $footer .= '<script src="' . $statics_path . 'js/admin.js" type="text/javascript"></script>'; } $footer .= 'Pow' . 'ered by <a href="http://mei' . 'upic.m' . 'eiu.cn/" target="_blank">Mei' . 'uPic ' . MPIC_VERSION . '</a> '; $footer .= safe_invert($setting->get_conf('site.footer'), true); $show_process_info = $setting->get_conf('system.show_process_info'); ob_start(); include $this->template($file, $templateid, $tpldir); $content = ob_get_clean(); return $content; }
public function __construct() { if ($this->auth) { $this->auth(); } loader::lib("view"); }
function plugin($config = null) { if (!is_null($config)) { $this->config = array_merge($this->config, $config); } $this->db =& loader::database(); $this->plugin_mgr =& loader::lib('plugin'); }
/** * Parse uri * * @return array * @author Lingter */ function parse_uri() { $arg['ctl'] = isset($_GET['ctl']) ? $_GET['ctl'] : 'default'; $arg['act'] = isset($_GET['act']) ? $_GET['act'] : 'index'; //过滤私有的方法 $arg['act'] = ltrim($arg['act'], '_'); unset($_GET['ctl']); unset($_GET['act']); $arg['pars'] = $_GET; $plugin =& loader::lib('plugin'); $plugin_uri = $plugin->filter('parse_url', $arg); return $plugin_uri; }
/** * 装载数据库 */ function &database($dbstr = 'default', $config = '') { if (!isset($GLOBALS[SP_LOADER]['DATABASES'][$dbstr])) { if (is_array($config)) { $DB_config = $config; } else { $Config =& loader::config(); $DB_config = $Config['database'][$dbstr]; } $db_class =& loader::lib('db'); $db_class->init($DB_config); $GLOBALS[SP_LOADER]['DATABASES'][$dbstr] =& $db_class; } return $GLOBALS[SP_LOADER]['DATABASES'][$dbstr]; }
/** * 装载数据库 */ static function &database($dbstr = 'default', $config = '') { if (!isset(self::$_databases[$dbstr])) { if (is_array($config)) { $DB_config = $config; } else { $Config =& loader::config(); $DB_config = $Config['database'][$dbstr]; } $db_class =& loader::lib('db'); $db_class->init($DB_config); self::$_databases[$dbstr] = $db_class; } return self::$_databases[$dbstr]; }
function index() { need_login('page'); $type = intval($this->getGet('type', '1')); $page = intval($this->getGet('page', 1)); $deleted_albums = $this->mdl_album->get_trash_count(); $deleted_photos = $this->mdl_photo->get_trash_count(); if ($deleted_albums <= 0 && $deleted_photos <= 0) { trash_status(2); $this->output->set('isempty', true); } else { if ($type == 1) { $data = $this->mdl_album->get_trash($page); if (is_array($data['ls'])) { foreach ($data['ls'] as $k => $v) { if ($v['cover_id']) { $cover_info = $this->mdl_photo->get_info($v['cover_id'], 'thumb'); if ($cover_info) { $data['ls'][$k]['cover_path'] = $cover_info['thumb']; } else { $data['ls'][$k]['cover_id'] = 0; } } } } } elseif ($type == 2) { $data = $this->mdl_photo->get_trash($page); } $pageurl = site_link('trash', 'index', array('type' => $type, 'page' => '[#page#]')); $page_obj =& loader::lib('page'); $pagestr = $page_obj->fetch($data['total'], $data['current'], $pageurl); $this->output->set('isempty', false); $this->output->set('pagestr', $pagestr); $this->output->set('data', $data['ls']); $this->output->set('deleted_albums', $deleted_albums); $this->output->set('deleted_photos', $deleted_photos); $this->output->set('type', $type); } //面包屑 $crumb_nav = array(); $crumb_nav[] = array('name' => lang('recycle')); $this->page_crumb($crumb_nav); $page_title = lang('recycle') . ' - ' . $this->setting->get_conf('site.title'); $page_keywords = $this->setting->get_conf('site.keywords'); $page_description = $this->setting->get_conf('site.description'); $this->page_init($page_title, $page_keywords, $page_description); $this->render(); }
function _save() { $cache =& loader::lib('cache'); foreach ($this->setting_pool as $k => $values) { $this->db->select('#@setting', 'value', 'name="' . $k . '"'); $data = $this->db->getOne(); if ($data) { $keyvalue = unserialize($data); if (is_array($keyvalue)) { $keyvalue = array_merge($keyvalue, $values); } else { $keyvalue = $values; } $this->db->update('#@setting', 'name="' . $k . '"', array('value' => addslashes(serialize($keyvalue)))); $this->db->query(); } else { $this->db->insert('#@setting', array('name' => $k, 'value' => addslashes(serialize($values)))); $this->db->query(); } $cache->remove('setting_' . $k); } }
function index() { global $base_path; $album_id = intval($this->getGet('aid')); $search = array(); $siteurl = $this->setting->get_conf('site.url'); $sitename = $this->setting->get_conf('site.title'); $description = $this->setting->get_conf('site.description'); $sitedomain = substr($siteurl, 0, -1 * strlen($base_path)); $feed =& loader::lib('rss'); if ($album_id) { $search['album_id'] = $album_id; $album_info = $this->mdl_album->get_info($album_id); $feed->title = $album_info['name'] . ' - ' . $sitename; } else { $feed->title = $sitename; } $feed->link = $siteurl; $feed->description = $description; $this->mdl_photo->set_pageset(50); $data = $this->mdl_photo->get_all(1, $search, 'tu_desc'); if ($data['ls']) { foreach ($data['ls'] as $v) { $item = new RSSItem(); $item->title = "<![CDATA[ " . $v['name'] . " ]]>"; $item->link = $sitedomain . site_link('photos', 'view', array('id' => $v['id'])); $item->set_pubdate($v['create_time']); if (!$this->mdl_album->check_album_priv($album_id, isset($album_info) ? $album_info : null)) { $img = lang('photo_has_priv') . '<br />'; } else { $img = '<img src="' . $siteurl . $v['path'] . '" /><br />'; } $item->description = "<![CDATA[ " . $img . $v['desc'] . " ]]>"; $feed->add_item($item); } } $feed->serve(); }
function index() { $page = intval($this->getGet('page', 1)); $type = $this->getGet('type'); $this->mdl_tag->set_pageset(40); $par = array(); if (in_array($type, array(1, 2))) { $par['type'] = $type; } $tags = $this->mdl_tag->get_all($page, $par); $par['page'] = '[#page#]'; if ($tags['ls']) { foreach ($tags['ls'] as $k => $v) { $tags['ls'][$k]['fontsize'] = $this->mdl_tag->get_fontsize($v['count']); } } $page_obj =& loader::lib('page'); $pageurl = site_link('tags', 'index', $par); $pagestr = $page_obj->fetch($tags['total'], $tags['current'], $pageurl); $this->output->set('pagestr', $pagestr); $this->output->set('tag_list', $tags['ls']); $this->output->set('tag_type', $type); //面包屑 $crumb_nav = array(); $crumb_nav[] = array('name' => lang('tag_list'), 'link' => site_link('tags')); if ($type == 1) { $crumb_nav[] = array('name' => lang('album')); } elseif ($type == 2) { $crumb_nav[] = array('name' => lang('photo')); } $this->page_crumb($crumb_nav); $page_title = lang('tag_list') . ' - ' . $this->setting->get_conf('site.title'); $page_keywords = $this->setting->get_conf('site.keywords'); $page_description = $this->setting->get_conf('site.description'); $this->page_init($page_title, $page_keywords, $page_description); $this->render(); }
function check_login() { $login_name = safe_convert($this->getPost('login_name')); $login_pass = $this->getPost('login_pass'); $remember_pass = $this->getPost('remember_pass'); $normal = $this->getPost('normal'); if ($this->setting->get_conf('system.enable_login_captcha')) { $captcha =& loader::lib('captcha'); if (!$captcha->check($this->getPost('captcha'))) { form_ajax_failed('text', lang('invalid_captcha_code')); } } if (!$login_name) { form_ajax_failed('text', lang('username_empty')); } if (!$login_pass) { form_ajax_failed('text', lang('userpass_empty')); } if ($remember_pass) { $expire_time = time() + 86400 * 30; //记住密码30天 } else { $expire_time = 0; } $go_url = $normal ? site_link('default') : $_SERVER['HTTP_REFERER']; if ($this->user->set_login($login_name, md5($login_pass), $expire_time)) { $this->plugin->trigger('user_loged_in', $login_name); //登录时检查更新 if ($this->setting->get_conf('system.enable_auto_update')) { check_update(); } form_ajax_success('box', lang('login_success'), null, 0.5, $go_url); } else { form_ajax_failed('text', lang('username_pass_error')); } }
/** * 生成模板返回路径 * * @param integer $id 碎片ID号 * @param string $template 风格 */ public function template_url($id, $template = '') { $filepath = CACHE_PATH . 'template' . DIRECTORY_SEPARATOR . 'block' . DIRECTORY_SEPARATOR . $id . '.php'; $dir = dirname($filepath); if ($template) { if (!is_dir($dir)) { mkdir($dir, 0777, true); } $tpl = loader::lib('Template'); $str = $tpl->template_parse(new_stripslashes($template)); @file_put_contents($filepath, $str); } else { if (!file_exists($filepath)) { if (!is_dir($dir)) { mkdir($dir, 0777, true); } $tpl = loader::lib('Template'); $str = $this->db->get_one(array('id' => $id), 'template'); $str = $tpl->template_parse($str['template']); @file_put_contents($filepath, $str); } } return $filepath; }
function processImage() { $this->imgHandler =& loader::lib('image'); if (!$this->imgHandler->load($this->realpath)) { return false; } if ($this->param['zoom']) { $this->imgHandler->resizeScale($this->param['w'], $this->param['h']); } elseif ($this->param['w'] && $this->param['h']) { $this->imgHandler->resizeCut($this->param['w'], $this->param['h']); } elseif ($this->param['w'] || $this->param['h']) { $this->imgHandler->resizeTo($this->param['w'], $this->param['h']); } else { return false; } return true; }
function ajaxlist() { $albums = $this->mdl_album->get_kv(); if ($albums) { $ret = array('ret' => true, 'list' => $albums); } else { $ret = array('ret' => false, 'msg' => lang('no_records')); } $json =& loader::lib('json'); echo $json->encode($ret); }
function get_extra($id) { $cache =& loader::lib('cache'); $value = $cache->get('user_extra_' . $id); if ($value) { return $value; } $this->db->select('#@usermeta', 'meta_key,meta_value', 'userid=' . intval($id)); $value = $this->db->getAssoc(); $cache->set('user_extra_' . $id, $value); return $value; }
function manage() { need_login('page'); //系统设置菜单 $setting_menu = $this->plugin->filter('setting_menu', ''); $this->output->set('setting_menu', $setting_menu); $page = intval($this->getGet('page', 1)); $status = $this->getGet('status', 'all'); $status_nums = $this->mdl_comment->count_group_status(); $pageurl = site_link('comments', 'manage', array('page' => '[#page#]', 'status' => $status)); $this->mdl_comment->set_pageset(20); $data = $this->mdl_comment->get_all($page, array('status' => $status)); if ($data['ls']) { foreach ($data['ls'] as $k => $v) { if ($v['type'] == 1) { $data['ls'][$k]['subject'] = $this->mdl_album->get_info($v['ref_id']); } else { $data['ls'][$k]['subject'] = $this->mdl_photo->get_info($v['ref_id']); } } } $page_obj =& loader::lib('page'); $this->output->set('pagestr', $page_obj->fetch($data['total'], $data['current'], $pageurl)); $this->output->set('comments', $data['ls']); $this->output->set('status', $status); $this->output->set('status_nums', $status_nums); //面包屑 $crumb_nav = array(); $crumb_nav[] = array('name' => lang('system_setting'), 'link' => site_link('setting')); $crumb_nav[] = array('name' => lang('comments_manage')); $this->page_crumb($crumb_nav); $page_title = lang('comments_manage') . ' - ' . lang('system_setting') . ' - ' . $this->setting->get_conf('site.title'); $page_keywords = $this->setting->get_conf('site.keywords'); $page_description = $this->setting->get_conf('site.description'); $this->page_init($page_title, $page_keywords, $page_description); $this->render(); }
function fileupload() { $json =& loader::lib('json'); $error = ""; $msg = ""; if (!$this->user->loggedin()) { echo $json->encode(array('error' => lang('not_authorized'), 'msg' => '')); exit; } $upaction = $this->getPost('upaction'); if ($upaction == 'watermark') { $path_dir = 'data/watermark'; $file_type = array('png', 'jpg', 'gif'); } elseif ($upaction == 'logo') { $path_dir = 'data/logo'; $file_type = array('png', 'jpg', 'gif'); } $fileElementName = 'fileToUpload'; if (!empty($_FILES[$fileElementName]['error'])) { $error = lang('upload_error'); } elseif (empty($_FILES[$fileElementName]['tmp_name']) || $_FILES[$fileElementName]['tmp_name'] == 'none') { $error = lang('need_sel_upload_file'); } else { $filename = $_FILES[$fileElementName]['name']; $fileext = file_ext($filename); $filesize = $_FILES[$fileElementName]['size']; $allowsize = allowsize($this->setting->get_conf('upload.allow_size')); if (!in_array($fileext, $file_type)) { echo $json->encode(array('error' => lang('failed_not_support', $filename), 'msg' => '')); exit; } if ($allowsize && $filesize > $allowsize) { echo $json->encode(array('error' => lang('failed_larger_than_usetting', $filename), 'msg' => '')); exit; } if ($filesize == 0) { echo $json->encode(array('error' => lang('failed_if_file', $filename), 'msg' => '')); exit; } $storlib =& loader::lib('storage'); $path = $path_dir . '/' . date('Ymd') . '.' . $fileext; if ($storlib->upload($path, $_FILES[$fileElementName]['tmp_name'])) { $msg = $path; } else { $error = lang('upload_error'); } } echo $json->encode(array('error' => $error, 'msg' => $msg)); exit; }
function meiu_bootstrap() { unset_globals(); global $base_url, $base_path, $base_root, $language, $templatelangs; timer_start('page'); require_once COREDIR . 'loader.php'; require_once INCDIR . 'functions.php'; include_once INCDIR . 'plugin.php'; init_defines(); if (file_exists(COREDIR . 'lang' . DIRECTORY_SEPARATOR . LANGSET . '.lang.php')) { require_once COREDIR . 'lang' . DIRECTORY_SEPARATOR . LANGSET . '.lang.php'; } boot_init(); $plugin =& loader::lib('plugin'); $Config =& loader::config(); if (!$Config['safemode']) { $plugin->init_plugins(); } $plugin->trigger('boot_init'); //输出对象 $output =& loader::lib('output'); //载入当前用户信息 $user =& loader::model('user'); $output->set('loggedin', $user->loggedin()); if ($user->loggedin()) { $output->set('u_info', $user->get_all_field()); $user_extrainfo = $user->get_extra($user->get_field('id')); $output->set('u_extrainfo', $user_extrainfo); $user_theme = isset($user_extrainfo['theme']) ? $user_extrainfo['theme'] : ''; } else { $user_theme = null; } init_template($user_theme); $templatelangs = array(); $uri =& loader::lib('uri'); $uriinfo = $uri->parse_uri(); $setting_mdl =& loader::model('setting'); //如果数据库中的版本和程序版本不一致则跳转到执行自动升级脚本 $version = $setting_mdl->get_conf('system.version'); if ($version != MPIC_VERSION) { if (file_exists(ROOTDIR . 'install/upgrade.php')) { include ROOTDIR . 'install/upgrade.php'; exit; } } $output->set('base_path', $base_path); $output->set('statics_path', $base_path . 'statics/'); $output->set('site_logo', $setting_mdl->get_conf('site.logo', '')); $output->set('site_name', $setting_mdl->get_conf('site.title', lang('myalbum'))); define('IN_CTL', $uriinfo['ctl']); define('IN_ACT', $uriinfo['act']); $_GET = array_merge($_GET, $uriinfo['pars']); $_REQUEST = array_merge($_REQUEST, $uriinfo['pars']); require_once INCDIR . 'pagecore.php'; if ($plugin->has_trigger('custom_page.' . IN_CTL . '.' . IN_ACT) || $plugin->has_trigger('custom_page.' . IN_CTL)) { $plugin->trigger('custom_page.' . IN_CTL . '.' . IN_ACT) || $plugin->trigger('custom_page.' . IN_CTL, IN_ACT); } else { if (file_exists(CTLDIR . $uriinfo['ctl'] . '.ctl.php')) { require_once CTLDIR . $uriinfo['ctl'] . '.ctl.php'; $controller_name = $uriinfo['ctl'] . '_ctl'; $controller = new $controller_name(); $controller->_init(); if (method_exists($controller, $uriinfo['act'])) { call_user_func(array($controller, $uriinfo['act'])); } else { header("HTTP/1.1 404 Not Found"); showError(lang('404_not_found')); } $controller->_called(); } else { header("HTTP/1.1 404 Not Found"); showError(lang('404_not_found')); } } }
function get_page_setting($type) { $arr = array(12, 30, 56); $setting_mdl =& loader::model('setting'); if ($type == 'album') { $default = $setting_mdl->get_conf('display.album_pageset', 12); } else { $default = $setting_mdl->get_conf('display.photo_pageset', 12); } $current = isset($_COOKIE['Mpic_pageset_' . $type]) ? $_COOKIE['Mpic_pageset_' . $type] : $default; $output =& loader::lib('output'); $output->set('pageset_menu', $arr); $output->set('pageset_menu_current', $current); $output->set('pageset_menu_type', $type); $str = loader::view('block/pageset_menu', false); return array($current, $str); }
/** * 删除 */ public function delete() { if (isset($_GET['dosubmit'])) { $catid = intval($_GET['catid']); if (!$catid) { showmessage(L('missing_part_parameters')); } $modelid = $this->categorys[$catid]['modelid']; $sethtml = $this->categorys[$catid]['sethtml']; $html_root = C('system', 'html_root'); if ($sethtml) { $html_root = ''; } $setting = string2array($this->categorys[$catid]['setting']); $content_ishtml = $setting['content_ishtml']; $this->db->set_model($modelid); $this->hits_db = Loader::model('hits_model'); if (isset($_GET['ajax_preview'])) { $ids = intval($_GET['id']); $_POST['ids'] = array(0 => $ids); } if (empty($_POST['ids'])) { showmessage(L('you_do_not_check')); } // 附件初始化 $attachment = Loader::model('attachment_model'); $this->content_check_db = Loader::model('content_check_model'); $this->position_data_db = Loader::model('position_data_model'); $this->search_db = Loader::model('search_model'); $this->comment = Loader::lib('comment:comment'); $search_model = S('search/search_model'); $typeid = $search_model[$modelid]['typeid']; $this->url = loader::lib('content:url'); foreach ($_POST['ids'] as $id) { $r = $this->db->getby_id($id); if ($content_ishtml && !$r['islink']) { $urls = $this->url->show($id, 0, $r['catid'], $r['inputtime']); $fileurl = $urls[1]; // 删除静态文件,排除htm/html/shtml外的文件 $lasttext = strrchr($fileurl, '.'); $len = -strlen($lasttext); $path = substr($fileurl, 0, $len); $path = ltrim($path, '/'); $filelist = glob(BASE_PATH . $path . '*'); foreach ($filelist as $delfile) { $lasttext = strrchr($delfile, '.'); if (!in_array($lasttext, array('.htm', '.html', '.shtml'))) { continue; } @unlink($delfile); } } else { $fileurl = 0; } // 删除内容 $this->db->delete_content($id, $fileurl, $catid); // 删除统计表数据 $this->hits_db->delete(array('hitsid' => 'c-' . $modelid . '-' . $id)); // 删除附件 $attachment->api_delete('c-' . $catid . '-' . $id); // 删除审核表数据 $this->content_check_db->delete(array('checkid' => 'c-' . $id . '-' . $modelid)); // 删除推荐位数据 $this->position_data_db->delete(array('id' => $id, 'catid' => $catid, 'application' => 'content')); // 删除全站搜索中数据 $this->search_db->delete_search($typeid, $id); // 删除相关的评论 $commentid = id_encode('content_' . $catid, $id); $this->comment->del($commentid, $id, $catid); } // 更新栏目统计 $this->db->cache_items(); showmessage(L('operation_success'), HTTP_REFERER); } else { showmessage(L('operation_failure')); } }
/** * 功能:引导MVC模式 * $Id$ */ //包含核心文件 require_once SYSTEMPATH . 'sf/sf.class.php'; require_once SYSTEMPATH . 'sf/config.class.php'; require_once SYSTEMPATH . 'sf/sfexception.class.php'; require_once SYSTEMPATH . 'sf/router.class.php'; require_once SYSTEMPATH . 'sf/loader.class.php'; require_once SYSTEMPATH . 'sf/language.class.php'; require_once SYSTEMPATH . 'sf/input.class.php'; //加载配置文件 config::load('default'); //加载必要库文件 loader::lib(array("controller", "model")); //加载默认helper loader::helper(config::get("auto_load_helper", 'url')); //加载默认插件 config::get("auto_load_plugin") && loader::plugin(config::get("auto_load_plugin")); //初始化pathinfo router::parse(); //加载语言文件 lang::setLang(config::get("default_lang", "chinese")); lang::load("global"); //执行控制器 $controller = sf::getController(router::getController()); try { method_exists($controller, "load") && $controller->load(); //存在LOAD方法执行LOAD方法(页面执行开始执行) if (!method_exists($controller, router::getMethod())) {
function core() { need_login('page'); @set_time_limit(0); @ignore_user_abort(true); $newversion = $this->getRequest('version'); $software = 'meiupic'; $version = MPIC_VERSION; if ($newversion == $version) { exit(lang('no_need_to_update')); } if (!$newversion) { exit(lang('version_can_not_be_empty')); } //检查目录是否可以读写 $directory = @dir(ROOTDIR); while ($entry = $directory->read()) { if ($entry == '..' || $entry == '.') { continue; } $filename = ROOTDIR . $entry; if (is_dir($filename) && !dir_writeable($filename)) { exit(lang('dir_not_writable', $filename)); } elseif (is_file($filename) && !is_writable($filename)) { exit(lang('file_not_writable', $filename)); } } $directory->close(); $langset = LANGSET; $time = time(); $hash = md5("{$newversion}{$software}{$version}{$langset}{$time}"); $q = base64_encode("newversion={$newversion}&software={$software}&version={$version}&langset={$langset}&time={$time}&hash={$hash}"); $url = CHECK_UPDATE_URL . '?act=update&q=' . $q; $response = get_remote($url, 2); if (!$response) { exit(lang('connect_to_server_failed')); } $json =& loader::lib('json'); $result = $json->decode($response); if ($result['return']) { $tmpfile = ROOTDIR . 'cache/tmp/update.zip'; if (file_exists($tmpfile) && md5_file($tmpfile) == $result['md5']) { echo lang('file_has_been_downloaded') . '<br />'; } else { $content = get_remote($result['package']); file_put_contents($tmpfile, $content); $file_md5 = md5_file($tmpfile); if ($file_md5 != $result['md5']) { echo lang('download_package_failed') . '<br />'; exit; } echo lang('download_package_succ') . '<br />'; } $zip =& loader::lib('zip'); $zip->load_file($tmpfile); $zip->extract(PCLZIP_OPT_PATH, './', PCLZIP_OPT_REPLACE_NEWER); echo lang('unzip_package_succ') . '<br />'; echo lang('delete_tmp_download_file') . '<br />'; @unlink($tmpfile); echo lang('upgrade_after_jump') . '<br />'; redirect(site_link('default'), 1); } else { exit(lang('get_update_fail')); } }
$mdl_setting->set_conf('system.installed_time', time()); $mdl_setting->set_conf('system.gravatar_url', 'http://www.gravatar.com/avatar/{idstring}?rating=G&size=48&d=mm'); $mdl_setting->set_conf('system.enable_auto_update', true); $mdl_setting->set_conf('system.show_process_info', false); $mdl_setting->set_conf('system.language', INS_LANG); $mdl_setting->set_conf('system.timezone', 8); $mdl_setting->set_conf('system.current_theme', 'sense'); $mdl_setting->set_conf('site.title', $sitename); $mdl_setting->set_conf('site.url', $siteurl); $mdl_setting->set_conf('site.footer', ''); $mdl_setting->set_conf('site.email', $email); $mdl_setting->set_conf('site.share_title', lang('share_title')); $mdl_setting->set_conf('site.keywords', lang('site_keywords')); $mdl_setting->set_conf('site.description', lang('site_desc')); showjsmessage(lang('update_user_setting')); $plugin =& loader::lib('plugin'); $plugin->install_plugin('copyimg'); $plugin->enable_plugin('copyimg'); showjsmessage(lang('install_default_plugins')); echo '<script type="text/javascript">document.getElementById("laststep").disabled=false;document.getElementById("laststep").value = \'' . lang('installed_complete') . '\';</script><script type="text/javascript">setTimeout(function(){window.location=\'index.php?method=complete\'}, 2000);</script>' . "\r\n"; @touch(ROOTDIR . 'conf/install.lock'); getstatinfo(array('email' => $email)); show_footer(); } else { show_form($form_db_init_items, $error_msg); } } elseif ($method == 'complete') { $step = 4; show_header(); echo '<ul style="line-height: 200%; margin-left: 30px;">'; echo '<li><a href="../">' . lang('install_succeed') . '</a><br>';
function clear_nav_cache() { $cache =& loader::lib('cache'); $cache->remove('enabled_navs'); }
function meta() { $id = intval($this->getGet('id')); $info = $this->mdl_photo->get_info($id); if (!$info) { showError(lang('photo_not_exists')); } if (!$info['exif']) { showError(lang('no_access_view_exif')); } if (!$this->mdl_album->check_album_priv($info['album_id'])) { $this->_priv_page($info['album_id']); exit; } $info['exif'] = unserialize($info['exif']); $exif_obj =& loader::lib('exif'); $exif = $exif_obj->parse_exif($info['exif']); $metas = array(); if ($exif) { foreach ($exif as $k => $v) { $metas[] = array('key' => $k, 'value' => $v, 'cname' => lang('exif_' . $k)); } } $this->output->set('metas', $metas); $this->output->set('info', $info); $album_info = $this->mdl_album->get_info($info['album_id']); //面包屑 $crumb_nav = $this->mdl_cate->cate_path_link($album_info['cate_id']); $crumb_nav[] = array('name' => $album_info['name'], 'link' => site_link('photos', 'index', array('aid' => $album_info['id']))); $crumb_nav[] = array('name' => lang('view_photo_exif', $info['name']), 'link' => site_link('photos', 'view', array('id' => $info['id']))); $this->page_crumb($crumb_nav); $page_title = lang('view_photo_exif', $info['name']) . ' - ' . $this->setting->get_conf('site.title'); $page_keywords = $this->setting->get_conf('site.keywords'); $page_description = $this->setting->get_conf('site.description'); $this->page_init($page_title, $page_keywords, $page_description, $info['album_id'], $id); $this->render(); }
<?php /** * 类名:翻页类 * 功能:完成数据的翻页功能 * $Id$ */ loader::lib("Collection"); class Pager extends Collection { private $maxnum; private $navchar = array(); private $form_vars = array(); private $key; private $totalnum; private $totalpage; private $startnum; private $endnum; private $pagenum; private $shownum; private $field; private $linkhead; private $cur_row = 0; private $total_row = 0; public function __construct($totalnum = '', $maxnum = '', $key = "", $form_vars = array()) { $this->totalnum = $totalnum; $this->maxnum = $maxnum; $this->key = $key; $has_post = false; $this->navchar = array(lang::get('first'), '[<]', '[>]', lang::get('last'));
function save_config($plugin, $config) { $this->db->update('#@plugins', 'plugin_id=' . $this->db->q_str($plugin), array('plugin_config' => addslashes(serialize($config)))); if ($this->db->query()) { $cache =& loader::lib('cache'); $cache->remove('plugins'); return true; } else { return false; } }
function save() { @set_time_limit(0); @ignore_user_abort(true); $type = $this->getGet('t'); $album_id = intval($this->getRequest('aid')); if (!$album_id) { showError(lang('pls_sel_album')); } if ($type == 'multi') { need_login('ajax'); /*$files_count = intval($this->getPost('muilti_uploader_count')); for($i=0;$i<$files_count;$i++){ $filename = $this->getPost("muilti_uploader_{$i}_tmpname"); $realname = $this->getPost("muilti_uploader_{$i}_name"); $purename = file_pure_name($filename); $purerealname = file_pure_name($realname); $photorow = $this->mdl_photo->get_photo_by_name_aid($album_id,$purename); if($photorow){ $this->mdl_photo->update($photorow['id'],array('name'=>$purerealname)); } } */ $this->mdl_album->update_photos_num($album_id); $this->mdl_album->check_repare_cover($album_id); $gourl = site_link('photos', 'index', array('aid' => $album_id)); form_ajax_success('box', lang('upload_photo_success'), null, 1, $gourl); } else { need_login('page'); $this->output->set('album_id', $album_id); $album_info = $this->mdl_album->get_info($album_id); $this->output->set('album_info', $album_info); $page_title = lang('upload_photo') . ' - ' . $this->setting->get_conf('site.title'); $page_keywords = $this->setting->get_conf('site.keywords'); $page_description = $this->setting->get_conf('site.description'); $this->page_init($page_title, $page_keywords, $page_description); $imglib =& loader::lib('image'); $supportType = $imglib->supportType(); $empty_num = 0; $error = ''; $allowsize = allowsize($this->setting->get_conf('upload.allow_size')); if (isset($_FILES['imgs'])) { foreach ($_FILES['imgs']['name'] as $k => $upfile) { if (!empty($upfile)) { $filesize = $_FILES['imgs']['size'][$k]; $tmpfile = $_FILES['imgs']['tmp_name'][$k]; $filename = $upfile; $fileext = file_ext($filename); if ($_FILES['imgs']['error'][$k] == 1) { $error .= lang('failed_larger_than_server', $filename) . '<br />'; continue; } if ($allowsize && $filesize > $allowsize) { $error .= lang('failed_larger_than_usetting', $filename) . '<br />'; continue; } if ($filesize == 0) { $error .= lang('failed_if_file', $filename) . '<br />'; continue; } if (!in_array($fileext, $supportType)) { $error .= lang('failed_not_support', $filename) . '<br />'; continue; } if (!$this->mdl_photo->save_upload($album_id, $tmpfile, $filename, true, array('cate_id' => $album_info['cate_id']))) { $error .= lang('file_upload_failed', $filename) . '<br />'; } } else { $empty_num++; } } } else { $error = lang('need_sel_upload_file'); } if (isset($_FILES['imgs']) && $empty_num == count($_FILES['imgs']['name'])) { $this->output->set('msginfo', '<div class="failed">' . lang('need_sel_upload_file') . '</div>'); } else { $this->mdl_album->update_photos_num($album_id); $this->mdl_album->check_repare_cover($album_id); if ($error) { $this->output->set('msginfo', '<div class="failed">' . $error . '</div>'); } else { $this->output->set('msginfo', '<div class="success">' . lang('upload_photo_success') . '<a href="' . site_link('photos', 'index', array('aid' => $album_id)) . '">' . lang('view_album') . '</a></div>'); } } $crumb_nav = array(); $crumb_nav[] = array('name' => lang('upload_photo')); $this->page_crumb($crumb_nav); loader::view('upload/normal'); } }
function rotate_photo($id, $degree) { $tmpfslib =& loader::lib('tmpfs'); $storlib =& loader::lib('storage'); $photo_info = $this->get_info($id); $path = $photo_info['path']; //将存储的图片读取到临时文件 $tmpfile = time() . rand(1000, 9999) . '.' . file_ext($path); $tmpfslib->write($tmpfile, $storlib->read($path)); $tmpfilepath = $tmpfslib->get_path($tmpfile); $thumbtmpfilepath = $tmpfilepath . '.thumb.tmp'; $imglib =& loader::lib('image'); $imglib->load($tmpfilepath); $imglib->rotate(intval($degree)); $imglib->save($tmpfilepath); $data['width'] = $imglib->getWidth(); $data['height'] = $imglib->getHeight(); $setting =& Loader::model('setting'); $thumb_width = $setting->get_conf('upload.thumb_width', 180); $thumb_height = $setting->get_conf('upload.thumb_height', 180); if ($data['width'] > $thumb_width || $data['height'] > $thumb_height) { if ($setting->get_conf('upload.enable_thumb_cut', false)) { $imglib->resizeCut($thumb_width, $resizeCut); //裁剪 } else { $imglib->resizeScale($thumb_width, $thumb_height); } $imglib->save($thumbtmpfilepath); } else { @copy($tmpfile, $thumbtmpfilepath); } $imglib->close(); $storlib->upload($photo_info['path'], $tmpfilepath); $storlib->upload($photo_info['thumb'], $thumbtmpfilepath); $this->update($id, $data); $tmpfslib->delete($tmpfilepath); $tmpfslib->delete($thumbtmpfilepath); if ($photo_info['is_cover']) { $mdl_album =& Loader::model('album'); $mdl_album->set_cover($id); } return true; }