Ejemplo n.º 1
0
 /**
  * Current Instance of Core
  * @return Core
  */
 public static function getInstance()
 {
     if (Core::$instance == null) {
         Core::$instance = new CoreAjax();
     }
     return Core::$instance;
 }
Ejemplo n.º 2
0
 public static function inst()
 {
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 3
0
 /**
  * Возвращает ссылку на себя
  * @example Core::getInstance()->parse_url();
  *
  * @example $core = Core::getInstance();
  * @example $core->parse_url();
  * @return Core
  */
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new Core();
     }
     return self::$instance;
 }
Ejemplo n.º 4
0
 /**
  * Get Instance
  *
  * Return an instance of this class
  * @return object Instance of this class
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 5
0
 /**
  * Utilizamos el método singleton para acceder a los objetos
  * @access public
  * @return
  */
 public static function singleton()
 {
     if (!isset(self::$instance)) {
         $obj = __CLASS__;
         self::$instance = new $obj();
     }
     return self::$instance;
 }
Ejemplo n.º 6
0
 public static function coreInstance()
 {
     if (!isset(self::$instance)) {
         $object = __CLASS__;
         self::$instance = new $object();
     }
     return self::$instance;
 }
Ejemplo n.º 7
0
 public static function getInstance()
 {
     // Implement the singleton pattern
     if (!isset(self::$instance)) {
         $obj = __CLASS__;
         self::$instance = new $obj();
     }
     return self::$instance;
 }
Ejemplo n.º 8
0
 /**
  * Processing of all storage requests
  *
  * @param int								$connection
  *
  * @return Storage\_Abstract|False_class
  */
 protected function connecting($connection)
 {
     /**
      * If connection found in list of failed connections - return instance of False_class
      */
     if (isset($this->failed_connections[$connection])) {
         return False_class::instance();
     }
     /**
      * If connection already exists - return reference on the instance of Storage engine object
      */
     if (isset($this->connections[$connection])) {
         return $this->connections[$connection];
     }
     $Config = Config::instance();
     /**
      * If connection to the local storage
      */
     if ($connection == 0) {
         $Core = Core::instance();
         $storage['connection'] = $Core->storage_type;
         $storage['url'] = $Core->storage_url;
         $storage['host'] = $Core->storage_host;
         $storage['user'] = $Core->storage_user;
         $storage['password'] = $Core->storage_password;
     } elseif (isset($Config->storage[$connection])) {
         $storage =& $Config->storage[$connection];
     } else {
         return False_class::instance();
     }
     /**
      * Create new Storage connection
      */
     $engine_class = '\\cs\\Storage\\' . $storage['connection'];
     $this->connections[$connection] = new $engine_class($storage['url'], $storage['host'], $storage['user'], $storage['password']);
     /**
      * If successfully - add connection to the list of success connections and return instance of DB engine object
      */
     if (is_object($this->connections[$connection]) && $this->connections[$connection]->connected()) {
         $this->successful_connections[] = $connection . '/' . $storage['host'] . '/' . $storage['connection'];
         unset($storage);
         $this->{$connection} = $this->connections[$connection];
         return $this->connections[$connection];
         /**
          * If failed - add connection to the list of failed connections and display connection error
          */
     } else {
         unset($this->{$connection});
         $this->failed_connections[$connection] = $connection . '/' . $storage['host'] . '/' . $storage['connection'];
         unset($storage);
         trigger_error(Language::instance()->error_storage . ' ' . $this->failed_connections[$connection], E_USER_WARNING);
         $return = False_class::instance();
         $return->error = 'Connection failed';
         return $return;
     }
 }
 private function _getShowCase($genre, $page = 0, $size = 4)
 {
     $books = $this->_getBooksByGenre($genre, $page, $size);
     $num_books = Core::instance()->getDb()->countBookyByGenre($genre);
     if (count($books) == 0) {
         return null;
     }
     $args = array('books' => $books, 'style' => 'showcase', 'text_details' => i('To the details'), 'navigation' => true, 'prev_hidden' => $num_books <= $size, 'next_hidden' => count($books) < $size, 'config' => urlencode(json_encode(array('page' => $page, 'size' => $size, 'request' => Controller::instance()->getViewUrl() . '&ajax=1&ajax_fn=nextShowcasePage&page={%page%}&size={%size%}&genre=' . $genre))));
     return TemplateRenderer::instance()->extendedRender('theme/templates/snippets/showcase.html', $args);
 }
 public function prepare()
 {
     $cwd = getcwd();
     chdir('..');
     require_once 'config.php';
     require_once 'classes/class.core.php';
     // prevent chdir problems
     $core = Core::instance();
     chdir($cwd);
 }
Ejemplo n.º 11
0
 /**
  * Current Instance of Core
  * @return Core
  */
 public static function getInstance()
 {
     try {
         if (Core::$instance == null) {
             Core::$instance = new self();
         }
         return Core::$instance;
     } catch (CoreException $exception) {
         throw new CoreException('Fatal Error: Cannot Instantiate Core');
     }
 }
 private function _getSearchResult($str, $category, $page = 0, $size = 10, $only_titles = false)
 {
     $category = !isset($category) || $category == null || $category == '' ? null : $category;
     $books = Core::instance()->getDb()->searchBooks($str, $category, $page, $size, null, $only_titles);
     if ($str != '') {
         foreach ($books as $key => $book) {
             $books[$key]['title'] = Utilities::highlight($book['title'], $str);
             $books[$key]['author'] = trim($books[$key]['author']);
             $description = Utilities::cutText($book['description'], 300);
             $books[$key]['description'] = Utilities::highlight($description, $str);
         }
     }
     $total = Core::instance()->getDb()->countSearchBooks($str, $category);
     $result = array('books' => $books, 'total' => $total);
     return $result;
 }
Ejemplo n.º 13
0
 *  ['name'	=> <i>module_name</i>]<br>
 *
 *  admin/System/components/modules/default_module/process<br>
 *  ['name'	=> <i>module_name</i>]<br>
 *
 *  admin/System/components/modules/db/process<br>
 *  ['name'	=> <i>module_name</i>]<br>
 *
 *  admin/System/components/modules/storage/process<br>
 *  ['name'	=> <i>module_name</i>]
 */
namespace cs;

$Cache = Cache::instance();
$Config = Config::instance();
$Core = Core::instance();
$db = DB::instance();
$L = Language::instance();
$Page = Page::instance();
$User = User::instance();
$Permission = Permission::instance();
$a = Index::instance();
if (isset($_POST['update_modules_list'])) {
    /**
     * List of currently presented modules in file system
     */
    $modules_list = array_fill_keys($new_modules = get_files_list(MODULES, false, 'd'), ['active' => -1, 'db' => [], 'storage' => []]);
    /**
     * Already known modules
     */
    $modules =& $Config->components['modules'];
Ejemplo n.º 14
0
     $block_until = $user_data['block_until'];
     $block_until = explode('T', $block_until);
     $block_until[0] = explode('-', $block_until[0]);
     $block_until[1] = explode(':', $block_until[1]);
     $user_data['block_until'] = mktime($block_until[1][0], $block_until[1][1], 0, $block_until[0][1], $block_until[0][2], $block_until[0][0]);
     unset($block_until);
 } else {
     $user_data['block_until'] = 0;
 }
 if ($user_data['password']) {
     if (strlen($user_data['password']) < $Config->core['password_min_length']) {
         $Page->warning($L->password_too_short);
     } elseif (password_check($user_data['password'], $Config->core['password_min_length']) < $Config->core['password_min_strength']) {
         $Page->warning($L->password_too_easy);
     } else {
         $user_data['password_hash'] = hash('sha512', hash('sha512', $user_data['password']) . Core::instance()->public_key);
     }
 }
 unset($user_data['password']);
 if ($user_data['login'] && $user_data['login'] != $User->get('login', $id) && (!filter_var($user_data['login'], FILTER_VALIDATE_EMAIL) && $User->get_id(hash('sha224', $user_data['login'])) === false || $user_data['login'] == $user_data['email'])) {
     $user_data['login_hash'] = hash('sha224', $user_data['login']);
 } else {
     if ($user_data['login'] != $User->get('login', $id)) {
         $Page->warning($L->login_occupied_or_is_not_valid);
     }
     unset($user_data['login']);
 }
 if ($user_data['email']) {
     $user_data['email_hash'] = hash('sha224', $user_data['email']);
 } else {
     unset($user_data['login']);
Ejemplo n.º 15
0
define('CACHE', DIR . '/storage/cache');
/**
 * Log directory for current domain
 */
define('LOGS', DIR . '/storage/logs');
/**
 * Temp directory for current domain
 */
define('TEMP', DIR . '/storage/temp');
/**
 * Directory with public cache (available from the outside)
 */
define('PCACHE', DIR . '/storage/pcache');
/**
 * Themes dir
 */
define('THEMES', DIR . '/themes');
/**
 * Including of custom user files
 */
foreach (glob(CUSTOM . '/*.php') ?: [] as $custom) {
    include $custom;
}
unset($custom);
/**
 * System running
 */
Core::instance();
Language::instance();
defined('CS_ERROR_HANDLER') && CS_ERROR_HANDLER && Error::instance();
Index::instance();
Ejemplo n.º 16
0
 /**
  * Test connection to the DB
  *
  * @param array|string $data	Array or string in JSON format of connection parameters
  *
  * @return bool
  */
 function test($data)
 {
     $Core = Core::instance();
     if (empty($data)) {
         return false;
     } elseif (is_array($data)) {
         $Config = Config::instance();
         if (isset($data[1])) {
             $db = $Config->db[$data[0]]['mirrors'][$data[1]];
         } elseif (isset($data[0])) {
             if ($data[0] == 0) {
                 $db = ['type' => $Core->db_type, 'host' => $Core->db_host, 'name' => $Core->db_name, 'user' => $Core->db_user, 'password' => $Core->db_password, 'charset' => $Core->db_charset];
             } else {
                 $db = $Config->db[$data[0]];
             }
         } else {
             return false;
         }
     } else {
         $db = _json_decode($data);
     }
     unset($data);
     if (is_array($db)) {
         errors_off();
         $engine_class = '\\cs\\DB\\' . $db['type'];
         $test = new $engine_class($db['name'], $db['user'], $db['password'], $db['host'] ?: $Core->db_host, $db['charset'] ?: $Core->db_charset);
         errors_on();
         return $test->connected();
     } else {
         return false;
     }
 }
Ejemplo n.º 17
0
 /**
  * Constructor. Initializes classes.
  *
  * @return \Core
  */
 public function __construct()
 {
     self::$version["major"] = 1;
     self::$version["build"] = 3;
     self::$version["revesion"] = 0;
     self::$version["release"] = 130;
     define("RECIPE_VERSION", self::$version["release"]);
     Hook::event("CoreStart");
     self::$instance = $this;
     $this->setDatabase()->setRequest()->setApplication()->setQuery()->setCache()->setOptions()->setTemplate()->setUser()->setLanguage()->initCron();
     Hook::event("CoreFinished");
     return;
 }
Ejemplo n.º 18
0
<?php

//
// Used to initialize the Database and fill some Values into it
//
//Delete all tables if Request is clear_tables, for test purpuses
// if you go live and have stable data, delete this part.
$db = Core::instance()->getDb();
//if(isset($_REQUEST['clear_tables']) && $_REQUEST['clear_tables'] == true) {
$db->drop('user');
$db->drop('book');
$db->drop('order');
$db->drop('position');
$db->drop('genre');
$db->drop('bookgenre');
$db->drop('type');
// }
TypeModel::create(array('key' => 'Taschenbuch2', 'name' => 'Taschenbuch2'));
//Check if there is the user Table, if not, create some entries
if (!$db->tableExists('user')) {
    UserModel::create(array('user_name' => 'tony', 'password' => Utilities::hash('12345', USER_SALT), 'first_name' => 'Tony', 'last_name' => 'Stark', 'lang' => 'de', 'isAdmin' => false, 'streetname' => 'Schwalbenweg', 'streetnumber' => '10a', 'zip' => 3012, 'city' => 'Bern', 'state' => 'Schweiz', 'email' => '*****@*****.**'));
    UserModel::create(array('user_name' => 'hulk', 'password' => Utilities::hash('12345', USER_SALT), 'first_name' => 'Bruce', 'last_name' => 'Banner', 'lang' => 'de', 'isAdmin' => true, 'streetname' => 'Tiefenaugasse', 'streetnumber' => '17', 'zip' => 3012, 'city' => 'Bern', 'state' => 'Schweiz', 'email' => '*****@*****.**'));
    UserModel::create(array('user_name' => 'thor', 'password' => Utilities::hash('12345', USER_SALT), 'first_name' => 'Thor', 'last_name' => 'Odinsson', 'lang' => 'de', 'isAdmin' => false, 'streetname' => 'Molkereiweg', 'streetnumber' => '31', 'zip' => 3217, 'city' => 'Thun', 'state' => 'Schweiz', 'email' => '*****@*****.**'));
    UserModel::create(array('user_name' => 'max', 'password' => Utilities::hash('12345', USER_SALT), 'first_name' => 'Max', 'last_name' => 'Muster', 'lang' => 'en', 'isAdmin' => true, 'streetname' => 'Ahornweg', 'streetnumber' => '4', 'zip' => 4212, 'city' => 'New York', 'state' => 'USA', 'email' => '*****@*****.**'));
}
//Check if there is the book Table, if not, create some entries
if (!$db->tableExists('book')) {
    BookModel::create(array('name' => "Angel Of The Dark", 'isbn' => "0062073451", 'cover' => "theme/images/books/0062073451.jpg", 'title' => "Angel Of The Dark", 'author' => "Sidney Sheldon", 'year_of_publication' => 2012, 'price' => 11.1, 'currency' => "CHF", 'available' => "Sofort", 'language' => "EN", 'description' => "As the future prima, or head witch of her clan, Angela McAllister is expected to bond with her consort during her twenty-first year, thus ensuring that she will come into her full powers at the appointed time. The clock is ticking down, and her consort has yet to make an appearance. Instead, her dreams are haunted by a man she's never seen, the one she believes must be her intended match.\n\nBut with time running out, and dark forces attempting to seize her powers for their own, Angela is faced with a terrible choice: give up her dreams of the man she may never meet and take the safer path, or risk leaving her clan and everyone in it at the mercy of those who seek their ruin.\n\nDarkangel is the first book in the Witches of Cleopatra Hill, a paranormal romance series set in the haunted town of Jerome, Arizona.", 'original_language' => "EN", 'number_of_pages' => 400, 'version' => 1, 'type' => "Taschenbuch", 'genre' => "Krimi"));
    BookModel::create(array('name' => "Max fährt mit", 'isbn' => "3197495950", 'cover' => "theme/images/books/3197495950.jpg", 'title' => "Max fährt mit", 'author' => "Ulrike Fischer", 'year_of_publication' => 2014, 'price' => 9.0, 'currency' => "CHF", 'available' => "Sofort", 'language' => "DE", 'description' => "Zielgruppe: Kinder ab 2 Jahren Auf dem Bauernhof gibt es viele Fahrzeuge. Doch wie staunt Max erst, als er in die Stadt kommt! Max fährt mit ist der sechste Titel in der Reihe bilibrini – die kleinen Zweisprachigen und widmet sich in kurzen, einfachen Sätzen dem Thema Fahrzeuge. Die farbenfrohen Illustrationen laden Kinder ab 2 Jahren zum Betrachten ein. Die Wort-Bild-Leiste auf jeder Seite greift wichtige Gegenstände erneut auf und ermöglicht eine aktive Förderung des Wortschatzes schon für die Kleinsten.", 'original_language' => "DE", 'number_of_pages' => 16, 'version' => 1, 'type' => "Hardcover Buch", 'genre' => "Kinderbuch"));
    BookModel::create(array('name' => "Wind", 'isbn' => "3453410831", 'cover' => "theme/images/books/3453410831.jpg", 'title' => "Wind", 'author' => "Stephen King", 'year_of_publication' => 2013, 'price' => 24.0, 'currency' => "CHF", 'available' => "Sofort", 'language' => "DE", 'description' => "Ein Sturm zieht auf\n\n\nRoland Deschain, der letzte Revolvermann, und seine Gefährten haben den Grünen Palast hinter sich gelassen. Als sie auf dem Pfad des Balkens ins Land Donnerschlag unterwegs sind, zieht ein heftiger Sturm herauf, und sie finden Schutz in einer verlassenen Hütte. Dort erzählt Roland seinen Begleitern, was in seiner Jugend geschah, nachdem er unbeabsichtigt seine Mutter umgebracht hatte: Sein Vater schickte ihn zu einer entlegenen Ranch, wo grausame Morde stattfanden. Alle Anzeichen deuteten auf einen Gestaltwandler als Täter hin, und es gab nur einen Zeugen – einen kleinen Jungen, der jetzt seines Lebens nicht mehr sicher war.\n\n\nMit Wind legt Stephen King einen achten Roman seines großen Endzeitepos um den Dunklen Turm vor, bei dem es sich nach eigenem Bekunden um sein wichtigstes Werk handelt. Derzeit befindet sich eine Verfilmung des gesamten Zyklus in der Vorproduktion.", 'original_language' => "EN", 'number_of_pages' => 432, 'version' => 1, 'type' => "Hardcover Buch", 'genre' => "Fantasy"));
    BookModel::create(array('name' => "Ein perfekter Freund", 'isbn' => "3257233787", 'cover' => "theme/images/books/3257233787.jpg", 'title' => "Ein perfekter Freund", 'author' => "Martin Suter\n", 'year_of_publication' => 2003, 'price' => 15.99, 'currency' => "CHF", 'available' => "Vergriffen", 'language' => "DE", 'description' => "Welch ein Erwachen! Kaum Gefühl im Gesicht, keine Ahnung, wo man ist. Und die Frau, die sich so rührend um einen kümmert, soll die eigene Freundin sein? Der Journalist Fabio Rossi hat einen Gedächtnisverlust erlitten. Irgendjemand hat ihm kräftig auf den Schädel gehauen. 50 Tage fehlen ihm seitdem. Und in diesen paar Tagen habe er sein Leben komplett umgekrempelt, habe Wohnung und Partnerin gewechselt, sei überhaupt nicht mehr der, der er einst wahr. Und das nicht zu seinem Vorteil. Als Journalist begibt er sich nun auf Recherche in eigener Sache und rekonstruiert die letzten Tage vor dem Black-out.\nMartin Suter hat die Geschichte raffiniert konstruiert und taucht die Leser immer wieder in widersprüchliche Gefühle. Ist Rossi nun wirklich der moralisch überlegene Journalist, hat ihm sein Kumpel den Scoop um BSE in Schokostängeln geklaut? Warum ist die frisch gebackene Witwe des Forschers so glücklich -- und plötzlich auch finanziell gut gepolstert? Rossi stand -- und steht nun wieder -- kurz vor der Enthüllung eines riesigen Skandals, als er die Macht der Lebensmittelkonzerne zu spüren bekommt. Ihr Angebot ist eines, das man nicht ablehnen sollte.\n\nMartin Suters Romane sind fehlerlos. Die Sprache ist präzis, manchmal von einer fast unheimlichen Trockenheit. Und vor allem ist Ein perfekter Freund höchst spannend -- und nebenbei auch noch lehrreich. Dass der Humor bei Suter nicht zu kurz kommt, vor allem der schwarze, kennt man. Und auch da liefert er höchst amüsante Müsterchen, die beispielsweise die Techniken des Gedächtnistrainings betreffen. So in dem Stil, wenn die Marlen plötzlich Lilli heißt.", 'original_language' => "DE", 'number_of_pages' => 352, 'version' => 1, 'type' => "Taschenbuch", 'genre' => "Roman"));
Ejemplo n.º 19
0
 /**
  * getInstance
  * @return object instance of the class
  */
 public static function getInstance($blnWithDbh = true, Zend_Config_Xml &$sysConfig, Zend_Config_Xml &$modConfig, Zend_Config_Xml &$webConfig)
 {
     if (self::$instance == null) {
         self::$instance = new Core($blnWithDbh, $sysConfig, $modConfig, $webConfig);
     }
     return self::$instance;
 }
 private function _getSearchResult($str, $category)
 {
     $result = Core::instance()->getDb()->searchBooks($str, $category);
 }
Ejemplo n.º 21
0
 */
if (!$Config->server['referer']['local'] || !$Config->server['ajax'] || !isset($_POST['verify_hash'], $_POST['new_password']) || !$User->user()) {
    sleep(1);
    error_code(403);
    return;
} elseif (!$_POST['new_password']) {
    error_code(400);
    $Page->error($L->please_type_new_password);
    return;
} elseif (hash('sha224', $User->password_hash . $User->get_session()) != $_POST['verify_hash']) {
    error_code(400);
    $Page->error($L->wrong_current_password);
    return;
} elseif (($new_password = xor_string($_POST['new_password'], $User->password_hash)) == $User->password_hash) {
    error_code(400);
    $Page->error($L->current_new_password_equal);
    return;
}
if ($new_password == hash('sha512', hash('sha512', '') . Core::instance()->public_key)) {
    error_code(400);
    $Page->error($L->please_type_new_password);
    return;
}
$id = $User->id;
if ($User->set('password_hash', $new_password)) {
    $User->add_session($id);
    $Page->json('OK');
} else {
    error_code(400);
    $Page->error($L->change_password_server_error);
}
Ejemplo n.º 22
0
	/**
	 * Returns the Core-object
	 * 
	 * @return	Core		Singleton-Instance
	 */
	public final static function get() {
		if (self::$instance === null) {
			self::$instance = new self();
		}
		
		return self::$instance;
	}
 /**
  * Has to be called by all static methods to ensure the table exists.
  * Creates the table with the provided column-settings of the child-class
  */
 private static function _initTable()
 {
     $db = Core::instance()->getDb();
     if ($db->tableExists(static::$TABLE)) {
         return;
     }
     $db_columns = array();
     foreach (static::$COLUMN_NAMES as $key => $col) {
         $db_columns[] = array($col, static::$COLUMN_TYPES[$key]);
     }
     $db->createTable(static::$TABLE, $db_columns);
 }
Ejemplo n.º 24
0
	/**
	 * Get the core singleton object
	 *
	 * @return Core
	 */
	public static function Singleton() {
		if(self::$instance === null){
			self::$instance = new self();
		}

		return self::$instance;
	}