Esempio n. 1
0
 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     if (\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale')) {
         return;
     }
     if (!$c) {
         $c = Page::getCurrentPage();
     }
     // don't translate dashboard pages
     $dh = \Core::make('helper/concrete/dashboard');
     if ($dh->inDashboard($c)) {
         return;
     }
     $ms = Section::getBySectionOfSite($c);
     if (!is_object($ms)) {
         $ms = static::getPreferredSection();
     }
     if (!$ms) {
         return;
     }
     $locale = $ms->getLocale();
     if (strlen($locale)) {
         \Localization::changeLocale($locale);
     }
 }
Esempio n. 2
0
	protected function testAndRunInstall() {
		if (file_exists(DIR_CONFIG_SITE . '/site_install_user.php')) {
			require(DIR_CONFIG_SITE . '/site_install.php');
			@include(DIR_CONFIG_SITE . '/site_install_user.php');
			if (defined('ACTIVE_LOCALE') && Localization::activeLocale() !== ACTIVE_LOCALE) {
				Localization::changeLocale(ACTIVE_LOCALE);
			}
			$e = Loader::helper('validation/error');
			$e = $this->validateDatabase($e);
			if ($e->has()) {
				$this->set('error', $e);
			} else {
				$this->addHeaderItem(Loader::helper('html')->css('jquery.ui.css'));
				$this->addHeaderItem(Loader::helper('html')->javascript('jquery.ui.js'));
				if (defined('INSTALL_STARTING_POINT') && INSTALL_STARTING_POINT) { 
					$spl = Loader::startingPointPackage(INSTALL_STARTING_POINT);
				} else {
					$spl = Loader::startingPointPackage('standard');
				}
				$this->set('installPackage', $spl->getPackageHandle());
				$this->set('installRoutines', $spl->getInstallRoutines());
				$this->set('successMessage', t('Congratulations. concrete5 has been installed. You have been logged in as <b>%s</b> with the password you chose. If you wish to change this password, you may do so from the users area of the dashboard.', USER_SUPER, $uPassword));
			}
		}
	}
Esempio n. 3
0
	public function do_update($pkgHandle = false) {
		$tp = new TaskPermission();
		if ($tp->canInstallPackages()) { 
			if ($pkgHandle) {
				$tests = Package::testForInstall($pkgHandle, false);
				if (is_array($tests)) {
					$tests = Package::mapError($tests);
					$this->set('error', $tests);
				} else {
					$p = Package::getByHandle($pkgHandle);
					$currentLocale = Localization::activeLocale();
					if ($currentLocale != 'en_US') {
						// Prevent the database records being stored in wrong language
						Localization::changeLocale('en_US');
					}
					try {
						$p->upgradeCoreData();
						if ($currentLocale != 'en_US') {
							Localization::changeLocale($currentLocale);
						}
						$p->upgrade();
						$this->set('message', t('The package has been updated successfully.'));
					} catch(Exception $e) {
						$this->set('error', $e);
					}
				}
			}
		}
		$this->view();
	}
Esempio n. 4
0
 /**
  * Get the localized site name.
  *
  * @param string $locale
  *
  * @return string
  */
 protected function getSiteNameForLocale($locale)
 {
     static $names = array();
     if (!isset($names[$locale])) {
         $prevLocale = \Localization::activeLocale();
         if ($prevLocale !== $locale) {
             \Localization::changeLocale($locale);
         }
         $names[$locale] = tc('SiteName', $this->app->make('config')->get('concrete.site'));
         if ($prevLocale !== $locale) {
             \Localization::changeLocale($prevLocale);
         }
     }
     return $names[$locale];
 }
Esempio n. 5
0
 static function changeLocale($locale)
 {
     // change core language to translate e.g. core blocks/themes
     if (strlen($locale)) {
         Localization::changeLocale($locale);
         // site translations
         $loc = Localization::getInstance();
         $loc->addSiteInterfaceLanguage($locale);
         // add package translations
         $pl = PackageList::get();
         $installed = $pl->getPackages();
         foreach ($installed as $pkg) {
             if ($pkg instanceof Package) {
                 $pkg->setupPackageLocalization($locale);
             }
         }
     }
 }
Esempio n. 6
0
 public function testTimeSince()
 {
     Localization::changeLocale("en_US");
     $minutes = 60;
     $hours = $minutes * 60;
     $days = $hours * 24;
     // time is in the future
     $future = time() + 7;
     $this->assertEquals($this->object->formatDate($future), $this->object->timeSince($future));
     // time is now
     $this->assertEquals("0 seconds", $this->object->timeSince(time()));
     // time is in the past
     $this->assertEquals("7 seconds", $this->object->timeSince(time() - 7));
     $this->assertEquals("3 minutes", $this->object->timeSince(time() - (3 * $minutes + 13)));
     $this->assertEquals("3 minutes, 13 seconds", $this->object->timeSince(time() - (3 * $minutes + 13), 1));
     $this->assertEquals("4 hours", $this->object->timeSince(time() - (4 * $hours + 2 * $minutes)));
     $this->assertEquals("4 hours, 1 minute", $this->object->timeSince(time() - (4 * $hours + 1 * $minutes), 1));
     $this->assertEquals("1 day", $this->object->timeSince(time() - (1 * $days + 1 * $minutes)));
     $this->assertEquals("2 days, 2 hours", $this->object->timeSince(time() - (2 * $days + 2 * $hours), 1));
     $this->assertEquals('145 days', $this->object->timeSince(time() - 145 * $days));
     $this->assertEquals($this->object->formatDate(time() - 367 * $days), $this->object->timeSince(time() - 367 * $days));
 }
Esempio n. 7
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
?>

<?php 
if (!is_array($messages)) {
    $messages = array();
}
$u = new User();
$ui = UserInfo::getByID($u->getUserID());
$page = Page::getByID($cID);
$ms = \Concrete\Core\Multilingual\Page\Section\Section::getBySectionOfSite($page);
if (is_object($ms)) {
    Localization::changeLocale($ms->getLocale());
}
$editor = \Concrete\Core\Conversation\Editor\Editor::getActive();
$editor->setConversationObject($args['conversation']);
$val = Loader::helper('validation/token');
$form = Loader::helper('form');
?>

<?php 
Loader::element('conversation/message/add_form', array('blockAreaHandle' => $blockAreaHandle, 'cID' => $cID, 'bID' => $bID, 'editor' => $editor, 'addMessageLabel' => $addMessageLabel, 'attachmentsEnabled' => $attachmentsEnabled, 'displayForm' => $displayForm, 'displayPostingForm' => $displayPostingForm, 'position' => 'top', 'enablePosting' => $enablePosting, 'conversation' => $conversation));
?>


<div class="ccm-conversation-message-list ccm-conversation-messages-<?php 
echo $displayMode;
?>
">
Esempio n. 8
0
		/**
		 * installs a block type
		 * @param string $btHandle
		 * @param BlockType $bt
		 * @param string $dir
		 * @param int $btID
		 * @param string $dirDbXml
		 */
		protected function doInstallBlockType($btHandle, $bt, $dir, $btID = 0, $dirDbXml) {
			$db = Loader::db();
			$env = Environment::get();
			$env->clearOverrideCache();
			
			if (file_exists($dir . '/' . $btHandle . '/' . FILENAME_BLOCK_CONTROLLER)) {
				$class = $bt->getBlockTypeClass();
				
				$path = $dirDbXml . '/' . $btHandle;
				if (!class_exists($class)) {
					require_once($dir . '/' . $btHandle . '/' . FILENAME_BLOCK_CONTROLLER);
				}
				
				if (!class_exists($class)) {
					throw new Exception(t("%s not found. Please check that the block controller file contains the correct class name.", $class));
				}
				$bta = new $class;
				
				//Attempt to run the subclass methods (install schema from db.xml, etc.)
				$r = $bta->install($path);

				//Validate
				if ($r === false) {
					return t('Error: Block Type cannot be installed because no db.xml file can be found. Either create a db.xml file for this block type, or remove the $btTable variable from its controller.');
				} else if (!$r->result && $r->message) {
					return $r->message;
				} else if (!$r->result && !$r->message) {
					return t('Error: Block Type cannot be installed due to an unknown database error. Please check that the db.xml file for this block type is formatted correctly.');
				} else if ($message = BlockType::validateInstalledDatabaseTable($bta->getBlockTypeDatabaseTable())) {
					$db->Execute('DROP TABLE IF EXISTS ' . $bta->getBlockTypeDatabaseTable());
					return $message;
				}
				
				$currentLocale = Localization::activeLocale();
				if ($currentLocale != 'en_US') {
					// Prevent the database records being stored in wrong language
					Localization::changeLocale('en_US');
				}

				//Install the block
				$btd = new BlockTypeDB();
				$btd->btHandle = $btHandle;
				$btd->btName = $bta->getBlockTypeName();
				$btd->btDescription = $bta->getBlockTypeDescription();
				$btd->btActiveWhenAdded = $bta->isActiveWhenAdded();
				$btd->btCopyWhenPropagate = $bta->isCopiedWhenPropagated();
				$btd->btIncludeAll = $bta->includeAll();
				$btd->btIsInternal = $bta->isBlockTypeInternal();
				$btd->btInterfaceHeight = $bta->getInterfaceHeight();
				$btd->btInterfaceWidth = $bta->getInterfaceWidth();
				$btd->pkgID = $bt->getPackageID();
				if ($currentLocale != 'en_US') {
					Localization::changeLocale($currentLocale);
				}
				
				if ($btID > 0) {
					$btd->btID = $btID;
					$btDisplayOrder = $db->GetOne('select btDisplayOrder from BlockTypes where btID = ?', array($btID));
					if (!$btDisplayOrder) {
						$btDisplayOrder = 0;
					}
					$btd->btDisplayOrder = $btDisplayOrder;
					$r = $btd->Replace();
				} else {
					if ($bta->isBlockTypeInternal()) {
						$btd->btDisplayOrder = 0;
					} else {
						$btMax = $db->GetOne('select max(btDisplayOrder) from BlockTypes');
						if ($btMax < 1 && $btMax !== '0') {
							$btd->btDisplayOrder = 0;
						} else {
							$btd->btDisplayOrder = $btMax + 1;
						}
					}

					$r = $btd->save();
				}
				
				// now we remove the block type from cache
				$ca = new Cache();
				$ca->delete('blockTypeByID', $btID);
				$ca->delete('blockTypeByHandle', $btHandle);
				$ca->delete('blockTypeList', false);		 	

				if (!$r) {
					return $db->ErrorMsg();
				}
			} else {
				return t("No block found with the handle %s.", $btHandle);
			}
		}
 public function testSpecialFormats()
 {
     Localization::changeLocale('en_US');
     $activeUser = User::isLoggedIn() ? new User() : null;
     if ($activeUser) {
         $activeUser->logout();
     }
     $timestamp = time();
     foreach (array('FILENAME', 'FILE_PROPERTIES', 'FILE_VERSIONS', 'FILE_DOWNLOAD', 'PAGE_VERSIONS', 'DASHBOARD_SEARCH_RESULTS_USERS', 'DASHBOARD_SEARCH_RESULTS_FILES', 'DASHBOARD_SEARCH_RESULTS_PAGES', 'DATE_ATTRIBUTE_TYPE_MDY', 'DATE_ATTRIBUTE_TYPE_T') as $formatName) {
         $this->assertEquals($this->object->date(constant("DATE_APP_{$formatName}"), $timestamp), $this->object->formatSpecial($formatName, $timestamp));
     }
     if ($activeUser) {
         User::getByUserID($activeUser->getUserID(), true);
     }
 }
Esempio n. 10
0
 public function install_package($package)
 {
     $tp = new TaskPermission();
     if ($tp->canInstallPackages()) {
         $p = Loader::package($package);
         if (is_object($p)) {
             if (!$p->showInstallOptionsScreen() || Loader::helper('validation/token')->validate('install_options_selected')) {
                 $tests = Package::testForInstall($package);
                 if (is_array($tests)) {
                     $tests = Package::mapError($tests);
                     $this->set('error', $tests);
                 } else {
                     $currentLocale = Localization::activeLocale();
                     if ($currentLocale != 'en_US') {
                         // Prevent the database records being stored in wrong language
                         Localization::changeLocale('en_US');
                     }
                     try {
                         $u = new User();
                         $pkg = $p->install($this->post());
                         if ($u->isSuperUser() && $p->allowsFullContentSwap() && $this->post('pkgDoFullContentSwap')) {
                             $p->swapContent($this->post());
                         }
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale($currentLocale);
                         }
                         $pkg = Package::getByHandle($p->getPackageHandle());
                         $this->redirect('/dashboard/extend/install', 'package_installed', $pkg->getPackageID());
                     } catch (Exception $e) {
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale($currentLocale);
                         }
                         if ($p->showInstallOptionsScreen()) {
                             $this->set('showInstallOptionsScreen', true);
                             $this->set('pkg', $p);
                         }
                         $this->set('error', $e);
                     }
                 }
             } else {
                 $this->set('showInstallOptionsScreen', true);
                 $this->set('pkg', $p);
             }
         } else {
             $msg = t('Install failed - invalid package. Check log for details');
             $this->error->add($msg);
             $this->set('error', $this->error);
         }
     } else {
         $this->error->add(t('You do not have permission to install add-ons.'));
         $this->set('error', $this->error);
     }
 }
Esempio n. 11
0
 public function view()
 {
     parent::view();
     $u = new User();
     $ui = UserInfo::getByID($u->getUserID());
     $nh = Loader::helper('navigation');
     $av = Loader::helper('concrete/avatar');
     $valt = Loader::helper('validation/token');
     $imgHelper = Loader::helper('image');
     /* If no page is passed to edit, create a new page.
      */
     $load = $_REQUEST['load'];
     if (empty($load)) {
         // Find the parent page this should go under
         $cityPage = ($parentCID = $_REQUEST['parentCID']) ? Page::getByID($parentCID) : ($ui->getAttribute('home_city') ?: Page::getByPath('/canada/toronto'));
         $c = $this->getUnstartedWalk($u, $cityPage);
     } else {
         $c = Page::getByPath($load);
         $cityPage = Page::getByID($c->getCollectionParentID());
     }
     $walk_ward = trim((string) $c->getAttribute('walk_wards'));
     $city_wards = $cityPage->getAttribute('city_wards');
     if ($city_wards) {
         $wards = array_map(function ($ward) use($walk_ward) {
             if ($ward->value == $walk_ward) {
                 $ward->selected = true;
             }
             return $ward;
         }, $city_wards->getOptions());
     } else {
         $wards = null;
     }
     // Set the language based on a trail to the city
     /* Set the city language to the first one matched, recursing from where we are */
     $crumbs = $nh->getTrailToCollection($c);
     $crumbs[] = $c;
     // Must check the current page first
     foreach ($crumbs as $crumb) {
         if ($lang = (string) $crumb->getAttribute('lang')) {
             Localization::changeLocale($lang);
             break;
         }
     }
     // Load our city
     $latlng = explode(',', $cityPage->getAttribute('latlng'));
     // If you don't have a lat and a lng, final resort is Toronto. It's at least better than being 400km off the coast of Nigeria.
     if (count((array) $latlng) !== 2) {
         $latlng = [43.653226, -79.3831843];
     }
     // Instantiate as models, for JSON serialization
     $city = new City($cityPage);
     $walk = new Walk($c);
     // Build data needed by frontend
     $this->addToJanesWalk(['city' => $city, 'form' => ['valt' => $valt->generate('upload')], 'walk' => ['name' => (string) $walk, 'data' => $walk, 'url' => $nh->getCollectionURL($c)], 'locale' => ['name' => Localization::activeLocale(), 'translation' => Localization::getActiveTranslateJsonURL()]]);
     // Set the view name
     $this->bodyData['pageViewName'] = 'CreateWalkView';
     $this->set('u', $u);
     $this->set('ui', $ui);
     $this->set('owner', UserInfo::getByID($c->getCollectionUserID()));
     $this->set('nh', $nh);
     $this->set('av', $av);
     $this->set('load', $load);
     $this->set('c', $c);
     $this->set('city', $city);
     $this->set('country', $city->country);
     $this->set('ui_cityorganizer', $city->city_organizer);
     $this->set('imgHelper', $imgHelper);
     $this->set('wards', $wards);
     $this->set('is_nyc', $is_nyc);
     $this->set('lat', $latlng[0]);
     $this->set('lng', $latlng[1]);
     $this->set('bodyData', $this->bodyData);
     // Load JS we need in the form
     $html = Loader::helper('html');
     // Set default stylesheets for libs
     $this->addHeaderItem($html->css('jquery.ui.css'));
     // Set libs we'll need on the page
     $this->addFooterItem(Loader::helper('html')->javascript('jquery.ui.js'));
 }
Esempio n. 12
0
 public static function setupSiteInterfaceLocalization()
 {
     // don't translate dashboard pages
     $c = Page::getCurrentPage();
     if ($c instanceof Page && Loader::helper('section', 'multilingual')->section('dashboard')) {
         return;
     }
     $ms = MultilingualSection::getCurrentSection();
     if (is_object($ms)) {
         $locale = $ms->getLocale();
     } else {
         $locale = DefaultLanguageHelper::getSessionDefaultLocale();
     }
     // change core language to translate e.g. core blocks/themes
     if (strlen($locale)) {
         Localization::changeLocale($locale);
     }
     // site translations
     if (is_dir(DIR_LANGUAGES_SITE_INTERFACE)) {
         if (file_exists(DIR_LANGUAGES_SITE_INTERFACE . '/' . $locale . '.mo')) {
             $loc = Localization::getInstance();
             $loc->addSiteInterfaceLanguage($locale);
         }
     }
     // add package translations
     if (strlen($locale)) {
         $ms = MultilingualSection::getByLocale($locale);
         if ($ms instanceof MultilingualSection) {
             $pl = PackageList::get();
             $installed = $pl->getPackages();
             foreach ($installed as $pkg) {
                 if ($pkg instanceof Package) {
                     $pkg->setupPackageLocalization($ms->getLocale());
                 }
             }
         }
     }
 }
Esempio n. 13
0
 public function get_environment_info()
 {
     $activeLocale = Localization::activeLocale();
     if ($activeLocale != 'en_US') {
         Localization::changeLocale('en_US');
     }
     $maxExecutionTime = ini_get('max_execution_time');
     set_time_limit(5);
     $environmentMessage = "# concrete5 Version\n" . APP_VERSION . "\n\n";
     $environmentMessage .= "# concrete5 Packages\n";
     $pla = PackageList::get();
     $pl = $pla->getPackages();
     $packages = array();
     foreach ($pl as $p) {
         if ($p->isPackageInstalled()) {
             $packages[] = $p->getPackageName() . ' (' . $p->getPackageVersion() . ')';
         }
     }
     if (count($packages) > 0) {
         natcasesort($packages);
         $environmentMessage .= implode(', ', $packages);
         $environmentMessage .= ".\n";
     } else {
         $environmentMessage .= "None\n";
     }
     $environmentMessage .= "\n";
     // overrides
     $environmentMessage .= "# concrete5 Overrides\n";
     $fh = Loader::helper('file');
     $overrides = array();
     $ovBlocks = $fh->getDirectoryContents(DIR_FILES_BLOCK_TYPES);
     $ovControllers = $fh->getDirectoryContents(DIR_FILES_CONTROLLERS);
     $ovElements = $fh->getDirectoryContents(DIR_FILES_ELEMENTS);
     $ovHelpers = $fh->getDirectoryContents(DIR_HELPERS);
     $ovJobs = $fh->getDirectoryContents(DIR_FILES_JOBS);
     $ovCSS = $fh->getDirectoryContents(DIR_BASE . '/' . DIRNAME_CSS);
     $ovJS = $fh->getDirectoryContents(DIR_BASE . '/' . DIRNAME_JAVASCRIPT);
     $ovLng = $fh->getDirectoryContents(DIR_BASE . '/' . DIRNAME_LANGUAGES);
     $ovLibs = $fh->getDirectoryContents(DIR_LIBRARIES);
     $ovMail = $fh->getDirectoryContents(DIR_FILES_EMAIL_TEMPLATES);
     $ovModels = $fh->getDirectoryContents(DIR_MODELS);
     $ovSingle = $fh->getDirectoryContents(DIR_FILES_CONTENT);
     $ovThemes = $fh->getDirectoryContents(DIR_FILES_THEMES);
     $ovTools = $fh->getDirectoryContents(DIR_FILES_TOOLS);
     foreach ($ovBlocks as $ovb) {
         $overrides[] = DIRNAME_BLOCKS . '/' . $ovb;
     }
     foreach ($ovControllers as $ovb) {
         $overrides[] = DIRNAME_CONTROLLERS . '/' . $ovb;
     }
     foreach ($ovElements as $ovb) {
         $overrides[] = DIRNAME_ELEMENTS . '/' . $ovb;
     }
     foreach ($ovHelpers as $ovb) {
         $overrides[] = DIRNAME_HELPERS . '/' . $ovb;
     }
     foreach ($ovJobs as $ovb) {
         $overrides[] = DIRNAME_JOBS . '/' . $ovb;
     }
     foreach ($ovJS as $ovb) {
         $overrides[] = DIRNAME_JAVASCRIPT . '/' . $ovb;
     }
     foreach ($ovCSS as $ovb) {
         $overrides[] = DIRNAME_CSS . '/' . $ovb;
     }
     foreach ($ovLng as $ovb) {
         $overrides[] = DIRNAME_LANGUAGES . '/' . $ovb;
     }
     foreach ($ovLibs as $ovb) {
         $overrides[] = DIRNAME_LIBRARIES . '/' . $ovb;
     }
     foreach ($ovMail as $ovb) {
         $overrides[] = DIRNAME_MAIL_TEMPLATES . '/' . $ovb;
     }
     foreach ($ovModels as $ovb) {
         $overrides[] = DIRNAME_MODELS . '/' . $ovb;
     }
     foreach ($ovSingle as $ovb) {
         $overrides[] = DIRNAME_PAGES . '/' . $ovb;
     }
     foreach ($ovThemes as $ovb) {
         $overrides[] = DIRNAME_THEMES . '/' . $ovb;
     }
     foreach ($ovTools as $ovb) {
         $overrides[] = DIRNAME_TOOLS . '/' . $ovb;
     }
     if (count($overrides) > 0) {
         $environmentMessage .= implode(', ', $overrides);
         $environmentMessage .= "\n";
     } else {
         $environmentMessage .= "None\n";
     }
     $environmentMessage .= "\n";
     print $environmentMessage;
     // cache
     $environmentMessage = "# concrete5 Cache Settings\n";
     $environmentMessage .= sprintf("Block Cache - %s\n", ENABLE_BLOCK_CACHE ? 'On' : 'Off');
     $environmentMessage .= sprintf("Overrides Cache - %s\n", ENABLE_OVERRIDE_CACHE ? 'On' : 'Off');
     $environmentMessage .= sprintf("Full Page Caching - %s\n", FULL_PAGE_CACHE_GLOBAL == 'blocks' ? 'On - If blocks on the particular page allow it.' : (FULL_PAGE_CACHE_GLOBAL == 'all' ? 'On - In all cases.' : 'Off'));
     if (FULL_PAGE_CACHE_GLOBAL) {
         $environmentMessage .= sprintf("Full Page Cache Lifetime - %s\n", FULL_PAGE_CACHE_LIFETIME == 'default' ? sprintf('Every %s (default setting).', Loader::helper('date')->describeInterval(CACHE_LIFETIME)) : (FULL_PAGE_CACHE_LIFETIME == 'forever' ? 'Only when manually removed or the cache is cleared.' : sprintf('Every %s minutes.', Config::get('FULL_PAGE_CACHE_LIFETIME_CUSTOM'))));
     }
     $environmentMessage .= "\n";
     print $environmentMessage;
     $environmentMessage = "# Server Software\n" . $_SERVER['SERVER_SOFTWARE'] . "\n\n";
     $environmentMessage .= "# Server API\n" . php_sapi_name() . "\n\n";
     $environmentMessage .= "# PHP Version\n" . PHP_VERSION . "\n\n";
     $environmentMessage .= "# PHP Extensions\n";
     if (function_exists('get_loaded_extensions')) {
         $gle = @get_loaded_extensions();
         natcasesort($gle);
         $environmentMessage .= implode(', ', $gle);
         $environmentMessage .= ".\n";
     } else {
         $environmentMessage .= "Unable to determine\n";
     }
     print $environmentMessage;
     ob_start();
     phpinfo();
     $phpinfo = array('phpinfo' => array());
     if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             if (strlen($match[1])) {
                 $phpinfo[$match[1]] = array();
             } else {
                 if (isset($match[3])) {
                     $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
                 } else {
                     $phpinfo[end(array_keys($phpinfo))][] = $match[2];
                 }
             }
         }
     }
     $environmentMessage = "\n# PHP Settings\n";
     $environmentMessage .= "max_execution_time - {$maxExecutionTime}\n";
     foreach ($phpinfo as $name => $section) {
         foreach ($section as $key => $val) {
             if (preg_match('/.*max_execution_time*/', $key)) {
                 continue;
             }
             if (!preg_match('/.*limit.*/', $key) && !preg_match('/.*safe.*/', $key) && !preg_match('/.*max.*/', $key)) {
                 continue;
             }
             if (is_array($val)) {
                 $environmentMessage .= "{$key} - {$val['0']}\n";
             } else {
                 if (is_string($key)) {
                     $environmentMessage .= "{$key} - {$val}\n";
                 } else {
                     $environmentMessage .= "{$val}\n";
                 }
             }
         }
     }
     print $environmentMessage;
     exit;
 }
 /**
  * Run startup and localization events on any installed packages.
  */
 public function setupPackages()
 {
     $pla = \Concrete\Core\Package\PackageList::get();
     $pl = $pla->getPackages();
     $cl = ClassLoader::getInstance();
     foreach ($pl as $p) {
         if ($p->isPackageInstalled()) {
             $pkg = Package::getClass($p->getPackageHandle());
             if (is_object($pkg)) {
                 $cl->registerPackage($pkg);
                 // handle updates
                 if (Config::get('concrete.misc.enable_auto_update_packages')) {
                     $pkgInstalledVersion = $p->getPackageVersion();
                     $pkgFileVersion = $pkg->getPackageVersion();
                     if (version_compare($pkgFileVersion, $pkgInstalledVersion, '>')) {
                         $currentLocale = Localization::activeLocale();
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale('en_US');
                         }
                         $p->upgradeCoreData();
                         $p->upgrade();
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale($currentLocale);
                         }
                     }
                 }
                 $pkg->setupPackageLocalization();
                 if (method_exists($pkg, 'on_start')) {
                     $pkg->on_start();
                 }
             }
         }
     }
 }
Esempio n. 15
0
 private function do_upgrade()
 {
     $runMessages = array();
     $prepareMessages = array();
     $currentLocale = Localization::activeLocale();
     if ($currentLocale != 'en_US') {
         // Prevent the database records being stored in wrong language
         Localization::changeLocale('en_US');
     }
     try {
         Cache::flush();
         $this->set_upgrades();
         foreach ($this->upgrades as $ugh) {
             if (method_exists($ugh, 'prepare')) {
                 $prepareMessages[] = $ugh->prepare($this);
             }
             if (isset($ugh->dbRefreshTables) && count($ugh->dbRefreshTables) > 0) {
                 $this->refreshDatabaseTables($ugh->dbRefreshTables);
             }
             if (method_exists($ugh, 'run')) {
                 $runMessages[] = $ugh->run();
             }
         }
         $message = '';
         if (is_array($prepareMessages) && count($prepareMessages)) {
             foreach ($prepareMessages as $m) {
                 if (is_array($m)) {
                     $message .= implode("<br/>", $m);
                 }
             }
         }
         if (is_array($runMessages) && count($runMessages)) {
             foreach ($runMessages as $m) {
                 if (is_array($m)) {
                     $message .= implode("<br/>", $m);
                 }
             }
             if (strlen($message)) {
                 $this->set('had_failures', true);
             }
         }
         $upgrade = true;
         if ($currentLocale != 'en_US') {
             Localization::changeLocale($currentLocale);
         }
     } catch (Exception $e) {
         $upgrade = false;
         if ($currentLocale != 'en_US') {
             Localization::changeLocale($currentLocale);
         }
         $message .= '<div class="alert-message block-message error"><p>' . t('An Unexpected Error occurred while upgrading: %s', $e->getTraceAsString()) . '</p></div>';
     }
     if ($upgrade) {
         $completeMessage .= '<div class="alert-message block-message success"><p>';
         if (defined('APP_VERSION_DISPLAY_IN_HEADER') && APP_VERSION_DISPLAY_IN_HEADER) {
             $completeMessage .= t('Upgrade to %s complete!', sprintf('<b>%s</b>', APP_VERSION));
         } else {
             $completeMessage .= t('Upgrade to latest version complete!');
         }
         $completeMessage .= '</p></div>';
         Config::save('SITE_APP_VERSION', APP_VERSION);
     }
     $this->set('completeMessage', $completeMessage);
     $this->set('message', $message);
 }