Пример #1
0
	/** Executes the job.
	* @return string Returns a string describing the job result in case of success.
	* @throws Exception Throws an exception in case of errors.
	*/
	public function run() {
		Cache::disableCache();
		Cache::disableLocalCache();
		
		try {
			$db = Loader::db();
			$instances = array(
				'navigation' => Loader::helper('navigation'),
				'dashboard' => Loader::helper('concrete/dashboard'),
				'view_page' => PermissionKey::getByHandle('view_page')
			);
			$rsPages = $db->query('SELECT cID FROM Pages WHERE (cID > 1) ORDER BY cID');
			$relName = ltrim(SITEMAPXML_FILE, '\\/');
			$osName = rtrim(DIR_BASE, '\\/') . '/' . $relName;
			$urlName = rtrim(BASE_URL . DIR_REL, '\\/') . '/' . $relName;
			if(!file_exists($osName)) {
				@touch($osName);
			}
			if(!is_writable($osName)) {
				throw new Exception(t('The file %s is not writable', $osName));
			}
			if(!$hFile = fopen($osName, 'w')) {
				throw new Exception(t('Cannot open file %s', $osName));
			}
			if(!@fprintf($hFile, '<?xml version="1.0" encoding="%s"?>' . self::EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', APP_CHARSET)) {
				throw new Exception(t('Error writing header of %s', $osName));
			}
			$addedPages = 0;
			if(self::AddPage($hFile, 1, $instances)) {
				$addedPages++;
			}
			while($rowPage = $rsPages->FetchRow()) {
				if(self::AddPage($hFile, intval($rowPage['cID']), $instances)) {
					$addedPages++;
				}
			}
			$rsPages->Close();
			unset($rsPages);
			if(!@fwrite($hFile, self::EOL . '</urlset>')) {
				throw new Exception(t('Error writing footer of %s', $osName));
			}
			@fflush($hFile);
			@fclose($hFile);
			unset($hFile);
			return t('%1$s file saved (%2$d pages).', $urlName, $addedPages);
		}
		catch(Exception $x) {
			if(isset($rsPages) && $rsPages) {
				$rsPages->Close();
				$rsPages = null;
			}
			if(isset($hFile) && $hFile) {
				@fflush($hFile);
				@ftruncate($hFile, 0);
				@fclose($hFile);
				$hFile = null;
			}
			throw $x;
		}
	}
Пример #2
0
	public function run() {
		$db = Loader::db();
		Loader::model('single_page');
		
		Cache::disableLocalCache();
		
		//  we backup the custom styles table
		$this->backupCustomStylesTables();
		
		// upgrade blocks that differ between versions
		$this->updateBlocks();
		
		// Migrate data from the custom styles tables to the new approach
		$this->migrateCustomStyleData();		
		
		$this->setupSiteSearchIndexing();
		
		$this->installTaskPermissions();
		
		$this->updateDashboard();
		
		// add the dark chocolate theme 						
		$pt = PageTheme::getByHandle('dark_chocolate');
		if (!is_object($pt)) {
			$chocolate = PageTheme::add('dark_chocolate');
		}
		
		Cache::enableLocalCache();
	}
Пример #3
0
 public function on_start()
 {
     $this->secCheck();
     // if you just reverted, but didn't manually clear out your files - cache would be a prob here.
     Cache::disableLocalCache();
     $this->site_version = Config::get('SITE_APP_VERSION');
     Database::ensureEncoding();
 }
Пример #4
0
 public function on_start()
 {
     $cnt = Loader::controller('/dashboard/system/backup_restore/update');
     $cnt->secCheck();
     // if you just reverted, but didn't manually clear out your files - cache would be a prob here.
     $ca = new Cache();
     $ca->flush();
     Cache::disableCache();
     Cache::disableLocalCache();
     $this->site_version = Config::get('SITE_APP_VERSION');
     Database::ensureEncoding();
 }
 /** Executes the job.
  * @return string Returns a string describing the job result in case of success.
  * @throws Exception Throws an exception in case of errors.
  */
 public function run()
 {
     Cache::disableCache();
     Cache::disableLocalCache();
     try {
         $db = Loader::db();
         $instances = array('navigation' => Loader::helper('navigation'), 'dashboard' => Loader::helper('concrete/dashboard'), 'view_page' => PermissionKey::getByHandle('view_page'), 'guestGroup' => Group::getByID(GUEST_GROUP_ID), 'now' => new DateTime('now'), 'ak_exclude_sitemapxml' => CollectionAttributeKey::getByHandle('exclude_sitemapxml'), 'ak_sitemap_changefreq' => CollectionAttributeKey::getByHandle('sitemap_changefreq'), 'ak_sitemap_priority' => CollectionAttributeKey::getByHandle('sitemap_priority'));
         $instances['guestGroupAE'] = array(GroupPermissionAccessEntity::getOrCreate($instances['guestGroup']));
         $xmlDoc = new SimpleXMLElement('<' . '?xml version="1.0" encoding="' . APP_CHARSET . '"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />');
         $rs = Loader::db()->Query('SELECT cID FROM Pages');
         while ($row = $rs->FetchRow()) {
             self::addPage($xmlDoc, intval($row['cID']), $instances);
         }
         $rs->Close();
         Events::fire('on_sitemap_xml_ready', $xmlDoc);
         $dom = dom_import_simplexml($xmlDoc)->ownerDocument;
         $dom->formatOutput = true;
         $addedPages = count($xmlDoc->url);
         $relName = ltrim(SITEMAPXML_FILE, '\\/');
         $osName = rtrim(DIR_BASE, '\\/') . '/' . $relName;
         $urlName = rtrim(BASE_URL . DIR_REL, '\\/') . '/' . $relName;
         if (!file_exists($osName)) {
             @touch($osName);
         }
         if (!is_writable($osName)) {
             throw new Exception(t('The file %s is not writable', $osName));
         }
         if (!($hFile = @fopen($osName, 'w'))) {
             throw new Exception(t('Cannot open file %s', $osName));
         }
         if (!@fwrite($hFile, $dom->saveXML())) {
             throw new Exception(t('Error writing to file %s', $osName));
         }
         @fflush($hFile);
         @fclose($hFile);
         unset($hFile);
         return t('%1$s file saved (%2$d pages).', sprintf('<a href="%s" target="_blank">%s</a>', $urlName, preg_replace('/^https?:\\/\\//i', '', $urlName)), $addedPages);
     } catch (Exception $x) {
         if (isset($hFile) && $hFile) {
             @fflush($hFile);
             @ftruncate($hFile, 0);
             @fclose($hFile);
             $hFile = null;
         }
         throw $x;
     }
 }
Пример #6
0
 /**
  * Testing
  */
 public function on_start()
 {
     if (isset($_POST['locale']) && $_POST['locale']) {
         define("ACTIVE_LOCALE", $_POST['locale']);
         $this->set('locale', $_POST['locale']);
     }
     require DIR_BASE_CORE . '/config/file_types.php';
     Cache::disableCache();
     Cache::disableLocalCache();
     $this->setRequiredItems();
     $this->setOptionalItems();
     Loader::model('package/starting_point');
     if (file_exists(DIR_CONFIG_SITE . '/site.php')) {
         throw new Exception(t('concrete5 is already installed.'));
     }
     if (!isset($_COOKIE['CONCRETE5_INSTALL_TEST'])) {
         setcookie('CONCRETE5_INSTALL_TEST', '1', 0, DIR_REL . '/');
     }
 }
Пример #7
0
 public function run()
 {
     $db = Loader::db();
     Cache::disableLocalCache();
     Loader::model('attribute/categories/collection');
     $cak = CollectionAttributeKey::getByHandle('exclude_page_list');
     if (!is_object($cak)) {
         $boolt = AttributeType::getByHandle('boolean');
         $cab4b = CollectionAttributeKey::add($boolt, array('akHandle' => 'exclude_page_list', 'akName' => t('Exclude From Page List'), 'akIsSearchable' => true));
         Loader::model('page_list');
         $pl = new PageList();
         $pl->filterByExcludeNav(1);
         $list = $pl->get();
         foreach ($list as $c) {
             $c->setAttribute('exclude_page_list', 1);
             $c->reindex();
         }
     }
     Cache::enableLocalCache();
 }
Пример #8
0
 /** 
  * Reindexes the search engine.
  */
 public function reindexAll($fullReindex = false)
 {
     Cache::disableLocalCache();
     $db = Loader::db();
     Loader::model('collection_attributes');
     if ($fullReindex) {
         $db->Execute("truncate table PageSearchIndex");
     }
     $pl = new PageList();
     $pl->ignoreAliases();
     $pl->ignorePermissions();
     $pl->sortByCollectionIDAscending();
     $pl->filter(false, '(c.cDateModified > psi.cDateLastIndexed or UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(psi.cDateLastIndexed) > ' . $this->searchReindexTimeout . ' or psi.cID is null or psi.cDateLastIndexed is null)');
     $pl->filter(false, '(ak_exclude_search_index is null or ak_exclude_search_index = 0)');
     $pages = $pl->get($this->searchBatchSize);
     $num = 0;
     foreach ($pages as $c) {
         // make sure something is approved
         $cv = $c->getVersionObject();
         if (!$cv->cvIsApproved) {
             continue;
         }
         $c->reindex($this, true);
         $num++;
         unset($c);
     }
     $pnum = Collection::reindexPendingPages();
     $num = $num + $pnum;
     Cache::enableLocalCache();
     $result = new stdClass();
     $result->count = $num;
     return $result;
 }
Пример #9
0
	public function run() {
		$db = Loader::db();
		
		Cache::disableLocalCache();
		Loader::model('attribute/categories/collection');
		Loader::model('attribute/categories/file');
		Loader::model('attribute/categories/user');
		$collectionErrors = array();
		$fileErrors = array();
		$userErrors = array();
		//add the new collection attribute keys
		$this->installCoreAttributeItems();	
		
		$dict = NewDataDictionary($db->db, DB_TYPE);
		$tables = $db->MetaTables();
		
		if (in_array('_CollectionAttributeKeys', $tables)) {
			$collectionErrors = $this->upgradeCollectionAttributes();
		}		
		if (in_array('_FileAttributeKeys', $tables)) {
			$fileErrors = $this->upgradeFileAttributes();
		}			
		if (in_array('_UserAttributeKeys', $tables)) {
			$userErrors = $this->upgradeUserAttributes();
		} 

		$cak=CollectionAttributeKey::getByHandle('exclude_sitemapxml');
		if (!is_object($cak)) {
			$cak = CollectionAttributeKey::add('exclude_sitemapxml', t('Exclude From sitemap.xml'), true, null, 'BOOLEAN');
		}
		
		//change the page/tab name of the dashboard users registration page
		$dashboardRegistrationPage=Page::getByPath('/dashboard/users/registration');
		if( intval($dashboardRegistrationPage->cID) ) 
			$dashboardRegistrationPage->update(array('cName'=>t('Login & Registration')));
		Config::save('LOGIN_ADMIN_TO_DASHBOARD', 1);
	
		//profile friends page install	
		Loader::model('single_page');
		$friendsPage=Page::getByPath('/profile/friends');
		if( !intval($friendsPage->cID)) {
			SinglePage::add('/profile/friends');
		}

		$membersPage =Page::getByPath('/members');
		if( !intval($membersPage->cID)) {
			SinglePage::add('/members');
		}

		$messagesPage =Page::getByPath('/profile/messages');
		if( !intval($messagesPage->cID)) {
			SinglePage::add('/profile/messages');
		}
		
		$ppme = UserAttributeKey::getByHandle('profile_private_messages_enabled');
		if (!is_object($ppme)) {
			UserAttributeKey::add('BOOLEAN', array('akHandle' => 'profile_private_messages_enabled', 'akName' => t('I would like to receive private messages.'), 'akIsSearchable' => true));
		}
		$ppmne = UserAttributeKey::getByHandle('profile_private_messages_notification_enabled');
		if (!is_object($ppmne)) {
			UserAttributeKey::add('BOOLEAN', array('akHandle' => 'profile_private_messages_notification_enabled', 'akName' => t('Send me email notifications when I receive a private message.'), 'akIsSearchable' => true));
		}
		
		$em = Page::getByPath('/dashboard/settings');
		if (!$em->isError()) {
			$em = SinglePage::getByID($em->getCollectionID());
			$em->refresh();
		}
		
		$em1=Page::getByPath('/dashboard/settings/mail');
		if ($em1->isError()) {
			$em1 = SinglePage::add('/dashboard/settings/mail');
			$em1->update(array('cName'=>t('Email'), 'cDescription'=>t('Enable post via email and other settings.')));
		}

		// remove adodb database logs
		$databaseReports = Page::getByPath('/dashboard/reports/database');
		if (!$databaseReports->isError()) {
			$databaseReports->delete();
		}
		if (in_array('adodb_logsql', $tables)) {			
			@$db->query('DROP TABLE adodb_logsql');	
		}
		
		Loader::library('mail/importer');
		$mi = MailImporter::getByHandle("private_message");
		if (!is_object($mi)) {
			MailImporter::add(array('miHandle' => 'private_message'));
		}

		Loader::model("job");
		Job::installByHandle('process_email');		

		Cache::enableLocalCache();
	
		return array_merge($collectionErrors, $fileErrors, $userErrors);
	}
Пример #10
0
 public function save()
 {
     session_write_close();
     if ($this->isPost()) {
         if (intval($this->post('entryID')) > 0) {
             $entry = ComposerPage::getByID($this->post('entryID'), 'RECENT');
         }
         if (!is_object($entry)) {
             $this->error->add(t('Invalid page.'));
         } else {
             $ct = CollectionType::getByID($entry->getCollectionTypeID());
         }
         $valt = Loader::helper('validation/token');
         $vtex = Loader::helper('validation/strings');
         if (!$valt->validate('composer')) {
             $this->error->add($valt->getErrorMessage());
         }
         if ($this->post("ccm-publish-draft")) {
             if (!$vtex->notempty($this->post('cName'))) {
                 $this->error->add(t('You must provide a name for your page before you can publish it.'));
             }
             if ($entry->isComposerDraft()) {
                 if ($ct->getCollectionTypeComposerPublishMethod() == 'CHOOSE' || $ct->getCollectionTypeComposerPublishMethod() == 'PAGE_TYPE') {
                     $parent = Page::getByID($entry->getComposerDraftPublishParentID());
                 } else {
                     if ($ct->getCollectionTypeComposerPublishMethod() == 'PARENT') {
                         $parent = Page::getByID($ct->getCollectionTypeComposerPublishPageParentID());
                     }
                 }
                 if (!is_object($parent) || ($parent->isInTrash() || $parent->isError())) {
                     $this->error->add(t('Invalid parent page.'));
                 } else {
                     $cp = new Permissions($parent);
                     if (!$cp->canAddSubCollection($ct)) {
                         $this->error->add(t('You do not have permissions to add this page type in that location.'));
                     }
                 }
             }
         } else {
             if ($this->post('ccm-submit-discard') && !$this->error->has()) {
                 if ($entry->isComposerDraft()) {
                     $entry->delete();
                     $this->redirect('/dashboard/composer/drafts', 'draft_discarded');
                 } else {
                     // we just discard the most recent changes
                     Events::fire('on_composer_delete_draft', $entry);
                     $v = CollectionVersion::get($entry, 'RECENT');
                     $v->discard();
                     $this->redirect('?cID=' . $entry->getCollectionID());
                 }
             }
         }
         if (!$this->error->has()) {
             if ($this->post('cHandle')) {
                 $handle = $this->post('cHandle');
             } else {
                 $handle = Loader::helper('text')->urlify($this->post('cName'));
             }
             $handle = str_replace('-', PAGE_PATH_SEPARATOR, $handle);
             $data = array();
             $pk = PermissionKey::getByHandle('edit_page_properties');
             $pk->setPermissionObject($entry);
             $asl = $pk->getMyAssignment();
             if ($asl->allowEditName()) {
                 $data['cName'] = $this->post('cName');
             }
             if ($asl->allowEditDescription()) {
                 $data['cDescription'] = $this->post('cDescription');
             }
             if ($asl->allowEditPaths()) {
                 $data['cHandle'] = $handle;
             }
             if ($asl->allowEditDateTime()) {
                 $data['cDatePublic'] = Loader::helper('form/date_time')->translate('cDatePublic');
             }
             $entry->getVersionToModify();
             // this is a pain. we have to use composerpage::getbyid again because
             // getVersionToModify is hard-coded to return a page object
             $entry = ComposerPage::getByID($entry->getCollectionID(), 'RECENT');
             $entry->update($data);
             $this->saveData($entry, $asl);
             $u = new User();
             if ($this->post('ccm-publish-draft')) {
                 Cache::disableCache();
                 Cache::disableLocalCache();
                 if ($entry->isComposerDraft()) {
                     $entry->move($parent);
                 }
                 $v = CollectionVersion::get($entry, 'RECENT');
                 $pkr = new ApprovePagePageWorkflowRequest();
                 $pkr->setRequestedPage($entry);
                 $pkr->setRequestedVersionID($v->getVersionID());
                 $pkr->setRequesterUserID($u->getUserID());
                 $pkr->trigger();
                 Events::fire('on_composer_publish', $entry);
                 $entry->markComposerPageAsPublished();
                 $this->redirect('?cID=' . $entry->getCollectionID());
             } else {
                 if ($this->post('autosave')) {
                     // this is done by javascript. we refresh silently and send a json success back
                     Events::fire('on_composer_save_draft', $entry);
                     $json = Loader::helper('json');
                     $obj = new stdClass();
                     $dh = Loader::helper('date');
                     $obj->error = false;
                     $obj->time = $dh->formatTime('now', false);
                     $obj->timestamp = date('m/d/Y g:i a');
                     print $json->encode($obj);
                     exit;
                 } else {
                     $this->redirect('/dashboard/composer/write', 'edit', $entry->getCollectionID(), 'saved');
                 }
             }
         } else {
             if (is_object($entry)) {
                 $this->edit($entry->getCollectionID());
             }
         }
     } else {
         $this->redirect('/dashboard/composer');
     }
 }
Пример #11
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$dh = Loader::helper('concrete/dashboard/sitemap');
if (!$dh->canRead()) {
    die(t("Access Denied."));
}
// we have to do this otherwise permissions pointers aren't correct
// (cInheritPermissionsFromCID on parent nodes)
Cache::disableLocalCache();
$q = Queue::get('copy_page');
$includeParent = true;
if ($_REQUEST['copyChildrenOnly']) {
    $includeParent = false;
}
$db = Loader::db();
if ($_POST['process']) {
    $obj = new stdClass();
    $js = Loader::helper('json');
    $messages = $q->receive(COPY_PAGES_LIMIT);
    foreach ($messages as $key => $p) {
        // delete the page here
        $page = unserialize($p->body);
        $oc = Page::getByID($page['cID']);
        // this is the page we're going to copy.
        // now we check to see if the parent ID of the current record has already been duplicated somewhere.
        $newCID = $db->GetOne('select cID from QueuePageDuplicationRelations where originalCID = ? and queue_name = ?', array($page['cParentID'], 'copy_page'));
        if ($newCID > 0) {
            $dc = Page::getByID($newCID);
        } else {
            $dc = Page::getByID($page['destination']);