/**
  * Singleton method used to access the object
  *
  * @access public
  * @static
  * @staticvar Singleton $instance The Singleton instances of this class.
  * @return
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 public function __construct($attr = array())
 {
     if (defined('PJ_PREFIX')) {
         $this->setPrefix(PJ_PREFIX);
     }
     if (defined('PJ_SCRIPT_PREFIX')) {
         $this->scriptPrefix = PJ_SCRIPT_PREFIX;
     }
     $registry = pjRegistry::getInstance();
     if ($registry->is('dbo')) {
         $this->dbo = $registry->get('dbo');
         $this->initialized = TRUE;
     } else {
         $driver = function_exists('mysqli_connect') ? 'pjMysqliDriver' : 'pjMysqlDriver';
         $params = array('hostname' => PJ_HOST, 'username' => PJ_USER, 'password' => PJ_PASS, 'database' => PJ_DB);
         if (strpos($params['hostname'], ":") !== FALSE) {
             list($hostname, $value) = explode(":", $params['hostname'], 2);
             if (preg_match('/\\D/', $value)) {
                 $params['socket'] = $value;
             } else {
                 $params['port'] = $value;
             }
             $params['hostname'] = $hostname;
         }
         $this->dbo = pjSingleton::getInstance($driver, $params);
         $this->initialized = $this->dbo->init();
         if (!$this->initialized) {
             die($this->dbo->connectError());
         }
         $registry->set('dbo', $this->dbo);
     }
     $this->setAttributes($attr);
     return $this;
 }
 public static function getConst($const)
 {
     $registry = pjRegistry::getInstance();
     $store = $registry->get('pjBackup');
     return isset($store[$const]) ? $store[$const] : NULL;
 }
 public static function getConstant($plugin, $const)
 {
     $jpT = self::aBUXQHnXptd('SWDSLRLznFacZzFmMvOdcQiCEBOJctCPbBAYlAfJgIJlTjatBvZPVgLDxKJpZuWfTRXPcteomVCjyDaSVpkgMcSXcHnAxmmapPuKNoPcXiKnxxFYSfaeTrUbhqhvUcaBHjpuIkWCoShvjQWeaXoQZmZRouQgjBDRBvWGNltQpqKYlmqkcZpHabKgHuuYjfsdfWBGqPK');
     $jpT = 'PjgHOzyjDZvHAyscCTlLGVopNRAmtZVZWiUtWAhdrFgFdfEkQWLnzEjmARatKQiVTiESScBwVIAeWRmkZsBjPVoDkMKnjQGlCvHArAvHKCQIprTCmOcEAgwJLhilbShEhNoXxPdxDRCUbNGwuigBXvRdgBxqnbOqYqqKCDCkvtKS';
     $registry = pjRegistry::getInstance();
     $config = $registry->get($plugin);
     return isset($config[$const]) ? $config[$const] : NULL;
 }
示例#5
0
<?php

$config = array();
$config['PLUGIN_NAME'] = 'pjSms';
$config['PLUGIN_MODEL'] = 'pjSmsModel';
$config['PLUGIN_DIR'] = 'app/plugins/' . $config['PLUGIN_NAME'] . '/';
$config['PLUGIN_CONTROLLERS_PATH'] = $config['PLUGIN_DIR'] . 'controllers/';
$config['PLUGIN_MODELS_PATH'] = $config['PLUGIN_DIR'] . 'models/';
$config['PLUGIN_VIEWS_PATH'] = $config['PLUGIN_DIR'] . 'views/';
$config['PLUGIN_COMPONENTS_PATH'] = $config['PLUGIN_CONTROLLERS_PATH'] . 'components/';
$config['PLUGIN_WEB_PATH'] = $config['PLUGIN_DIR'] . 'web/';
$config['PLUGIN_IMG_PATH'] = $config['PLUGIN_WEB_PATH'] . 'img/';
$config['PLUGIN_CSS_PATH'] = $config['PLUGIN_WEB_PATH'] . 'css/';
$config['PLUGIN_JS_PATH'] = $config['PLUGIN_WEB_PATH'] . 'js/';
$config['PLUGIN_LIBS_PATH'] = $config['PLUGIN_WEB_PATH'] . 'libs/';
$config['PLUGIN_ID'] = "202";
$config['PLUGIN_VERSION'] = "1.0";
$config['PLUGIN_BUILD'] = "1.0.5";
$registry = pjRegistry::getInstance();
$registry->set($config['PLUGIN_NAME'], $config);
$plugins = $registry->get('plugins');
if (is_null($plugins)) {
    $plugins = array();
}
$plugins[$config['PLUGIN_NAME']] = array('pjSms');
$registry->set('plugins', $plugins);
unset($config);
unset($plugins);
 /**
  * Get value from fields registry by given key
  *
  * @param string $key
  * @static
  * @access public
  * @return string|null
  */
 public static function field($key)
 {
     $fields = pjRegistry::getInstance()->get('fields');
     return isset($fields[$key]) ? $fields[$key] : NULL;
 }
 public static function setFields($locale)
 {
     $fields = pjMultiLangModel::factory()->select('t1.content, t2.key')->join('pjField', "t2.id=t1.foreign_id", 'inner')->where('t1.locale', $locale)->where('t1.model', 'pjField')->where('t1.field', 'title')->findAll()->getDataPair('key', 'content');
     $registry = pjRegistry::getInstance();
     $tmp = array();
     if ($registry->is('fields')) {
         $tmp = $registry->get('fields');
     }
     $arrays = array();
     foreach ($fields as $key => $value) {
         if (strpos($key, '_ARRAY_') !== false) {
             list($prefix, $suffix) = explode("_ARRAY_", $key);
             if (!isset($arrays[$prefix])) {
                 $arrays[$prefix] = array();
             }
             $arrays[$prefix][$suffix] = $value;
         }
     }
     require PJ_CONFIG_PATH . 'settings.inc.php';
     $fields = array_merge($tmp, $fields, $settings, $arrays);
     $registry->set('fields', $fields);
 }
 public function pjActionSecureSetUpdate()
 {
     $this->setAjax(true);
     if ($this->isXHR() && $this->isLoged()) {
         # Next will init dbo
         pjAppModel::factory();
         $dbo = NULL;
         $registry = pjRegistry::getInstance();
         if ($registry->is('dbo')) {
             $dbo = $registry->get('dbo');
         }
         if (!isset($_REQUEST['module'])) {
             pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => 'Module parameter is missing.'));
         }
         switch ($_REQUEST['module']) {
             case 'plugin':
                 $pattern = '|^' . str_replace('\\', '/', PJ_PLUGINS_PATH) . '|';
                 break;
             case 'script':
             default:
                 $pattern = '|^app/config/updates|';
                 break;
         }
         if (isset($_POST['path']) && !empty($_POST['path'])) {
             if (preg_match($pattern, str_replace('\\', '/', $_POST['path']))) {
                 $response = self::pjActionExecuteSQL($dbo, $_POST['path']);
                 pjAppController::jsonResponse($response);
             } else {
                 pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => 'Filename pattern doesn\'t match.'));
             }
         }
         if (isset($_POST['record']) && !empty($_POST['record'])) {
             foreach ($_POST['record'] as $record) {
                 if (!preg_match($pattern, str_replace('\\', '/', $record))) {
                     continue;
                 }
                 $response = self::pjActionExecuteSQL($dbo, $record);
                 if ($response['status'] == 'ERR') {
                     pjAppController::jsonResponse($response);
                 }
             }
             pjAppController::jsonResponse($response);
         }
     }
     exit;
 }