Ejemplo n.º 1
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;
     }
 }