コード例 #1
0
ファイル: Templater.php プロジェクト: colorium/templating
 /**
  * Generate content from static template compilation
  *
  * @param string $template
  * @param array $vars
  * @param array $blocks
  * @return string
  */
 public static function make($template, array $vars = [], array $blocks = [])
 {
     if (!static::$instance) {
         static::$instance = new static();
     }
     return static::$instance->render($template, $vars, $blocks);
 }
コード例 #2
0
 public function testGetMapping()
 {
     $templater = new Templater();
     $html = $templater->getTemplate("envios", array("CONTENIDO" => "Hello Test"));
     echo $html;
     $this->assertNotNull($html);
 }
コード例 #3
0
ファイル: rediger.php プロジェクト: hansnn/MeetingRooms
function direct_to_correct_page() {

	$editStylesheet = '<link href="/static/css/edit.css" rel="stylesheet">';
	$uploadStylesheet = '<link href="/static/css/upload.css" rel="stylesheet">';
	$editoruploadStylesheet = '<link href="/static/css/editorupload.css" rel="stylesheet">';

	$templater = new Templater;
	$templater->title = 'Rediger';
	
	if (isset($_GET['path'])) {
		if ($_GET['path'] == 'upload') {
			$templater->extra_headers = array($uploadStylesheet);
			$templater->render('uploadTmpl.php');

		} else if ($_GET['path'] == 'edit') {
			$date = isset($_GET['date']) ? 
					date('Ymd', strtotime($_GET['date'])) :
					date('Ymd');
			$templater->date = date('d-m-Y', strtotime($date));
			$templater->meeting_data = extract_meetings_all_rooms(false, $date); 
			$templater->extra_headers = array($editStylesheet);
			$templater->render('editTmpl.php');

		} else
			echo "I don't know what to do with this get request: " . var_dump($_GET);
	}
	else {
		$templater->extra_headers = array($editoruploadStylesheet);
		$templater->render('editoruploadTmpl.php');
	}
}
コード例 #4
0
ファイル: Viewer.php プロジェクト: Mlin3/Simple-chat
 protected function loadTemplate($template)
 {
     $main = new Templater('main');
     $body = new Templater($template);
     $main->attach('Body', $body);
     $main->register('JSPath', 'web/index.php/js/', Templater::URL);
     $main->register('CSSPath', 'web/css/main.css', Templater::URL);
     Messenger::send($main->render());
 }
コード例 #5
0
 function actionIndex()
 {
     $main = new Templater();
     $main->import("boxes/settings.tpl");
     $main->setvar("%URL%", "http://" . $GLOBALS['url']);
     $main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
     $main->setvar("%YEAR%", date("Y"));
     $main->setvar("%CSS%", "<style>" . templater("css/game.css", array("%ROOT%" => "/storage/tpl")) . "</style>");
     $main->setvar("%GAME_TITLE%", $GLOBALS['name']);
     $main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
     $main->setvar("%CONTENT%", $result);
     $main->renderEcho();
 }
コード例 #6
0
ファイル: User.php プロジェクト: kalroot/phpweb20demo
 public function sendEmail($tpl)
 {
     $templater = new Templater();
     $templater->user = $this;
     $body = $templater->render('email/' . $tpl);
     list($subject, $body) = preg_split('/\\r|\\n/', $body, 2);
     $mail = new Zend_Mail();
     $mail->addTo($this->profile->email, trim($this->profile->first_name . ' ' . $this->profile->last_name));
     $mail->setFrom(Zend_Registry::get('config')->email->from->email, Zend_Registry::get('config')->email->from->name);
     $mail->setSubject(trim($subject));
     $mail->setBodyText(trim($body));
     $mail->send();
 }
コード例 #7
0
ファイル: Sandbox.php プロジェクト: colorium/templating
 /**
  * Compile template
  *
  * @param array $vars
  * @return string
  *
  * @throws \Exception
  */
 public function compile(array $vars = [])
 {
     // start compilation
     if ($this->compiling) {
         throw new \LogicException('Template is already compiling.');
     }
     $this->compiling = true;
     // extract user vars
     extract($vars);
     unset($vars);
     // start stream capture
     ob_start();
     // display file
     require $this->file;
     // stop stream capture
     $content = ob_get_clean();
     $content .= "\n\n";
     // compile layout
     if ($this->layout) {
         list($layout, $vars) = $this->layout;
         $blocks = array_merge($this->blocks, ['__CONTENT__' => $content]);
         $content = $this->templater->render($layout, $vars, $blocks);
     }
     // end
     $this->compiling = false;
     return $content;
 }
コード例 #8
0
ファイル: frontcontroller.php プロジェクト: erkie/cowl
 public function __construct()
 {
     Cowl::timer('cowl init');
     @session_start();
     // I know that the @-notation is frowned upon, but adding it to session_start saves us unnecessary warnings
     Cache::setDir(COWL_CACHE_DIR);
     Current::initialize(COWL_DIR);
     if (COWL_CLI) {
         $this->parseCLIPath();
     } else {
         $this->parseRequestPath();
     }
     Cowl::timer('cowl set defaults');
     // Get and set all directories for various things.
     list($commands_dir, $model_dir, $validators_dir, $library_dir, $view_dir, $helpers_dir, $helpers_app_dir, $drivers_dir, $app_dir, $view_layout_dir, $validator_error_messages, $lang) = Current::$config->gets('paths.commands', 'paths.model', 'paths.validators', 'paths.library', 'paths.view', 'paths.helpers', 'paths.helpers_app', 'paths.drivers', 'paths.app', 'paths.layouts', 'paths.validator_messages', 'lang');
     Controller::setDir($commands_dir);
     DataMapper::setMappersDir($model_dir);
     DataMapper::setObjectsDir($model_dir);
     Validator::setPath($validators_dir);
     Validator::loadStrings($validator_error_messages, $lang);
     Templater::setBaseDir($view_dir);
     Templater::setLayoutDir($view_layout_dir);
     Library::setPath($library_dir);
     Helpers::setPath($helpers_dir);
     Helpers::setAppPath($helpers_app_dir);
     Database::setPath($drivers_dir);
     StaticServer::setDir($app_dir);
     Cowl::timerEnd('cowl set defaults');
     Cowl::timer('cowl plugins load');
     Current::$plugins = new Plugins();
     Cowl::timerEnd('cowl plugins load');
     // Load default helper
     Helpers::load('standard', 'form');
     Cowl::timerEnd('cowl init');
 }
コード例 #9
0
ファイル: TemplaterClass.php プロジェクト: n2j7/plainwork
 public function catchBlock($buf_name)
 {
     /*******************************************************\
     		 * Next check isn't correct due to php5.2 will generate
     		 * ParseError on anonymous function definition
     		 * I just leave this code here for some time
     		\*******************************************************/
     #if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
     #	ob_start(function ($buffer_val) use($buf_name){
     #		if(!array_key_exists($buf_name, Templater::$bufs)){
     #			Templater::$bufs[$buf_name] = array();
     #		}
     #		array_push(Templater::$bufs[$buf_name], $buffer_val);
     #		return $buffer_val;
     #	});
     #}
     #else{
     // this variant for php < 5.3.0
     // my production still use 5.2 (((
     // this variant don't support nesting catching
     self::$cur_buf_name = $buf_name;
     function handler($buffer_val)
     {
         if (!array_key_exists(Templater::$cur_buf_name, Templater::$bufs)) {
             Templater::$bufs[Templater::$cur_buf_name] = array();
         }
         array_push(Templater::$bufs[Templater::$cur_buf_name], $buffer_val);
         return $buffer_val;
     }
     ob_start('handler');
     #}
 }
コード例 #10
0
ファイル: inv.php プロジェクト: NikoVonLas/RaptorGameEngine
 function actionIndex()
 {
     if (!isset($char)) {
         $char = new Char();
     }
     $currency = Database::GetOne("config", array("mod" => "currency"));
     $inv_params = Database::GetOne("config", array("mod" => "inv_params"));
     $inv_actions = Database::GetOne("config", array("mod" => "inv_actions"));
     $main = new Templater();
     $main->import("boxes/inv_page.tpl");
     $main->setvar("%URL%", "http://" . $GLOBALS['url']);
     $main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
     $main->setvar("%YEAR%", date("Y"));
     $main->setvar("%CSS%", "<style>" . templater("css/game.css", array("%ROOT%" => "/storage/tpl")) . "</style>");
     $main->setvar("%GAME_TITLE%", $GLOBALS['name']);
     $main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
     $result = '';
     foreach ($char->inv->getItems() as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         $addparams = array("%NAME%" => $value['name'], "%IMG%" => $value['image'], "%COST%" => $value['cost'], "%COUNT%" => $value['count'], "%C_NAME%" => $currency[$value['currency']]['name'], "%C_IMG%" => $currency[$value['currency']]['img'], "%CAT%" => $value['cat']);
         $id = $key;
         foreach ($inv_params as $skey => $svalue) {
             if (!strstr($skey, "p_")) {
                 continue;
             }
             $addparams["%" . $skey . "%"] = $char->inv->getParam($skey, $key);
             $addparams['%_PARAMS_%'] .= "<tr><td>" . $inv_params[$skey]['name'] . "</td><td>" . $char->inv->getParam($skey, $key) . "</td></tr>";
         }
         foreach ($inv_actions as $skey => $svalue) {
             if (!strstr($skey, "act_")) {
                 continue;
             }
             if (eval($svalue['eval'])) {
                 $addparams["%_SCR_ACTIONS_%"][] = "<a href='?act=" . $skey . "&id=" . $id . "'>" . $svalue['name'] . "</a>";
                 if ($_GET['act'] == $skey and $_GET['id'] == $id) {
                     call_user_func("UseItem", $skey, $id);
                 }
             }
         }
         $addparams["%_SCR_ACTIONS_%"] = isset($addparams["%_SCR_ACTIONS_%"]) ? implode(" / ", $addparams["%_SCR_ACTIONS_%"]) : '';
         $result .= templater("boxes/inv_list.tpl", $addparams);
     }
     $main->setvar("%CONTENT%", $result);
     $main->renderEcho();
 }
コード例 #11
0
 public static function process($directory = "", $defaults, $config = array())
 {
     PipelineHooks::beforeProcessingFilesIn($directory, $defaults, $config);
     // Hook for before this directory is processed
     $configPath = $directory . "config.json";
     if (file_exists($configPath)) {
         CL::printDebug("Config File at: " . $configPath, 1);
     }
     $config = Secretary::getJSON($configPath, $config);
     if (array_key_exists("Content", $config)) {
         CL::println("WARNING: You've declared field \"Content\" in JSON file: " . $directory . "config.json", 0, Colour::Red);
         CL::println("The \"Content\" keyword is reserved for storing the file contents in.", 0, Colour::Red);
         CL::println("The value for \"Content\" stored in the JSON file will be ignored.", 0, Colour::Red);
     }
     $files = array();
     $markdowns = glob($directory . "*.md");
     foreach ($markdowns as $markdown) {
         CL::printDebug("Processing: " . $markdown);
         $file = new File($markdown);
         // Set up our @data
         $data = array_merge($config, $file->data);
         // Renaming to make more semantic sense as we're now working with the "data"
         $data["Content"] = $file->contents;
         // Pass in our file contents
         $raw = $data;
         // Store raw data before processing
         // Process our data through data extensions
         if (array_key_exists("DataExtensions", $defaults)) {
             $data = DataProcessor::process($data, $defaults["DataExtensions"]);
             // Process our data to be filled in
             CL::printDebug("Processed data", 1, Colour::Green);
         } else {
             CL::printDebug("No data extensions declared", 1);
         }
         $data["Content"] = Regex::process($data["Content"]);
         // Now regex it all
         CL::printDebug("Processed Regex", 1, Colour::Green);
         $templateFile = Templater::process($data["Template"]);
         // Generate our template
         CL::printDebug("Processed template: " . $data["Template"], 1, Colour::Green);
         $processedFile = LTM::process($templateFile, $data, $raw);
         // Fill in any conditions and optionals
         CL::printDebug("Processed LTM", 1, Colour::Green);
         $file->contents = $processedFile;
         // Store the complete processed file back into the file object
         array_push($files, $file);
         // Add it to the array ready to be exported!
     }
     PipelineHooks::afterProcessing($files, $directory, $defaults, $config);
     // Hook for after this directory is processed - and lets pass some files!
     $directories = glob($directory . "*", GLOB_ONLYDIR);
     foreach ($directories as $directory) {
         $newFiles = self::process($directory . "/", $defaults, $config);
         foreach ($newFiles as $newFile) {
             array_push($files, $newFile);
         }
     }
     return $files;
 }
コード例 #12
0
ファイル: news.php プロジェクト: NikoVonLas/RaptorGameEngine
 function actionRead()
 {
     $main = new Templater();
     $main->import("interface/news_list.tpl");
     $main->setvar("%URL%", "http://" . $GLOBALS['url']);
     $main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
     $main->setvar("%YEAR%", date("Y"));
     $main->setvar("%GAME_TITLE%", $GLOBALS['name']);
     $main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
     $array = Database::GetOne("news", array('_id' => toId($_GET['id'])));
     $html = templater("interface/news_full.tpl", array("%SUBJECT%" => $array['title'], "%DATE%" => $array['date'], "%ANNOUNCE%" => $array['short'], "%TEXT%" => $array['full'], "%ID%" => $array['_id']));
     $main->setvar("%CONTENT%", $html);
     $main->renderEcho();
 }
コード例 #13
0
   public static function singleton() 
   {
      if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c;
      }

      return self::$instance;
   }
コード例 #14
0
ファイル: authenticate.php プロジェクト: hansnn/MeetingRooms
function direct() {
	$ROOT = $_SERVER['DOCUMENT_ROOT'];
	require_once $ROOT . '/helpers/templater.php';
	require_once $ROOT . '/../mkkauth.php';


	if (isset($_POST['password']) && htmlspecialchars($_POST['password']) === MKK_AUTH_KEY) {
		$_SESSION['login'] = true;
		header('Location: rediger.php');
		exit;
	}
	else {
		$stylesheet = '<link href="static/css/authenticate.css" rel="stylesheet">';
		$templater = new Templater;
		$templater->title = 'Login';
		$templater->extra_headers = array($stylesheet);
		$templater->render('authenticateTmpl.php');
	}
}
コード例 #15
0
ファイル: money.php プロジェクト: NikoVonLas/RaptorGameEngine
 function actionIndex()
 {
     $char = new Char();
     $params = Database::GetOne("config", array("mod" => "currency"));
     $main = new Templater();
     $main->import("boxes/money_page.tpl");
     $main->setvar("%URL%", "http://" . $GLOBALS['url']);
     $main->setvar("%STORAGE_TPL_URL%", "/storage/tpl");
     $main->setvar("%YEAR%", date("Y"));
     $main->setvar("%CSS%", "<style>" . templater("game.css", array("%ROOT%" => "/storage/tpl")) . "</style>");
     $main->setvar("%GAME_TITLE%", $GLOBALS['name']);
     $main->setvar("%STORAGE_STATIC_URL%", "/storage/static");
     $result = '';
     foreach ($params as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         $result .= templater("boxes/money_list.tpl", array("%NAME%" => $value['name'], "%IMG%" => $value['img'], "%COUNT%" => $char->{$key}));
     }
     $main->setvar("%CONTENT%", $result);
     $main->renderEcho();
 }
コード例 #16
0
ファイル: wiki.php プロジェクト: NikoVonLas/RaptorGameEngine
 public function actionIndex()
 {
     $article = Database::GetOne('wiki_pages', array('type' => 'main'));
     //$side_menu = Database::GetOne('wiki_side_menu',array('status' => 1));
     $tpl = new Templater();
     $tpl->import('wiki/wiki.tpl');
     $tpl->setvar('%GAME_TITLE%', $GLOBALS['name']);
     $tpl->setvar("%YEAR%", date("Y"));
     $tpl->setvar("%CONTENT%", $article['content']);
     $tpl->setvar("%SIDE_MENU%", 'Тут будет кастомное меню');
     $tpl->renderEcho();
 }
コード例 #17
0
ファイル: core.class.php プロジェクト: AstroProfundis/Feathur
 public static function SendEmail($sTo, $sSubject, $sTemplate, $sVariable)
 {
     global $sPanelURL;
     global $sPanelMode;
     global $sTitle;
     global $locale;
     $sEmail = Templater::AdvancedParse('/email/' . $sTemplate, $locale->strings, array("EmailVars" => array("entry" => $sVariable)));
     $sMail = Core::GetSetting('mail');
     $sMail = $sMail->sValue;
     if ($sMail == 1) {
         $sSendGridUser = Core::GetSetting('mail_username');
         $sSendGridPass = Core::GetSetting('mail_password');
         $sSendGridUser = $sSendGridUser->sValue;
         $sSendGridPass = $sSendGridPass->sValue;
         if (!empty($sSendGridUser) && !empty($sSendGridPass)) {
             $sGrid = new SendGrid($sSendGridUser, $sSendGridPass);
             $sMail = new SendGrid\Mail();
             $sMail->addTo($sTo)->setFrom("noreply@{$sPanelURL->sValue}")->setSubject($sSubject)->setHtml($sEmail);
             $sGrid->web->send($sMail);
             return true;
         } else {
             return $sReturn = array("content" => "Unfortunately Send Grid is incorrectly configured!");
         }
     } elseif ($sMail == 2) {
         $sMandrillUser = Core::GetSetting('mail_username');
         $sMandrillPass = Core::GetSetting('mail_password');
         $sMandrillUser = $sMandrillUser->sValue;
         $sMandrillPass = $sMandrillPass->sValue;
         try {
             $sMandrill = new Mandrill($sMandrillPass);
             $sMessage = array('html' => $sEmail, 'subject' => $sSubject, 'from_email' => "noreply@{$sPanelURL->sValue}", 'from_name' => "{$sTitle->sValue}", 'to' => array(array('email' => $sTo, 'type' => 'to')), 'important' => true, 'track_opens' => null, 'track_clicks' => null, 'auto_text' => null, 'auto_html' => null, 'inline_css' => null, 'url_strip_qs' => null, 'preserve_recipients' => null, 'view_content_link' => null, 'tracking_domain' => null, 'signing_domain' => null, 'return_path_domain' => null, 'merge' => true);
             $sAsync = false;
             $sIPPool = 'Main Pool';
             $sSendAt = NULL;
             $sResult = $sMandrill->messages->send($sMessage, $sAsync, $sIPPool, $sSendAt);
         } catch (Exception $e) {
             return $sReturn = array("content" => "Mandril Error: {$e}");
         }
         return true;
     } else {
         $sHeaders = "MIME-Version: 1.0" . "\r\n";
         $sHeaders .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
         $sHeaders .= 'From: <noreply@' . $sPanelURL->sValue . '>' . "\r\n";
         if (mail($sTo, $sSubject, $sEmail, $sHeaders)) {
             return true;
         } else {
             return $sReturn = array("content" => "Unfortunatly the email failed to send, please check your server's sendmail settings.");
         }
     }
 }
コード例 #18
0
ファイル: TemplaterTest.php プロジェクト: apexstudios/yamwlib
 public function testSimpleTemplateGeneration()
 {
     $markupMgr = new MarkupManager();
     $filePath = __DIR__ . "/mocks/basic_template";
     $cmpPath = __DIR__ . "/mocks/generated_template";
     $date = date(DATE_RFC2822, time());
     $markupName = new Markup\SimpleTemplateMarkup('name', 'NAME', 'John Doe');
     $markupTime = new Markup\MethodInvocationMarkup('time', 'TIME', array('date', array(DATE_RFC2822, time())));
     $markupMgr->registerMarkup($markupName)->registerMarkup($markupTime);
     Templater::loadCache(file_get_contents($filePath));
     Templater::setMarkupMgr($markupMgr);
     Templater::generateTemplate();
     $generatedTemplate = Templater::retrieveTemplate();
     self::assertEquals(trim(file_get_contents($cmpPath)) . " " . $date, trim($generatedTemplate));
 }
コード例 #19
0
ファイル: Box.php プロジェクト: webcitron/subframe
 public final function render($arrViewData = array(), $strViewName = '')
 {
     $strBoxFullName = get_called_class();
     $arrBoxFullNameTokens = explode('\\', $strBoxFullName);
     if (empty($strViewName)) {
         $strViewName = array_pop($arrBoxFullNameTokens);
     } else {
         array_pop($arrBoxFullNameTokens);
     }
     $strBoxViewDirectory = sprintf('%s/%s/view', APP_DIR, join('/', $arrBoxFullNameTokens));
     $strBoxViewPath = sprintf('%s/%s', $strBoxViewDirectory, $strViewName);
     $objApp = Application::getInstance();
     $objApp->objLanguages->loadPhrases($strBoxFullName);
     $objTemplater = Templater::createSpecifiedTemplater(Config::get('templater'));
     $strBoxContent = $objTemplater->getTemplateFileContent($strBoxViewPath, $arrViewData);
     $objApp->objLanguages->clearLoadedPhrases();
     return $strBoxContent;
 }
コード例 #20
0
 /**
  * Request a template from the templates directory
  * @param  String $templateName The name of the template to request
  * @return String               The processed template file
  */
 static function process($templateName)
 {
     $ref = new ReflectionClass('Templater');
     $filePath = dirname(dirname($ref->getFileName())) . "/templates/" . $templateName . ".html";
     if (!file_exists($filePath)) {
         // Does the requested file actuallye exist?
         CL::println("Template at " . $filePath . " does not exist.", 0, Colour::Red);
         CL::println("Warehouse cannot continue. Please fix. Exiting program.", 0, Colour::Red);
         exit;
     }
     $rawFile = file_get_contents($filePath);
     // If it does get it's contents
     $regex = "/@template\\(([\\w|.]+)\\)/";
     // Check to see if there are any @template calls
     $processedFile = preg_replace_callback($regex, function ($matches) {
         return Templater::process($matches[1]);
         // recursion recursion recursion recursion..
     }, $rawFile);
     return $processedFile;
 }
コード例 #21
0
ファイル: Composer.php プロジェクト: pinahq/framework
 public static function draw($pos, $ps, &$view)
 {
     if (!isset(self::$data[$pos])) {
         return '';
     }
     $items = self::$data[$pos];
     if (!is_array($items)) {
         return '';
     }
     $r = '';
     foreach ($items as $params) {
         $params = Arr::merge($ps, $params);
         if ($params['__widget'] == 'view') {
             $r .= Templater::processView($params, $view);
         } else {
             $r .= Templater::processModule($params, $view);
         }
     }
     return $r;
 }
コード例 #22
0
 public function Render()
 {
     global $locale;
     switch ($this->sErrorType) {
         case CPHP_ERRORHANDLER_TYPE_ERROR:
             $template = "errorhandler.error";
             break;
         case CPHP_ERRORHANDLER_TYPE_INFO:
             $template = "errorhandler.info";
             break;
         case CPHP_ERRORHANDLER_TYPE_WARNING:
             $template = "errorhandler.warning";
             break;
         case CPHP_ERRORHANDLER_TYPE_SUCCESS:
             $template = "errorhandler.success";
             break;
         default:
             return false;
     }
     return Templater::AdvancedParse($template, $locale->strings, array('title' => $this->sTitle, 'message' => $this->sMessage));
 }
コード例 #23
0
ファイル: templater.php プロジェクト: erkie/cowl
 public static function setLayoutDir($dir)
 {
     self::$layout_dir = $dir;
 }
コード例 #24
0
ファイル: ftp.php プロジェクト: deanet/Neon
<?php

include './includes/loader.php';
if ($LoggedIn === false) {
    header("Location: index.php");
    die;
} else {
    $sContent = Templater::AdvancedParse('/blue_default/ftp', $locale->strings, array('PanelTitle' => $sPanelTitle->sValue, 'ErrorMessage' => "", 'Username' => $sUser->sUsername));
    echo Templater::AdvancedParse('/blue_default/master', $locale->strings, array('PageTitle' => "FTP Accounts", 'PageName' => "ftp", 'PanelTitle' => $sPanelTitle->sValue, 'ErrorMessage' => "", 'Username' => $sUser->sUsername, 'Content' => $sContent));
}
コード例 #25
0
ファイル: main.php プロジェクト: AstroProfundis/Feathur
<?php

include './includes/loader.php';
if (empty($sUser)) {
    header("Location: index.php");
    die;
}
if ($sUser->sPermissions == 7 && empty($_GET['force'])) {
    header("Location: admin.php");
    die;
}
$sPullVPS = $database->CachedQuery("SELECT * FROM vps WHERE `user_id` = :UserId", array('UserId' => $sUser->sId));
if (empty($sPullVPS)) {
    $sErrors[] = array("red" => "You currently do not have any VPS. Please contact our support department.");
}
$sMain = Templater::AdvancedParse($sTemplate->sValue . '/main', $locale->strings, array());
echo Templater::AdvancedParse($sTemplate->sValue . '/master', $locale->strings, array("Content" => $sMain, "Page" => "main", "Errors" => $sErrors));
コード例 #26
0
ファイル: settings.php プロジェクト: deanet/Neon
<?php

include './includes/loader.php';
if ($LoggedIn === false) {
    header("Location: index.php");
    die;
} else {
    $sContent = Templater::AdvancedParse('/blue_default/settings', $locale->strings, array('ErrorMessage' => ""));
    echo Templater::AdvancedParse('/blue_default/master', $locale->strings, array('PageTitle' => "Server Settings", 'PageName' => "settings", 'ErrorMessage' => "", 'Content' => $sContent));
}
コード例 #27
0
 public function kvm_statistics($sUser, $sVPS, $sRequested)
 {
     global $sTemplate;
     global $database;
     global $locale;
     $sServer = new Server($sVPS->sServerId);
     $sSSH = Server::server_connect($sServer);
     $sLog[] = array("command" => "virsh list | grep kvm{$sVPS->sContainerId}", "result" => $sSSH->exec("virsh list | grep kvm{$sVPS->sContainerId}"));
     if ($sTemplates = $database->CachedQuery("SELECT * FROM templates WHERE `id` = :TemplateId", array('TemplateId' => $sVPS->sTemplateId))) {
         $sVPSTemplate = new Template($sVPS->sTemplateId);
         $sTemplateName = $sVPSTemplate->sName;
     } else {
         $sTemplateName = "N/A";
     }
     if ($sVPS->sBandwidthUsage > 0) {
         $sBandwidthUsage = FormatBytes($sVPS->sBandwidthUsage, 0);
     } else {
         $sBandwidthUsage = "0 KB";
     }
     $sPercentBandwidth = round(100 / ($sVPS->sBandwidthLimit * 1024 * 1024) * $sVPS->sBandwidthUsage, 0);
     if (empty($sPercentBandwidth)) {
         $sPercentBandwidth = 0;
     }
     $sMac = explode(",", $sVPS->sMac);
     $sIPList = VPS::list_ipspace($sVPS);
     $sStatistics = array("info" => array("ram" => $sVPS->sRAM, "disk" => $sVPS->sDisk, "cpulimit" => $sVPS->sCPULimit, "bandwidth_usage" => $sBandwidthUsage, "bandwidth_limit" => FormatBytes($sVPS->sBandwidthLimit * 1024, 0), "percent_bandwidth" => round(100 / ($sVPS->sBandwidthLimit * 1024) * $sVPS->sBandwidthUsage, 0), "template" => $sTemplateName, "hostname" => $sVPS->sHostname, "primary_ip" => $sVPS->sPrimaryIP, "gateway" => $sIPList[0]["gateway"], "netmask" => $sIPList[0]["netmask"], "mac" => $sMac[0]));
     $sStatistics = Templater::AdvancedParse($sTemplate->sValue . '/' . $sVPS->sType . '.statistics', $locale->strings, array("Statistics" => $sStatistics));
     if (strpos($sLog[0]["result"], 'running') === false) {
         return $sArray = array("json" => 1, "type" => "status", "result" => "offline", "hostname" => $sVPS->sHostname, "content" => $sStatistics);
     } else {
         return $sArray = array("json" => 1, "type" => "status", "result" => "online", "hostname" => $sVPS->sHostname, "content" => $sStatistics);
     }
 }
コード例 #28
0
ファイル: update.php プロジェクト: AstroProfundis/Feathur
        $sErrors[] = array("result" => "Automatic updates have been turned off.", "type" => "success");
    }
}
if ($sAction == force) {
    $sSSH = new Net_SSH2('127.0.0.1');
    $sKey = new Crypt_RSA();
    $sKey->loadKey(file_get_contents($cphp_config->settings->rootkey));
    if ($sSSH->login("root", $sKey)) {
        $sOldVersion = file_get_contents('/var/feathur/version.txt');
        $sSSH->exec("cd /var/feathur/; git reset --hard; git pull; cd /var/feathur/feathur/; php update.php; rm -rf update.php;");
        $sVersion = file_get_contents('/var/feathur/version.txt');
        $sLastUpdate = Core::UpdateSetting('last_update_check', time());
        $sCurrentVersion = file_get_contents('/var/feathur/version.txt');
        if ($sCurrentVersion != $sOldVersion) {
            $sErrors[] = array("result" => "Force update completed.", "type" => "success");
        } elseif ($sCurrentVersion->sValue == $sOldVersion->sValue) {
            $sErrors[] = array("result" => "Force update failed, no updates available.", "type" => "error");
        } else {
            $sErrors[] = array("result" => "Force update failed, unknown error.", "type" => "error");
        }
    }
    $sJson = 1;
}
$sAutomaticUpdates = Core::GetSetting('automatic_updates');
$sUpdates[] = check_updates();
$sContent .= Templater::AdvancedParse($sAdminTemplate->sValue . '/update', $locale->strings, array("AutomaticUpdates" => $sAutomaticUpdates->sValue, "Updates" => $sUpdates, "Outdated" => $sUpdates[0]["update"], "Errors" => $sErrors));
if ($sJson == 1) {
    echo json_encode(array("content" => $sContent));
    die;
}
unset($sErrors);
コード例 #29
0
ファイル: infoskjerm.php プロジェクト: hansnn/MeetingRooms
// ------------------------------------
// Vis bilde hvis det er sommerferie
$today = date('d-m-Y', time());
$summerEnd = date('04-08-2014');
if (strtotime($today) < strtotime($summerEnd)) {
	require('static/sommer.html');
	die;
}
// ------------------------------------


$ROOT = $_SERVER['DOCUMENT_ROOT'];
require_once 'helpers/templater.php';
require_once 'helpers/database.php';

$stylesheet1 = '<link href="static/css/mainview.css" rel="stylesheet">';
$stylesheet2 = '<link href="static/css/infoskjerm.css" rel="stylesheet">';
$script1 = '<script src="static/js/infoskjerm.js"></script>';
$script2 = '<script src="static/js/mainview.js"></script>';


$templater = new Templater;
$templater->title = 'Møteromsoversikt';
$templater->date = utf8_encode(strftime('%A %d. %B %Y'));
$templater->last_updated = utf8_encode(strftime('%A %d. %B kl %H:%M', strtotime(extract_last_updated())));
$templater->meeting_data = extract_meetings_all_rooms();
$templater->extra_headers = array($stylesheet1, $stylesheet2);
$templater->extra_footers = array($script1, $script2);

$templater->render('mainviewTmpl.php');
コード例 #30
0
ファイル: admin.php プロジェクト: AstroProfundis/Feathur
<?php

include './includes/loader.php';
$sId = $_GET['id'];
$sView = $_GET['view'];
$sAction = $_GET['action'];
$sSearch = $_GET['search'];
$sType = $_GET['type'];
$sPage = "admin";
$sPageType = "";
if (empty($sUser)) {
    header("Location: index.php");
    die;
}
if ($sUser->sPermissions != 7) {
    header("Location: main.php");
    die;
}
if (file_exists('./admin/' . $sView . '.php')) {
    include './admin/' . $sView . '.php';
} else {
    include "./admin/dashboard.php";
}
echo Templater::AdvancedParse($sTemplate->sValue . '/master', $locale->strings, array("Content" => $sContent, "Page" => $sPage, "PageType" => $sPageType, "Errors" => $sErrors));