Example #1
0
 /**
  * takes matching php block and converts to php code
  *
  * @param array $code matches from preg_replace_callback
  * @return string $token
  */
 protected function _processPhp($code)
 {
     $token = '$' . uniqid() . '$';
     $php = new Php($code[2]);
     $php->setCssPrefix($this->_css_prefix);
     $html = $code[1] . $php->getHtml() . $code[3];
     $this->_php_blocks[$token] = '<span class="' . $this->_css_prefix . 'default">' . $html . '</span>';
     return $token;
 }
Example #2
0
 /**
  * Run installation and setup
  * @param DatabaseSqlite3 &$db Database object
  * @return boolean
  */
 public function run(&$db)
 {
     // Set object access to database
     $this->db = $db;
     Log::debug('Starting operating system setup');
     // Get operating system information
     if (is_file('/etc/os-release')) {
         // Generic release file
         $os = file_get_contents('/etc/os-release');
         // Grab Linux distribution name
         $id = array();
         $rc = preg_match('/\\nID="?([^"\\n]*)"?\\n/', $os, $id);
         if ($rc !== 1 || !isset($id[1])) {
             Log::error('Error while trying to detect the Linux distribution name');
             return false;
         } else {
             $id = $id[1];
         }
         // Grab Linux distribution version
         $version = array();
         $rc = preg_match('/\\nVERSION_ID="?([^"\\n]*)"?\\n/', $os, $version);
         if ($rc !== 1 || !isset($version[1])) {
             Log::error('Error while trying to detect the Linux distribution version');
             return false;
         } else {
             $version = (int) $version[1];
         }
         // Verify supported CentOS 7
         if ($id !== "centos" || $version !== 7) {
             Log::error('Operating system distribution and/or version not supported by this setup module');
             return false;
         }
         $rc = preg_match('/\\nPRETTY_NAME="?([^"\\n]*)"?\\n/', $os, $fullId);
         if ($rc !== 1 || isset($fullId[1])) {
             Log::debug('Detected: ' . $fullId[1]);
         }
     } else {
         Log::error('File not found: /etc/os-release');
         // Generic release file not found
         return false;
     }
     // Requirements for the setup procedure
     if (class_exists('PDO', false) === false) {
         Log::error('The PDO package is required by the setup procedure. Please install it by running "yum install php-pdo".');
         exit(9);
     }
     if (function_exists('mb_substr') === false) {
         Log::error('The multibyte package is required by the setup procedure. Please install it by running "yum install php-mbstring".');
         exit(9);
     }
     // Required repositories
     $rc = $this->_repository();
     if ($rc === false) {
         return false;
     }
     // Required packages
     $rc = $this->_package();
     if ($rc === false) {
         return false;
     }
     // Setup SELinux
     $rc = $this->_selinux($this->db);
     if ($rc === false) {
         return false;
     }
     // Load and setup external features
     // PHP
     $feature = new Php();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // OpenDKIM
     $feature = new OpenDKIM();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable OpenDKIM
     if (Config::read('opendkim') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // NSD
     $feature = new Nsd();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable NSD
     if (Config::read('nsd') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // ClamAV
     $feature = new ClamAV();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable ClamAV
     if (Config::read('clamav') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // Spamassassin
     $feature = new SpamAssassin();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable Spamassassin
     if (Config::read('spamassassin') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // Postfix
     $feature = new Postfix();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable Postfix
     if (Config::read('postfix') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // Dovecot
     $feature = new Dovecot();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable Dovecot
     if (Config::read('dovecot') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // MariaDB
     $feature = new MariaDb();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable MariaDB
     if (Config::read('mariadb') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     // Roundcube webmail
     $feature = new Roundcube();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Disable Roundcube if needed, else leave enabled by default
     if (Config::read('roundcube') === 'disabled') {
         $feature->disable();
     }
     // Apache
     $feature = new Apache();
     $rc = $feature->exportConfiguration($this->db);
     if ($rc === false) {
         return false;
     }
     // Enable or disable Apache
     if (Config::read('apache') === 'enabled') {
         $feature->enable();
     } else {
         $feature->disable();
     }
     return true;
 }
Example #3
0
 /**
  * @covers Panadas\Util\Php::toString()
  * @dataProvider toStringProvider
  */
 public function testToString($var, $expected)
 {
     $this->assertEquals($expected, Php::toString($var));
 }
Example #4
0
 /**
  * @dataProvider serializerProvider
  */
 public function testIsSerialized($var)
 {
     $formatter = new Php();
     $this->assertFalse($formatter->isSerialized($var));
     $this->assertTrue($formatter->isSerialized($formatter->serialize($var)));
 }
Example #5
0
File: Val.php Project: appcia/utils
 /**
  * Get hash for value for any type
  *
  * @param mixed $value
  *
  * @return string
  */
 public static function hash($value)
 {
     $hash = is_object($value) ? spl_object_hash($value) : md5(Php::encode($value));
     return $hash;
 }
Example #6
0
<?php

/**
 * Входная точка в движок
 *
 * @author Zmi
 */
// Режим работы сайта (Debug || Production)
define('DEBUG_MODE', (bool) (strpos($_SERVER["REMOTE_ADDR"], "127.0.0.") === 0 || strpos($_SERVER["REMOTE_ADDR"], "192.168.0.") === 0));
// Режим вывода ошибок по идёт инициализация движка, после перенастроится на параметр $g_config['phpIni']['display_errors']
ini_set('display_errors', DEBUG_MODE);
define('BASEPATH', str_replace('\\', '/', dirname(__FILE__)) . '/');
require_once BASEPATH . 'core/core.php';
ob_start();
header(Php::Status(200));
$g_config['isControllerLoad'] = IncludeCom(GetQuery());
$content = ob_get_clean();
// Если страницы небыло то 404-ая
if (!$g_config['isControllerLoad']) {
    ob_start();
    IncludeCom('404');
    $content = ob_get_clean();
}
// Если страницу нужно загрузить в главном шаблоне
if ($g_config['isLoadInMainTpl']) {
    ob_start();
    IncludeCom($g_config['mainTpl'], array('content' => $content));
    $content = ob_get_clean();
}
echo PrepareContent($content);
Example #7
0
<?php

header(Php::Status(500));
ob_start();
IncludeCom('_500');
$content = ob_get_clean();
echo $content;
exit;
Example #8
0
 /**
  * Serialize this instance as PHP.
  *
  * @return string
  */
 public function asPhp()
 {
     return Php::encode($this);
 }
Example #9
0
<?php

header(Php::Status(404));
Example #10
0
<?php

/**
 * Simple XML Load File to Listview
 * @package iMobile
 * @filesource
 */
/**
 * Include the iMobile class.
 */
include '../lib/iMobile.php';
/**
 * Create a new Php object.
 */
$iMobile = new Php();
/**
 * Create a new page object.
 */
$p = new Page('simple-xml');
$p->theme('b');
$p->title('Cars');
$bt = $p->header()->addButton('', 'index.php', 'b', 'home', false, false, true);
$bt->rel('external')->attribute('data-iconpos', 'notext');
/**
 * Adding Listview to page.
 */
$lv = $p->addContent(new Listviem(), true);
$lv->filter(true);
/**
 * Reading XML;
 */