Exemple #1
0
function getFilms(&$return, $paths = NULL)
{
    $error = "";
    $db = connectDB();
    if (!isset($paths)) {
        if (defined("PATHS")) {
            $paths = unserialize(PATHS);
        }
        return false;
    }
    foreach ($paths as $path) {
        $path = str_replace('\\', '/', $path . '/');
        //f*****g Windows
        $result = NULL;
        if (!listFile($result, $path)) {
            $error .= "Erreur sur l'ouverture du répértoire ('{$path}')\n";
            continue;
        }
        //récupération de l'id de la source ou son ajout si nécessaire
        if (($source_id = getSourceId($db, $path)) === false) {
            $source_id = insertSource($db, $path);
        }
        $return = array();
        foreach ($result as $row) {
            if (!getInfoOfFilm($row[RESULT_NAME], $title, $file_type)) {
                $error .= "Name is invalide " . $row[RESULT_NAME];
                continue;
            }
            //récupération de l'id du type de fichier
            if (($file_type_id = getTypeId($db, $file_type)) === false) {
                //PARANOIA use default type id : 1
                $file_type_id = 1;
            }
            $row[RESULT_PATH_CLEAR] = str_replace($path, "", $row[RESULT_PATH]);
            if (empty($row[RESULT_PATH_CLEAR])) {
                $row[RESULT_PATH_CLEAR] = ".";
            }
            //récupération de l'id de du fichier ou son ajout si nécessaire
            if (($file_id = getFile($db, $source_id, $row[RESULT_PATH_CLEAR], $row[RESULT_NAME], $file_type_id)) === false) {
                $file_id = insertFile($db, $source_id, $row[RESULT_PATH_CLEAR], $row[RESULT_NAME], $title, $file_type_id);
            }
            if ($title !== false) {
                // echo $error;
                $return[] = array($file_id, $title);
            } else {
                $error .= "Titre non trouvé pour le fichier ('{$row[RESULT_PATH]}{$row[RESULT_NAME]}')";
            }
        }
    }
    if (empty($return)) {
        return false;
    }
    return true;
}
Exemple #2
0
 			$customize .= "AND type_id = '$optionId' ";
 		}*/
 if ($_POST['v_tense'] != 'any') {
     $optionId = getTypeId($_POST['v_tense'], 'fib_v_tenses');
     $customize .= "AND verb_tense_id = '{$optionId}' ";
 }
 if ($_POST['politeness'] != 'any') {
     $optionId = getTypeId($_POST['politeness'], 'fib_politenesses');
     $customize .= "AND politeness_id = '{$optionId}' ";
 }
 if ($_POST['theme'] != 'any') {
     $optionId = getTypeId($_POST['theme'], 'fib_themes');
     $customize .= "AND theme_id = '{$optionId}' ";
 }
 if ($_POST['format'] != 'any') {
     $optionId = getTypeId($_POST['format'], 'fib_formats');
     $customize .= "AND format_id = '{$optionId}' ";
 }
 /*if($_POST['minna_lv'] != 'any'){ //deprecated, but use this if you want hail mary
 			$customize .= "AND difficulty = '$minnaLv' ";
 		}*/
 //grabs a random phrase for wordBox
 //No need to enter if showing answers
 //Prevent repeat questions
 $i = 0;
 if ($_POST['action'] != 'Answer') {
     do {
         $query = sprintf("SELECT id,element FROM fib_word WHERE {$customize} ORDER BY RAND() LIMIT 1");
         $result = mysql_query($query) or error_log('hi' . mysql_error());
         $fibWord = mysql_fetch_array($result);
         $i++;