예제 #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;
     }
 }
 /**
  * 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";
     if ($this->db->connect()) {
         if ($this->user->logged_on) {
             $txt .= 'os: ' . php_uname() . "\n";
             $txt .= 'php: ' . phpversion() . "\n";
             $txt .= 'database type: ' . FS_DB_TYPE . "\n";
             $txt .= 'database version: ' . $this->db->version() . "\n";
             if (FS_FOREIGN_KEYS == 0) {
                 $txt .= "foreign keys: NO\n";
             }
             if ($this->cache->connected()) {
                 $txt .= "memcache: YES\n";
                 $txt .= 'memcache version: ' . $this->cache->version() . "\n";
             } else {
                 $txt .= "memcache: NO\n";
             }
             if (function_exists('curl_init')) {
                 $txt .= "curl: YES\n";
             } else {
                 $txt .= "curl: NO\n";
             }
             $txt .= 'plugins: ' . join(',', $GLOBALS['plugins']) . "\n";
             if ($this->check_for_updates()) {
                 $txt .= "updated: NO\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);
 }
예제 #3
0
 /**
  * @param type $name sustituir por __CLASS__
  * @param type $title es el título de la página, y el texto que aparecerá en el menú
  * @param type $folder es el menú dónde quieres colocar el acceso directo
  * @param type $admin OBSOLETO
  * @param type $shmenu debe ser TRUE si quieres añadir el acceso directo en el menú
  * @param type $important debe ser TRUE si quieres que se la primera página que ven los nuevos usuarios
  */
 public function __construct($name = '', $title = 'home', $folder = '', $admin = FALSE, $shmenu = TRUE, $important = FALSE)
 {
     $tiempo = explode(' ', microtime());
     $this->uptime = $tiempo[1] + $tiempo[0];
     $this->errors = array();
     $this->messages = array();
     $this->advices = array();
     $this->simbolo_divisas = array();
     $this->extensions = array();
     $this->cache = new fs_cache();
     $this->db = new fs_db2();
     /// comprobamos la versión de PHP
     if (floatval(substr(phpversion(), 0, 3)) < 5.3) {
         $this->new_error_msg('FacturaScripts necesita PHP 5.3 o superior, y tú tienes PHP ' . phpversion() . '.');
     }
     if ($this->db->connect()) {
         $this->user = new fs_user();
         $this->page = new fs_page(array('name' => $name, 'title' => $title, 'folder' => $folder, 'version' => $this->version(), 'show_on_menu' => $shmenu, 'important' => $important));
         if ($name != '') {
             $this->page->save();
         }
         $this->empresa = new empresa();
         $this->default_items = new fs_default_items();
         /// cargamos las extensiones
         $fsext = new fs_extension();
         foreach ($fsext->all() as $ext) {
             if ($ext->to == $name or $ext->type == 'head' and is_null($ext->to)) {
                 $this->extensions[] = $ext;
             }
         }
         if (isset($_GET['logout'])) {
             $this->template = 'login/default';
             $this->log_out();
         } else {
             if (isset($_POST['new_password']) and isset($_POST['new_password2'])) {
                 $ips = array();
                 if ($this->ip_baneada($ips)) {
                     $this->banear_ip($ips);
                     $this->new_error_msg('Tu IP ha sido baneada. Tendrás que esperar 10 minutos antes de volver a intentar entrar.');
                 } else {
                     if ($_POST['new_password'] != $_POST['new_password2']) {
                         $this->new_error_msg('Las contraseñas no coinciden.');
                     } else {
                         if ($_POST['new_password'] == '') {
                             $this->new_error_msg('Tienes que escribir una contraseña nueva.');
                         } else {
                             if ($_POST['db_password'] != FS_DB_PASS) {
                                 $this->banear_ip($ips);
                                 $this->new_error_msg('La contraseña de la base de datos es incorrecta.');
                             } else {
                                 $suser = $this->user->get($_POST['user']);
                                 if ($suser) {
                                     $suser->set_password($_POST['new_password']);
                                     if ($suser->save()) {
                                         $this->new_message('Contraseña cambiada correctamente.');
                                     } else {
                                         $this->new_error_msg('Imposible cambiar la contraseña del usuario.');
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $this->template = 'login/default';
             } else {
                 if (!$this->log_in()) {
                     $this->template = 'login/default';
                     $this->public_core();
                 } else {
                     if ($this->user->have_access_to($this->page->name)) {
                         if ($name == '') {
                             $this->template = 'index';
                         } else {
                             $this->set_default_items();
                             $this->template = $name;
                             $this->query = '';
                             if (isset($_REQUEST['query'])) {
                                 $this->query = $_REQUEST['query'];
                             }
                             $this->private_core();
                         }
                     } else {
                         if ($name == '') {
                             $this->template = 'index';
                         } else {
                             $this->template = 'access_denied';
                             $this->user->clean_cache(TRUE);
                             $this->empresa->clean_cache();
                         }
                     }
                 }
             }
         }
     } else {
         $this->template = 'no_db';
         $this->new_error_msg('¡Imposible conectar con la base de datos <b>' . FS_DB_NAME . '</b>!');
     }
 }
예제 #4
0
파일: cron.php 프로젝트: arielopez/temporal
 * 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
         * procesos a la vez. Para evitar esto, uso la entrada cron_lock.
         * Además uso la entrada cron_exists para marcar que alguna vez se ha ejecutado el cron,
         * y cron_error por si hubiese algún fallo.
         */
        $cron_vars['cron_lock'] = 'TRUE';