Ejemplo n.º 1
0
 /**
  * 
  * @param type $name nombre de la tabla de la base de datos.
  * @param type $basedir ruta del directorio table donde se encuentra el XML
  * con la estructura de la tabla de la base de datos.
  */
 public function __construct($name = '', $basedir = '')
 {
     $this->base_dir = $basedir;
     $this->cache = new fs_cache();
     $this->db = new fs_db2();
     $this->table_name = $name;
     $this->default_items = new fs_default_items();
     if (!self::$errors) {
         self::$errors = array();
     }
     if (!self::$checked_tables) {
         self::$checked_tables = $this->cache->get_array('fs_checked_tables', TRUE);
         if (self::$checked_tables) {
             /// nos aseguramos de que existan todas las tablas que se suponen comprobadas
             $tables = $this->db->list_tables();
             foreach (self::$checked_tables as $ct) {
                 if (!$this->db->table_exists($ct, $tables)) {
                     $this->clean_checked_tables();
                     break;
                 }
             }
         }
     }
     if ($name != '') {
         if (!in_array($name, self::$checked_tables)) {
             if ($this->check_table($name)) {
                 self::$checked_tables[] = $name;
                 $this->cache->set('fs_checked_tables', self::$checked_tables, 5400, TRUE);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function install_MX()
 {
     $path = realpath(dirname(__FILE__));
     $this->Install_Path = realpath(dirname($path, 1)) . self::DS;
     unset($path);
     $FsConf = $this->Install_Path . 'config.php';
     $FsUnI = $this->Install_Path . 'plugins' . self::DS . 'admin_mexico' . self::DS . 'extras' . self::DS . 'uninstall.xml';
     if (!copy($FsConf, $FsConf . '.bak')) {
         return (bool) false;
     }
     if (is_writable($FsConf)) {
         $strConf = file_get_contents($FsConf);
         if (strpos($strConf, "define('FS_INSTALL_PATH',") === false) {
             $setDef = self::R . '/// Modificación admin_mexico' . self::R . "define('FS_INSTALL_PATH', '" . $this->Install_Path . "');";
             if (!file_put_contents($FsConf, $setDef, FILE_APPEND | LOCK_EX)) {
                 return (bool) false;
             }
         }
         unset($strConf);
         if (file_exists($FsUnI)) {
             unlink($FsUnI);
         }
         $fp = fopen($FsUnI, 'w+');
         fwrite($fp, '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n");
         fwrite($fp, '<files>' . self::R);
         fclose($fp);
         require_once $this->Install_Path . 'base' . self::DS . 'fs_db2.php';
         $db = new fs_db2();
         if ($db->connect()) {
             $tables = $db->list_tables();
             file_put_contents($FsUnI, '<databases>' . self::R, FILE_APPEND | LOCK_EX);
             $qry = "SELECT TABLE_NAME AS name FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . FS_DB_NAME . "' AND COLUMN_NAME = 'codpostal' AND TABLE_NAME='empresa';";
             if ($rs = $db->select($qry)) {
                 foreach ($rs as $tb) {
                     $e = '<tb nam="' . $tb["name"] . '" />' . self::R;
                     file_put_contents($FsUnI, $e, FILE_APPEND | LOCK_EX);
                     $db->exec("ALTER TABLE " . $tb["name"] . " ADD colonia TEXT NULL AFTER codpostal;", false);
                 }
             }
             file_put_contents($FsUnI, '</databases>' . self::R . '</files>', FILE_APPEND | LOCK_EX);
         } else {
             return (bool) false;
         }
         return (bool) false;
     } else {
         return (bool) false;
     }
 }
Ejemplo n.º 3
0
 /**
  * 
  * @param type $name nombre de la tabla de la base de datos.
  */
 public function __construct($name = '')
 {
     $this->cache = new fs_cache();
     $this->db = new fs_db2();
     $this->table_name = $name;
     /// buscamos el xml de la tabla en los plugins
     $this->base_dir = '';
     foreach ($GLOBALS['plugins'] as $plugin) {
         if (file_exists('plugins/' . $plugin . '/model/table/' . $name . '.xml')) {
             $this->base_dir = 'plugins/' . $plugin . '/';
             break;
         }
     }
     $this->default_items = new fs_default_items();
     if (!self::$errors) {
         self::$errors = array();
     }
     if (!self::$checked_tables) {
         self::$checked_tables = $this->cache->get_array('fs_checked_tables', TRUE);
         if (self::$checked_tables) {
             /// nos aseguramos de que existan todas las tablas que se suponen comprobadas
             $tables = $this->db->list_tables();
             foreach (self::$checked_tables as $ct) {
                 if (!$this->db->table_exists($ct, $tables)) {
                     $this->clean_checked_tables();
                     break;
                 }
             }
         }
     }
     if ($name != '') {
         if (!in_array($name, self::$checked_tables)) {
             if ($this->check_table($name)) {
                 self::$checked_tables[] = $name;
                 $this->cache->set('fs_checked_tables', self::$checked_tables, 5400, TRUE);
             }
         }
     }
 }