Exemplo n.º 1
0
function createBlankImage($image, $font, $text, $color, $shadow, $drop, $maxwidth, $alignment, $valign, $padding = "5")
{
    global $web_root, $root_dir;
    // First we need to see if GD is installed or not...
    if (gd_version() == 0) {
        // Ok, no GD, let's write that to the log...
        writeLogData('error', 'Sorry, GD Libraries not found!');
        return false;
    }
    /* Now let's create our destination image with our new height/width */
    $src_img = imagecreatefromjpeg($image);
    if (gd_version() >= 2) {
        $dest_img = imageCreateTrueColor($maxwidth, $maxwidth);
    } else {
        $dest_img = imageCreate($maxwidth, $maxwidth);
    }
    // decode color arguments and allocate colors
    $color_args = explode(' ', $color);
    $color = imagecolorallocate($dest_img, $color_args[0], $color_args[1], $color_args[2]);
    $shadow_args = explode(' ', $shadow);
    $shadow = imagecolorallocate($dest_img, $shadow_args[0], $shadow_args[1], $shadow_args[2]);
    /* Let's get the width and height of the source image */
    $src_width = imagesx($src_img);
    $src_height = imagesy($src_img);
    /* Now let's copy the data from the old picture to the new one witht the new settings */
    if (gd_version() >= 2) {
        imageCopyResampled($dest_img, $src_img, 0, 0, 0, 0, $maxwidth, $maxwidth, $src_width, $src_height);
    } else {
        imageCopyResized($dest_img, $src_img, 0, 0, 0, 0, $maxwidth, $maxwidth, $src_width, $src_height);
    }
    /* Now let's clean up our temp image */
    imagedestroy($src_img);
    $fontwidth = ImageFontWidth($font);
    $fontheight = ImageFontHeight($font);
    $margin = floor($padding + $drop) / 2;
    // So that shadow is not off image on right align & bottom valign
    if ($maxwidth != NULL) {
        $maxcharsperline = floor(($maxwidth - $margin * 2) / $fontwidth);
        $text = wordwrap($text, $maxcharsperline, "\n", 1);
    }
    $lines = explode("\n", $text);
    switch ($valign) {
        case "center":
            $y = (imageSY($dest_img) - $fontheight * sizeof($lines)) / 2;
            break;
        case "bottom":
            $y = imageSY($dest_img) - ($fontheight * sizeof($lines) + $margin);
            break;
        default:
            $y = $margin;
            break;
    }
    switch ($alignment) {
        case "right":
            while (list($numl, $line) = each($lines)) {
                ImageString($dest_img, $font, imagesx($dest_img) - $fontwidth * strlen($line) - $margin + $drop, $y + $drop, $line, $shadow);
                ImageString($dest_img, $font, imagesx($dest_img) - $fontwidth * strlen($line) - $margin, $y, $line, $color);
                $y += $fontheight;
            }
            break;
        case "center":
            while (list($numl, $line) = each($lines)) {
                ImageString($dest_img, $font, floor((imagesx($dest_img) - $fontwidth * strlen($line)) / 2) + $drop, $y + $drop, $line, $shadow);
                ImageString($dest_img, $font, floor((imagesx($dest_img) - $fontwidth * strlen($line)) / 2), $y, $line, $color);
                $y += $fontheight;
            }
            break;
        default:
            while (list($numl, $line) = each($lines)) {
                ImageString($dest_img, $font, $margin + $drop, $y + $drop, $line, $shadow);
                ImageString($dest_img, $font, $margin, $y, $line, $color);
                $y += $fontheight;
            }
            break;
    }
    /* Now let's create our new image */
    $new_image = $web_root . $root_dir . "/temp/temp-image.jpg";
    @touch($new_image);
    // Now let's make sure that new image is writable
    if (is_writable($new_image)) {
        imagejpeg($dest_img, $new_image);
        /* Now let's clean up our temp image */
        imagedestroy($dest_img);
        return true;
    } else {
        echo "Sorry, I couldn't open the temporary image file for writing.<br>" . "looks like something is wrong with the permissions on your temp directory at:<br><br>" . $web_root . $root_dir . "/temp<br><br>" . "Sorry about that, but this is a fatal error!<br><br>" . "You could turn off auto art searching in settings.php by changing<br><br>" . '$search_album_art = "false";';
        exit;
        return false;
    }
}
Exemplo n.º 2
0
    ?>
){
										t.innerHTML = converTime(seconds) + "/<?php 
    echo convertSecMins($curTrackLength);
    ?>
";
									} else {
										t.innerHTML = "<?php 
    echo convertSecMins($curTrackLength);
    ?>
/<?php 
    echo convertSecMins($curTrackLength);
    ?>
";
										<?php 
    writeLogData("messages", "Jukebox block: Refreshing the jukebox display");
    ?>
										seconds = 1;
										updateJukebox(true);
									}
									setTimeout("displayCountdown()",1000);
								} 
								displayCountdown();
								--> 
							</script> 
							<?php 
}
// Now we need to return the path to the track that is playing so we can get the art and description for it
$filePath = $jb->getCurrentTrackPath();
$track = new jzMediaNode($filePath, "filename");
// Now let's make sure we are looking at a track for real
Exemplo n.º 3
0
 /**
  * Helper function to add a single web track
  * to the database.
  * @author Ben Dodson
  * @since 1/29/10
  */
 function addWebTrack($mediaref, $parent, $mdate, $level, $link)
 {
     $medianame = $mediaref;
     while ($medianame[strlen($medianame) - 1] == '/') {
         $medianame = substr($medianame, 0, strlen($medianame) - 1);
     }
     $medianame = substr($medianame, strrpos($medianame, '/') + 1);
     $slashedNodePath = jz_db_escape($parent);
     $slashedFileName = jz_db_escape($medianame);
     // First, try putting me in the DB.
     $slashedFileName = jz_db_escape($medianame);
     $slashedFilePath = $slashedNodePath == "" ? $slashedFileName : $slashedNodePath . "/" . $slashedFileName;
     $fullSlashedFilePath = jz_db_escape($mediaref);
     $mid = uniqid("T");
     $sql = "INSERT INTO jz_nodes(name,path,filepath,ptype,level,date_added,leaf,my_id) ";
     $sql .= "VALUES('{$slashedFileName}','{$slashedFilePath}','{$fullSlashedFilePath}','track',{$level}+1,'{$mdate}','true','" . $mid . "') ";
     $updatesql = "UPDATE jz_nodes SET valid = 'true' WHERE path " . jz_db_case_sensitive() . " '{$slashedFilePath}'";
     jz_db_query($link, $sql) || jz_db_query($link, $updatesql);
     $pname = jz_db_escape($medianame);
     $bitrate = "";
     $length = "";
     $filesize = "";
     $name = jz_db_escape($medianame);
     $artist = "";
     $album = "";
     $year = "";
     $track = "";
     $genre = "";
     $frequency = "";
     $description = "";
     $lyrics = "";
     $fileExt = "";
     $long_description = "";
     $thumb_file = "";
     $sql = "INSERT INTO jz_tracks(path,level,my_id,filepath,name,trackname,bitrate,filesize,frequency,length,lyrics,genre,artist,album,year,number,extension)\n\t\t\t       VALUES('{$slashedFilePath}',{$level}+1,'" . $mid . "','{$fullSlashedFilePath}','{$pname}','{$name}','{$bitrate}','{$filesize}','{$frequency}','{$length}','{$lyrics}','{$genre}','{$artist}','{$album}','{$year}','{$track}','{$fileExt}')";
     // Now let's update status and log this
     if (isset($_SESSION['jz_import_full_progress'])) {
         $_SESSION['jz_import_full_progress']++;
     } else {
         $_SESSION['jz_import_full_progress'] = 1;
     }
     writeLogData('importer', "Importing track: " . $fullSlashedFilePath);
     $updatesql = "UPDATE jz_tracks SET valid = 'true',\n\t\t\t\t\tlevel = {$level}+1,\n\t\t\t\t\ttrackname = '{$name}',\n\t\t\t\t\tbitrate = '{$bitrate}',\n\t\t\t\t\tfilesize = '{$filesize}',\n\t\t\t\t\tfrequency = '{$frequency}',\n\t\t\t\t\tlength = '{$length}',";
     $updatesql .= "year = '{$year}',\n\t\t\t\t\tgenre = '{$genre}',\n\t\t\t\t\tartist = '{$artist}',\n\t\t\t\t\talbum = '{$album}',\n\t\t\t\t\tnumber = '{$track}',\n\t\t\t\t\textension = '{$fileExt}'";
     $updatesql .= " WHERE path " . jz_db_case_sensitive() . " '{$slashedFilePath}'";
     jz_db_query($link, $sql) || jz_db_query($link, $updatesql);
     // last thing: add thumb and/or descriptions.
     $sql = "valid = 'true'";
     jz_db_query($link, "UPDATE jz_nodes SET {$sql} WHERE path " . jz_db_case_sensitive() . " '{$slashedFilePath}'");
 }
Exemplo n.º 4
0
/**
 * Returns how long is left in the current track (in seconds)
 * 
 * @author Ross Carlson
 * @version 2/9/05
 * @since 2/9/05
 * @return Returns the name of the current playing track
 */
function getCurTrackLocation()
{
    global $jbArr;
    $val = @file_get_contents("http://" . $jbArr[$_SESSION['jb_id']]['server'] . ":" . $jbArr[$_SESSION['jb_id']]['port'] . "/getoutputtime?p=" . $jbArr[$_SESSION['jb_id']]['password'] . "&frmt=0");
    $val = round($val / 1000, 0);
    writeLogData("messages", "Winamp3: Returning current track location: " . $val);
    return $val;
}
Exemplo n.º 5
0
 $exit = true;
 switch ($argv[1]) {
     // UPDATE
     case "force_update":
         $force_update = true;
     case "update":
         if (!isset($force_update)) {
             $force_update = false;
         }
         if (isset($argv[2])) {
             $node = new jzMediaNode($argv[2]);
         } else {
             $node = new jzMediaNode();
         }
         // Should this force the update? Set the last param here...
         writeLogData("messages", "Command line Jinzora: Updating the node cache");
         updateNodeCache($node, true, "cli", $force_update);
         break;
         // LYRICS SCAN:
     // LYRICS SCAN:
     case "scan_lyrics":
         if (isset($argv[2])) {
             $node = new jzMediaNode($argv[2]);
         } else {
             $node = new jzMediaNode();
         }
         $tracks = $node->getSubNodes("tracks", -1);
         $nfound = 0;
         $nmissed = 0;
         $nskipped = 0;
         foreach ($tracks as $track) {
Exemplo n.º 6
0
            }
            break;
        case "generateRandom":
            writeLogData("messages", "Index: Generating a random playlist");
            if ($jzUSER->getSetting('stream') === false && $jzUSER->getSetting('lofi') === false) {
                exit;
            }
            $pl =& new jzPlaylist();
            // Let's time it.
            $timer = microtime_float();
            $pl->generate($_POST['random_play_type'], $_POST['random_play_number'], $_POST['random_play_genre']);
            $timer = round(microtime_float() - $timer, 2);
            if ($_POST['random_play_genre'] != "") {
                writeLogData('playback', "generated random playlist of " . $_POST['random_play_number'] . " tracks from genre '" . $_POST['random_play_genre'] . "' in {$timer} seconds.");
            } else {
                writeLogData('playback', "generated random playlist of " . $_POST['random_play_number'] . " tracks in {$timer} seconds.");
            }
            $pl->play();
            exit;
            break;
    }
}
// Last thing: we want to draw a standard page, since we did not previously exit.
// TODO: check for specialty pages (search,playlistmanager,etc)
// Let's count how many of everything we have
if (!isset($_SESSION['jz_num_genres'])) {
    $root =& new jzMediaNode();
    $_SESSION['jz_num_genres'] = $root->getSubNodeCount("nodes", distanceTo("genre"));
    $_SESSION['jz_num_artists'] = $root->getSubNodeCount("nodes", distanceTo("artist"));
    $_SESSION['jz_num_albums'] = $root->getSubNodeCount("nodes", distanceTo("album"));
    $_SESSION['jz_num_tracks'] = $root->getSubNodeCount("nodes", distanceTo("track"));
Exemplo n.º 7
0
 /**
  * Constructor for the class.
  * 
  * @author Ross Carlson
  * @version 2/9/05
  * @since 2/9/05
  */
 function jzJukebox()
 {
     global $include_path, $jbArr;
     jzJukebox::getJbArr();
     // Ok, now we need to include the right subclass for this player
     // TODO: make getting jukebox by description the only available method.
     if (isset($_SESSION['jb_id']) && !is_numeric($_SESSION['jb_id'])) {
         foreach ($jbArr as $id => $jb) {
             if ($jb['description'] == $_SESSION['jb_id']) {
                 $_SESSION['jb_id'] = $id;
                 $this->id = $id;
                 break;
             }
         }
     }
     if (!isset($_SESSION['jb_id']) || $_SESSION['jb_id'] >= sizeof($jbArr)) {
         $_SESSION['jb_id'] = 0;
     }
     if ($this->id === false) {
         $this->id = $_SESSION['jb_id'];
     }
     // Now let's make sure they have installed the jukebox
     if (!isset($jbArr[0]['type'])) {
         // Let's take them through the installer
         $this->install();
     }
     writeLogData("messages", "Jukebox: building the jukebox object of type " . $this->getSetting('type'));
     include_once $include_path . "jukebox/jukeboxes/" . $this->getSetting('type') . ".php";
 }
Exemplo n.º 8
0
 function updateCacheHelper($recursive, $levelsLeft, $root, $showStatus, $readID3)
 {
     global $audio_types, $video_types, $ext_graphic, $default_art, $backend, $track_num_seperator, $hierarchy, $protocols;
     if ($root !== false) {
         $mediapath = $root;
     } else {
         $mediapath = $this->getFilePath();
     }
     if ($mediapath == "-") {
         // let's find it..
         $parent = $this->getParent();
         $mediapath = $parent->getFilePath() . "/" . $this->getName();
     }
     $nodepath = $this->getPath("String");
     /* Echo out our current status, if they want it: */
     if ($showStatus === true) {
         showStatus($mediapath);
     } else {
         if ($showStatus == "cli") {
             echo word("Scanning: ") . $mediapath . "\n";
         }
     }
     // First add $this.
     // Was I already cached?
     $cache = $this->readCache();
     if ($cache[0] == "-") {
         $cache[0] = $nodepath;
     }
     if ($cache[13] == "-") {
         $cache[13] = $mediapath;
     }
     if ($cache[6] == "-") {
         $cache[6] = jz_filemtime($mediapath);
     }
     if ($cache[15] == "-") {
         $ptype = findPType($this);
         $cache[15] = $ptype;
     }
     $blankfilecache = blankCache("track");
     // Recurse and add $this's media files.
     if (!($handle = opendir($mediapath))) {
         die("Could not access directory {$mediapath}");
     }
     // scan for info while going through directory:
     $trackcount = 0;
     $new_nodes = $cache[7];
     $new_tracks = $cache[8];
     $bestImage = "";
     $bestDescription = "";
     while ($file = readdir($handle)) {
         $childpath = $nodepath == "" ? $file : $nodepath . "/" . $file;
         $fullchildpath = $mediapath . "/" . $file;
         if ($file == "." || $file == "..") {
             continue;
         } else {
             if (is_dir($fullchildpath)) {
                 if ($recursive) {
                     $next =& new jzMediaNode($childpath);
                     $next->updateCacheHelper(true, $levelsLeft, $fullchildpath, $showStatus, $readID3);
                 } else {
                     if ($levelsLeft === false && $this->getNaturalDepth() > 1) {
                         $next =& new jzMediaNode($childpath);
                         $next->updateCacheHelper(false, $this->getNaturalDepth() - 2, $fullchildpath, $showStatus, $readID3);
                     } else {
                         if ($levelsLeft > 0) {
                             $next =& new jzMediaNode($childpath);
                             $next->updateCacheHelper(false, $levelsLeft - 1, $fullchildpath, $showStatus, $readID3);
                         }
                     }
                 }
                 if ($new_nodes != array()) {
                     $key = array_search($file, $new_nodes);
                     if (false === $key) {
                         $new_nodes[] = $file;
                         $next =& new jzMediaNode($childpath);
                     }
                 } else {
                     $new_nodes[] = $file;
                     $next =& new jzMediaNode($childpath);
                 }
             } else {
                 if (preg_match("/\\.(txt)\$/i", $file)) {
                     // TODO: GET THE CORRECT DESCRIPTION IN $bestDescription
                     // $bestDescription = $fullchildpath;
                 } else {
                     if (preg_match("/\\.({$ext_graphic})\$/i", $file) && !stristr($file, ".thumb.")) {
                         // An image
                         if (@preg_match("/({$default_art})/i", $file)) {
                             $bestImage = $fullchildpath;
                         } else {
                             if ($bestImage == "") {
                                 $bestImage = $fullchildpath;
                             }
                         }
                     } else {
                         if (preg_match("/\\.({$audio_types})\$/i", $file) || preg_match("/\\.({$video_types})\$/i", $file)) {
                             //* * * A track * * * *//
                             // Add it to the track list.
                             if ($new_tracks != array()) {
                                 $key = array_search($file, $new_tracks);
                                 if (false === $key) {
                                     $new_tracks[] = $file;
                                 }
                             } else {
                                 $new_tracks[] = $file;
                             }
                             // And at it's details..
                             $childnode =& new jzMediaTrack($childpath);
                             if ($cache[2] == "-" || $cache[2] < date("U", jz_filemtime($fullchildpath)) || !$childnode->readCache()) {
                                 // Add as a new/updated track.
                                 $filecache[$trackcount] = $childnode->readCache();
                                 if ($filecache[$trackcount][0] == "-") {
                                     $filecache[$trackcount][0] = $fullchildpath;
                                     $filecache[$trackcount][6] = jz_filemtime($fullchildpath);
                                     $filecache[$trackcount][2] = $file;
                                 }
                                 //////////
                                 // META //
                                 //////////
                                 $track =& new jzMediaTrack($childpath);
                                 $track->playpath = $fullchildpath;
                                 if ($readID3 === true) {
                                     $meta = $track->getMeta("file");
                                     // read meta info from the file;
                                 } else {
                                     $meta = array();
                                 }
                                 $filecache[$trackcount][7] = $meta['title'];
                                 $filecache[$trackcount][8] = $meta['frequency'];
                                 $filecache[$trackcount][9] = $meta['comment'];
                                 $filecache[$trackcount][11] = $meta['year'];
                                 $filecache[$trackcount][13] = $meta['size'];
                                 $filecache[$trackcount][14] = $meta['length'];
                                 $filecache[$trackcount][15] = $meta['genre'];
                                 $filecache[$trackcount][16] = $meta['artist'];
                                 $filecache[$trackcount][17] = $meta['album'];
                                 $filecache[$trackcount][18] = $meta['type'];
                                 $filecache[$trackcount][19] = $meta['lyrics'];
                                 $filecache[$trackcount][20] = $meta['bitrate'];
                                 $filecache[$trackcount][21] = $meta['number'];
                                 // Now let's see if there is a description file...
                                 $desc_file = str_replace("." . $meta['type'], "", $fullchildpath) . ".txt";
                                 $long_description = "";
                                 if (is_file($desc_file) and filesize($desc_file) != 0) {
                                     // Ok, let's read the description file
                                     $handle2 = fopen($desc_file, "rb");
                                     $filecache[$trackcount][10] = fread($handle2, filesize($desc_file));
                                     fclose($handle2);
                                 } else {
                                     $filecache[$trackcount][10] = "";
                                 }
                                 // Now let's see if there is a thumbnail for this track
                                 $filecache[$trackcount][1] = searchThumbnail($fullchildpath);
                             } else {
                                 // slow but necessary..
                                 //$filecache[$trackcount] = $childnode->readCache();
                             }
                             $trackcount++;
                             // Let's track this
                             writeLogData('importer', "Importing track: " . $fullchildpath);
                             $_SESSION['jz_import_full_progress']++;
                         }
                     }
                 }
             }
         }
     }
     if ($new_nodes != array()) {
         foreach ($new_nodes as $i => $my_path) {
             $me =& new jzMediaNode($nodepath . "/" . $my_path);
             if ($me->getFilePath() == "-") {
                 $arr = explode("/", $my_path);
                 $mfp = $this->getFilePath() . "/" . $arr[sizeof($arr) - 1];
             } else {
                 $mfp = $me->getFilePath();
             }
             if (!is_dir($mfp)) {
                 // TODO: The commented out part should check to see if there are 'permanent' subnodes.
                 // It is possible a directory was created to house links (and does not have
                 // any data on the filesystem)
                 $remove_me = true;
                 $list = $me->getSubNodes("tracks", -1);
                 foreach ($list as $el) {
                     if (stristr($el->getFilePath(), "://")) {
                         $remove_me = false;
                         break;
                     }
                 }
                 if ($remove_me) {
                     $me->deleteCache();
                     unset($new_nodes[$i]);
                 }
             }
         }
     }
     if ($new_tracks != array()) {
         foreach ($new_nodes as $i => $my_path) {
             $me =& new jzMediaTrack($nodepath . "/" . $my_path);
             if (!is_file($fpath = $me->getFilePath())) {
                 $valid = false;
                 $parr = explode("|", $protocols);
                 if (strlen($fpath) > 2) {
                     foreach ($parr as $p) {
                         if (stristr($fpath, $p) !== false) {
                             $valid = true;
                         }
                     }
                 }
                 if (!$valid) {
                     $me->deleteCache();
                     unset($new_tracks[$i]);
                 }
             }
         }
     }
     // Update $this
     if ($bestImage != "") {
         $cache[1] = $bestImage;
     }
     if ($bestDescription != "") {
         $cache[10] = file_get_contents($bestDescription);
     }
     $cache[2] = date("U");
     natcasesort($new_nodes);
     $cache[7] = array_values($new_nodes);
     natcasesort($new_tracks);
     $cache[8] = array_values($new_tracks);
     // * * * * * * * *
     // Write the cache.
     $this->writeCache($cache, "nodes");
     if ($filecache != array()) {
         $this->writeCache($filecache, "tracks");
     }
 }
Exemplo n.º 9
0
 function loadService($type, $service)
 {
     global $include_path;
     if (strpos($type, "..") !== false) {
         die('Security breach detected.');
     }
     if (strpos($service, "..") !== false) {
         die('Security breach detected.');
     }
     switch ($type) {
         case "lyrics":
             $function_name = "SERVICE_LYRICS";
             break;
         case "similar":
             $function_name = "SERVICE_SIMILAR";
             break;
         case "metadata":
             $function_name = "SERVICE_METADATA";
             break;
         case "link":
             $function_name = "SERVICE_LINK";
             break;
         case "tagdata":
             $function_name = "SERVICE_TAGDATA";
             break;
         case "playlist":
             $function_name = "SERVICE_PLAYLIST";
             break;
         case "players":
             $function_name = "SERVICE_PLAYERS";
             break;
         case "images":
             $function_name = "SERVICE_IMAGES";
             break;
         case "resample":
             $function_name = "SERVICE_RESAMPLE";
             break;
         case "cdburning":
             $function_name = "SERVICE_CDBURNING";
             break;
         case "cms":
             $function_name = "SERVICE_CMS";
             break;
         case "reporting":
             $function_name = "SERVICE_REPORTING";
             break;
         case "shopping":
             $function_name = "SERVICE_SHOPPING";
             break;
         case "importing":
             $function_name = "SERVICE_IMPORTING";
             break;
         default:
             return;
     }
     if (!file_exists($include_path . "services/services/{$type}/{$service}.php")) {
         return false;
     }
     writeLogData("messages", "Services: Loading service: " . $service . " type: " . $type);
     $this->loaded[$type] = $service;
     if (!defined($function_name . "_" . $service)) {
         require_once $include_path . "services/services/{$type}/{$service}.php";
         if (isset($jzSERVICE_INFO)) {
             $this->service_info[$type] = $jzSERVICE_INFO;
             $this->cached[$type][$service] = $jzSERVICE_INFO;
             unset($jzSERVICE_INFO);
         } else {
             $arr = array();
             $arr['name'] = $service;
             $this->service_info[$type][$service] = $arr;
         }
     } else {
         // already loaded.
         if (isset($this->cached[$type][$service])) {
             $this->service_info[$type] = $this->cached[$type][$service];
         }
     }
 }
Exemplo n.º 10
0
function jukebox()
{
    global $jzUSER;
    if (!isset($_REQUEST['jb_id']) && $_REQUEST['action'] != 'list') {
        return;
    }
    $_SESSION['jb_id'] = $_REQUEST['jb_id'];
    if (isset($_REQUEST['action'])) {
        if ($_REQUEST['action'] == 'list') {
            if ($jzUSER->getSetting('jukebox_admin') === false && $jzUSER->getSetting('jukebox_queue') === false) {
                echo "";
                return;
            }
            @(include_once 'jukebox/class.php');
            $jbArr = jzJukebox::getJbArr();
            foreach ($jbArr as $key => $val) {
                echo $key . ':' . $val['description'] . "\n";
            }
        }
    }
    // Do we need to use the standard jukebox or not?
    // Now did they have a subcommand?
    if ($jzUSER->getSetting('jukebox_admin') === false && $jzUSER->getSetting('jukebox_queue') === false) {
        echo 'insufficient permissions.';
        exit;
    }
    if (isset($_REQUEST['external_playlist'])) {
        require_once 'playlists/class.php';
        $pl = new JzPlaylist();
        $pl->addFromExternal($_REQUEST['external_player']);
        $pl->jukebox();
        // Questions: how to handle addwhere param;
        // how to bring in media as JzObject (without breaking built-in calls)
        return;
    }
    // Jukebox commands:
    if (isset($_REQUEST['command'])) {
        $command = $_REQUEST['command'];
        // Let's include the Jukebox classes
        writeLogData("messages", "API: Passing command: " . $command . " to the jukebox");
        include_once "jukebox/class.php";
        $jb = new jzJukebox();
        $jb->passCommand($command);
    }
}
Exemplo n.º 11
0
/** 
 * Returns the AJAX code for the small jukebox
 *
 * @author Ben Dodson
 * @since 8/21/05
 * @param new_jb: the jukebox to change to.
 **/
function ajaxSmallJukebox($new_jb = false, $text = false, $buttons = false, $linebreaks = false)
{
    global $include_path;
    writeLogData("messages", "Jukebox: Displaying the small jukebox interface");
    $blocks = new jzBlocks();
    if ($new_jb !== false) {
        // Change the jukebox
        include_once $include_path . "jukebox/class.php";
        $jbArr = jzJukebox::getJbArr();
        for ($i = 0; $i < count($jbArr); $i++) {
            if ($jbArr[$i]['description'] == $new_jb) {
                $_SESSION['jb_id'] = $i;
            }
        }
        $_POST['jbplaywhere'] = $new_jb;
        ajaxJukeboxRequest('playwhere');
    }
    $blocks->smallJukebox($text, $buttons, $linebreaks);
}
Exemplo n.º 12
0
 function plaintextSubstr($text, $end)
 {
     if ($text === false) {
         return false;
     }
     // Only need to search starting from the first html tag
     $currentPos = strpos($text, "<");
     if (!$currentPos || $currentPos > $end) {
         // Plain text (or html occurs after $end); just return a substring
         return substr($text, 0, $end);
     }
     // Number of chars of non-body data we've seen so far
     $nonDisplayTextCounter = 0;
     // Used to keep track of whether we're looking at plain text or tag body text
     $inTagBody = false;
     $textFullLength = strlen($text);
     while ($currentPos <= $textFullLength) {
         // CASE 1: Tag opening
         if ($text[$currentPos] == '<') {
             if (!$inTagBody) {
                 $inTagBody = true;
                 $nonDisplayTextCounter++;
             } else {
                 // This is only reachable for malformatted html, e.g. "<a = <stuff>"
                 writeLogData("messages", "Warning: found possibly malformatted open tag.");
             }
             // CASE 2: Tag closing
         } else {
             if ($text[$currentPos] == '>') {
                 if ($inTagBody) {
                     $inTagBody = false;
                     $nonDisplayTextCounter++;
                 } else {
                     // Malformatted html (e.g. "<b> stuff >") or real greater-than symbol meaning
                     writeLogData("messages", "Warning: found possibly malformatted close tag.");
                 }
                 // Case 3: plain text, either body text or tag text
             } else {
                 if ($inTagBody) {
                     $nonDisplayTextCounter++;
                 }
             }
         }
         // Stop once we find $end characters
         if ($currentPos - $nonDisplayTextCounter == $end) {
             break;
         }
         $currentPos++;
     }
     return substr($text, 0, $currentPos);
 }
Exemplo n.º 13
0
/**
 * The general resample/transcode function
 * 
 * @author Ross Carlson, Ben Dodson
 * @version 05.25.05
 * @since 05.25.05
 * @param $file The file that we are resampling/transcoding
 * @param $name The name of the stream
 * @param $resample The rate to resample/transcode to
 */
function SERVICE_RESAMPLE($file, $name, $resample)
{
    global $path_to_lame, $path_to_flac, $path_to_mpc, $path_to_wavunpack, $path_to_oggdec, $lame_cmd, $path_to_wmadec, $path_to_shn, $path_to_mplayer, $mplayer_opts, $path_to_faad, $path_to_macpipe, $path_to_ofr;
    $jzSERVICES = new jzServices();
    $jzSERVICES->loadStandardServices();
    // Now let's add the proper options to the lame command
    $lame_cmd .= $resample . ' -f -';
    //Now let's figure out the file type
    $extArr = explode(".", $file);
    $ext = $extArr[count($extArr) - 1];
    // Now if we're on Windows we need to change the slashes for the command line
    if (stristr($_ENV['OS'], "win")) {
        $file = str_replace("/", "\\", $file);
    }
    switch ($ext) {
        case "mp3":
            $meta = $jzSERVICES->getTagData($file);
            if ($meta['bitrate'] <= $resample) {
                header("Content-Type: audio/x-mp3");
                streamFile($file, $meta['artist'] . $meta['title'], $resample);
                exit;
            } else {
                $command = $path_to_lame . " --mp3input -S --silent --quiet --lowpass 12.0 --resample 22.05 -m j -b " . $resample . ' - < "' . $file . '" -';
            }
            break;
        case "flac":
            $command = $path_to_flac . ' -d -c --totally-silent "' . $file . '" | ' . $lame_cmd;
            break;
        case "mpc":
            $command = $path_to_mpc . ' --wav "' . $file . '" | ' . $lame_cmd;
            break;
        case "wv":
            $command = $path_to_wavunpack . ' -q "' . $file . '" - | ' . $lame_cmd;
            break;
        case "ogg":
            // Ok, are they using oggdec or ogg123?
            if (stristr($path_to_oggdec, "oggdec")) {
                //$command = $path_to_oggdec. ' --stdout "'. $file. '" | '. $lame_cmd;
                $command = $path_to_oggdec . ' -Q "' . $file . '" -o - | ' . $lame_cmd;
            } else {
                $command = $path_to_oggdec . ' --skip 1 -q -d wav -f - "' . $file . '" | ' . $lame_cmd;
            }
            break;
        case "wav":
            $command = $path_to_lame . " -S --silent --quiet --lowpass 12.0 --resample 22.05 -m j -b " . $resample . ' - < "' . $file . '" -';
            break;
        case "shn":
            if (stristr($_ENV['OS'], "win")) {
                $command = $path_to_shn . ' -x "' . $file . '" - | ' . str_replace(" -S --silent", " -x -S --silent", $lame_cmd);
            } else {
                $command = $path_to_shn . ' -x "' . $file . '" - | ' . $lame_cmd;
            }
            break;
        case "wma":
            $command = $path_to_wmadec . ' -w "' . $file . '" | ' . $lame_cmd;
            break;
        case "ape":
            $command = $path_to_macpipe . ' "' . $file . '" - -d | ' . $lame_cmd;
            break;
        case "ofr":
            $command = $path_to_ofr . ' --decode --silent "' . $file . '" --output - | ' . str_replace(" -S --silent", " -x -S --silent", $lame_cmd);
            break;
        case "ra":
        case "ram":
        case "rm":
        case "m4a":
            if (stristr($_ENV['OS'], "win")) {
                $command = $path_to_faad . ' -w "' . $file . '" | ' . str_replace(" -S --silent", " -x -S --silent", $lame_cmd);
            } else {
                $command = $path_to_mplayer . ' ' . $mplayer_opts . ' "' . $file . '" | ' . $lame_cmd;
            }
            break;
        default:
            exit;
            break;
    }
    // Let's log the command we just passed
    writeLogData("resample-command", $command);
    // Now let's send the resampled data
    sendResampledFile($command, $name);
    exit;
}
Exemplo n.º 14
0
 function login($user, $password, $remember = false, $prehashed = false)
 {
     global $cms_mode, $cms_type;
     if ($cms_mode != "false") {
         $cms = true;
     } else {
         $cms = false;
     }
     if (!$prehashed) {
         $password = jz_password($password);
     }
     $dp = $this->data_dir . "/" . "users";
     $users = unserialize(file_get_contents($dp));
     // Clear their data cache.
     if ($cms === false) {
         /*
         foreach ($_SESSION as $var=>$val) {
           unset($_SESSION[$var]);
         }
         */
         //Stupid PHP!!
         $_SESSION = array();
     }
     $this->initUser();
     if ($cms !== false) {
         // The login is coming from CMS.
         // This means we can assume they are authenticated;
         // Just make sure they have an entry in our users file.
         if (!isset($users[$user])) {
             // first timer:
             $this->addUser($user, "cms-user");
             // TODO: LOAD PERMISSIONS FOR CMS-DEFAULTS HERE!
             // now just re-login.
             return $this->login($user, $password, $remember, true);
         } else {
             if ($users[$user]['password'] != jz_password("cms-user")) {
                 // double user. bad move.
                 // Actually let's let this fly and see how it works out for CMS users.
                 // To disallow this again, be sure to edit install/step6.php so the
                 // admin user is created w. password 'cms-user' during a CMS install.
                 $this->id = $users[$user]['id'];
                 $_SESSION['jzUserID'] = jz_cookie_encode($this->id);
                 $this->loadSettings();
                 writeLogData("access", "cms-user '" . $user . "' logged in successfully.");
                 return true;
             } else {
                 $this->id = $users[$user]['id'];
                 $_SESSION['jzUserID'] = jz_cookie_encode($this->id);
                 $this->loadSettings();
                 writeLogData("access", "cms-user '" . $user . "' logged in successfully.");
                 return true;
             }
         }
         return false;
     }
     // NO CMS; standard way.
     // Passwords are hashes.
     if (isset($users[$user]) && 0 == strcasecmp($users[$user]['password'], $password)) {
         $this->id = $users[$user]['id'];
         if ($remember) {
             setcookie('jzUserID', jz_cookie_encode($this->id), time() + 60 * 60 * 24 * 30);
         }
         $_SESSION['jzUserID'] = jz_cookie_encode($this->id);
         $this->loadSettings();
         writeLogData("access", "user '" . $user . "' logged in successfully.");
         return true;
     } else {
         unset($_SESSION['jzUserID']);
         writeLogData("access", "failed login for user '" . $user . "'.");
         return false;
     }
 }
Exemplo n.º 15
0
/* Session name separate from one used in index.php 
 * This one is embedded in the URL sent in the playlist
 */
session_name('jza');
session_start();
// Let's set the error reporting level
@error_reporting(E_ERROR);
include_once 'system.php';
@(include_once 'settings.php');
include_once 'backend/backend.php';
include_once 'playlists/playlists.php';
include_once 'lib/general.lib.php';
include_once 'lib/jzcomp.lib.php';
include_once 'services/class.php';
$ssid = strip_tags(SID);
writeLogData("as_debug", "mediabroadcast: SID = " . $ssid);
// Let's setup the services
$jzSERVICES = new jzServices();
$jzSERVICES->loadStandardServices();
// Now let's see if we need to split the URL apart
if (isset($_SERVER['PATH_INFO'])) {
    // Ok, now we need to get the variables
    $vars = substr($_SERVER['PATH_INFO'], 1);
    $vArr = explode("&", $vars);
    foreach ($vArr as $item) {
        // Now let's split that out
        $iArr = explode("=", $item);
        // Now let's set the variables
        $_GET[$iArr[0]] = $iArr[1];
    }
}
Exemplo n.º 16
0
/**
 * Passes a command to the jukebox player
 * 
 * @author Ross Carlson
 * @version 2/9/05
 * @since 2/9/05
 * @param $command The command that we passed to the player
 * @param $goBack Should we go back after executing (default is true)
 */
function control($command, $goBack = true)
{
    global $jbArr, $SHOUT_CMD;
    // Now let's execute the command
    switch ($command) {
        case "startsc":
            $cmd = $SHOUT_CMD;
            writeLogData("messages", "Starting Shoutcast with: " . $cmd);
            exec($cmd);
            break;
        case "play":
            return;
            break;
        case "stop":
            return;
            break;
        case "pause":
            return;
            break;
        case "previous":
            return;
            break;
        case "next":
            return;
            break;
        case "volume":
            // Now we have to set the value based on 0-255
            $vol = $_POST['jbvol'];
            return;
            break;
        case "playwhere":
            // Ok, let's set where they are playing
            $_SESSION['jb_playwhere'] = $_POST['jbplaywhere'];
            // Now let's figure out it's ID
            for ($i = 0; $i < count($jbArr); $i++) {
                if ($jbArr[$i]['description'] == $_SESSION['jb_playwhere']) {
                    $_SESSION['jb_id'] = $i;
                }
            }
            break;
        case "jumpto":
            // We need to add 1 so we don't start at 0
            $pos = $_POST['jbjumpto'];
            return;
            break;
        case "clear":
            return;
            break;
        case "random_play":
            return;
            break;
        case "addwhere":
            $_SESSION['jb-addtype'] = $_POST['addplat'];
            break;
    }
    if ($goBack && defined('NO_AJAX_JUKEBOX')) {
        ?>
			<script>
				history.back();
			</script>
			<?php 
    }
}
Exemplo n.º 17
0
/** 
 * Returns the AJAX code for the NSB
 *
 * @author Ross Carlson
 * @since 8.21.05
 *
 **/
function returnNowStreaming()
{
    global $jzUSER, $img_tiny_play, $im_tiny_play_dis, $css, $img_tiny_info, $skin, $root_dir, $include_path, $jzSERVICES, $who_is_where_height;
    $define_only = true;
    //include_once($include_path. $css);
    writeLogData("messages", "NSB: starting up");
    // Now let's figure out the height
    $be = new jzBackend();
    $display = new jzDisplay();
    $tracks = $be->getPlaying();
    $retVal = "";
    $count = 0;
    foreach ($tracks as $sid => $song) {
        // Let's make sure we got data
        if (count($song) != 0) {
            // Now let's setup for our links
            $url_array = array();
            $url_array['jz_path'] = $song['path'];
            $url_array['action'] = "playlist";
            $url_array['type'] = "track";
            $urlArr = array();
            $urlArr['session'] = $sid;
            $urlArr['action'] = "popup";
            $urlArr['ptype'] = "viewcurrentinfo";
            $infoLink = '<a href="' . str_replace("ajax_request", "index", urlize($urlArr)) . '" onclick="openPopup(this, 450, 300); return false;">' . $img_tiny_info . '</a>';
            $arr = array();
            $pArr = explode("/", $song['path']);
            unset($pArr[count($pArr) - 1]);
            $arr['jz_path'] = implode("/", $pArr);
            $songTrack = $display->returnShortName($song['track'], 15);
            /*
            if ($lyricsLink == ""){
            	$songTrack = $display->returnShortName($song['track'],15);
            } else {
            	$songTrack = $display->returnShortName($song['track'],13);
            }
            */
            $track = new jzMediaNode($song['path']);
            $item = $track->getParent();
            if ($item->getPType() == "disk") {
                $item = $item->getParent();
            }
            $album = $item->getName();
            $artParent = $item->getParent();
            $artist = $artParent->getName();
            $art = $item->getMainArt("75x75");
            if ($art) {
                $albumImage = str_replace("'", "\\'", str_replace('"', '', $display->returnImage($art, $album, 75, 75, "limit", false, false, "left", "3", "3")));
            } else {
                $albumImage = "";
            }
            $desc_truncate = 200;
            $desc = htmlentities(str_replace("'", "\\'", str_replace('"', '', $item->getDescription())));
            // Now let's set the title and body
            $title = htmlentities(str_replace("'", "\\'", str_replace('"', '', $artist . " - " . $song['track'])));
            $userName = $song['name'];
            if ($userName == "") {
                $userName = word("Anonymous");
            }
            if ($song['fullname'] != "") {
                $userName = $song['fullname'];
            }
            $body = "<strong>" . word("Streaming to: ") . $userName . "</strong><br>" . $albumImage . $display->returnShortName($desc, $desc_truncate);
            //$albumImage;
            $count++;
            if ($jzUSER->getSetting('stream')) {
                $retVal .= ' <a href="' . str_replace("ajax_request.php", "index.php", urlize($url_array)) . '"';
                if (checkPlayback() == "embedded") {
                    //$jzSERVICES = new jzServices();
                    $jzSERVICES->loadUserServices();
                    $retVal .= ' ' . $jzSERVICES->returnPlayerHref();
                }
                $retVal .= '>' . $img_tiny_play . '</a>' . $infoLink . '<a ' . $display->returnToolTip($body, $title) . ' target="_parent" href="' . str_replace("ajax_request", "index", urlize($arr)) . '">' . $songTrack . '</a><br>';
            } else {
                $retVal .= '' . $img_tiny_play_dis . '' . $infoLink . '<a ' . $display->returnToolTip($body, $title) . ' target="_parent" ' . $title . ' href="' . str_replace("ajax_request", "index", urlize($arr)) . '">' . $songTrack . '</a><br>';
            }
        }
    }
    if ($count == 1 or $count == 0) {
        $tCtr = "";
    } else {
        $tCtr = " (" . $count . ")";
    }
    $retVal = "<strong>" . word("Now Streaming") . $tCtr . "</strong><br />" . $retVal;
    $maxHeight = $who_is_where_height * 13 + 26;
    $style = "";
    if ($maxHeight < $count * 13 + 26) {
        $style = "<style>#whoiswhere{height: " . $maxHeight . "px;overflow:auto;}</style>";
    }
    $return = $style . $retVal;
    writeLogData("messages", "NSB: displaying data");
    echo $retVal;
    exit;
}
Exemplo n.º 18
0
/**
* Returns how long is left in the current track (in seconds)
* 
 * @author Ben Dodson
* @version 9/15/07
* @since 9/15/07
* @return Returns the name of the current playing track
*/
function getCurTrackLocation()
{
    global $jbArr;
    $xml = getStatusXML();
    writeLogData("messages", "VLC: Returning current track location: " . $val);
    return $xml->time;
}
Exemplo n.º 19
0
 }
 // First lets set the art
 if ($pic_data) {
     $meta['pic_data'] = $pic_data;
     $meta['pic_ext'] = $pic_ext;
     $meta['pic_name'] = $pic_name;
     $meta['pic_mime'] = $pic_mime;
 }
 if ($track[$i]->getPath() == "") {
     continue;
 }
 // Ok, now we need to figure out the data from the path
 $path = $track[$i]->getPath();
 $filename = $track[$i]->getDataPath("String");
 if (!fopen($filename, 'r+')) {
     writeLogData("messages", "ERROR: Could not open file for retagging: {$filename}");
     continue;
 }
 $tName = $path[count($path) - 1];
 $fName = $tName;
 // now let's split the exension and number IF it's there
 $tArr = explode(".", $tName);
 unset($tArr[count($tArr) - 1]);
 $tName = implode(".", $tArr);
 if (is_numeric(substr($tName, 0, 2))) {
     $tNum = substr($tName, 0, 2);
     $tName = substr($tName, 3);
     // Now we need to clean off the dashes
     trim($tName);
     if (substr($tName, 0, 1) == "-") {
         $tName = trim(substr($tName, 1));
Exemplo n.º 20
0
 function printCurrentQueue($msg = "")
 {
     $this->queuedTracks = $_SESSION['as_queued_tracks'];
     if (count($this->queuedTracks) == 0) {
         return TRUE;
     }
     writeLogData("as_debug", "\n---{$msg}----------------------------------");
     while (list($timestamp, $track) = each($this->queuedTracks)) {
         writeLogData("as_debug", "Track: " . $track['track'] . " start time: " . $timestamp . " correct stop time: " . $track['stoptime'] . " current: " . time() . " retry: " . $track['retrycnt']);
     }
     writeLogData("as_debug", "\n--------------------------------------------------");
 }
Exemplo n.º 21
0
/**
 * Handle a search query from the GET/POST variables.
 * @author Ben Dodson
 */
function handleSearch($search_string = false, $search_type = false)
{
    global $jzUSER;
    $root =& new jzMediaNode();
    $timer = microtime_float();
    if ($search_string === false) {
        $search_string = $_GET['search_query'];
    }
    if ($search_type === false) {
        $search_type = $_GET['search_type'];
    }
    $string_array = splitKeywords($search_string);
    $keywords = $string_array['keywords'];
    $string = $string_array['search'];
    if (isset($keywords['genres'])) {
        $locations[sizeof($locations)] = 'genre';
        $search_type = "genres";
    }
    if (isset($keywords['artists'])) {
        $locations[sizeof($locations)] = 'artist';
        $search_type = "artists";
    }
    if (isset($keywords['albums'])) {
        $locations[sizeof($locations)] = 'album';
        $search_type = "albums";
    }
    if (isset($keywords['tracks'])) {
        $locations[sizeof($locations)] = 'track';
        $search_type = "tracks";
    }
    if (isset($keywords['lyrics'])) {
        $search_type = "lyrics";
    }
    if (isset($keywords['radio'])) {
        $search_type = "artists";
        $max_res = 1;
    } else {
        if (isset($keywords['limit'])) {
            $max_res = $keywords['limit'];
        } else {
            $max_res = 100;
        }
    }
    switch (strtolower($search_type)) {
        case "all":
            $stype = "both";
            $distance = -1;
            break;
        case "genres":
        case "genre":
            $stype = "nodes";
            $distance = distanceTo("genre");
            break;
        case "artists":
        case "artist":
            $stype = "nodes";
            $distance = distanceTo("artist");
            break;
        case "albums":
        case "album":
            $stype = "nodes";
            $distance = distanceTo("album");
            break;
        case "tracks":
        case "track":
            $stype = "tracks";
            $distance = -1;
            break;
        case "lyrics":
        case "lyric":
            $stype = "lyrics";
            $distance = -1;
            break;
        case "best":
        default:
            $stype = "both";
            $distance = -1;
            $keywords['best'] = true;
    }
    if ($distance === false) {
        die("Could not search for {$search_type}.");
    }
    // Are they searching by ID explicitly?
    if (isset($keywords['id'])) {
        $stype = "id";
        // We handle this differently than above in
        // case they set @genre and @id (or whatever).
    }
    /* if we have 2 locations,
         the closest to the root is our anchor
         and the further is our return type.
      */
    if (sizeof($locations) > 1) {
        if ($locations[1] == 'track') {
            $r = 'tracks';
        } else {
            $r = 'nodes';
        }
        $limit = 1;
        if (isset($keywords['limit'])) {
            $limit = $keywords['limit'];
        }
        $results = $root->search($string, "nodes", distanceTo($locations[0]), 1, 'exact');
        if (sizeof($results) > 0) {
            $results = $results[0]->getSubNodes($r, distanceTo($locations[1], $results[0]), true, $limit);
        } else {
            $results = $root->search($string, "nodes", distanceTo($locations[0]), 1);
            if (sizeof($results) > 0) {
                $results = $results[0]->getSubNodes($r, distanceTo($locations[1], $results[0]), true, $limit);
            }
        }
    } else {
        if (isset($keywords['play']) || isset($keywords['radio'])) {
            $results = $root->search($string, $stype, $distance, 1, 'exact');
            if (sizeof($results) == 0) {
                $results = $root->search($string, $stype, $distance, 1);
                // better to limit 1 or $max_res?
            }
        } else {
            if (isset($keywords['best'])) {
                $results = $root->search($string, $stype, $distance, -1, 'exact');
                if (sizeof($results) == 0) {
                    $results = $root->search($string, $stype, $distance, $max_res);
                    // better to limit 1 or $max_res?
                }
            } else {
                $results = $root->search($string, $stype, $distance, $max_res);
            }
        }
    }
    if (sizeof($results) == 0) {
        // Maybe a search by ID will work...
        $results = $root->search($string, "id", $distance, $max_res);
        if (sizeof($results) == 0) {
            return $results;
        }
    }
    $timer = round(microtime_float() - $timer, 2);
    writeLogData('search', "searched '{$search_type}' for '{$string}' in {$timer} seconds.");
    // What about keywords?
    if (isset($keywords['play']) && sizeof($results) > 0) {
        $pl = new jzPlaylist();
        $pl->add($results);
        //    if (isset($keywords['limit'])) {
        //  $pl->flatten();
        //}
        if (isset($keywords['random'])) {
            $pl = $pl->getSmartPlaylist($max_res);
        } else {
            if (isset($keywords['limit'])) {
                $pl->flatten();
                $pl->truncate($max_res);
            }
        }
        $pl->play();
        exit;
    } else {
        if (isset($keywords['radio'])) {
            $pl = new jzPlaylist();
            $pl->add($results);
            $pl = $pl->getSmartPlaylist(50, "radio");
            $pl->play();
            exit;
        }
    }
    return $results;
}
Exemplo n.º 22
0
 function setHTTPAuthUser()
 {
     global $http_auth_anon_name, $http_auth_auto_create, $http_auth_newuser_template;
     if (isset($_SERVER['REMOTE_USER'])) {
         $username = $_SERVER['REMOTE_USER'];
     } else {
         $username = NOBODY;
     }
     if (isset($http_auth_anon_name) && $username == $http_auth_anon_name) {
         $username = NOBODY;
     }
     if (($this->id = $this->lookupUID($username)) != false) {
         return;
     }
     if (isset($http_auth_auto_create) && $http_auth_auto_create == "true" && $username != NOBODY) {
         // auto-create the user w/ random password
         $this->id = $this->addUser($username, uniqid('P'));
     }
     if ($this->id != false) {
         writeLogData("access", "created user entry for user '" . $username . "'");
         if (isset($http_auth_newuser_template) && $http_auth_newuser_template != "") {
             $be = new jzBackend();
             $classes = $be->loadData('userclasses');
             if (isset($classes[$http_auth_newuser_template])) {
                 $settings = array();
                 $settings['template'] = $http_auth_newuser_template;
                 $this->setSettings($settings, $this->id, true);
             }
         }
         return;
     }
     // convert user to nobody
     if (($this->id = $this->lookupUID(NOBODY)) === false) {
         // create NOBODY
         $this->id = $this->addUser(NOBODY, "");
     }
 }