public function on_start()
 {
     $this->error = Loader::helper('validation/error');
     if (USER_REGISTRATION_WITH_EMAIL_ADDRESS == true) {
         $this->set('uNameLabel', t('Email Address'));
     } else {
         $this->set('uNameLabel', t('Username'));
     }
     $txt = Loader::helper('text');
     if (strlen($_GET['uName'])) {
         // pre-populate the username if supplied, if its an email address with special characters the email needs to be urlencoded first,
         $this->set("uName", trim($txt->email($_GET['uName'])));
     }
     $languages = array();
     $locales = array();
     if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN')) {
         Loader::library('3rdparty/Zend/Locale');
         Loader::library('3rdparty/Zend/Locale/Data');
         $languages = Localization::getAvailableInterfaceLanguages();
         if (count($languages) > 0) {
             array_unshift($languages, 'en_US');
         }
         $locales = array('' => t('** Default'));
         Zend_Locale_Data::setCache(Cache::getLibrary());
         foreach ($languages as $lang) {
             $loc = new Zend_Locale($lang);
             $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', ACTIVE_LOCALE);
         }
     }
     $this->locales = $locales;
     $this->set('locales', $locales);
     $this->openIDReturnTo = BASE_URL . View::url("/login", "complete_openid");
 }
Ejemplo n.º 2
0
 public function getLibrary()
 {
     static $cache;
     if (!isset($cache) && defined('DIR_FILES_CACHE')) {
         if (is_dir(DIR_FILES_CACHE) && is_writable(DIR_FILES_CACHE)) {
             Loader::library('3rdparty/Zend/Cache');
             $frontendOptions = array('lifetime' => CACHE_LIFETIME, 'automatic_serialization' => true, 'cache_id_prefix' => CACHE_ID);
             $backendOptions = array('read_control' => false, 'cache_dir' => DIR_FILES_CACHE, 'file_locking' => false);
             if (defined('CACHE_BACKEND_OPTIONS')) {
                 $opts = unserialize(CACHE_BACKEND_OPTIONS);
                 foreach ($opts as $k => $v) {
                     $backendOptions[$k] = $v;
                 }
             }
             if (defined('CACHE_FRONTEND_OPTIONS')) {
                 $opts = unserialize(CACHE_FRONTEND_OPTIONS);
                 foreach ($opts as $k => $v) {
                     $frontendOptions[$k] = $v;
                 }
             }
             if (!defined('CACHE_LIBRARY') || defined("CACHE_LIBRARY") && CACHE_LIBRARY == "default") {
                 define('CACHE_LIBRARY', 'File');
             }
             $customBackendNaming = false;
             if (CACHE_LIBRARY == 'Zend_Cache_Backend_ZendServer_Shmem') {
                 $customBackendNaming = true;
             }
             $cache = Zend_Cache::factory('Core', CACHE_LIBRARY, $frontendOptions, $backendOptions, false, $customBackendNaming);
         }
     }
     return $cache;
 }
Ejemplo n.º 3
0
	public function enableNativeMobile() {
		Loader::library('3rdparty/mobile_detect');
		$md = new Mobile_Detect();
		if ($md->isMobile()) {
			$this->addHeaderItem('<meta name="viewport" content="width=device-width,initial-scale=1"></meta>');
		}
	}
Ejemplo n.º 4
0
 /**
  * Takes text and returns it in the "lowercase-and-dashed-with-no-punctuation" format
  *
  * @param string $handle
  * @param string $maxlength           Max number of characters of the return value
  * @param string $locale              Language code of the language rules that should be prioritized
  * @param bool   $removeExcludedWords Set to true to remove excluded words, false to allow them.
  * @return string
  */
 public function urlify($handle, $maxlength = PAGE_PATH_SEGMENT_MAX_LENGTH, $locale = '', $removeExcludedWords = true)
 {
     $text = strtolower(str_replace(array("\r", "\n", "\t"), ' ', $this->asciify($handle, $locale)));
     if ($removeExcludedWords) {
         $excludeSeoWords = Config::get('SEO_EXCLUDE_WORDS');
         if (is_string($excludeSeoWords)) {
             if (strlen($excludeSeoWords)) {
                 $remove_list = explode(',', $excludeSeoWords);
                 $remove_list = array_map('trim', $remove_list);
                 $remove_list = array_filter($remove_list, 'strlen');
             } else {
                 $remove_list = array();
             }
         } else {
             Loader::library('3rdparty/urlify');
             $remove_list = URLify::$remove_list;
         }
         if (count($remove_list)) {
             $text = preg_replace('/\\b(' . join('|', $remove_list) . ')\\b/i', '', $text);
         }
     }
     $text = preg_replace('/[^-\\w\\s]/', '', $text);
     // remove unneeded chars
     $text = str_replace('_', ' ', $text);
     // treat underscores as spaces
     $text = preg_replace('/^\\s+|\\s+$/', '', $text);
     // trim leading/trailing spaces
     $text = preg_replace('/[-\\s]+/', '-', $text);
     // convert spaces to hyphens
     $text = strtolower($text);
     // convert to lowercase
     return trim(substr($text, 0, $maxlength), '-');
     // trim to first $maxlength chars
 }
Ejemplo n.º 5
0
 public function view($message = false)
 {
     if ($message) {
         switch ($message) {
             case 'reset_complete':
                 $this->set('message', t('Reserved words reset.'));
                 break;
             case 'saved':
                 $this->set('success', t('Reserved words updated.'));
                 break;
         }
     }
     Loader::library('3rdparty/urlify');
     $this->set('SEO_EXCLUDE_WORDS_ORIGINAL_ARRAY', Urlify::$remove_list);
     $excludeSeoWords = Config::get('SEO_EXCLUDE_WORDS');
     if (is_string($excludeSeoWords)) {
         if (strlen($excludeSeoWords)) {
             $remove_list = explode(',', $excludeSeoWords);
             $remove_list = array_map('trim', $remove_list);
             $remove_list = array_filter($remove_list, 'strlen');
         } else {
             $remove_list = array();
         }
     } else {
         $remove_list = Urlify::$remove_list;
     }
     $this->set('SEO_EXCLUDE_WORDS_ARRAY', $remove_list);
     $this->set('SEO_EXCLUDE_WORDS', SEO_EXCLUDE_WORDS);
 }
Ejemplo n.º 6
0
 /**
  * 
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->loadModel('item');
     Loader::library('API', TRUE);
     Loader::library('Curl');
 }
Ejemplo n.º 7
0
	function update_favicon(){
		Loader::library('file/importer');
		if ($this->token->validate("update_favicon")) { 
		
			if(intval($this->post('remove_favicon'))==1){
				Config::save('FAVICON_FID',0);
					$this->redirect('/dashboard/system/basics/icons/', 'favicon_removed');
			} else {
				$fi = new FileImporter();
				$resp = $fi->import($_FILES['favicon_file']['tmp_name'], $_FILES['favicon_file']['name'], $fr);
				if (!($resp instanceof FileVersion)) {
					switch($resp) {
						case FileImporter::E_FILE_INVALID_EXTENSION:
							$this->error->add(t('Invalid file extension.'));
							break;
						case FileImporter::E_FILE_INVALID:
							$this->error->add(t('Invalid file.'));
							break;
						
					}
				} else {
				
					Config::save('FAVICON_FID', $resp->getFileID());
					$filepath=$resp->getPath();  
					//@copy($filepath, DIR_BASE.'/favicon.ico');
					$this->redirect('/dashboard/system/basics/icons/', 'favicon_saved');

				}
			}		
			
		}else{
			$this->set('error', array($this->token->getErrorMessage()));
		}
	}
Ejemplo n.º 8
0
 function __construct()
 {
     Loader::library('controller', $this->pkgHandle);
     //Used by controllers
     Loader::library('dashboardcontroller', $this->pkgHandle);
     //Used by controllers
 }
Ejemplo n.º 9
0
	/**
	 * @todo documentation
	 * @return array <Zend_Mail_Transport_Smtp, Zend_Mail>
	*/
	public static function getMailerObject(){
		Loader::library('3rdparty/Zend/Mail');
		$response = array();
		$response['mail'] = new Zend_Mail(APP_CHARSET);
	
		if (MAIL_SEND_METHOD == "SMTP") {
			Loader::library('3rdparty/Zend/Mail/Transport/Smtp');
			$config = array();
			
			$username = Config::get('MAIL_SEND_METHOD_SMTP_USERNAME');
			$password = Config::get('MAIL_SEND_METHOD_SMTP_PASSWORD');
			if ($username != '') {
				$config['auth'] = 'login';
				$config['username'] = $username;
				$config['password'] = $password;
			}
			
			$port = Config::get('MAIL_SEND_METHOD_SMTP_PORT');
			if ($port != '') {
				$config['port'] = $port;
			}
			
			$encr = Config::get('MAIL_SEND_METHOD_SMTP_ENCRYPTION');
			if ($encr != '') {
				$config['ssl'] = $encr;
			}
			$transport = new Zend_Mail_Transport_Smtp(
				Config::get('MAIL_SEND_METHOD_SMTP_SERVER'), $config
			);					
			
			$response['transport'] = $transport;
		}	
		
		return $response;		
	}
Ejemplo n.º 10
0
 public function view($updated = false)
 {
     Loader::library('database_indexed_search');
     if ($this->post('reindex')) {
         IndexedSearch::clearSearchIndex();
         $this->redirect('/dashboard/system/seo/search_index', 'index_cleared');
     } else {
         if ($updated) {
             $this->set('message', t('Search Index Preferences Updated'));
         }
         if ($this->isPost()) {
             if ($this->token->validate('update_search_index')) {
                 $areas = $this->post('arHandle');
                 if (!is_array($areas)) {
                     $areas = array();
                 }
                 Config::save('SEARCH_INDEX_AREA_LIST', serialize($areas));
                 Config::save('SEARCH_INDEX_AREA_METHOD', Loader::helper('security')->sanitizeString($this->post('SEARCH_INDEX_AREA_METHOD')));
                 $this->redirect('/dashboard/system/seo/search_index', 'updated');
             } else {
                 $this->set('error', array($this->token->getErrorMessage()));
             }
         }
         $areas = Area::getHandleList();
         $selectedAreas = array();
         $this->set('areas', $areas);
         $this->set('selectedAreas', IndexedSearch::getSavedSearchableAreas());
     }
 }
Ejemplo n.º 11
0
 public static function get($name, $additionalConfig = array())
 {
     Loader::library('3rdparty/Zend/Queue');
     $config = array('name' => $name, 'driverOptions' => array('host' => DB_SERVER, 'username' => DB_USERNAME, 'password' => DB_PASSWORD, 'dbname' => DB_DATABASE, 'type' => 'pdo_mysql'));
     $config = array_merge($config, $additionalConfig);
     return new Zend_Queue('Concrete5', $config);
 }
Ejemplo n.º 12
0
 static function getSessionDefaultLocale()
 {
     if (isset($_REQUEST['fsenDocLang'])) {
         $doc_lang = $_REQUEST['fsenDocLang'];
         $locale = self::$mLang2LocaleMap[$doc_lang];
         if (strlen($locale)) {
             return $locale;
         }
     }
     if (isset($_SESSION['FSEInfo'])) {
         $locale = $_SESSION['FSEInfo']['def_locale'];
         if (strlen($locale)) {
             return $locale;
         }
     }
     // they have a language in a certain session going already
     if (isset($_SESSION['DEFAULT_LOCALE'])) {
         return $_SESSION['DEFAULT_LOCALE'];
     }
     // if they've specified their own default locale to remember
     if (isset($_COOKIE['DEFAULT_LOCALE'])) {
         return $_COOKIE['DEFAULT_LOCALE'];
     }
     Loader::library('3rdparty/Zend/Locale');
     $locale = new Zend_Locale();
     return (string) $locale;
 }
Ejemplo n.º 13
0
 public function view()
 {
     Loader::library('update');
     $this->set('latest_version', Update::getLatestAvailableVersionNumber());
     $tp = new TaskPermission();
     $updates = 0;
     $local = array();
     $remote = array();
     if ($tp->canInstallPackages()) {
         $local = Package::getLocalUpgradeablePackages();
         $remote = Package::getRemotelyUpgradeablePackages();
     }
     // now we strip out any dupes for the total
     $updates = 0;
     $localHandles = array();
     foreach ($local as $_pkg) {
         $updates++;
         $localHandles[] = $_pkg->getPackageHandle();
     }
     foreach ($remote as $_pkg) {
         if (!in_array($_pkg->getPackageHandle(), $localHandles)) {
             $updates++;
         }
     }
     $this->set('updates', $updates);
 }
Ejemplo n.º 14
0
	public function run() {
		Cache::disableCache();

		Loader::library('database_indexed_search');
		$is = new IndexedSearch();
		if ($_GET['force'] == 1) {
			Loader::model('attribute/categories/collection');
			Loader::model('attribute/categories/file');
			Loader::model('attribute/categories/user');
			$attributes = CollectionAttributeKey::getList();
			$attributes = array_merge($attributes, FileAttributeKey::getList());
			$attributes = array_merge($attributes, UserAttributeKey::getList());
			foreach($attributes as $ak) {
				$ak->updateSearchIndex();
			}

			$result = $is->reindexAll(true);
		} else {
			$result = $is->reindexAll();
		}
		if ($result->count == 0) {
			return t('Indexing complete. Index is up to date');
		} else {
			if ($result->count == $is->searchBatchSize) {
				return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count);
			} else {
				return t('Index updated. %s %s required reindexing.', $result->count, $result->count == 1 ? t('page') : t('pages'));
			}
		}
	}
Ejemplo n.º 15
0
	public function getLatestAvailableVersionNumber() {
		if (defined('MULTI_SITE') && MULTI_SITE == 1) {
			$updates = Update::getLocalAvailableUpdates();
			$multiSiteVersion = 0;
			foreach($updates as $up) {
				if (version_compare($up->getUpdateVersion(), $multiSiteVersion, '>')) {
					$multiSiteVersion = $up->getUpdateVersion();
				}	
			}
			Config::save('APP_VERSION_LATEST', $multiSiteVersion);
			return $multiSiteVersion;
		}
		
		$d = Loader::helper('date');
		// first, we check session
		$queryWS = false;
		Cache::disableCache();
		$vNum = Config::get('APP_VERSION_LATEST', true);
		Cache::enableCache();
		if (is_object($vNum)) {
			$seconds = strtotime($vNum->timestamp);
			$version = $vNum->value;
			if (is_object($version)) {
				$versionNum = $version->version;
			} else {
				$versionNum = $version;
			}
			$diff = time() - $seconds;
			if ($diff > APP_VERSION_LATEST_THRESHOLD) {
				// we grab a new value from the service
				$queryWS = true;
			}
		} else {
			$queryWS = true;
		}
		
		if ($queryWS) {
			Loader::library('marketplace');
			$mi = Marketplace::getInstance();
			if ($mi->isConnected()) {
				Marketplace::checkPackageUpdates();
			}
			$update = Update::getLatestAvailableUpdate();
			$versionNum = $update->version;
			
			if ($versionNum) {
				Config::save('APP_VERSION_LATEST', $versionNum);
				if (version_compare($versionNum, APP_VERSION, '>')) {
					Loader::model('system_notification');
					SystemNotification::add(SystemNotification::SN_TYPE_CORE_UPDATE, t('A new version of concrete5 is now available.'), '', $update->notes, View::url('/dashboard/system/update'));
				}		
			} else {
				// we don't know so we're going to assume we're it
				Config::save('APP_VERSION_LATEST', APP_VERSION);
			}
		}
		
		return $versionNum;
	}
Ejemplo n.º 16
0
 public function on_start()
 {
     $addFuncSelected = true;
     $updateSelected = false;
     $subnav = array(array(View::url('/dashboard/install'), t('Installed and Available'), true), array(View::url('/dashboard/install', 'browse', 'themes'), t('More Themes'), false), array(View::url('/dashboard/install', 'browse', 'addons'), t('More Add-Ons'), false));
     $this->set('subnav', $subnav);
     Loader::library('marketplace');
 }
Ejemplo n.º 17
0
 public function on_page_view()
 {
     Loader::library('controller', $pkgHandle);
     $path = EasyNewsController::getRssPagePath() . '?c=' . $this->cParentID;
     $imagepath = EasyNewsController::getPackageUrl() . '/templates/img/rss.png';
     $rss = '<link rel="alternate" type="application/rss+xml" title="Feed" href="' . $path . '" />';
     $this->addHeaderItem($rss, 'CONTROLLER');
 }
Ejemplo n.º 18
0
 public static function min_html_end()
 {
     $pageContent = ob_get_contents();
     ob_end_clean();
     Loader::library("minco", "mainio_minco");
     $m = Minco::getInstance();
     echo $m->minify($pageContent);
 }
Ejemplo n.º 19
0
 /**
  * Minifies the passed HTML source.
  */
 public function minify($pageContent)
 {
     Loader::library("3rdparty/minify-2.1.5/min/lib/Minify/HTML", "mainio_minco");
     Loader::library("3rdparty/minify-2.1.5/min/lib/Minify/CSS", "mainio_minco");
     Loader::library("3rdparty/minify-2.1.5/min/lib/JSMin", "mainio_minco");
     $opts = array('cssMinifier' => "Minify_CSS::minify", 'jsMinifier' => "JSMin::minify");
     return Minify_HTML::minify($pageContent, $opts);
 }
Ejemplo n.º 20
0
 public function validate(&$post)
 {
     Loader::library('kohana_validation', 'automobiles');
     $v = new KohanaValidation($post);
     $this->add_standard_rules($v, array('name' => 'Name'));
     $v->validate();
     return $v->errors(true);
     //pass true to get a C5 "validation/error" object back
 }
Ejemplo n.º 21
0
 protected function getDataAdapterObj()
 {
     if (!$this->adapter) {
         Loader::library('data_adapter/' . $this->meta['adapter'], 'openjuice');
         $className = ucfirst($this->meta['adapter']) . 'DataAdapter';
         $this->adapter = new $className($this, $this->meta, $this->fields, $this->relations);
     }
     return $this->adapter;
 }
Ejemplo n.º 22
0
 public function save($resourceKey, $resourceVersion = false, $fileExtension = '')
 {
     $dirname = 'mainio_minco_combined_assets';
     $url = MINCO_RESOURCES_SAVE_DIR_REL . '/' . $dirname;
     $saveDir = MINCO_RESOURCES_SAVE_DIR . '/' . $dirname;
     Loader::library("minco_file_writer", "mainio_minco");
     $file = MincoFileWriter::writeStatic($resourceKey, $resourceVersion, $fileExtension, $saveDir);
     return $url . '/' . $file;
 }
Ejemplo n.º 23
0
	/** 
	 * Encodes a data structure into a JSON string
	 * @param string $mixed
	 * @return string
	 */
	public function encode($mixed) {
		if (function_exists('json_encode')) {
			return json_encode($mixed);
		} else {
			Loader::library('3rdparty/JSON/JSON');
			$sjs = new Services_JSON();
			return $sjs->encode($mixed);
		}
	}
 public function __construct()
 {
     Loader::library('3rdparty/Zend/Locale');
     $countries = Zend_Locale::getTranslationList('territory', Localization::activeLocale(), 2);
     // unset invalid countries
     unset($countries['SU'], $countries['ZZ'], $countries['IM'], $countries['JE'], $countries['VD']);
     asort($countries, SORT_LOCALE_STRING);
     $this->countries = $countries;
 }
Ejemplo n.º 25
0
 public function do_search()
 {
     $q = $_REQUEST['query'];
     $_q = $q;
     Loader::library('database_indexed_search');
     $ipl = new IndexedPageList();
     $aksearch = false;
     $ipl->ignoreAliases();
     if (is_array($_REQUEST['akID'])) {
         Loader::model('attribute/categories/collection');
         foreach ($_REQUEST['akID'] as $akID => $req) {
             $fak = CollectionAttributeKey::getByID($akID);
             if (is_object($fak)) {
                 $type = $fak->getAttributeType();
                 $cnt = $type->getController();
                 $cnt->setAttributeKey($fak);
                 $cnt->searchForm($ipl);
                 $aksearch = true;
             }
         }
     }
     if (isset($_REQUEST['month']) && isset($_REQUEST['year'])) {
         $month = strtotime($_REQUEST['year'] . '-' . $_REQUEST['month'] . '-01');
         $month = date('Y-m-', $month);
         $ipl->filterByPublicDate($month . '%', 'like');
         $aksearch = true;
     }
     if (empty($_REQUEST['query']) && $aksearch == false) {
         return false;
     }
     $ipl->setSimpleIndexMode(true);
     if (isset($_REQUEST['query'])) {
         $ipl->filterByKeywords($_q);
     }
     if (is_array($_REQUEST['search_paths'])) {
         foreach ($_REQUEST['search_paths'] as $path) {
             if (!strlen($path)) {
                 continue;
             }
             $ipl->filterByPath($path);
         }
     } elseif ($this->baseSearchPath != '') {
         $ipl->filterByPath($this->baseSearchPath);
     }
     $ipl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
     $ipl->filter(false, '(ak_exclude_search_index = 0 or ak_exclude_search_index is null)');
     $ipl->setItemsPerPage(5);
     $res = $ipl->getPage();
     foreach ($res as $r) {
         $results[] = new IndexedSearchResult($r['cID'], $r['cName'], $r['cDescription'], $r['score'], $r['cPath'], $r['content']);
     }
     $this->set('query', $q);
     $this->set('paginator', $ipl->getPagination());
     $this->set('results', $results);
     $this->set('do_search', true);
     $this->set('searchList', $ipl);
 }
Ejemplo n.º 26
0
 public function validate(&$post)
 {
     Loader::library('kohana_validation', 'automobiles');
     $v = new KohanaValidation($post);
     $this->add_standard_rules($v, array('name' => 'Name', 'country' => 'Country'));
     // Don't validate is_luxury -- it's a boolean / checkbox so it either exists or it doesn't.
     $v->validate();
     return $v->errors(true);
     //pass true to get a C5 "validation/error" object back
 }
Ejemplo n.º 27
0
	public static function getSlotContents() {
		if (!isset(self::$slots)) {
			$fh = Loader::helper('file');
			Loader::library('marketplace');
			$cfToken = Marketplace::getSiteToken();
			$r = $fh->getContents(NEWSFLOW_SLOT_CONTENT_URL . '?cfToken=' . $cfToken);
			self::$slots = NewsflowSlotItem::parseResponse($r);
		}
		return self::$slots;
	}
Ejemplo n.º 28
0
 public function __construct()
 {
     Loader::library('3rdparty/Auth/OpenID/Consumer');
     Loader::library('3rdparty/Auth/OpenID/FileStore');
     Loader::library('3rdparty/Auth/OpenID/SReg');
     Loader::library('3rdparty/Auth/OpenID/PAPE');
     $this->store = new Auth_OpenID_FileStore(DIR_FILES_CACHE . '/openid.store');
     $this->consumer = new Auth_OpenID_Consumer($this->store);
     $this->response = new stdClass();
 }
Ejemplo n.º 29
0
 private static function &_getNewBlock($cacheID = null, $fileVersion = null)
 {
     if (strlen(self::$_mainCacheID) < 1) {
         global $c, $u;
         Loader::library("minco", "mainio_minco");
         self::$_mainCacheID = $c->getCollectionID() . ':' . ($u->isLoggedIn() ? '1' : '0');
     }
     $b = new MincoBlock($cacheID, $fileVersion);
     array_push(self::$_blockQueue, $b);
     return $b;
 }
Ejemplo n.º 30
0
 protected function getCacheFile($mixed)
 {
     Loader::library('3rdparty/mobile_detect');
     $md = new Mobile_Detect();
     if ($md->isMobile()) {
         $prefix = DIR_FILES_PAGE_CACHE_MOBILE;
     } else {
         $prefix = DIR_FILES_PAGE_CACHE;
     }
     return $this->getCacheFileWithPrefix($mixed, $prefix);
 }