Ejemplo n.º 1
0
 public function delete_common($table, $filters, $query_extra)
 {
     //criando o objeto pdo...
     $pdo = parent::get_instance();
     //filtros
     foreach ($filters as $key => $value) {
         $filters_delete = "{$key}=:{$key} AND ";
     }
     //removendo ultimo "AND";
     $filters_delete = substr($filters_delete, 0, -4);
     //preparando query apartir dos campos($fields) e os parametros de valores nomeados($values)
     $query = "DELETE FROM {$table} WHERE {$filters_delete};";
     //se a consulta precisar de algo mais..
     if ($query_extra != "") {
         $query .= $query_extra;
     }
     //echo $query,'<br>';
     //continuação da preparação da query...
     $statement = $pdo->prepare($query);
     if (!$statement) {
         echo "\\PDO::errorInfo():\n";
         print_r($dbh->errorInfo());
     }
     //substituindo os parametros dos filtros nomeados pelos verdadeiros valores, ex: ":name" por "Alessandro"
     foreach ($filters as $key => $value) {
         //$parameters[":$key"] = $value;
         $statement->bindValue(":{$key}", $value, PDO::PARAM_STR);
     }
     //$statement->debugDumpParams();
     //executando a query já com seus valores
     if ($statement->execute()) {
         //se der certo retorna true...
         return true;
     } else {
         //se não der certo, retornará false...
         return false;
     }
 }
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     parent::__construct();
     $this->load->helper('module_helper');
     // Redirect the not authorized user to the login panel. See /application/config/connect.php
     Connect()->restrict_type_redirect = array('uri' => config_item('admin_url') . '/user/login', 'flash_msg' => 'You have been denied access to %s', 'flash_use_lang' => false, 'flash_var' => 'error');
     //	$this->output->enable_profiler(true);
     // PHP standard session is mandatory for FileManager authentication
     // and other external lib
     //		session_start();
     // Librairies
     $this->connect = Connect::get_instance();
     // Current user
     $this->template['current_user'] = $this->connect->get_current_user();
     // Set the admin theme as current theme
     Theme::set_theme('admin');
     /*
      * Admin languages : Depending on installed translations in /application/languages/
      * The Admin translations are only stored in the translation file /application/languages/xx/admin_lang.php
      *
      */
     // Set admin lang codes array
     Settings::set('admin_languages', $this->settings_model->get_admin_langs());
     Settings::set('displayed_admin_languages', explode(',', Settings::get('displayed_admin_languages')));
     // Set Router's found language code as current language
     Settings::set('current_lang', config_item('language_abbr'));
     // Load the current language translations file
     $this->lang->load('admin', Settings::get_lang());
     /*
      * Modules config
      *
      */
     $this->get_modules_config();
     // Including all modules languages files
     require APPPATH . 'config/modules.php';
     $this->modules = $modules;
     foreach ($this->modules as $module) {
         $lang_file = MODPATH . $module . '/language/' . Settings::get_lang() . '/' . strtolower($module) . '_lang.php';
         if (is_file($lang_file)) {
             include $lang_file;
             $this->lang->language = array_merge($this->lang->language, $lang);
             unset($lang);
         }
     }
     /*
      * Loads all Module's addons
      *
      */
     $this->_get_modules_addons();
     // Load all modules lang files
     /*
     Look how to make Modules translations available in javascript 
     Notice : $yhis->lang object is transmitted to JS through load->view('javascript_lang')
      
     		if ( ! empty($lang_files))
     		{
     			foreach($lang_files as $l)
     			{
     				if (is_file($l))
     				{
     //					$logical_name = substr($l, strripos($l, '/') +1);
     //					$logical_name = str_replace('_lang.php', '', $logical_name);
     //					$this->lang->load($logical_name, Settings::get_lang());
     
     					include $l;
     					$this->lang->language = array_merge($this->lang->language, $lang);
     					unset($lang);
     
     				}
     			}
     		}
     */
     /*
      * Settings
      *
      */
     // @TODO : Remove this thing from the global CMS. Not more mandatory, but necessary for compatibility with historical version
     // Available menus
     // Each menu was a root node in which you can put several pages, wich are composing a menu.
     // Was never really implemented in ionize historical version, but already used as : menus[0]...
     Settings::set('menus', config_item('menus'));
     // Don't want to cache this content
     $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
     $this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
     $this->output->set_header("Pragma: no-cache");
 }
/**
 * Initialize Connect and run the folder protection.
 *
 * @return void
 */
function init_connect()
{
    // get the connect object and the router object
    $connect = Connect::get_instance();
    $router =& load_class('Router');
    $dir = trim($router->directory, ' /\\');
    if (isset($dir)) {
        // We have a subdir
        if (isset($connect->folder_protection[$dir])) {
            // send restriction settings to Connect::restrict()
            $connect->restrict($connect->folder_protection[$dir]);
        }
    }
}