/** * Setup the instance (singleton) * * @return Encryption */ public static function getInstance() { if (!self::$_instance instanceof self) { self::$_instance = new self(); } self::$_instance->setup(); return self::$_instance; }
/** * Add existing object to the end of list. If this exists it is not added. * * @param instance $obj * * @return inserted object */ public function add($obj) { $id = $obj->get('id'); if (!array_key_exists($id, $this->objects)) { $this->objects[$id] = $obj; array_push($this->sort, $id); } return $this->objects[$id]; }
/** * Connect into your DataBase * */ public function connect(abstractConnectorConfig $connectorConfig) { if (!$this->isConnected()) { try { $this->instance = new PDO($connectorConfig->getDsn(), $connectorConfig->getUser(), $connectorConfig->getPassword()); } catch (PDOException $e) { throw new Exception("Error to connect on your database." . $e->getMessage()); } $this->instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } }
/** * testView * * @return void * @access public */ public function testView() { $result = $this->GlobalTag->getViewData('cakephp'); $this->assertInternalType('array', $result); $expected = 'cakephp'; $this->assertEquals($expected, $result['GlobalTag']['keyname']); $result = $this->GlobalTag->getViewData('invalid-key!!!'); $this->assertEmpty($result); }
public function __construct() { $this->request = instance::getInstance("request"); $view = new view(); $this->view = $view->view; $construct = C("app.default.construct"); if (method_exists($this, $construct)) { $this->{$construct}(); } }
/** * testAdd * * @return void */ public function testEdit() { $this->assertNull($this->Tag->edit(1)); $this->assertEqual($this->Tag->data['Tag']['id'], 1); $data = array('Tag' => array('id' => 1, 'name' => 'CAKEPHP')); $this->assertTrue($this->Tag->edit(1, $data)); $data = array('Tag' => array('id' => 1, 'name' => 'CAKEPHP111')); $this->assertFalse($this->Tag->edit(1, $data)); $data = array('Tag' => array('id' => 1, 'name' => 'CAKEPHP', 'keyname' => '')); $this->assertEqual($this->Tag->edit(1, $data), $data); $this->expectException('Exception'); $this->assertTrue($this->Tag->edit('invalid-id', array())); }
public static function start() { $request = instance::getInstance("request"); $controller_namespace = "app\\controller\\"; $controller = $request->controller; $action = $request->action; $controller = $controller_namespace . $controller . "Controller"; if (!class_exists($controller)) { throw new exception("{$controller} : Controller not found"); } if (!method_exists($controller, $action)) { throw new exception("{$action} : action not found on {$controller}"); } call_user_func_array(array(new $controller(), $action), array()); }
public function remove() { $sql = "DELETE FROM `" . $this->tableName . "` WHERE 1=1 "; $binds = array(); for ($pkeyNum = 0; count($this->pkeys) > $pkeyNum; $pkeyNum++) { $sql .= " AND `" . $this->pkeys[$pkeyNum] . "` = :" . $this->pkeys[$pkeyNum] . " "; $binds[$this->pkeys[$pkeyNum]] = $this->{$this->pkeys[$pkeyNum]}; } if (count($binds) > 0) { // DB操作実行 $response = $this->_DBO->execute($sql, $binds); if (FALSE === $response) { // XXX イレギュラー throw new Exception(""); } } }
/** * Instance de PHPMailer * @return instance */ public static function getMail() { $params = \Params::get(); if (self::$emailconfig == null) { $instance = self::GetConfig(); self::$emailconfig = new PHPMailer(); self::$emailconfig->isSMTP(); self::$emailconfig->isHTML(true); self::$emailconfig->Host = $instance->settings['Host']; self::$emailconfig->SMTPAuth = $instance->settings['SMTPAuth']; self::$emailconfig->Username = $instance->settings['Username']; self::$emailconfig->Password = $instance->settings['Password']; self::$emailconfig->SMTPSecure = $instance->settings['SMTPSecure']; self::$emailconfig->Port = $instance->settings['Port']; self::$emailconfig->setFrom('*****@*****.**', 'Sous L\'olivier'); self::$emailconfig->From = 'sous l\'olivier'; self::$emailconfig->CharSet = $instance->settings['CharSet']; self::$emailconfig->CharSet = $instance->settings['CharSet']; self::$emailconfig->addCC($params->owner_email); self::$emailconfig->addAddress('*****@*****.**', 'DESSI Alain'); } return self::$emailconfig; }
/** * Ecrit les données de session dans le support de stockage * @method write * @param string $session_id * @param string $session_data * @return boolean */ public function write($session_id, $session_data) { // definition de la durée avant expiration $session_expire = intval(time() + $this->session_time); // verification de session existante $sql = "SELECT COUNT(session_id) AS total\n FROM " . $this->session_table . " WHERE session_id='{$session_id}';"; $query = $this->link_db->prepare($sql); $query->execute(); $session = $query->fetch(\PDO::FETCH_OBJ); // session inexistante if (!$session || $session->total == 0) { // insertion de la session $insert = $this->link_db->prepare('INSERT INTO ' . $this->session_table . ' VALUES(?, ?, ?)'); return $insert->execute([$session_id, $session_data, $session_expire]); } else { // mise à jour de la session $sqlUpdate = 'UPDATE ' . $this->session_table . ' SET session_data=\'' . $session_data . '\', session_expire=\'' . $session_expire . '\' WHERE session_id=\'' . $session_id . '\';'; $update = $this->link_db->prepare($sqlUpdate); return $update->execute(); } }
/** * Send a cURL Wordpress request to retrieve the requested data from the Vimeo API. * * @param string $endpoint Vimeo API endpoint * @return array Response Body */ private function _make_vimeo_request($endpoint, $params, $last_modified) { try { $response = $this->_vimeo->request($endpoint, $params, 'GET', $last_modified); switch ($response['status']) { case 200: return $response['body']; case 304: return NULL; case 400: throw new Vimeography_Exception(__('a bad request made was made. ', 'vimeography') . $response['body']->error); case 401: throw new Vimeography_Exception(__('an invalid token was used for the API request. Try removing your Vimeo token on the Vimeography Pro page and following the steps again to create a Vimeo app.', 'vimeography')); case 404: throw new Vimeography_Exception(__('the plugin could not retrieve data from the Vimeo API! ', 'vimeography') . $response['body']->error); case 500: throw new Vimeography_Exception(__('looks like Vimeo is having some API issues. Try reloading, or, check back in a few minutes.', 'vimeography')); default: throw new Vimeography_Exception(sprintf(__('Unknown response status %1$d, %2$s', 'vimeography'), $response['status'], $response['body']->error)); } } catch (Exception $e) { throw new Vimeography_Exception(__('the request to Vimeo failed. ', 'vimeography') . $e->getMessage()); } }
include_once LIBRARIES_DIR . 'Lang.Class.php'; include_once LIBRARIES_DIR . 'File.Class.php'; include_once LIBRARIES_DIR . 'Url.Class.php'; include_once LIBRARIES_DIR . 'Exceptions.Class.php'; include_once LIBRARIES_DIR . 'Helper.Class.php'; include_once LIBRARIES_DIR . 'Security.Class.php'; include_once LIBRARIES_DIR . 'Output.Class.php'; include_once LIBRARIES_DIR . 'Utf8.Class.php'; include_once LIBRARIES_DIR . 'Input.Class.php'; include_once LIBRARIES_DIR . 'Loader.Class.php'; include_once LIBRARIES_DIR . 'database/db.php'; include_once LIBRARIES_DIR . 'Tendoo.Class.php'; include_once LIBRARIES_DIR . 'Session.Class.php'; include_once LIBRARIES_DIR . 'Notice.Class.php'; include_once LIBRARIES_DIR . 'Roles.Class.php'; include_once LIBRARIES_DIR . 'LCV.Class.php'; // @since 1.4 /* =-=-=-=-=-=-=-=-=-=-=-=-= LOAD HELPERS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ include_once HELPERS_DIR . 'apps_helper.php'; include_once HELPERS_DIR . 'form_helper.php'; include_once HELPERS_DIR . 'core_helper.php'; include_once HELPERS_DIR . 'date.php'; include_once HELPERS_DIR . 'text.php'; include_once HELPERS_DIR . 'cookie_helper.php'; include_once HELPERS_DIR . 'themes_helper.php'; include_once HELPERS_DIR . 'modules_helper.php'; include_once HELPERS_DIR . 'users_helper.php'; /* =-=-=-=-=-=-=-=-=-=-=-=-= LAUNCH TENDOO -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ $instance = new instance(); $instance->boot(); /* =-=-=-=-=-=-=-=-=-=-=-=-= Tendoo Foundation 2014 - http://tendoo.org -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/** * Fonction permettant de lister tous les produits * @param Int $ids Liste des ids des articles * @return array Recupére tous les caractéristiques des articles grâce à toutes les ids */ public function listPanier($ids) { $query = 'SELECT * FROM articles WHERE id_articles IN (' . implode(',', $ids) . ')'; $resultat = $this->db->getPanier($query); return $resultat; }
/** * Reads the content of this stream and write it to another stream. * * @param instance $stream The destination stream to write to * @return integer The number of copied bytes */ public function pipe($stream) { $offset = $stream->tell(); $result = stream_copy_to_stream($this->resource(), $stream->resource()); if ($stream->isSeekable()) { $stream->seek($offset); } return $result; }
/** * Fonction permettant de supprimer un utilisateur * @param Int $id_users Id de l'user */ public function deleteUser($id_users) { $query = 'DELETE FROM users WHERE id_users = :id'; $tab = array('id' => $id_users); $resultat = $this->db->execute($query, $tab); }
/** * Get views as an array and create SQL view stand-in * * @param array $tables_full array of all tables in given db or dbs * @param instance $export_sql_plugin export plugin instance * @param $db database name * * @return array $views */ function PMA_getViewsAndCreateSqlViewStandIn($tables_full, $export_sql_plugin, $db) { $views = array(); foreach ($tables_full as $each_table => $tmp) { // to be able to rename a db containing views, // first all the views are collected and a stand-in is created // the real views are created after the tables if (PMA_Table::isView($db, $each_table)) { $views[] = $each_table; // Create stand-in definition to resolve view dependencies $sql_view_standin = $export_sql_plugin->getTableDefStandIn($db, $each_table, "\n"); PMA_DBI_select_db($_REQUEST['newname']); PMA_DBI_query($sql_view_standin); $GLOBALS['sql_query'] .= "\n" . $sql_view_standin; } } return $views; }
/** * alterのマイグレーションを適用する * @param instance $argDBO * @return boolean */ public function alter($argDBO, $argDescribes) { $executed = FALSE; // ALTERは一行づつ処理 foreach ($argDescribes as $field => $propaty) { $sql = ''; if ('DROP' === $propaty['alter']) { $sql = 'ALTER TABLE `' . $this->tableName . '` DROP COLUMN `' . $field . '`'; } else { $fielPropatyQuerys = $this->_getFieldPropatyQuery(array($field => $propaty)); $fieldDef = $fielPropatyQuerys['fieldDef']; if (strlen($fieldDef) > 0) { $sql = 'ALTER TABLE `' . $this->tableName . '` ' . $propaty['alter'] . ' COLUMN ' . $fieldDef; if (isset($propaty['first']) && TRUE === $propaty['first']) { $sql .= ' FIRST '; } else { if (isset($propaty['after']) && 0 < strlen($propaty['after'])) { $sql .= ' AFTER `' . $propaty['after'] . '`'; } } } } if (strlen($sql) > 0) { try { debug('migration alter sql=' . $sql); $argDBO->execute($sql); $executed = TRUE; } catch (Exception $Exception) { logging($Exception->getMessage(), 'exception'); // ALTERのADDは、2重実行でエラーになるので、ここでのExceptionは無視してModfyを実行してみる $sql = str_replace('ALTER TABLE `' . $this->tableName . '` ' . $propaty['alter'] . ' COLUMN ', 'ALTER TABLE `' . $this->tableName . '` MODIFY COLUMN ', $sql); // MODIFYに変えて実行しなおし $argDBO->execute($sql); $executed = TRUE; // XXX それでもダメならException! } } } if (TRUE === $executed) { $argDBO->commit(); } return TRUE; }
/** * Fonction permettant de supprimer un article avec son id * @param Int $id_articles ID de l'article */ public function deleteArticle($id_articles) { $query = 'DELETE FROM articles WHERE id_articles = :id'; $tab = array('id' => $id_articles); $this->db->execute($query, $tab); }
public function deleteDocument($id) { //-- $connect = $this->solr_connect(); //-- if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') { //-- SmartFrameworkRegistry::setDebugMsg('db', 'solr|total-queries', 1, '+'); //-- $time_start = microtime(true); //-- } //end if //-- if ((string) $id == '') { Smart::log_warning('Solr ERROR # deleteDocument # ' . 'Document ID is Empty'); return -100; } //end if //-- try { //-- $updateResponse = $this->instance->deleteById((string) $id); $this->instance->commit(); // save //-- } catch (Exception $e) { //-- Smart::log_warning('Solr ERROR # deleteDocument # EXCEPTION: ' . $e->getMessage() . "\n" . 'ID=' . $id); return -201; //-- } //end try catch //-- $response = $updateResponse->getResponse(); // get answer message //print_r($response); //-- if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') { //-- $time_end = (double) (microtime(true) - (double) $time_start); //-- SmartFrameworkRegistry::setDebugMsg('db', 'solr|total-time', $time_end, '+'); //-- SmartFrameworkRegistry::setDebugMsg('db', 'solr|log', ['type' => 'nosql', 'data' => 'DELETE-QUERY', 'command' => array('ID' => (string) $id), 'time' => Smart::format_number_dec($time_end, 9, '.', '')]); //-- } //end if //-- if (is_object($response)) { if ($response instanceof SolrObject) { if (is_object($response['responseHeader'])) { if ($response['responseHeader'] instanceof SolrObject) { if ($response['responseHeader']->status === 0) { // OK } else { Smart::log_warning('Solr ERROR # deleteDocument # Invalid Status (' . $response['responseHeader']->status . ') : ' . 'ID=' . $id); return -206; } //end if else } else { Smart::log_warning('Solr ERROR # deleteDocument # Invalid responseHeader / Not instanceof SolrObject: ' . 'ID=' . $id); return -205; } //end if else } else { Smart::log_warning('Solr ERROR # deleteDocument # Invalid responseHeader / Invalid Object: ' . 'ID=' . $id); return -204; } //end if else } else { Smart::log_warning('Solr ERROR # deleteDocument # Invalid Answer / Not instanceof SolrObject: ' . 'ID=' . $id); return -203; } //end if else } else { Smart::log_warning('Solr ERROR # deleteDocument # Not Object: ' . 'ID=' . $id); return -202; } //end if else //-- return 0; // OK //-- }
/** * Compter les users * @return int compter les users */ public function countUsers() { $query = "SELECT COUNT(id_users) AS nbrUsers FROM users"; $resultat = $this->db->get($query); return $resultat; }
* @var string e.g. `basename(namespace/sub_namespace/class)`. * This is the `class` only. */ public $ns_class_basename = ''; // e.g. `class` /** * Instance config properties for JavaScript libs. * * @param boolean $exclude_core Optional; defaults to a FALSE value. If TRUE, this routine will exclude all core-specific config vars. * Since JS plugin extensions depend on the core itself, there's no reason for plugins to load them again. * * @return \stdClass A new standard class object instance. This will contain only the essentials. */ public function for_js($exclude_core = FALSE) { $for_js = new \stdClass(); foreach ($this as $_key => $_value) { if (!$exclude_core && in_array($_key, array('core_name', 'core_site', 'core_prefix', 'core_prefix_with_dashes', 'core_ns', 'core_ns_with_dashes', 'core_ns_stub', 'core_ns_stub_with_dashes'), TRUE) || in_array($_key, array('plugin_name', 'plugin_site', 'plugin_var_ns', 'plugin_var_ns_with_dashes', 'plugin_prefix', 'plugin_prefix_with_dashes', 'plugin_root_ns', 'plugin_root_ns_with_dashes', 'plugin_root_ns_stub', 'plugin_root_ns_stub_with_dashes'), TRUE)) { $for_js->{$_key} = $_value; } } unset($_key, $_value); return $for_js; } } # -------------------------------------------------------------------------------------------------------------------------------- # Initialize the XDaRk Core instance config class. # -------------------------------------------------------------------------------------------------------------------------------- instance::initialize(); // Also registers class alias. }
public function exist($args, $compare = null) { $row = instance::one($this->read(), "select * from %t where " . instance::implode($args, 'AND'), [$this->table()]); if (empty($row)) { return false; } else { if (!$compare) { return true; } else { foreach ($compare as $k => $v) { if ($row[$k] != $v) { return true; } } return false; } } }
/** * Fonction permettant de supprimer des association articles avec categories * @param Int $id_categories Id de la catégorie * @param Int $id_articles Id de l'article */ public function deleteAsso_Art_Categ($id_categories, $id_articles) { $query = "DELETE FROM asso_art_categ WHERE id_categories = :id_categories AND id_articles = :id_articles"; $tab = array('id_categories' => $id_categories, 'id_articles' => $id_articles); $this->db->execute($query, $tab); }
/** * Get model instance * * @return model instance */ protected function getModel($model) { return $this->model->load($model); }
function get_instance() { return instance::get(); }