コード例 #1
0
// define variables
$arrdesc = NULL;
$arrid = NULL;
$isduplicated = NULL;
$n = 0;
// counter
$add = $_POST['addcategory'];
// variable
// Depurate input
$add = stripslashes($add);
$add = htmlspecialchars($add);
$add = depurateContent($add);
if ($add != NULL and $add != "all") {
    /// 000
    // create unique and depurated id from the description (using the function renamefilestrict)
    $id = avoidXSS(renamefilestrict($add));
    //deletes also accents
    $id = ampersandRemove($id);
    //ampersand create issues
    if (strlen($id) < 3) {
        $suffix = random_str(5);
        $id = $id . $suffix;
    }
    $parser = simplexml_load_file($absoluteurl . "categories.xml", 'SimpleXMLElement', LIBXML_NOCDATA);
    //parse
    //	if (isset($parser->document->category)) {
    foreach ($parser->category as $singlecategory) {
        // echo $singlecategory->id[0]->tagData."<br>";
        // echo $singlecategory->description[0]->tagData;
        // echo "<br><br>";
        if ($id != $singlecategory->id[0] and $add != $singlecategory->description[0]) {
コード例 #2
0
    //write content into the file
    fclose($createtxtbox);
}
######################## END - FREEBOX FILE CREATION
######################## CATEGORY FILE CREATION
if (file_exists("../categories.xml")) {
    //if categories already exist stop the script
    echo "<span style=\"color:red;\">" . _("Categories file already exists...") . "</span><br />";
} else {
    // else create "categories.xml" file in the root dir
    // take the localized _("Uncategorized") variable in setup_LANGUAGE, depurate it and generate a unique id to use in the categories.xml file generated
    $idcat = stripslashes(_("Uncategorized"));
    $idcat = htmlspecialchars($idcat);
    $idcat = depurateContent($idcat);
    // category name (external)
    $id = avoidXSS(renamefilestrict($idcat));
    // category id generated (internal)
    $categoriesfiletocreate = '<?xml version="1.0" encoding="utf-8"?>
<PodcastGenerator>
	<category>
	<id>' . $id . '</id>
	<description>' . $idcat . '</description>
	</category>
	</PodcastGenerator>';
    $createcatf = fopen("{$absoluteurl}" . "categories.xml", 'w');
    //create categories file
    fwrite($createcatf, $categoriesfiletocreate);
    //write content into the file
    fclose($createcatf);
}
######################## END - CATEGORY FILE CREATION
コード例 #3
0
function autoIndexingEpisodes()
{
    include "core/includes.php";
    // Open podcast directory and read all the files contained
    $fileNamesList = readMediaDir($absoluteurl, $upload_dir);
    if (!empty($fileNamesList)) {
        // If media directory contains files
        $episodesCounter = 0;
        //set counter to zero
        // Loop through each file in the media directory
        foreach ($fileNamesList as $singleFileName) {
            ////Validate the current episode
            //NB. validateSingleEpisode returns [0] episode is supported (bool), [1] Episode Absolute path, [2] Episode XML DB absolute path,[3] File Extension (Type), [4] File MimeType, [5] File name without extension, [6] episode file supported but to XML present
            $thisPodcastEpisode = validateSingleEpisode($singleFileName);
            ////If episode is supported and does NOT have a related xml db
            if ($thisPodcastEpisode[6] == TRUE) {
                // From config.php
                if ($strictfilenamepolicy == "yes") {
                    $episodeNewFileName = date('Y-m-d') . "_" . renamefilestrict($thisPodcastEpisode[5]);
                } else {
                    $episodeNewFileName = renamefile($thisPodcastEpisode[5]);
                }
                //lowercase extension
                $episodeNewFileExtension = strtolower($thisPodcastEpisode[3]);
                // New file full path
                $episodeNewNameAbsPath = $absoluteurl . $upload_dir . $episodeNewFileName . '.' . $episodeNewFileExtension;
                //if file already exists add an incremental suffix
                $filesuffix = NULL;
                while (file_exists($episodeNewNameAbsPath)) {
                    $filesuffix++;
                    $episodeNewNameAbsPath = $absoluteurl . $upload_dir . $episodeNewFileName . $filesuffix . '.' . $episodeNewFileExtension;
                }
                if (file_exists($thisPodcastEpisode[1])) {
                    //rename episode
                    rename($thisPodcastEpisode[1], $episodeNewNameAbsPath);
                    // Change file date to now
                    touch($episodeNewNameAbsPath, time());
                } else {
                    exit;
                }
                //Episode size and data from GETID3 from retrieveMediaFileDetails function
                //NB retrieveMediaFileDetails returns: [0] $ThisFileSizeInMB, [1] $file_duration, [2] $file_bitrate, [3] $file_freq, [4] $thisFileTitleID3, [5] $thisFileArtistID3
                $episodeID3 = retrieveMediaFileDetails($episodeNewNameAbsPath, $absoluteurl, $thisPodcastEpisode[5], $img_dir);
                //// Assign title and short description (from ID3 title and artist, respectively. Or default)
                if ($episodeID3[4] != "") {
                    $thisEpisodeTitle = $episodeID3[4];
                } else {
                    $thisEpisodeTitle = $thisPodcastEpisode[5];
                }
                if ($episodeID3[5] != "") {
                    $thisEpisodeShortDesc = $episodeID3[5];
                } else {
                    $thisEpisodeShortDesc = _("Podcast Episode");
                }
                // Use GETID3 Title and Artist to fill title and description automatically
                $thisEpisodeData = array($thisEpisodeTitle, $thisEpisodeShortDesc, NULL, NULL, NULL, NULL, $explicit_podcast, NULL, NULL);
                $episodeXMLDBAbsPath = $absoluteurl . $upload_dir . $episodeNewFileName . $filesuffix . '.xml';
                //// Creating xml file associated to episode
                writeEpisodeXMLDB($thisEpisodeData, $absoluteurl, $episodeNewNameAbsPath, $episodeXMLDBAbsPath, $episodeNewFileName . $filesuffix, TRUE);
                $episodesCounter++;
            }
            // END - If episode is supported
        }
        // END - Loop through each file
    }
    // END - If media directory contains files
    return $episodesCounter;
}
コード例 #4
0
     $podcast_filetype = $fileData[0];
 } else {
     $podcast_filetype = NULL;
 }
 if ($fileExtension == strtoupper($podcast_filetype)) {
     $podcast_filetype = strtoupper($podcast_filetype);
 }
 //accept also uppercase extension
 if ($fileExtension == $podcast_filetype) {
     //003 (if file extension is accepted, go on....
     ##############
     ##############
     ### file name depuration!!!! Important... By default Podcastgen uses a "strict" depuration policy (just characters from a to z and numbers... no accents and other characters).
     if ($strictfilenamepolicy == "yes") {
         #enable this to have a very strict filename policy
         $filenameWithoutExtension = renamefilestrict($filenameWithoutExtension);
     } else {
         # LESS strict renaming policy
         $filenameWithoutExtension = renamefile($filenameWithoutExtension);
     }
     $fileExtension = strtolower($fileExtension);
     //lowercase file extension
     ##############
     ############## end filename depuration
     if ($strictfilenamepolicy == "yes") {
         $filenamechanged = date('Y-m-d') . "_" . $filenameWithoutExtension;
     } else {
         $filenamechanged = $filenameWithoutExtension;
     }
     $uploadFile = $upload_dir . $filenamechanged . "." . $fileExtension;
     while (file_exists("{$uploadFile}")) {