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;
     }
 }
Exemple #2
0
 /**
  * Devuelve información del sistema para el informe de errores
  * @return type la información del sistema
  */
 public function system_info()
 {
     $txt = 'facturascripts: ' . $this->version() . "\n";
     $txt .= 'os: ' . php_uname() . "\n";
     $txt .= 'php: ' . phpversion() . "\n";
     $txt .= 'database type: ' . FS_DB_TYPE . "\n";
     $txt .= 'database version: ' . $this->db->version() . "\n";
     if ($this->cache->connected()) {
         $txt .= "memcache: YES\n";
     } else {
         $txt .= "memcache: NO\n";
     }
     $txt .= 'memcache version: ' . $this->cache->version() . "\n";
     if (function_exists('curl_init')) {
         $txt .= "curl: YES\n";
     } else {
         $txt .= "curl: NO\n";
     }
     $txt .= 'plugins: ' . join(',', $GLOBALS['plugins']) . "\n";
     if (isset($_SERVER['REQUEST_URI'])) {
         $txt .= 'url: ' . $_SERVER['REQUEST_URI'] . "\n------";
     }
     foreach ($this->get_errors() as $e) {
         $txt .= "\n" . $e;
     }
     return str_replace('"', "'", $txt);
 }
Exemple #3
0
 /**
  * Comprueba y actualiza la estructura de la tabla si es necesario
  * @param type $table_name
  * @return boolean
  */
 protected function check_table($table_name)
 {
     $done = TRUE;
     $consulta = '';
     $xml_columnas = array();
     $xml_restricciones = array();
     if ($this->get_xml_table($table_name, $xml_columnas, $xml_restricciones)) {
         if ($this->db->table_exists($table_name)) {
             if (!$this->db->check_table_aux($table_name)) {
                 $this->new_error_msg('Error al convertir la tabla a InnoDB.');
             }
             /// eliminamos restricciones
             $restricciones = $this->db->get_constraints($table_name);
             $consulta2 = $this->db->compare_constraints($table_name, $xml_restricciones, $restricciones, TRUE);
             if ($consulta2 != '') {
                 if (!$this->db->exec($consulta2)) {
                     $this->new_error_msg('Error al comprobar la tabla ' . $table_name);
                 }
             }
             /// comparamos las columnas
             $columnas = $this->db->get_columns($table_name);
             $consulta .= $this->db->compare_columns($table_name, $xml_columnas, $columnas);
             /// comparamos las restricciones
             $restricciones = $this->db->get_constraints($table_name);
             $consulta .= $this->db->compare_constraints($table_name, $xml_restricciones, $restricciones);
         } else {
             /// generamos el sql para crear la tabla
             $consulta .= $this->db->generate_table($table_name, $xml_columnas, $xml_restricciones);
             $consulta .= $this->install();
         }
         if ($consulta != '') {
             if (!$this->db->exec($consulta)) {
                 $this->new_error_msg('Error al comprobar la tabla ' . $table_name);
                 $done = FALSE;
             }
         }
     } else {
         $this->new_error_msg('Error con el xml.');
         $done = FALSE;
     }
     return $done;
 }
Exemple #4
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/// accedemos al directorio de FacturaScripts
chdir(__DIR__);
/// cargamos las constantes de configuración
require_once 'config.php';
require_once 'base/config2.php';
$tiempo = explode(' ', microtime());
$uptime = $tiempo[1] + $tiempo[0];
require_once 'base/fs_db2.php';
$db = new fs_db2();
require_once 'base/fs_default_items.php';
require_once 'base/fs_model.php';
require_model('empresa.php');
require_model('fs_var.php');
if ($db->connect()) {
    $fsvar = new fs_var();
    $cron_vars = $fsvar->array_get(array('cron_exists' => FALSE, 'cron_lock' => FALSE, 'cron_error' => FALSE));
    if ($cron_vars['cron_lock']) {
        echo "ERROR: Ya hay un cron en ejecución. Si crees que es un error," . " ve a Admin > Información del sistema para solucionar el problema.";
        /// marcamos el error en el cron
        $cron_vars['cron_error'] = 'TRUE';
    } else {
        /**
         * He detectado que a veces, con el plugin kiwimaru,
         * el proceso cron tarda más de una hora, y por tanto se encadenan varios
Exemple #5
0
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/// cargamos las constantes de configuración
require_once 'config.php';
require_once 'base/config2.php';
require_once 'base/fs_db2.php';
$db = new fs_db2();
require_once 'base/fs_model.php';
require_model('fs_extension.php');
if ($db->connect()) {
    if (!isset($_REQUEST['v'])) {
        echo 'Version de la API ausente. Actualiza el cliente.';
    } else {
        if ($_REQUEST['v'] == '2') {
            if (isset($_REQUEST['f'])) {
                $ejecutada = FALSE;
                $fsext = new fs_extension();
                foreach ($fsext->all_4_type('api') as $ext) {
                    if ($ext->text == $_REQUEST['f']) {
                        try {
                            $_REQUEST['f']();
                        } catch (Exception $e) {