Esempio n. 1
0
 * @package   Galette
 *
 * @author    Johan Cwiklinski <*****@*****.**>
 * @copyright 2013-2014 The Galette Team
 * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
 * @version   SVN: $Id$
 * @link      http://galette.tuxfamily.org
 * @since     Available since 0.8 - 2013-01-11
 */
use Galette\Core\Install as GaletteInstall;
use Galette\Core\Db as GaletteDb;
$db_connected = $install->testDbConnexion();
$conndb_ok = true;
$permsdb_ok = true;
if ($db_connected === true) {
    $zdb = new GaletteDb();
    /** FIXME: when tables already exists and DROP not allowed at this time
        the showed error is about CREATE, whenever CREATE is allowed */
    //We delete the table if exists, no error at this time
    $zdb->dropTestTable();
    $results = $zdb->grantCheck($install->getMode());
    $result = array();
    $error = false;
    //test returned values
    if ($results['create'] instanceof Exception) {
        $result[] = array('message' => _T("CREATE operation not allowed"), 'debug' => $results['create']->getMessage(), 'res' => false);
        $error = true;
    } elseif ($results['create'] != '') {
        $result[] = array('message' => _T("CREATE operation allowed"), 'res' => true);
    }
    if ($results['insert'] instanceof Exception) {
Esempio n. 2
0
 /**
  * Check for missing images in database
  *
  * @param Db $zdb Database instance
  *
  * @return void
  */
 public function missingInDb(Db $zdb)
 {
     $existing_disk = array();
     //retrieve files on disk
     if ($handle = opendir($this->store_path)) {
         while (false !== ($entry = readdir($handle))) {
             $reg = "/^(\\d+)\\.(" . implode('|', $this->allowed_extensions) . ")\$/i";
             if (preg_match($reg, $entry, $matches)) {
                 $id = $matches[1];
                 $extension = strtolower($matches[2]);
                 if ($extension == 'jpeg') {
                     //jpeg is an allowed extension,
                     //but we change it to jpg to reduce further tests :)
                     $extension = 'jpg';
                 }
                 $existing_disk[$id] = array('name' => $entry, 'id' => $id, 'ext' => $extension);
             }
         }
         closedir($handle);
         if (count($existing_disk) === 0) {
             //no image on disk, nothing to do :)
             return;
         }
         //retrieve files in database
         $class = get_class($this);
         $select = $zdb->select($this->tbl_prefix . $class::TABLE);
         $select->columns(array(self::PK))->where->in(self::PK, array_keys($existing_disk));
         $results = $zdb->execute($select);
         $existing_db = array();
         foreach ($results as $result) {
             $existing_db[] = (int) $result[self::PK];
         }
         $existing_diff = array_diff(array_keys($existing_disk), $existing_db);
         //retrieve valid members ids
         $members = new Members();
         $valids = $members->getArrayList($existing_diff, null, false, false, array(self::PK));
         foreach ($valids as $valid) {
             $file = $existing_disk[$valid->id_adh];
             $this->_storeInDb($zdb, $file['id'], $this->store_path . $file['id'] . '.' . $file['ext'], $file['ext']);
         }
     } else {
         Analog::log('Something went wrong opening images directory ' . $this->store_path, Analog::ERROR);
     }
 }
Esempio n. 3
0
 /**
  * Current Galette installed version, according to database
  *
  * @param Db $zdb Database instance
  *
  * @return string
  */
 public function getCurrentVersion($zdb)
 {
     try {
         $db_ver = $zdb->getDbVersion();
         if (isset($this->_versions_mapper[$db_ver])) {
             return $this->_versions_mapper[$db_ver];
         } else {
             return $db_ver;
         }
     } catch (\LogicException $e) {
         return false;
     }
 }
Esempio n. 4
0
}
if (isset($session['warning_detected'])) {
    $warning_detected = unserialize($session['warning_detected']);
    unset($session['warning_detected']);
}
if (isset($session['success_detected'])) {
    $success_detected = unserialize($session['success_detected']);
    unset($session['success_detected']);
}
if (!$installer and !defined('GALETTE_TESTS')) {
    //If we're not working from installer nor from tests
    include_once GALETTE_CONFIG_PATH . 'config.inc.php';
    /**
     * Database instanciation
     */
    $zdb = new Core\Db();
    if ($zdb->checkDbVersion() || strpos($_SERVER['PHP_SELF'], 'picture.php') !== false) {
        /**
         * Load preferences
         */
        $preferences = new Core\Preferences($zdb);
        /**
         * Set the path to the current theme templates
         */
        define('_CURRENT_TEMPLATE_PATH', GALETTE_TEMPLATES_PATH . $preferences->pref_theme . '/');
        /**
         * Authentication
         */
        if (isset($session['login'])) {
            $login = unserialize($session['login']);
        } else {