示例#1
0
 function edit()
 {
     events::observe('save', 'templates', 'apps', '_save');
     events::observer();
     $tmpl_file = events::get('tmpl_file');
     $app = events::get('app');
     if (events::detect('restore')) {
         self::restoreVersion($app, $tmpl_file, events::get('restore'));
     }
     admin::components('tabs', 'validator');
     f::set('app', $app);
     f::set('tmpl_file', $tmpl_file);
     s::set('app', $app);
     s::set('tmpl_file', $tmpl_file);
     $file = SYS_ROOT . 'tmpls/' . ADMIN_SITE . '/' . $app . '/' . $tmpl_file;
     $code = files::get($file);
     f::set('tmpl_code', $code);
     self::getApps();
     /*
     	Load versions
     */
     db::table('templates_versions');
     db::where('app', $app);
     db::where('tmpl_file', $tmpl_file);
     db::order('version_date', 'DESC');
     $res = db::select();
     while ($row = mysql_fetch_assoc($res)) {
         $row['version_date'] = dt::date2print('%H:%i %d.%m.%Y', $row['version_date']);
         $row['version_code'] = '{non}' . htmlspecialchars($row['version_code']) . '{/non}';
         s::roll('versions', $row);
     }
 }
示例#2
0
 /**
  * Make sure the session is started within the constructor
  */
 public function __construct()
 {
     s::start();
     if (!isset($_SESSION['_cache'])) {
         $_SESSION['_cache'] = array();
     }
 }
示例#3
0
 /**
  * Set flash data
  *
  * @param  string  $key
  * @param  mixed  $value
  * @return void
  */
 public static function set($key, $value)
 {
     if (!isset($data[$key])) {
         static::$data[$key] = $value;
     }
     Session::set(self::sessionKey(), static::$data);
 }
示例#4
0
文件: errors.php 项目: rigidus/ea
 function show($name)
 {
     foreach (self::$errors as $k => $v) {
         $show .= '<li>' . $v . '</li>';
     }
     s::set($name, '<ul>' . $show . '</ul>');
 }
示例#5
0
 public function login($welcome = null)
 {
     if ($user = panel()->site()->user()) {
         go(panel()->urls()->index());
     }
     $message = l('login.error');
     $error = false;
     $form = panel()->form('login');
     $form->cancel = false;
     $form->save = l('login.button');
     $form->centered = true;
     if (r::is('post') and get('_csfr') and csfr(get('_csfr'))) {
         $data = $form->serialize();
         $user = site()->user(str::lower($data['username']));
         if (!$user) {
             $error = true;
         } else {
             if (!$user->hasPanelAccess()) {
                 $error = true;
             } else {
                 if (!$user->login(get('password'))) {
                     $error = true;
                 } else {
                     go(panel()->urls()->index());
                 }
             }
         }
     }
     if ($username = s::get('username')) {
         $form->fields->username->value = html($username, false);
     }
     return layout('login', array('meta' => new Snippet('meta'), 'welcome' => $welcome ? l('login.welcome') : '', 'form' => $form, 'error' => $error ? $message : false));
 }
示例#6
0
 /**
  * Remove old values from the Session’s flash data.
  */
 public static function flush()
 {
     // Make sure the session is started
     s::start();
     // Retrieve the flash data
     $registry = s::get(self::$namespace);
     // Clean up registry
     if (!empty($registry)) {
         foreach ($registry as $key => $expiry) {
             $expiry++;
             // Remove all old values from the session
             if ($expiry > 1) {
                 s::remove($key);
                 unset($registry[$key]);
             } else {
                 $registry[$key] = $expiry;
             }
         }
         // Write registry back to session
         if (!empty($registry)) {
             s::set(self::$namespace, $registry);
         } else {
             s::remove(self::$namespace);
         }
     }
 }
示例#7
0
文件: buffer.php 项目: rigidus/ea
 function get($app, $tpl, $data, $section = false, $sys = false)
 {
     if ($tpl) {
         $tmpl = false;
         if ($sys) {
             $file = APPS . $app . '/' . self::$module . '/' . RULE . '/' . $tpl;
         } else {
             $file = SYS_ROOT . 'tmpls/' . parent::$site . '/' . $app . '/' . $tpl;
         }
         $file_id = md5($file);
         if (isset(self::$file_data[$file_id])) {
             return self::$file_data[$file_id];
         }
         if (file_exists($file)) {
             ob_start();
             include $file;
             $data = ob_get_contents();
             ob_end_clean();
             //$data = file_get_contents($file);
             if ($section) {
                 s::section($section);
             }
             self::$file_data[$file_id] = $data;
         }
     }
     return $data;
 }
示例#8
0
 public function index()
 {
     if (site()->users()->count() > 0) {
         go(panel()->urls()->login());
     }
     if ($problems = installation::check()) {
         $content = view('installation/check', array('problems' => $problems));
     } else {
         $form = panel()->form('installation', array('language' => kirby()->option('panel.language', 'en')));
         $form->cancel = false;
         $form->save = l('installation.signup.button');
         $form->centered = true;
         foreach (panel()->languages() as $lang) {
             $form->fields()->get('language')->options[$lang->code()] = $lang->title();
         }
         $form->on('submit', function ($form) {
             try {
                 // fetch all the form data
                 $data = $form->serialize();
                 // make sure that the first user is an admin
                 $data['role'] = 'admin';
                 // try to create the new user
                 $user = panel()->site()->users()->create($data);
                 // store the new username for the login screen
                 s::set('username', $user->username());
                 // redirect to the login
                 go(panel()->urls()->login() . '/welcome');
             } catch (Exception $e) {
                 $form->alert($e->getMessage());
             }
         });
         $content = view('installation/signup', array('form' => $form));
     }
     return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content));
 }
示例#9
0
文件: clouds.php 项目: rigidus/ea
 function get($res, $name = 'clouds')
 {
     $nums_clouds = array();
     if (db::rows() > 0) {
         while ($row = mysql_fetch_array($res)) {
             $nums_clouds[$row['tag_name']] = $row['num'];
         }
         ksort($nums_clouds);
         $max_size = 200;
         // max font size in %
         $min_size = 100;
         // min font size in %
         $max_qty = max(array_values($nums_clouds));
         $min_qty = min(array_values($nums_clouds));
         $spread = $max_qty - $min_qty;
         if (0 == $spread) {
             $spread = 1;
         }
         $step = ($max_size - $min_size) / $spread;
         foreach ($nums_clouds as $k => $v) {
             $size = $min_size + ($v - $min_qty) * $step;
             s::roll($name, array('name' => $k, 'size' => $size, 'value' => $v));
         }
     }
 }
示例#10
0
文件: panel.php 项目: 04x10/04x10.com
 function __construct()
 {
     s::start();
     c::set('home.keepurl', true);
     // auto-detect the url if it is not set
     if (!c::get('url')) {
         c::set('url', c::get('scheme') . server::get('http_host'));
     }
     // setup the thumb plugin
     c::set('thumb.cache.root', c::get('root') . '/thumbs');
     c::set('thumb.cache.url', c::get('url') . '/thumbs');
     c::set('url', c::get('url') . '/' . c::get('panel.folder'));
     // remove the panel folder name from the uri
     c::set('subfolder', ltrim(c::get('subfolder') . '/' . c::get('panel.folder'), '/'));
     // attach the uri after caching
     $this->uri = new paneluri();
     if (c::get('lang.support')) {
         $path = $this->uri->path->toArray();
         $first = array_shift($path);
         if (!in_array($first, c::get('lang.available', array()))) {
             $first = c::get('lang.default');
         }
         // set the current language
         c::set('lang.current', $first);
         $this->uri->path = new uriPath($path);
     }
     // get the first set of pages
     $this->rootPages();
     // get the additional site info from content/site.txt
     $this->siteInfo();
 }
示例#11
0
 public function paginated($mode = 'sidebar')
 {
     if ($limit = $this->page->blueprint()->pages()->limit()) {
         $hash = sha1($this->page->id());
         switch ($mode) {
             case 'sidebar':
                 $id = 'pages.' . $hash;
                 $var = 'page';
                 break;
             case 'subpages/visible':
                 $id = 'subpages.visible.' . $hash;
                 $var = 'visible';
                 break;
             case 'subpages/invisible':
                 $id = 'subpages.invisible.' . $hash;
                 $var = 'invisible';
                 break;
         }
         $children = $this->paginate($limit, array('page' => get($var, s::get($id)), 'omitFirstPage' => false, 'variable' => $var, 'method' => 'query'));
         // store the last page
         s::set($id, $children->pagination()->page());
         return $children;
     } else {
         return $this;
     }
 }
示例#12
0
 public function message()
 {
     if ($message = s::get('message') and is_array($message)) {
         $text = a::get($message, 'text');
         $type = a::get($message, 'type', 'notification');
         $element = new Brick('div');
         $element->addClass('message');
         if ($type == 'error') {
             $element->addClass('message-is-alert');
         } else {
             $element->addClass('message-is-notice');
         }
         $element->append(function () use($text) {
             $content = new Brick('span');
             $content->addClass('message-content');
             $content->text($text);
             return $content;
         });
         $element->append(function () {
             $toggle = new Brick('a');
             $toggle->attr('href', url::current());
             $toggle->addClass('message-toggle');
             $toggle->html('<i>&times;</i>');
             return $toggle;
         });
         s::remove('message');
         return $element;
     }
 }
示例#13
0
 protected function signup()
 {
     $self = $this;
     $form = $this->form('installation/signup', array(), function ($form) use($self) {
         $form->validate();
         if (!$form->isValid()) {
             return false;
         }
         try {
             // fetch all the form data
             $data = $form->serialize();
             // make sure that the first user is an admin
             $data['role'] = 'admin';
             // try to create the new user
             $user = site()->users()->create($data);
             // store the new username for the login screen
             s::set('username', $user->username());
             // try to login the user automatically
             if ($user->hasPanelAccess()) {
                 $user->login($data['password']);
             }
             // redirect to the login
             $self->redirect('login');
         } catch (Exception $e) {
             $form->alert($e->getMessage());
         }
     });
     return $this->modal('index', compact('form'));
 }
示例#14
0
文件: auth.php 项目: LucasFyl/korakia
 public function logout()
 {
     s::restart();
     if ($user = panel()->site()->user()) {
         $user->logout();
     }
     go(panel()->urls()->login());
 }
示例#15
0
 protected function tearDown()
 {
     s::restart();
     // clean all triggers
     kirby::$triggered = array();
     kirby::$hooks = array();
     $this->removeContent();
     $this->removeAccounts();
 }
示例#16
0
 public static function get($name)
 {
     $messages = s::get('messages');
     foreach ($messages as $key => $message) {
         if ($message->name == $name) {
             return $message->value;
         }
     }
     s::remove('messages');
 }
示例#17
0
文件: manage.app.php 项目: rigidus/ea
 function rollApps()
 {
     $tmp = $apps = array();
     $file = SYS_ROOT . 'conf/global/apps.ini';
     $tmp = ini::parse($file);
     foreach ($tmp as $k => $v) {
         $v['app'] = $k;
         s::roll('apps', $v);
     }
 }
示例#18
0
 protected static function kill()
 {
     self::$user = null;
     // overwrite the token
     $token = str::random();
     // the cookie is valid for 24 hours
     cookie::set('authFrontend', $token, 60 * 60 * 24);
     // restart the session
     s::restart();
 }
示例#19
0
文件: blocks.app.php 项目: rigidus/ea
 function getBlocks($site_id = 1)
 {
     db::table('blocks');
     db::where('site_id', $site_id);
     db::where('block_pub', '1');
     db::order('block_name');
     $res = db::select();
     while ($row = mysql_fetch_assoc($res)) {
         s::roll('blocks', $row);
     }
 }
示例#20
0
文件: menus.app.php 项目: rigidus/ea
 function getMenus($site_id)
 {
     db::table('menus');
     db::where('site_id', $site_id);
     db::where('menu_pub', '1');
     db::order('menu_title');
     $res = db::select();
     while ($row = mysql_fetch_assoc($res)) {
         s::roll('menus', $row);
     }
 }
示例#21
0
 function view()
 {
     db::table('news');
     db::order('news_date', 'DESC');
     $res = db::select();
     while ($row = mysql_fetch_assoc($res)) {
         $row = filter::get('news_pub', array('unpub', 'pub'), $row);
         $row['news_title'] = strip_tags($row['news_title']);
         $row['news_date'] = dt::date2print('%d %F %Y, %H:%i', $row['news_date']);
         s::roll('news', $row);
     }
 }
示例#22
0
文件: log.module.php 项目: rigidus/ea
 function view()
 {
     db::table('admin_log_actions');
     db::join('admin_users', 'admin_log_actions', 'user_id');
     db::order('log_date', 'DESC');
     db::limit(30);
     $res = db::select();
     while ($row = mysql_fetch_assoc($res)) {
         $row['log_date'] = dt::format('%d.%m.%Y %H:%M', $row['log_date']);
         s::roll('logs_list', $row);
     }
 }
示例#23
0
 public function __call($method, array $params = array())
 {
     $prop = mb_strtolower(mb_substr($method, 3, 1)) . mb_substr($method, 4);
     // ucfirst in mb_string
     if (s::startsWith($method, 'get')) {
         return $this->get($prop);
     } elseif (s::startsWith($method, 'set')) {
         return $this->set($prop, $params[0]);
     } else {
         throw new \Psc\Exception('Undefined Method: ' . __CLASS__ . '::' . $method);
     }
 }
示例#24
0
 function show()
 {
     $event = web::getEvent();
     if ($event === false) {
         $year = date('Y');
     } else {
         $year = $event;
     }
     s::set('info_date_select', htmlspecialchars($year));
     $sql = "SELECT `section_year` as date FROM `info_sections` WHERE `section_view`='0'  GROUP BY `date` ORDER BY `date` DESC";
     $res = db::query($sql);
     $rows = mysql_num_rows($res);
     if ($rows > 1) {
         s::add('info_date_selector', '<ul class="years">');
         while ($row = mysql_fetch_assoc($res)) {
             if ($row['date'] == $year) {
                 $row['date'] = '<li><span>' . $row['date'] . '</span></li>';
             } else {
                 $row['date'] = '<li><a href="' . web::get('page_folder') . '' . $row['date'] . '/">' . $row['date'] . '</a></li>';
             }
             s::add('info_date_selector', $row['date']);
         }
         s::add('info_date_selector', '</ul>');
     }
     $files = array();
     db::table('info_files');
     $r = db::select();
     while ($a = mysql_fetch_assoc($r)) {
         $files[$a['section_id']][] = $a;
     }
     db::table('info_sections');
     db::order('section_order', 'DESC');
     db::where('section_year', $year);
     $r = db::select();
     if (db::rows() == 0) {
         web::error404();
     }
     while ($a = mysql_fetch_assoc($r)) {
         if ($a['section_view'] == '0') {
             s::roll('sections', $a);
         } else {
             s::roll('sections_view', $a);
         }
         if (isset($files[$a['section_id']])) {
             foreach ($files[$a['section_id']] as $v) {
                 $v['file_icon'] = files::getFileIco($v['file_type']);
                 $v['file_size'] = files::parseSizeSmart($v['file_size']);
                 s::roll('items' . $a['section_id'], $v);
             }
         }
     }
 }
示例#25
0
 function view()
 {
     events::observe('upload', 'index');
     events::observer();
     $dir = IMAGES_PATH . 'index/';
     db::table('images');
     $r = db::select();
     while ($a = mysql_fetch_assoc($r)) {
         $a = filter::get('img_set', array('unpub', 'pub'), $a);
         $a['thumb'] = $dir . $a['img_id'] . '_m.jpg';
         s::roll('images', $a);
     }
 }
示例#26
0
 function view()
 {
     db::table('mails');
     $res = db::select();
     if (db::rows() == 0) {
         s::section('no_data');
     } else {
         s::section('yes_data');
     }
     while ($row = mysql_fetch_assoc($res)) {
         s::roll('mails', $row);
     }
 }
示例#27
0
文件: app.php 项目: kompuser/panel
 public static function configure()
 {
     if (is_null(static::$site)) {
         static::$site = kirby::panelsetup();
     }
     // load all available routes
     static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'api.php');
     static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'views.php');
     // setup the blueprint root
     blueprint::$root = c::get('root.site') . DS . 'blueprints';
     // start the router
     static::$router = new Router();
     static::$router->register(static::$routes);
     // content language switcher variable
     if (static::$site->multilang()) {
         if ($language = server::get('http_language') or $language = s::get('lang')) {
             static::$site->visit('/', $language);
         }
         app::$language = static::$site->language()->code();
         s::set('lang', app::$language);
     }
     // load the interface language file
     if (static::$site->user()) {
         $languageCode = static::$site->user()->language();
     } else {
         $languageCode = c::get('panel.language', 'en');
     }
     // validate the language code
     if (!in_array($languageCode, static::languages()->keys())) {
         $languageCode = 'en';
     }
     // store the interface language
     app::$interfaceLanguage = $languageCode;
     $language = (require root('panel.app.languages') . DS . $languageCode . '.php');
     // set all language variables
     l::$data = $language['data'];
     // register router filters
     static::$router->filter('auth', function () {
         if (!app::$site->user()) {
             go('panel/login');
         }
     });
     // check for a completed installation
     static::$router->filter('isInstalled', function () {
         if (app::$site->users()->count() == 0) {
             go('panel/install');
         }
     });
     // only use the fragments of the path without params
     static::$path = implode('/', (array) url::fragments(detect::path()));
 }
示例#28
0
文件: loader.php 项目: rigidus/ea
 function start()
 {
     db::connect();
     if (!router::get(1)) {
         return true;
     }
     self::$map = array('mode' => router::get(0), 'app' => router::get(1), 'module' => 'main', 'action' => router::get(2), 'id' => router::get(4));
     s::set('SYS_PATH', 'http://' . SERVER . SYS_DIR);
     define('APP', APPS . self::get('app') . '/');
     s::set('APP', APP);
     define('MODULE', APP . self::get('module') . '/');
     s::set('MODULE', MODULE);
     if (stristr(self::$map['mode'], 'admin')) {
         self::$map['mode'] = 'admin';
     } else {
         self::$map['mode'] = 'web';
     }
     if (self::$map['mode'] == 'admin') {
         if (defined('ADMIN_USER_SITE_ID')) {
             admin::observer();
             define('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
             s::set('ADMIN_SITE_ID', ADMIN_USER_SITE_ID);
             db::table('admin_sites');
             db::where('site_id', ADMIN_USER_SITE_ID);
             db::limit(1);
             $row = db::select();
             define('ADMIN_SITE', db::get('site_domain'));
             s::set('ADMIN_SITE', ADMIN_SITE);
         }
     } else {
         web::getSite();
         $lang = lang::gets(LANG_INDEX, SITE_ID);
         /*
         	Authentification webUser
         */
         web::observer();
     }
     /*
     	Set params
     */
     params::send();
     if (router::get(0) == 'feed' || router::get(0) == 'rss') {
         self::$map['module'] = 'feed';
     }
     if (self::$map['mode'] == 'admin') {
         load::module(self::get('app'), self::get('module'), self::get('action'));
     } else {
         load::handler(self::get('app'), self::get('module'), self::get('action'));
     }
 }
示例#29
0
 public function login($welcome = null)
 {
     if ($user = panel()->site()->user()) {
         go(panel()->urls()->index());
     }
     $form = panel()->form('login');
     $form->cancel = false;
     $form->save = l('login.button');
     $form->centered = true;
     if ($username = s::get('username')) {
         $form->fields->username->value = html($username, false);
     }
     return layout('login', array('meta' => new Snippet('meta'), 'welcome' => $welcome ? l('login.welcome') : '', 'form' => $form));
 }
示例#30
0
 function showOne()
 {
     $news_id = web::getThis();
     db::table('news');
     db::where('news_pub', '1');
     $news = db::assoc();
     if (db::rows() == 0) {
         web::error404();
     }
     $news['news_date'] = dt::date2print('%d %F %Y', $news['news_date']);
     s::set('page_title', $news['news_title']);
     s::set('page_header', $news['news_title']);
     s::set($news);
 }