Example #1
1
 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $structure = $databox->get_structure();
     $DOM = new DOMDocument();
     $DOM->loadXML($structure);
     $xpath = new DOMXpath($DOM);
     foreach ($xpath->query('/record/subdefs/subdefgroup[@name="video"]/subdef[@name="preview"]/acodec') as $node) {
         $node->nodeValue = 'libvo_aacenc';
     }
     foreach ($xpath->query('/record/subdefs/subdefgroup[@name="video"]/subdef[@name="preview"]/vcodec') as $node) {
         $node->nodeValue = 'libx264';
     }
     $databox->saveStructure($DOM);
     $subdefgroups = $databox->get_subdef_structure();
     foreach ($subdefgroups as $groupname => $subdefs) {
         foreach ($subdefs as $name => $subdef) {
             $this->addScreenDeviceOption($subdefgroups, $subdef, $groupname);
             if (in_array($name, ['preview', 'thumbnail'])) {
                 if ($name == 'thumbnail' || $subdef->getSubdefType()->getType() != \Alchemy\Phrasea\Media\Subdef\Subdef::TYPE_VIDEO) {
                     $this->addMobileSubdefImage($subdefgroups, $subdef, $groupname);
                 } else {
                     $this->addMobileSubdefVideo($subdefgroups, $subdef, $groupname);
                 }
             }
             if ($subdef->getSubdefType()->getType() != \Alchemy\Phrasea\Media\Subdef\Subdef::TYPE_VIDEO) {
                 continue;
             }
             $this->addHtml5Video($subdefgroups, $subdef, $groupname);
         }
     }
     return true;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $conn = $databox->get_connection();
     $sql = 'SELECT value FROM pref WHERE prop = "structure"';
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $result = $stmt->fetch(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     if (!$result) {
         throw new \RuntimeException('Unable to find structure');
     }
     $DOMDocument = new DOMDocument();
     $DOMDocument->loadXML($result['value']);
     $XPath = new DOMXPath($DOMDocument);
     foreach ($XPath->query('/record/subdefs/subdefgroup/subdef/delay') as $delay) {
         $delay->nodeValue = min(500, max(50, (int) $delay->nodeValue * 400));
     }
     foreach ($XPath->query('/record/subdefs/subdefgroup/subdef/acodc') as $acodec) {
         if ($acodec->nodeValue == 'faac') {
             $acodec->nodeValue = 'libvo_aacenc';
         }
     }
     $sql = 'UPDATE pref SET value = :structure WHERE prop = "structure"';
     $stmt = $conn->prepare($sql);
     $stmt->execute([':structure' => $DOMDocument->saveXML()]);
     $stmt->closeCursor();
     return true;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     foreach ($databox->get_meta_structure() as $databox_field) {
         $databox_field->save();
     }
     return true;
 }
function traer_opciones_menu($padre = "", $nivel = 0)
{
    $cdb = new base();
    $salida = "";
    $seleccion = array("id", "url", "titulo", "acceso");
    $limitantes[] = array("", "estatus", "!=", "0");
    if ($padre != "") {
        $limitantes[] = array("and", "padre", "=", $padre);
    } else {
        $limitantes[] = array("and", "padre", "IS", $padre);
    }
    $tabla[] = "menu";
    $cdb->set_referencia("posicion");
    $cdb->set_forma("asc");
    $respuesta = $cdb->seleccionar($seleccion, $limitantes, $tabla);
    if ($respuesta['codigo'] == 1) {
        if ($padre == "") {
            $salida .= "<ul class=nav >";
        } else {
            $salida .= "<ul>";
        }
        for ($i = 0; $i < count($respuesta['mensaje']); $i++) {
            $salida .= "<li><a href=\"" . $respuesta['mensaje'][$i]['url'] . "\" >" . $respuesta['mensaje'][$i]['titulo'] . "</a>";
            $salida .= traer_opciones_menu($respuesta['mensaje'][$i]['id'], $nivel + 1);
            $salida .= "</li>";
        }
        $salida .= "</ul>";
        return $salida;
    }
}
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $dql = 'SELECT u FROM Phraseanet:User u WHERE u.nonce IS NULL';
     $q = $app['orm.em']->createQuery($dql);
     $q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
     $users = $q->getResult();
     $n = 0;
     foreach ($users as $user) {
         $user->setNonce($app['random.medium']->generateString(64));
         $app['orm.em']->persist($user);
         $n++;
         if ($n % 100 === 0) {
             $app['orm.em']->flush();
         }
     }
     $app['orm.em']->flush();
     $sql = 'SELECT task_id, `class` FROM task2';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $sql = 'UPDATE task2 SET `class` = :class WHERE task_id = :task_id';
     $stmt = $appbox->get_connection()->prepare($sql);
     foreach ($rs as $row) {
         if (strpos($row['class'], 'task_period_') !== false) {
             continue;
         }
         $params = [':task_id' => $row['task_id'], ':class' => str_replace('task_', 'task_period_', $row['class'])];
         $stmt->execute($params);
     }
     $stmt->closeCursor();
     return true;
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     if (!$this->hasSessionTable($app)) {
         return true;
     }
     // Remove deleted users sessions
     $sql = 'SELECT s.id FROM `Sessions` s INNER JOIN Users u ON (u.id = s.user_id) WHERE u.deleted = 1';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     foreach ($rows as $row) {
         if (null !== ($session = $app['repo.sessions']->find($row['id']))) {
             $app['orm.em']->remove($session);
         }
     }
     // Remove API sessions
     $query = $app['orm.em']->createQuery('SELECT s FROM Phraseanet:Session s WHERE s.user_agent LIKE :guzzle');
     $query->setParameter(':guzzle', 'Guzzle%');
     foreach ($query->getResult() as $session) {
         $app['orm.em']->remove($session);
     }
     $app['orm.em']->flush();
     return true;
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'DELETE FROM Tasks';
     $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $sql = 'SELECT task_id, active, crashed, name, class, settings FROM task2';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     foreach ($rs as $row) {
         try {
             $job = $this->createJob($app, $row['class']);
         } catch (\RuntimeException $e) {
             continue;
         }
         $settings = simplexml_load_string($row['settings']);
         $period = $job->getEditor()->getDefaultPeriod();
         if ($settings->period) {
             $period = (int) $settings->period;
             unset($settings->period);
             $row['settings'] = $settings->asXML();
         }
         $task = new Task();
         $task->setCrashed($row['crashed'])->setJobId($job->getJobId())->setName($row['name'])->setPeriod($period)->setSettings($row['settings'])->setStatus($row['active'] ? Task::STATUS_STARTED : Task::STATUS_STOPPED);
         $app['EM']->persist($task);
     }
     $app['EM']->flush();
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = "UPDATE log_docs SET `action`='mail' WHERE `action`='download' AND LOCATE('@', comment)";
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     return true;
 }
Example #9
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = 'SELECT id, src FROM metadatas_structure';
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $update = [];
     $tagDirname = new \Alchemy\Phrasea\Metadata\Tag\TfDirname();
     $tagBasename = new \Alchemy\Phrasea\Metadata\Tag\TfBasename();
     foreach ($rs as $row) {
         if (strpos(strtolower($row['src']), 'tf-parentdir') !== false) {
             $update[] = ['id' => $row['id'], 'src' => $tagDirname->getTagname()];
         }
         if (strpos(strtolower($row['src']), 'tf-filename') !== false) {
             $update[] = ['id' => $row['id'], 'src' => $tagBasename->getTagname()];
         }
     }
     $sql = 'UPDATE metadatas_structure SET src = :src
             WHERE id = :id';
     $stmt = $databox->get_connection()->prepare($sql);
     foreach ($update as $row) {
         $stmt->execute([':src' => $row['src'], ':id' => $row['id']]);
     }
     $stmt->closeCursor();
     return true;
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = "UPDATE metadatas_structure SET `aggregable`=20 WHERE `aggregable`=1";
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     return true;
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'SELECT `key`, `value` FROM `registry`
             WHERE `key` = "GV_X_Accel_Redirect"
                 OR `key` = "GV_X_Accel_Redirect_mount_point"
                 OR `key` = "GV_modxsendfile"';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $registry = ['GV_X_Accel_Redirect' => null, 'GV_X_Accel_Redirect_mount_point' => null, 'GV_modxsendfile' => null];
     foreach ($rows as $row) {
         $registry[$row['key']] = $row['value'];
     }
     $xsendfilePath = $registry['GV_X_Accel_Redirect'];
     $xsendfileMountPoint = $registry['GV_X_Accel_Redirect_mount_point'];
     $config = $app['configuration.store']->setDefault('xsendfile')->getConfig();
     $config['xsendfile']['enabled'] = (bool) $registry['GV_modxsendfile'];
     $config['xsendfile']['type'] = $config['xsendfile']['enabled'] ? 'nginx' : '';
     if (null !== $xsendfilePath && null !== $xsendfileMountPoint) {
         $config['xsendfile']['mapping'] = [['directory' => $xsendfilePath, 'mount-point' => $xsendfileMountPoint]];
     }
     $app['configuration.store']->setConfig($config);
     $toRemove = ['GV_X_Accel_Redirect', 'GV_X_Accel_Redirect_mount_point', 'GV_modxsendfile'];
     $sql = 'DELETE FROM registry WHERE `key` = :k';
     $stmt = $appbox->get_connection()->prepare($sql);
     foreach ($toRemove as $registryKey) {
         $stmt->execute([':k' => $registryKey]);
     }
     $stmt->closeCursor();
     return true;
 }
Example #12
0
 public static function get()
 {
     $base = new base(Config::$driver);
     $base->setup(Config::$host, Config::$user, Config::$pass, Config::$base);
     $base->record_style('fields');
     $base->debug_on(Config::$debug);
     return $base;
 }
Example #13
0
function guardar_multiple($id, $datos, $tabla)
{
    $cdb = new base();
    foreach ($datos as $dato) {
        $respuesta = $cdb->insertar(array("negocio" => $id, "categoria" => $dato, "estatus" => "1"), $tabla, "0");
    }
    return $respuesta;
}
Example #14
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'DELETE FROM basusr WHERE actif = "0"';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     return true;
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     $sql = 'UPDATE record SET parent_record_id = "1"
             WHERE parent_record_id != "0"';
     $stmt = $databox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     return true;
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'UPDATE basusr SET nowatermark=1 WHERE needwatermark=0';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     unset($stmt);
     return true;
 }
Example #17
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'UPDATE permalinks SET label = "untitled"
             WHERE label = ""';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     return true;
 }
Example #18
0
function buscar($tabla, $dato, $columna = "titulo")
{
    $cdb = new base();
    $seleccion = array("id", "titulo");
    $limitante[] = array("", "{$columna}", "=", "%{$dato}%");
    $limitante[] = array("and", "estatus", "=", "1");
    $tabla = array($tabla);
    $respuesta = $cdb->seleccionar($seleccion, $limitante, $tabla);
    return $respuesta;
}
Example #19
0
function traer_titulo($codigo, $tabla, $columna = "titulo")
{
    $cdb = new base();
    $seleccion = array($columna);
    $limitantes[] = array("", "id", "=", $codigo);
    $limitantes[] = array("and", "estatus", "!=", "0");
    $tabla = array($tabla);
    $respuesta = $cdb->seleccionar($seleccion, $limitantes, $tabla);
    $respuesta['mensaje'] = $respuesta['mensaje'][0][0];
    return $respuesta;
}
Example #20
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $databox, Application $app)
 {
     try {
         $sql = 'ALTER TABLE `metadatas` DROP INDEX `unique`';
         $stmt = $databox->get_connection()->prepare($sql);
         $stmt->execute();
         $stmt->closeCursor();
     } catch (DBALException $e) {
     }
     return true;
 }
Example #21
0
function session_hash(database $database, base $base, $username)
{
    //generate new hash
    $session_hash = $base->randomString(35);
    //update old hash to new one (after checking the hahs doesn't exist)
    $database->processQuery("SELECT * FROM `users` WHERE `cookie` = ?", array($session_hash), false);
    if ($database->getRowCount() == 0) {
        $database->processQuery("UPDATE `users` SET `cookie` = ? WHERE `username` = ? LIMIT 1", array($session_hash, $username), false);
        return $session_hash;
    } else {
        session_hash();
    }
}
Example #22
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $conn = $appbox->get_connection();
     $sql = 'SELECT sbas_id, record_id, id FROM BasketElements';
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     foreach ($result as $row) {
         $sbas_id = (int) $row['sbas_id'];
         try {
             $connbas = $app->findDataboxById($sbas_id)->get_connection();
             $connbas->connect();
         } catch (\Exception $e) {
             $conn->exec('DELETE FROM ValidationDatas WHERE basket_element_id = ' . $row['id']);
             $conn->exec('DELETE FROM BasketElements WHERE id = ' . $row['id']);
             continue;
         }
         $sql = 'SELECT record_id FROM record WHERE record_id = :record_id';
         $stmt = $connbas->prepare($sql);
         $stmt->execute([':record_id' => $row['record_id']]);
         $rowCount = $stmt->rowCount();
         $stmt->closeCursor();
         if ($rowCount == 0) {
             $conn->exec('DELETE FROM ValidationDatas WHERE basket_element_id = ' . $row['id']);
             $conn->exec('DELETE FROM BasketElements WHERE id = ' . $row['id']);
         }
     }
     $dql = "SELECT b FROM Phraseanet:Basket b WHERE b.description != ''";
     $n = 0;
     $perPage = 100;
     $query = $app['orm.em']->createQuery($dql)->setFirstResult($n)->setMaxResults($perPage);
     $paginator = new Paginator($query, true);
     $count = count($paginator);
     while ($n < $count) {
         $query = $app['orm.em']->createQuery($dql)->setFirstResult($n)->setMaxResults($perPage);
         $paginator = new Paginator($query, true);
         foreach ($paginator as $basket) {
             $htmlDesc = $basket->getDescription();
             $description = trim(strip_tags(str_replace("<br />", "\n", $htmlDesc)));
             if ($htmlDesc == $description) {
                 continue;
             }
             $basket->setDescription($description);
         }
         $n += $perPage;
         $app['orm.em']->flush();
     }
     $app['orm.em']->flush();
     return true;
 }
Example #23
0
function traer_slideshow()
{
    $cdb = new base();
    $cdb->set_referencia("s.posicion");
    $cdb->set_forma("asc");
    $respuesta = $cdb->seleccionar(array("i.url", "s.posicion", "s.titulo"), array(array("", "s.estatus", "!=", "0"), array("and", "s.imagen", "=", "i.id")), array("slideshow s", "imagen i"));
    if ($respuesta['codigo'] == 1) {
        echo "<img src=\"" . $respuesta['mensaje'][count($respuesta['mensaje']) - 1]['url'] . "\" />";
        for ($i = 0; $i < count($respuesta['mensaje']) - 1; $i++) {
            echo "<img src=\"" . $respuesta['mensaje'][$i]['url'] . "\" />";
        }
    } else {
        echo $respuesta['mensaje'];
    }
}
Example #24
0
 /**
  * {@inheritdoc}
  */
 public function apply(base $appbox, Application $app)
 {
     $sql = 'SELECT `value` FROM `registry` WHERE `key` = "GV_i18n_service"';
     $stmt = $appbox->get_connection()->prepare($sql);
     $stmt->execute();
     $row = $stmt->fetch(\PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     if (null !== $row && false !== strpos($row['value'], 'localization.webservice.alchemyasp.com')) {
         $sql = 'UPDATE `registry` SET `value` = "http://geonames.alchemyasp.com/" WHERE `key` = "GV_i18n_service"';
         $stmt = $appbox->get_connection()->prepare($sql);
         $stmt->execute();
         $stmt->closeCursor();
     }
     return true;
 }
Example #25
0
 function creditcontrol()
 {
     parent::__construct();
     $this->init_input();
     $this->load('note');
     $this->load('misc');
 }
Example #26
0
 function tagcontrol()
 {
     parent::__construct();
     $this->init_input();
     $this->load('tag');
     $this->load('misc');
 }
 function to_local_time_zone($timest, $gmt = null)
 {
     $first_arr = explode(" ", $timest);
     $second_arr = explode("-", $first_arr[0]);
     $third_arr = explode(":", $first_arr[1]);
     $year = $second_arr[0];
     $month = $second_arr[1];
     $day = $second_arr[2];
     $hour = $third_arr[0];
     $minute = $third_arr[1];
     $second = $third_arr[2];
     $param_arr = array($_SESSION['user_id']);
     if ($gmt == null) {
         $sel = base::query('SELECT gmt FROM users WHERE id = \'::0::\'', 'assoc_array', $param_arr);
         if (!empty($sel)) {
             $gmt = $sel[0]['gmt'];
         } else {
             $gmt = '+0';
         }
     }
     if ($_SESSION['user_id'] == 1) {
         if (!empty($_COOKIE['gmt'])) {
             $gmt = $_COOKIE['gmt'];
         }
     }
     $timest = date("Y-m-d H:i:s", mktime($hour, $minute, $second, $month, $day, $year) + $gmt * 3600);
     return $timest;
 }
Example #28
0
 public function offsetSet($k, $v = null)
 {
     if (!is_object($v) || __NAMESPACE__ . '\\definition' != get_class($v)) {
         trigger_error('input object not definition() ' . print_r($v, true));
     }
     return parent::offsetSet($k, $v);
 }
Example #29
0
 function usercontrol()
 {
     parent::__construct();
     $this->load('user');
     //note client 仅在需要时初始化 $this->app
     $this->app = $this->cache['apps'][UC_APPID];
 }
Example #30
0
 public function __construct()
 {
     parent::__construct();
     $this->dbLaiyuan = $this->load_model('laiyuan');
     $this->dbLeimu = $this->load_model('leimu');
     $this->dbSubyuan = $this->load_model('yuanlei');
 }