private function __construct() { $connectionSettings = ConfigHandler::LoadConfigFile("db"); switch ($connectionSettings['type']) { case 'cassandra': require_once(ROOT_PDIR . 'core/libs/phpcassa-0.7.a.4/connection.php'); require_once(ROOT_PDIR . 'core/libs/core/ADODB_cassandra.class.php'); $this->connection = new ADODB_cassandra(); $this->connection->connect($connectionSettings['server'], null, null, $connectionSettings['name']); //var_dump($this->connection); die(); break; default: $dsn = "{$connectionSettings['type']}://" . "{$connectionSettings['user']}:{$connectionSettings['pass']}" . "@{$connectionSettings['server']}" . "/{$connectionSettings['name']}" . "?persist&fetchmode=ASSOC"; $this->connection =& ADONewConnection($dsn); break; } // No go? if (!$this->connection) return; // Caching? // @todo Make this a config option. //$this->connection->memCache = true; //$this->connection->memCacheHost = 'localhost'; //$this->connection->memCacheCompress = false; }
public function index() { $view = $this->getView(); $request = $this->getPageRequest(); if (!\Core\user()->checkAccess('g:admin')) { return View::ERROR_ACCESSDENIED; } if ($request->isPost()) { // Update/save the site id. ConfigHandler::Set('/livefyre/siteid', $_POST['siteid']); \Core\set_message('Set Site ID Successfully!', 'success'); \Core\reload(); } // Pull the configuration options to see if livefyre is currently setup. $siteid = ConfigHandler::Get('/livefyre/siteid'); // Generate the form to either set or update the siteid. $form = new Form(); $form->set('method', 'POST'); $form->addElement('text', ['name' => 'siteid', 'title' => 'Site ID', 'value' => $siteid]); $view->assign('siteid', $siteid); $view->assign('url', ROOT_URL_NOSSL); $view->assign('form', $form); // Setup instructions: // http://www.livefyre.com/install/ }
function login() { $this->_fix_failedlogins(); if(MEMBER_ID < 1) { $this->Messager("请先在前台进行<a href='index.php?mod=account&code=login'><b>登录</b></a>",null); } $loginperm = $this->_logincheck(); if(!$loginperm) { $this->Messager("累计 5 次错误尝试,15 分钟内您将不能登录。",null); } $this->Title="用户登录"; if ($this->CookieHandler->GetVar('referer')=='') { $this->CookieHandler->Setvar('referer',referer()); } $action="admin.php?mod=login&code=dologin"; $question_select=FormHandler::Select('question',ConfigHandler::get('member','question_list'),0); $role_type_select=FormHandler::Radio('role_type',ConfigHandler::get('member','role_type_list'),'normal'); ob_clean(); include(handler('template')->file("@admin/login")); }
public function render() { if (!isset($this->_attributes['title'])) { $this->_attributes['title'] = ConfigHandler::Get('/captcha/formtext'); } return parent::render(); }
public static function SiteSearch() { $key = \ConfigHandler::Get('/google/cse/key'); $min = \ConfigHandler::Get('/core/markup/minified'); // If there's no code available, don't display anything. if (!$key) { return; } $script = <<<EOD \t\t<script> \t\t\t(function() { \t\t\t\tvar cx = '{$key}'; \t\t\t\tvar gcse = document.createElement('script'); \t\t\t\tgcse.type = 'text/javascript'; \t\t\t\tgcse.async = true; \t\t\t\tgcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + \t\t\t\t\t\t'//www.google.com/cse/cse.js?cx=' + cx; \t\t\t\tvar s = document.getElementsByTagName('script')[0]; \t\t\t\ts.parentNode.insertBefore(gcse, s); \t\t\t})(); \t\t</script> EOD; // Just to make it a little smaller... if ($min) { $script = trim(str_replace(array("\n", "\r"), '', $script)); } // Add the necessary script \Core\view()->addScript($script, 'foot'); return true; }
public function view() { $page = PageRequest::GetSystemRequest(); $pageview = $page->getView(); $pagemetas = $pageview->meta; $view = $this->getView(); // The main identifier for livefyre, retrieved from within the livefyre "install" section. // Transposed to siteId $siteid = ConfigHandler::Get('/livefyre/siteid'); if (!$siteid) { $msg = 'Livefyre is not configured yet.'; if (\Core\user()->checkAccess('g:admin')) { $msg .= ' Please <a href="' . \Core\resolve_link('/livefyre') . '">configure it now</a>'; } return $msg; } // The "article" is the base url. This doesn't change despite changing URLs. // Transposed to articleId $article = $page->getBaseURL(); // The title, used in the collectionMeta. // Transposed to title $title = $pageview->title; // The canonical URL, used in the collectionMeta. $url = $pageview->canonicalurl; $view->assign('siteId', $siteid); $view->assign('articleId', $article); $view->assign('title', $title); $view->assign('url', $url); }
/** * @deprecated 2012.06.13 */ public function execute() { $v = $this->getView(); $u = Core::User(); $v->assign('user', $u); $v->assign('loggedin', $u->exists()); $v->assign('allowregister', ConfigHandler::Get('/user/register/allowpublic')); }
/** * @copyright (C)2014 Cenwor Inc. * @author Cenwor <www.cenwor.com> * @package php * @name common.func.php * @date 2014-11-04 13:51:54 */ function position() { global $rewriteHandler; $decribe=__('您的位置:'); $child_symbol=' > '; $mod=$_GET['rmod']?$_GET['rmod']:$_GET['mod']; if(strpos($mod,'_')!==false)list($mod,$mod_child)=explode('_',$mod); $code=$_GET['code']; $config = ConfigHandler::get(); $list['index']="<a href='{$config['site_url']}'>{$config['site_name']}".__('首页')."</a>"; $list['mod']=ConfigHandler::get('header_menu','list',$mod); if($list['mod']!=false) { if($rewriteHandler)$list['mod']['link']=$rewriteHandler->formatURL($list['mod']['link']); $list['mod']="<a href='{$list['mod']['link']}'>{$list['mod']['name']}</a>"; } else { unset($list['mod']); } $args_list=func_get_args(); if(is_array($args_list) and count($args_list)>0) { foreach ($args_list as $key=>$value) { if(empty($value))continue; if(is_string($value)) { if(trim($value)=='')continue; $value=preg_replace("~(\s+[/]\s+)|(\-\>)~",$child_symbol,$value); } else { if(isset($value['name'])) { $value['url']=($value['url']!='')?$value['url']:$value['link']; $url=$value['url']; $name=$value['name']; } else { $url=current($value); $name=key($value); } if($rewriteHandler)$url=$rewriteHandler->formatURL($url); $value="<a href='$url'>$name</a>"; } $list[$key]=$value; } } $position=implode($child_symbol,$list); return $decribe.$position; }
function set() { global $_CONFIG; $func_num_args=func_num_args(); $func_args=func_get_args(); $value=array_pop($func_args); $value = dstripslashes($value); $type=array_shift($func_args); $remark = '/'.'********************************************* *[tttuangou] (C)2005 - 2010 Cenwor Inc. * * tttuangou '.$type.'配置 * * @author www.tttuangou.net * * @time '.date('Y-m-d H:i').' *********************************************'.'/ '; $file=ConfigHandler::file($type); if($type===null) { $data="<?php \r\n {$remark} \r\n \$config=".var_export($value,true)."; \r\n ?>"; } else { if(($config=$_CONFIG[$type])===null) { $config=array(); @include($file); $config=$config[$type]; } foreach($func_args as $arg) { $path_str.="['$arg']"; } eval($value===null?'unset($config'.$path_str.');':'$config'.$path_str.'=$value;'); $data="<?php \r\n {$remark} \r\n\$config['$type']=".var_export($config,true).";\r\n?>"; } @$fp=fopen($file,'wb'); if(!$fp) { zlog('error')->found('denied.io', $file); die($file."文件无法写入,请检查是否有可写权限。"); } $len=fwrite($fp, $data); fclose($fp); if($len)$_CONFIG[$type]=$config; return $len; }
public static function InstallTracking() { $siteid = \ConfigHandler::Get('/piwik/siteid'); $server = \ConfigHandler::Get('/piwik/server/host'); $all_domains = \ConfigHandler::Get('/piwik/tracking/all_subdomains'); $domain_title = \ConfigHandler::Get('/piwik/tracking/domain_title'); // If there's no code available, don't display anything. if (!($siteid && $server)) { return; } // Trim the server. $server = trim($server, '/'); $paqopts = []; $paqopts[] = '"trackPageView"'; $paqopts[] = '"enableLinkTracking"'; if ($all_domains) { $h = '*.' . HOST; if (strpos($h, '*.www.') === 0) { $h = str_replace('*.www.', '*.', $h); } $paqopts[] = '"setCookieDomain", "' . $h . '"'; } if ($domain_title) { $paqopts[] = '"setDocumentTitle", document.domain + "/" + document.title'; } $paqstr = ''; foreach ($paqopts as $k => $v) { $paqstr .= ' _paq.push([' . $v . ']);' . "\n"; } // This version of the script is Piwik's newest version as of 2013.06.19 $script = <<<EOD <!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; {$paqstr} (function() { var u=(("https:" == document.location.protocol) ? "https" : "http") + "://{$server}/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', {$siteid}]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Piwik Code --> EOD; // Add the necessary scripts \Core\view()->addScript($script, 'head'); \Core\view()->appendBodyContent('<noscript><p><img src="http://' . $server . '/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>'); return true; }
public static function InstallTracking() { $gacode = \ConfigHandler::Get('/google-analytics/accountid'); $tagcode = \ConfigHandler::Get('/google/tagmanager/tagid'); //$site = HOST; $min = \ConfigHandler::Get('/core/markup/minified'); // If there's no code available, don't display anything. if ($tagcode) { // Tag Manager, load EITHER this or analytics. $script = <<<EOD <noscript> \t<iframe src="//www.googletagmanager.com/ns.html?id={$tagcode}" height="0" width="0" style="display:none;visibility:hidden"></iframe> </noscript> <script> \t(function(w,d,s,l,i){ \t\tw[l]=w[l]||[]; \t\tw[l].push( { \t\t\t'gtm.start': new Date().getTime(), \t\t\tevent:'gtm.js' \t\t}); \t\tvar f=d.getElementsByTagName(s)[0], \t\t\tj=d.createElement(s), \t\t\tdl=l!='dataLayer'?'&l='+l:''; \t\tj.async=true; \t\tj.src='//www.googletagmanager.com/gtm.js?id='+i+dl; \t\tf.parentNode.insertBefore(j,f); \t})(window,document,'script','dataLayer','{$tagcode}'); </script> EOD; } elseif ($gacode) { // This version of the script is Google's newest version as of 2014.05 $script = <<<EOD <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', '{$gacode}', 'auto'); ga('send', 'pageview'); </script> EOD; } else { return null; } // Just to make it a little smaller... if ($min) { $script = trim(str_replace(array("\n", "\r"), '', $script)); } // Add the necessary script \Core\view()->addScript($script, 'foot'); return true; }
/** * Parse an array of key-value pairs and return an array of specified * parameters. * * @param array An array of parameters. * @param string A parameter identifer. * * @return string A string representation of an array of initialization * parameters, if any parameters exists, otherwise the string * form of null. * * @author Sean Kerr (skerr@mojavi.org) * @since 3.0.0 */ public static function &parse(&$array, $identifer = 'param') { $parameters = array(); // get the identifer length $identifer = $identifer . '.'; $length = strlen($identifer); foreach ($array as $key => &$value) { if (strlen($key) > $length && substr($key, 0, $length) == $identifer) { // literalize our value $value = ConfigHandler::literalize($value); // we found a parameter, let's add this baby to our list $parameter = substr($key, $length); if (preg_match('/\\.[0-9]+$/', $parameter)) { // we have an array of parameter values, get the actual // parameter name preg_match('/(.*?)\\.[0-9]+$/', $parameter, $match); $parameter = $match[1]; if (!isset($parameters[$parameter])) { // create our parameter's sub-array $parameters[$parameter] = array(); } // add our parameter to the array $parameters[$parameter][] =& $value; } else { // just a boring 'ol string value $parameters[$parameter] =& $value; } } } if (count($parameters) == 0) { // no parameters $retval = 'null'; return $retval; } // init our return value $retval = array(); // loop through the parameters list foreach ($parameters as $parameter => &$value) { if (is_array($value)) { // we have an array value $tmp = "'%s' => array(%s)"; $retval[] = sprintf($tmp, $parameter, implode(', ', $value)); } else { // we have a normal value $tmp = "'%s' => %s"; $retval[] = sprintf($tmp, $parameter, $value); } } // complete the return value $tmp = 'array(%s)'; $retval = sprintf($tmp, implode(', ', $retval)); return $retval; }
function CheckUsername() { $username=trim($this->Post['username'] ? $this->Post['username'] : $this->Post['check_value']); if (strlen($username) < 3 || strlen($username) > 15) { response_text(__("用户名长度请控制在3~15")); } if (($filter_msg = filter($username))) { response_text("用户名 ".$filter_msg); } if (preg_match('~[\~\`\!\@\#\$\%\^\&\*\(\)\=\+\[\{\]\}\;\:\'\"\,\<\.\>\/\?]~',$username)) { response_text(__("用户名不能包含特殊字符")); } $censoruser = ConfigHandler::get('user','forbid'); $censoruser .= "topic login member profile tag get_password report weather master url"; $censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($censoruser = trim($censoruser)), '/')).')$/i'; if($censoruser && @preg_match($censorexp, $username)) { response_text(sprintf(__("用户名<b>%s</b>被保留,禁止注册"), $username)); } $response= "对不起,您输入的用户名 <B>{$username}</B> 不能注册或已经被他人使用,请选择其他名字后再试。"; $this->DatabaseHandler->SetTable(TABLE_PREFIX. 'system_members'); $is_exists=$this->DatabaseHandler->Select('',"username='******'"); if($is_exists) { response_text($response); } if(true === UCENTER) { include_once(UC_CLIENT_ROOT . './client.php'); $uc_result = uc_user_checkname($username); if($uc_result < 0) { response_text($response); } } exit ; }
function ModuleObject( $config ) { $this->MasterObject($config); Load::logic('product'); $this->ProductLogic = new ProductLogic(); Load::logic('pay'); $this->PayLogic = new PayLogic(); Load::logic('me'); $this->MeLogic = new MeLogic(); Load::logic('order'); $this->OrderLogic = new OrderLogic(); $this->ID = ( int )($this->Post['id'] ? $this->Post['id'] : $this->Get['id']); $this->CacheConfig = ConfigHandler::get('cache'); $this->ShowConfig = ConfigHandler::get('show'); $runCode = Load::moduleCode($this, $this->Code); $this->$runCode(); }
public static function Load() { // I need jquery UI as a pre-req... if (!JQuery::IncludeJQueryUI()) { return false; } if (ConfigHandler::Get('/core/javascript/minified')) { \Core\view()->addScript('js/jquery.lightbox-0.5.min.js'); } else { \Core\view()->addScript('js/jquery.lightbox-0.5.js'); } \Core\view()->addStylesheet('css/jquery.lightbox-0.5.css'); // IMPORTANT! Tells the script that the include succeeded! return true; }
function MasterObject(&$config) { $config['v'] = SYS_VERSION; $this->Config=$config; $this->Get = &$_GET; $this->Post = &$_POST; $this->Cookie = &$_COOKIE; $this->Session = &$_SESSION; $this->Request = &$_REQUEST; $this->Server = &$_SERVER; $this->Files = &$_FILES; $this->Module = $this->Post['mod']?$this->Post['mod']:$this->Get['mod']; $this->Code = $this->Post['code']?$this->Post['code']:$this->Get['code']; $this->OPC = trim($this->Post['op']?$this->Post['op']:$this->Get['op']); $GLOBALS['iframe'] = ''; $ipbanned=ConfigHandler::get('access','ipbanned'); if(!empty($ipbanned) && preg_match("~^({$ipbanned})~",$_SERVER['REMOTE_ADDR'])) { die(__("您的IP已经被禁止访问。")); } $this->TemplateHandler=new TemplateHandler($config); Obj::register('TemplateHandler',$this->TemplateHandler); $this->CookieHandler = handler('cookie'); $this->DatabaseHandler = dbc(); Obj::register('DatabaseHandler',$this->DatabaseHandler); Obj::register('CookieHandler',$this->CookieHandler); Obj::register('config',$this->Config); }
function Execute() { $this -> config=ConfigHandler::get('product'); $sql='select * from '.TABLE_PREFIX.'tttuangou_city '; $query = $this->DatabaseHandler->Query($sql); $this -> cityary=$query->GetAll(); if($_GET['city']!=''){ foreach($this -> cityary as $value){ if($value['shorthand'] == $_GET['city']){ $this->CookieHandler->setVar('mycity',$value['cityid']); $this -> city =$value['cityid']; break; }; }; }; if($this -> city == ''){ if($this->CookieHandler->getVar('mycity')!=''){ $this -> city = $this->CookieHandler->getVar('mycity'); }else{ $this -> city=1; }; }; foreach($this -> cityary as $value){ if($value['cityid'] == $this -> city){ $this -> cityname = $value['cityname']; break; }; }; ob_start(); $load_file=array("vivian_reg.css",'validate.js'); switch($this->Code) { case 'dologin': $this->DoLogin(); break; case 'logout': $this->LogOut(); break; default: $this->login(); break; } $body=ob_get_clean(); $this->ShowBody($body); }
public function register() { $view = $this->getView(); $user = \Core\user(); // Set the access permissions for this page as anonymous-only. if(!$user->checkAccess('g:anonymous;g:!admin')){ return ''; } // Also disallow access to this page if the configuration option is disabled. if(!ConfigHandler::Get('/user/register/allowpublic')){ return ''; } $auths = \Core\User\Helper::GetEnabledAuthDrivers(); $view->assign('drivers', $auths); }
function sms_remain() { $sms = ConfigHandler::get('sms'); $sms['server'] = sms_server_init(); $data = 'name='.$sms['account'].'&password='******'password']); $result = dfopen($sms['server'].'?method=remaincount&'.$data, 10485760, '', '', true); $result = iconv('GB2312', 'UTF-8/'.'/IGNORE', $result); preg_match('/<describe>(.*?)<\/describe>/', $result, $match); $status = $match[1]; preg_match('/<count>(.*?)<\/count>/', $result, $match); $remain = (int)$match[1]/10; if ($match[0] == '') { preg_match('/<message>(.*?)<\/message>/', $result, $match); $remain = $match[1]; } return array('status'=>$status, 'remain'=>$remain); }
/** * Widget to display some of the newest registrations, (if any). */ public function newestSignups(){ if(!\Core\user()->checkAccess('p:/user/users/manage')){ return ''; } // How far back do I want to search for? // 1 month sounds good! $date = new CoreDateTime(); $date->modify('-1 month'); $searches = UserModel::Find(['created > ' . $date->getFormatted('U')], 10, 'created DESC'); // No results? No problem :) if(!sizeof($searches)) return ''; $view = $this->getView(); $view->assign('enableavatar', (\ConfigHandler::Get('/user/enableavatar'))); $view->assign('users', $searches); }
/** * Simple method to handle any legacy call to favicon.ico */ public function index() { $view = $this->getView(); $image = ConfigHandler::Get('/favicon/image'); $file = \Core\Filestore\Factory::File($image); $view->contenttype = 'image/png'; $view->record = false; $view->mode = View::MODE_NOOUTPUT; // Fix Bug #562, Favicon "none" option. // Do not render anything if no icon is selected. if (!$image) { return; } if (!$file->exists()) { return; } $file->displayPreview('32x32!'); }
function ModuleObject( $config ) { $this->MasterObject($config); if (MEMBER_ID < 1) { $this->Messager(__('请先登录!'), '?mod=account&code=login'); } Load::logic('product'); $this->ProductLogic = new ProductLogic(); Load::logic('pay'); $this->PayLogic = new PayLogic(); Load::logic('me'); $this->MeLogic = new MeLogic(); Load::logic('order'); $this->OrderLogic = new OrderLogic(); $this->config = $config; $this->ID = ( int )($this->Post['id'] ? $this->Post['id'] : $this->Get['id']); $this->CacheConfig = ConfigHandler::get('cache'); $this->ShowConfig = ConfigHandler::get('show'); $runCode = Load::moduleCode($this, $this->Code); $this->$runCode(); }
function Execute() { if ($this->Code == '') { $this->Code = 'main'; } $this -> config=ConfigHandler::get('product'); list($this->cityary,$this->city,$this->cityname)=logic('misc')->City(); if ('main' == $this->Code) { ob_start(); $this->UrlList(); $body = ob_get_clean(); $this->ShowBody($body); } else { $this->RssOutput(); } }
public function __construct() { $admin = \Core\user()->checkAccess('g:admin'); $this->canupload = $admin || \Core\user()->checkAccess('p:/mediamanager/upload'); $this->canaccess = $this->canupload || \Core\user()->checkAccess('p:/mediamanager/browse'); switch (\ConfigHandler::Get('/mediamanager/sandbox')) { case 'user-sandboxed': $this->_basedir = 'public/media/' . \Core\user()->get('id') . '/'; break; case 'shared-user-sandbox': $this->_basedir = 'public/media/'; break; case 'completely-open': $this->_basedir = 'public/'; break; default: $this->_basedir = 'public/media/'; break; } }
public function badge() { $view = $this->getView(); $request = $this->getRequest(); $uid = $request->getParameter('user'); if ($uid instanceof UserModel) { $user = $uid; $uid = $user->get('id'); } else { $user = UserModel::Construct($uid); } $direction = $request->getParameter('direction') ? $request->getParameter('direction') : 'horizontal'; $orientation = $request->getParameter('orientation') ? $request->getParameter('orientation') : 'left'; $view->assign('enableavatar', \ConfigHandler::Get('/user/enableavatar')); $view->assign('link', UserSocialHelper::ResolveProfileLink($user)); $view->assign('user', $user); $view->assign('profiles', $user->get('external_profiles')); $view->assign('direction', $direction); $view->assign('orientation', $orientation); $view->assign('title', $request->getParameter('title')); }
public function fetch() { $data = []; $image = ConfigHandler::Get('/favicon/image'); if ($image) { $file = \Core\Filestore\Factory::File($image); } else { // Check the theme default. $file = \Core\Filestore\Factory::File('asset/images/favicon.png'); //return []; } if (!$file->exists()) { return []; } $data['favicon'] = '<link rel="icon" type="image/png" href="' . $file->getPreviewURL('32x32!') . '"/>'; $data['favicon-apple-touch-icon'] = '<link rel="apple-touch-icon" type="image/png" sizes="72x72" href="' . $file->getPreviewURL('72x72!') . '"/>'; $data['favicon-apple-touch-icon-2'] = '<link rel="apple-touch-icon" type="image/png" sizes="114x114" href="' . $file->getPreviewURL('114x114!') . '"/>'; $data['favicon-apple-touch-icon-retina'] = '<link rel="apple-touch-icon" sizes="512x512" type="image/png" href="' . $file->getPreviewURL('512x512!') . '"/>'; $data['favicon-windows-8'] = '<meta name="msapplication-TileImage" content="' . $file->getPreviewURL('270x270!') . '"/>'; return $data; }
function Execute(){ include_once ROOT_PATH . './setting/constants.php'; $this -> Title ='商家' . TUANGOU_STR . '管理'; if(MEMBER_ID < 1)$this->Messager("您必须先注册或登录!"); $this -> config=ConfigHandler::get('product'); list($this->cityary,$this->city,$this->cityname)=logic('misc')->City(); ob_start(); switch($this->Code){ case 'ticket': $this->Ticket(); break; case 'sendmail': $this->Sendmail(); break; case 'express': $this->Express(); break; default: $this->Main(); break; }; $body = ob_get_clean(); $this->ShowBody($body); }
/** * Display the login widget for facebook. This is actually just a button and FB handles the rest :) */ public function login() { // If facebook isn't in the list of allowed user backends, just exit out. if (!in_array('facebook', ConfigHandler::Get('/user/backends'))) { return ''; } $view = $this->getView(); $facebook = new Facebook(['appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_APP_SECRET]); $user = $facebook->getUser(); if ($user) { // User was already logged in. try { $user_profile = $facebook->api('/me'); $facebooklink = false; } catch (Exception $c) { $facebooklink = $facebook->getLoginUrl(); } // $logoutUrl = $facebook->getLogoutUrl(); } else { $facebooklink = $facebook->getLoginUrl(); } $view->assign('facebooklink', $facebooklink); }
public static function IncludeJQuery() { $use2x = \ConfigHandler::Get('/jquery/use_2_x'); if ($use2x === 'auto') { // Determine if it should be used based on the UA. // Remember, only IE <= 8.0 requires this. $ua = \Core\UserAgent::Construct(); if ($ua->browser == 'IE' && $ua->version <= 8) { $use2x = '0'; } else { $use2x = '1'; } } if ($use2x == '1') { // The site is setup to use 2.x, (default as of Core 4.0). \Core\view()->addScript('js/jquery/jquery-2.1.4.js'); } else { // The admin requested not to use the new version of jQuery. Stick with 1.11 then. \Core\view()->addScript('js/jquery/jquery-1.11.0.js'); } // IMPORTANT! Tells the script that the include succeeded! return true; }
public static function Check() { $pw = \ConfigHandler::Get('/security/site_password'); if ($pw == '') { return true; } if (EXEC_MODE != 'WEB') { // Simple site passwords only work when on the web. return true; } if (isset($_SERVER['PHP_AUTH_PW'])) { $userpw = $_SERVER['PHP_AUTH_PW']; } else { $userpw = null; } if ($userpw != $pw) { header('WWW-Authenticate: Basic realm="' . SITENAME . '"'); header('HTTP/1.0 401 Unauthorized'); echo 'Access to ' . SITENAME . ' requires a password.'; exit; } // Else everything. return true; }