require_once $prefix . '/lib/rating.lib.php'; } /* Set a new Error Handler */ $old_error_handler = set_error_handler('ampache_error_handler'); /* Check their PHP Vars to make sure we're cool here */ $post_size = @ini_get('post_max_size'); if (substr($post_size, strlen($post_size) - 1, strlen($post_size)) != 'M') { /* Sane value time */ ini_set('post_max_size', '8M'); } // In case the local setting is 0 ini_set('session.gc_probability', '5'); if (!isset($results['memory_limit']) || UI::unformat_bytes($results['memory_limit']) < UI::unformat_bytes('32M')) { $results['memory_limit'] = '32M'; } set_memory_limit($results['memory_limit']); /**** END Set PHP Vars ****/ // If we want a session if (!defined('NO_SESSION') && AmpConfig::get('use_auth')) { /* Verify their session */ if (!Session::exists('interface', $_COOKIE[AmpConfig::get('session_name')])) { Auth::logout($_COOKIE[AmpConfig::get('session_name')]); exit; } // This actually is starting the session Session::check(); /* Create the new user */ $GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']); /* If the user ID doesn't exist deny them */ if (!$GLOBALS['user']->id && !AmpConfig::get('demo_mode')) { Auth::logout(session_id());
} // Allow lots of memory function set_memory_limit() { global $Opt; if (!@$Opt["memoryLimit"]) { $suf = array("" => 1, "k" => 1 << 10, "m" => 1 << 20, "g" => 1 << 30); if (preg_match(',\\A(\\d+)\\s*([kmg]?)\\z,', strtolower(ini_get("memory_limit")), $m) && $m[1] * $suf[$m[2]] < 128 << 20) { $Opt["memoryLimit"] = "128M"; } } if (@$Opt["memoryLimit"]) { ini_set("memory_limit", $Opt["memoryLimit"]); } } set_memory_limit(); // Create the conference // XXX more modern method if (isset($Opt["dbName"])) { if (!isset($Opt["sessionName"])) { $Opt["sessionName"] = $Opt["dbName"]; } if (!isset($Opt["downloadPrefix"])) { $Opt["downloadPrefix"] = $Opt["dbName"] . "-"; } } global $Conf; if (!@$Conf) { $Conf = new Conference(Dbl::make_dsn($Opt)); } if (!$Conf->dblink) {
break; case 'video': $media_ids[] = array('object_type' => 'Video', 'object_id' => $media_id); break; } // switch on type } // foreach media_id $name = 'Batch-' . date("dmY", time()); default: // Rien a faire break; } // action switch } if (!User::stream_control($media_ids)) { debug_event('UI::access_denied', 'Stream control failed for user ' . $GLOBALS['user']->username, '3'); UI::access_denied(); exit; } // Write/close session data to release session lock for this script. // This to allow other pages from the same session to be processed // Do NOT change any session variable after this call session_write_close(); // Take whatever we've got and send the zip $song_files = get_media_files($media_ids); if (is_array($song_files['0'])) { set_memory_limit($song_files['1'] + 32); send_zip($name, $song_files['0']); } exit;