Esempio n. 1
0
	$contents = $file->getContents();

	foreach($matches as $k => $m){
		// For each match, skim through Core's i18n file for this same string.
		// If found, remove from array.
		if(preg_match('/^' . $m . ' = .*/m', $contents) === 1){
			unset($matches[$k]);
		}
	}
}

// Sort them
sort($matches);

if(!sizeof($matches)){
	\Core\CLI\CLI::PrintError($dir . ' does not seem to contain any translation strings!');
	exit;
}

// Get a list of languages currently available on the system.
$locales = \Core\i18n\I18NLoader::GetLocalesEnabled();
$bases = [];
foreach($locales as $lang => $dat){
	$base = substr($lang, 0, strpos($lang, '_'));
	
	if(!isset($bases[$base])){
		$bases[$base] = [
			'base' => $base,
		    'dialects' => [],
		];
	}
	public function error($message){
		if($this->realtime){
			CLI::PrintError($message);
		}

		$this->_profiler->record($message);
		$this->errors[] = $message;
		++$this->error;
	}
Esempio n. 3
0
	echo "Scanning for JS resources...\n";

	$results  = [];

	// Allow specifying core, a component, or a theme.
	if($onlyCore === true){
		exec('find "' . ROOT_PDIR . 'core/" -name "[a-z][a-z0-9_-]*.js"', $results);
	}
	elseif($onlyComponent !== null){
		exec('find "' . ROOT_PDIR . 'components/' . $onlyComponent . '/" -name "[a-z][a-z0-9_-]*.js"', $results);
	}
	elseif($onlyTheme !== null){
		exec('find "' . ROOT_PDIR . 'themes/' . $onlyTheme . '/" -name "[a-z][a-z0-9_-]*.js"', $results);
	}
	else{
		\Core\CLI\CLI::PrintError('You must specify at least one theme, component, or core!');
		exit;
	}

	foreach($results as $file) {

		// Is this already a minified file?
		if(strpos($file, '.min.js') !== false) {
			continue;
		}

		// Only compress files that are located within an "assets" directory.
		// This is because if any script is used for server-side tasks or test-related tasks,
		// there is no reason to need the minified version!
		if(strpos($file, '/assets/') === false) {
			continue;
Esempio n. 4
0
		}
		else{
			try{
				$parser->parse();

				/** @var $thisversion Core\Utilities\Changelog\Section */
				$thisversion = $parser->getSection($compversion);

				// Read the current changelog.
				$changelog .= $thisversion->fetchAsHTML(3);

				CLI::PrintActionStatus('ok');
			}
			catch(Exception $e){
				CLI::PrintActionStatus('fail');
				CLI::PrintError($e->getMessage());
				$changelog .= '<h3>' . $dat['name'] . ' ' . $compversion . '</h3>';
			}
		}
	}

	// Keys
	if($xml){
		CLI::PrintHeader('Assembling GPG Keys for ' . $b['name'] . ' ' . $version);
		foreach($xml->getElements('//key') as $el){
			$id = $el->getAttribute('id');
			CLI::PrintActionStart('Exporting key ' . $id);
			exec('gpg -a --export ' . $id . ' > "' . $destdir . '/' . $id . '.gpg"');
			exec('gpg --homedir "' . $destdir . '/' . $desttgz . '/gnupg" --no-permission-warning --import "' . $destdir . '/' . $id . '.gpg"', $output, $result);
			unlink($destdir . '/' . $id . '.gpg');
			CLI::PrintActionStatus('ok');
Esempio n. 5
0
	public function email_test(){
		// Admin-only page.
		if(!\Core\user()->checkAccess('g:admin')){
			return View::ERROR_ACCESSDENIED;
		}

		$request = $this->getPageRequest();
		$view = $this->getView();

		if(!$request->isPost()){
			return View::ERROR_BADREQUEST;
		}

		if(!$request->getPost('email')){
			return View::ERROR_BADREQUEST;
		}

		$view->mode = View::MODE_NOOUTPUT;
		$view->contenttype = View::CTYPE_HTML;
		$view->render();

		$dest         = $request->getPost('email');
		$method       = ConfigHandler::Get('/core/email/mailer');
		$smtpHost     = ConfigHandler::Get('/core/email/smtp_host');
		$smtpUser     = ConfigHandler::Get('/core/email/smtp_user');
		$smtpPass     = ConfigHandler::Get('/core/email/smtp_password');
		$smtpPort     = ConfigHandler::Get('/core/email/smtp_port');
		$smtpSec      = ConfigHandler::Get('/core/email/smtp_security');
		$sendmailPath = ConfigHandler::Get('/core/email/sendmail_path');
		$emailDebug   = [];

		$emailDebug[] = 'Sending Method: ' . $method;

		switch($method){
			case 'smtp':
				$emailDebug[] = 'SMTP Host: ' . $smtpHost . ($smtpPort ? ':' . $smtpPort : '');
				$emailDebug[] = 'SMTP User/Pass: '******'//' . ($smtpPass ? '*** saved ***' : 'NO PASS') : 'Anonymous');
				$emailDebug[] = 'SMTP Security: ' . $smtpSec;
				break;
			case 'sendmail':
				$emailDebug[] = 'Sendmail Path: ' . $sendmailPath;
				break;
		}

		CLI::PrintHeader('Sending test email to ' . $dest);

		CLI::PrintActionStart('Initializing Email System');
		try{
			$email = new Email();
			$email->addAddress($dest);
			$email->setSubject('Test Email');
			$email->templatename = 'emails/admin/test_email.tpl';
			$email->assign('debugs', $emailDebug);
			$email->getMailer()->SMTPDebug = 2;

			CLI::PrintActionStatus(true);
		}
		catch(Exception $e){
			CLI::PrintActionStatus(false);
			CLI::PrintError($e->getMessage());
			CLI::PrintLine($e->getTrace());

			return;
		}

		CLI::PrintActionStart('Sending Email via ' . $method);
		try{
			$email->send();

			CLI::PrintActionStatus(true);
		}
		catch(Exception $e){
			CLI::PrintActionStatus(false);
			CLI::PrintError($e->getMessage());
			CLI::PrintLine(explode("\n", $e->getTraceAsString()));
		}

		CLI::PrintHeader('Sent Headers:');
		CLI::PrintLine(explode("\n", $email->getMailer()->CreateHeader()));

		CLI::PrintHeader('Sent Body:');
		CLI::PrintLine(explode("\n", $email->getMailer()->CreateBody()));
	}
Esempio n. 6
0
				break 2; // Exit back to the menu.
			case 'package-sign':
				$bundle = $packager->package($packagername, $packageremail, true);
				echo "Created signed package of " . $packager->getLabel() . ' ' . $packager->getVersion() . NL . " as " . $bundle . NL;
				break 2; // Exit back to the menu.
			case 'package-sign-commit':
				$bundle = $packager->package($packagername, $packageremail, true);
				echo "Created signed package of " . $packager->getLabel() . ' ' . $packager->getVersion() . NL . " as " . $bundle . NL;
				$packager->gitCommit();
				break 2; // Exit back to the menu.
			case 'commit':
				$packager->gitCommit();
				break 2; // Exit back to the menu.
			case 'menu':
				break 2; // Exit back to the menu.
			case 'quit':
				if($saved){
					echo 'Bye!' . NL;
				}
				else{
					echo "Aborting build" . NL;
				}
				exit;
				break;
			default:
				CLI::PrintError('Unknown option');
				break;
		}
	}
}