Esempio n. 1
0
 public function getContent()
 {
     $liste = new Liste();
     $songs = $liste->getSongs('erschienen');
     $retval = '<br><br><h1>erschienen</h1>';
     foreach ($songs as $song) {
         $retval .= $song->renderSong('songErschienenListItem');
     }
     return $retval;
 }
Esempio n. 2
0
 public function getContent()
 {
     //$id3 = new getid3_mp3(new getID3());
     $liste = new Liste();
     $liste->getSongs('all');
     foreach ($liste->songs as $song) {
         if ($song->mp3 != '') {
             $f = PATH . 'files/' . $song->mp3;
             if (file_exists($f)) {
                 $seconds = $this->getLenght($f);
                 $song->duration = $seconds;
                 $song->saveSong();
             }
             // if(0 < ($seconds = $this->getLenght($song->mp3)))
         }
     }
 }
Esempio n. 3
0
 public function getContent()
 {
     //$id3 = new getid3_mp3(new getID3());
     $liste = new Liste();
     $liste->getSongs('all');
     foreach ($liste->songs as $song) {
         if ($song->mp3 != '') {
             $f = PATH . 'files/' . $song->mp3;
             if (file_exists($f)) {
                 z($f);
                 $datum = date("Y-m-d", filemtime($f));
                 z($datum);
                 $song->__set('angefangen', $datum);
                 $song->saveSong();
             }
             // if(0 < ($seconds = $this->getLenght($song->mp3)))
         }
     }
 }
Esempio n. 4
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 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/>.
*/
require '../init.php';
$data['error'] = 'OK';
$data['countAlive'] = $data['countKilled'] = 0;
try {
    $l = new Liste();
    $data['priorities'] = $PRIORITIES;
    $data['labels'] = $l->getListe('t_labels', "*", 'id', 'ASC');
    $data['devs'] = $l->getListe('t_devs', "*", 'id', 'ASC', 'id', '>=', '0');
    $l->getListe('t_bugs', "id", "priority", "DESC", "closed", "=", 0);
    $data['countAlive'] = $l->countResults();
    $l->getListe('t_bugs', "id", "priority", "DESC", "closed", "=", 1);
    $data['countKilled'] = $l->countResults();
    $l->resetFiltre();
    $l->addFiltre('nom', '!=', 'password_access');
    $l->addFiltre('nom', '!=', 'api_access');
    $l->getListe('t_config', '*', 'id', 'ASC');
    $data['globalConf'] = $l->simplifyList('nom');
    $data['available_languages'] = array();
    foreach (glob($pathLang . '/*') as $langFile) {
        if (is_dir($langFile)) {
Esempio n. 5
0
 public function getUebrigeSong()
 {
     $liste = new Liste();
     $songs = $liste->getSongs('uebrige');
     $retval = '';
     $headline = '';
     foreach ($songs as $S) {
         if ($S->genre != $headline) {
             $headline = $S->genre;
             $retval .= '<h2>' . $headline . '</h2>';
         }
         if (!isset($this->usedSongs[$S->getID()])) {
             $retval .= $S->renderUebrigeSong(0);
             $this->uebrigeSongs[] = $S;
         }
     }
     return $retval;
 }
Esempio n. 6
0
     if (!isset($id_bug)) {
         throw new Exception("API::get_bug : missing id_bug!");
     }
     $b = new Bug((int) $id_bug);
     $response["data"] = $b->getBugData();
     $response["error"] = "OK";
     $response["message"] = "Bug retreived.";
 }
 /**
  * ACTION COUNT BUGS
  */
 if ($action === "count_bugs") {
     if (!isset($closed)) {
         $closed = false;
     }
     $lB = new Liste();
     $bugList = $lB->getListe('t_bugs', '*', 'date', 'DESC', 'closed', '=', (int) $closed);
     if (!$bugList) {
         $bugList = array();
     }
     $response["data"] = count($bugList);
     $response["error"] = "OK";
     $response["message"] = "Bugs count retreived.";
 }
 /**
  * ACTION ADD BUG (need password api_access)
  */
 if ($action === "insert_bug") {
     if (!isset($password)) {
         throw new Exception("API: missing password!");
     }
Esempio n. 7
0
	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 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/>.
*/
require '../init.php';
$data['error'] = 'OK';
try {
    extract($_GET);
    if (!isset($type)) {
        $type = 0;
    }
    $l = new Liste();
    $bugList = $l->getListe('t_bugs', "*", "priority", "DESC", "closed", "=", $type);
    if (!$bugList) {
        $bugList = array();
    }
    $data['bugsList'] = $bugList;
} catch (Exception $e) {
    $data['error'] = $e->getMessage();
    $data['trace'] = $e->getTrace();
}
header('HTTP/1.1 200 OK');
header('Content-type: application/json; charset=UTF-8');
echo ")]}',\n";
// Pour sécu anti injection JSONP
echo json_encode($data, JSON_UNESCAPED_UNICODE);
Esempio n. 8
0
 /**
  * Populates a new bug's data with all table's columns with defaults
  */
 private function initNewBug()
 {
     $this->bugID = Liste::getAIval($this->bugInfos->getTable());
     foreach (Liste::getCols($this->bugInfos->getTable()) as $col) {
         $val = '';
         if ($col === 'id') {
             $val = $this->bugID;
         }
         if ($col === 'date') {
             $val = date('Y-m-d H:i:s');
         }
         if ($col === 'author') {
             $val = 'Admin';
         }
         if ($col === 'priority') {
             $val = 4;
         }
         if ($col === 'closed') {
             $val = 0;
         }
         if ($col === 'FK_comment_ID') {
             $val = '[]';
         }
         $this->bugData[$col] = $val;
     }
 }
Esempio n. 9
0
 /**
  * Initialise une liste de données à récupérer pour une table donnée
  * @param STRING $table Le nom de la table
  * @param STRING $want Une liste de colonnes à retourner (default '*' (tout))
  * @param STRING $tri La colonne à utiliser pour le tri (default 'id')
  * @param STRING $ordre La direction du tri (default 'ASC')
  * @param STRING $filtre_key La colonne à utiliser pour filtrer les résultats (default FALSE (pas de filtre))
  * @param STRING $filtre_comp La comparaison à effectuer pour le filtrage (default '=')
  * @param STRING $filtre La valeur à utiliser pour filtrer les résultats (default null)
  * @param INT $limit Nombre maximum de données à retourner (default FALSE (pas de limite)
  * @param BOOLEAN $withFK TRUE pour récupérer les données JOINTES (cf config->table relations) (default TRUE)
  * @param BOOLEAN $decodeJson TRUE pour décoder les champs contenant du JSON automatiquement. FALSE pour avoir les champs JSON au format STRING (default TRUE)
  * @param BOOLEAN $parseDatesJS TRUE pour formater les dates au format ISO 8601 pour javascript (default TRUE)
  * @return ARRAY Le tableau des résultats, ou FALSE si aucune donnée
  */
 public function getListe($table, $want = '*', $tri = 'id', $ordre = 'ASC', $filtre_key = false, $filtre_comp = '=', $filtre = null, $limit = false, $withFK = true, $decodeJson = true, $parseDatesJS = true)
 {
     global $DATE_FIELDS;
     $this->listResult = array();
     $this->table = $table;
     $this->what = $want;
     $this->tri = $tri;
     $this->ordre = $ordre;
     // Check si table existe
     if (!$this->check_table_exist($table)) {
         throw new Exception("Liste::getListe() : La table '{$table}' n'existe pas");
     }
     // pour chaque filtre défini par Liste::addFiltre()
     if (is_array($this->filtres) && count($this->filtres) > 0) {
         $FM = '';
         foreach ($this->filtres as $f) {
             $FM .= $f;
         }
         $filtrage_multiple = trim($FM, " {$this->lastLogiquefiltre} ");
     }
     if ($filtre_key && (string) $filtre != null) {
         if (Liste::check_col_exist($filtre_key)) {
             $this->isFiltred = true;
             $this->filtre_key = $filtre_key;
             $this->filtre = addslashes($filtre);
         } else {
             return false;
         }
     }
     if ($this->isFiltred) {
         $this->request = "SELECT {$this->what} FROM `{$this->table}` WHERE `{$this->filtre_key}` {$filtre_comp} '{$this->filtre}' ORDER BY `{$tri}` {$ordre}";
     } elseif (isset($filtrage_multiple)) {
         $this->request = "SELECT {$this->what} FROM `{$this->table}` WHERE {$filtrage_multiple} ORDER BY `{$tri}` {$ordre}";
     } elseif (isset($this->filtreSQL)) {
         $this->request = "SELECT {$this->what} FROM `{$this->table}` WHERE {$this->filtreSQL} ORDER BY `{$tri}` {$ordre}";
     } else {
         $this->request = "SELECT {$this->what} FROM `{$this->table}` ORDER BY `{$this->tri}` {$this->ordre}";
     }
     if (is_int($limit)) {
         $this->request .= " LIMIT {$limit}";
     }
     $q = $this->bddCx->prepare($this->request);
     $q->execute();
     if ($q->rowCount() >= 1) {
         // Formatage des résultats de la requête
         $result = $q->fetchAll(PDO::FETCH_ASSOC);
         $retour = array();
         $i = 0;
         foreach ($result as $resultOK) {
             unset($resultOK['password']);
             foreach ($resultOK as $k => $v) {
                 // Décodage JSON le cas échéant
                 if ($decodeJson && is_string($v) && preg_match('/((^\\[)*(]$))|((^\\{")*(}$))/', $v)) {
                     $valArr = json_decode($v, true);
                     if (!is_array($valArr)) {
                         continue;
                     }
                     $resultOK[$k] = $valArr;
                 }
                 // Remplacement par la Foreign Key le cas échéant
                 if ($withFK && preg_match("/^" . FOREIGNKEYS_PREFIX . "/", $k)) {
                     $fk = $this->getForeignKey($k, $v, $decodeJson, $parseDatesJS);
                     if (!is_array($fk)) {
                         continue;
                     }
                     $resultOK[$fk[0]] = $fk[1];
                 }
                 if (is_array(@$DATE_FIELDS) && $parseDatesJS) {
                     if (in_array($k, $DATE_FIELDS)) {
                         $resultOK[$k] = date("c", strtotime($v));
                     }
                     // Formatage de la date au format ISO 8601 (pour que JS puisse la parser)
                 }
             }
             if (count($resultOK) == 1) {
                 // Si une seule valeur demandée, pas besoin d'une dimension en plus
                 $retour[$i] = reset($resultOK);
             } else {
                 $retour[$i] = $resultOK;
             }
             $i++;
         }
         $this->listResult = $retour;
         return $retour;
     } else {
         return false;
     }
 }
Esempio n. 10
0
 /**
  * MISE À JOUR (SAVE) d'une entrée dans la table courante
  * @param STRING $filterKey Le nom de la colonne à utiliser pour identifier l'entrée (default 'id')
  * @param STRING $filterVal L'identifiant à utiliser (default 'this' -> correspond à l'entrée actuelle)
  * @param BOOLEAN $addCol TRUE pour ajouter la(les) colonne(s) si elle(s) n'existe(nt) pas
  * @param STRING $autoDate TRUE pour mettre à jour le champ de dernière modification avec la date courante, et la date de création dans le cas d'un INSERT, si la colonne est présente. (default TRUE)
  * @return STRING Le type de requête SQL qui vient d'être utilisée pour le save ('UPDATE', ou 'INSERT')
  */
 public function save($filterKey = 'id', $filterVal = 'this', $addCol = true, $autoDate = true)
 {
     if (!$this->bddCx || !is_object($this->bddCx)) {
         $this->initPDO();
     }
     // si pas d'argument on utilise l'entrée courante
     if ($filterVal == 'this') {
         $filterVal = @$this->data[$filterKey];
     }
     // Mise à jour d'une éventuelle colonne de date de last modif (la constante de config LAST_UPDATE doit être définie)
     if ($autoDate && defined("LAST_UPDATE") && LAST_UPDATE !== false) {
         $this->data[LAST_UPDATE] = date("Y-m-d H:i:s");
     }
     // Vérifie si tous les champs existent, sinon crée le champ à la volée
     if ($addCol) {
         $this->checkMissingCols();
     }
     // Construction de la chaine des clés et valeurs SQL pour la requête
     $keys = '';
     $vals = '';
     $up = '';
     foreach ($this->data as $k => $v) {
         if (is_array($v)) {
             $v = json_encode($v, JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE + JSON_NUMERIC_CHECK);
         }
         if (is_string($v)) {
             $v = addslashes($v);
         }
         $keys .= "`{$k}`, ";
         $vals .= "'{$v}', ";
         $up .= "`{$k}`='{$v}', ";
     }
     $keys = rtrim($keys, ', ');
     $vals = rtrim($vals, ', ');
     $up = rtrim($up, ', ');
     // Update de l'entrée si chargée en mémoire
     if ($this->loaded) {
         $req = "UPDATE `{$this->table}` SET {$up} WHERE `{$filterKey}` LIKE '{$filterVal}'";
     } else {
         // Insertion de l'entrée si nouvelle
         $req = "INSERT INTO `{$this->table}` ({$keys}) VALUES ({$vals})";
         // Ajout de la date de création (si la colonne est présente) (la constante de config DATE_CREATION doit être définie)
         if ($autoDate && defined("DATE_CREATION") && DATE_CREATION !== false) {
             $this->data[DATE_CREATION] = date("Y-m-d H:i:s");
         }
         $nextid = Liste::getAIval($this->table);
     }
     // Sauvegarde en base de données
     $q = $this->bddCx->prepare($req);
     try {
         $q->execute();
     } catch (Exception $e) {
         $msg = $e->getMessage();
         if ($e->getCode() == 23000) {
             $keyOffset = strrpos($msg, "'", -2);
             $key = substr($msg, $keyOffset);
             throw new Exception("Infos::save() : Duplicate entry for '{$key}' in table '{$this->table}'.");
         } else {
             throw new Exception("Infos::save(), table '{$this->table}' -> {$msg}");
         }
     }
     if (@$nextid) {
         $this->data['id'] = (int) $nextid;
     }
     $this->loaded = true;
     $err = $q->errorInfo();
     if ($err[0] == 0) {
         return substr($req, 0, 6);
     } else {
         throw new Exception('Infos::save() : ' . $err[2]);
     }
 }