function download_file($file_id, $file_name) { global $DATA_DIR; $file_path = $DATA_DIR . $file_id; if (file_exists($file_path)) { increment_file_downloads($file_id); $content_type = get_content_type($file_name); header("Content-type: {$content_type}"); $user_agent = $_SERVER['HTTP_USER_AGENT']; if (!is_image($file_name)) { if (is_integer(strpos($user_agent, "msie")) && is_integer(strpos($user_agent, "win"))) { header("Content-Disposition:filename=\"{$file_name}\""); } else { header("Content-Disposition: attachment; filename=\"{$file_name}\""); } header("Content-Description: Download"); } ob_clean(); flush(); readfile($file_path); } else { require_once 'dbo.php'; header("HTTP/1.0 404 Not Found"); echo "<h1>HTTP/1.0 404 Not Found</h1>"; $link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; echo "Sorry, file was not found. Please notify <a href=\"mailto:webmaster@lmms.io" . "?subject=LSP 404&body=FYI: 404 Not Found: {$link}\">webmaster@lmms.io</a> of this error."; } exit; }
/** * Upload main image and thumbnails to CDN. * Remove the local copy */ function upload_images($meta_id, $post_id, $meta_key = '', $meta_value = '') { if ($meta_key == '_wp_attachment_metadata') { // Create new CDN instance if it doesn't exist $_SESSION['cdn'] = isset($_SESSION['cdn']) ? $_SESSION['cdn'] : new RS_CDN(); // Get upload dir $upload_dir = wp_upload_dir(); // Get files to upload $files_to_upload = get_files_to_sync(); // Add original file to array $files_to_upload['upload'][] = array('file_name' => $meta_value['file']); // Upload files foreach ($files_to_upload['upload'] as $cur_file) { // Set file name $cur_file_data = $cur_file; $cur_file = $upload_dir['basedir'] . '/' . $cur_file_data['file_name']; $file_name = $cur_file_data['file_name']; // Upload file to CDN, add to file check try { $_SESSION['cdn']->upload_file($cur_file, $file_name); } catch (Exception $exc) { return false; die; } // Delete file when successfully uploaded, if set if (isset($_SESSION['cdn']->api_settings->remove_local_files) && $_SESSION['cdn']->api_settings->remove_local_files == true) { @unlink($cur_file); } } } if ($meta_key == '_wp_attached_file') { // Create new CDN instance if it doesn't exist $_SESSION['cdn'] = isset($_SESSION['cdn']) ? $_SESSION['cdn'] : new RS_CDN(); // Get upload dir $upload_dir = wp_upload_dir(); $cur_file = $upload_dir['basedir'] . '/' . $meta_value; $file_name = $meta_value; $content_type = get_content_type($cur_file); // Upload file to CDN, add to file check try { $_SESSION['cdn']->upload_file($cur_file, $file_name); } catch (Exception $exc) { return false; die; } // Delete file when successfully uploaded, if set if (isset($_SESSION['cdn']->api_settings->remove_local_files) && $_SESSION['cdn']->api_settings->remove_local_files == true) { if (stripos($content_type, 'image') === false) { @unlink($cur_file); } } } }
/** * Uploads given file attachment onto CDN if it doesn't already exist */ public function upload_file($file_path, $file_name = null, $existing_container = null, $post_id = null) { global $wpdb; // Check if file exists $check_file_name = isset($file_name) ? $file_name : basename($file_path); if (verify_exists($check_file_name)) { return true; } else { // Get ready to upload file to CDN $container = $this->container_object(); $file = $this->file_object($container, $file_path, $file_name); // Upload object if ($this->opencloud_version == '1.10.0') { if ($container->uploadObject($file['file_name'], $file['file_content'])) { return true; } } else { $content_type = get_content_type($file_path); if ($content_type !== false) { if ($file->Create(array('content_type' => $content_type))) { return true; } } else { if ($file->Create()) { return true; } } } } // Upload failed, remove local images if (stripos($file_path, 'http') == 0) { $upload_dir = wp_upload_dir(); $file_path = str_replace($upload_dir['baseurl'], $upload_dir['basedir'], $file_path); unlink($file_path); } else { unlink($file_path); } // Upload failed, remove attachment from db if (isset($post_id)) { $wpdb->query("DELETE FROM {$wpdb->posts} WHERE ID='{$post_id}' AND post_type='attachment'"); $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id='{$post_id}'"); } return false; }
function setup_module($column, $moduleName, $obj) { global $content_type, $users, $uid, $_GET, $user; switch ($column) { case 'left': $obj->mode = PRI; if ($moduleName != 'LogoModule') { $obj->block_type = HOMEPAGE; } if ($moduleName == 'RecentCommentsModule') { $obj->cid = $_REQUEST['cid']; $obj->block_type = HOMEPAGE; $obj->mode = PRI; } break; case 'middle': $obj->content_id = @$_REQUEST['cid']; $obj->mode = PUB; $obj->uid = $_SESSION['user']['id']; $obj->type = get_content_type(@$_GET['type']); $obj->block_type = 'media_management'; $obj->Paging["page"] = 1; $obj->Paging["show"] = 10; break; case 'right': $obj->mode = PRI; break; } }
$item['sparkle:releaseNotesLink'] = curPageURL() . '&echo=' . urlencode($item['description']); } } unset($item['description']); } // The publish date if (isset($item['pubDate'])) { $item['pubDate'] = parse_date($item['pubDate']); } // Filesize and content type $cacheid = $item['enclosure']['_params']['url']; if (isset($item['enclosure']['_params']['type']) && isset($item['enclosure']['_params']['length'])) { // } elseif (!isset($data['cache'][$cacheid])) { $headers = get_remote_headers($item['enclosure']['_params']['url']); $type = get_content_type($headers); $length = get_content_length($headers); if (!$headers) { appcastr_die('Appcastr can\'t make a connection to <code>' . $item['enclosure']['url'] . '</code>, or the file doesn\'t exist.'); } else { $item['enclosure']['_params']['type'] = $type; $item['enclosure']['_params']['length'] = $length; $data['cache'][$cacheid] = array('type' => $type, 'length' => $length); } } elseif (isset($data['cache'][$cacheid])) { $item['enclosure']['_params']['type'] = $data['cache'][$cacheid]['type']; $item['enclosure']['_params']['length'] = $data['cache'][$cacheid]['length']; } // Still no content type? if (!isset($item['enclosure']['_params']['type'])) { $item['enclosure']['_params']['type'] = 'application/octet-stream';
function blog_atom_entry($blog) { global $config; $summary = $blog['description']; if ($config['local_alternates']) { $blog['url'] = slinkto("blog_search.php", array(), array("blog_id" => $blog['blog_id'])); } $image = ""; $default_image_pattern = "/default\\.png/i"; if ($blog['image'] && !preg_match($default_image_pattern, $blog['image'])) { $image = sprintf("<link rel='related' title='portrait' type='%s' href='%s%s'/>", get_content_type($blog['image']), $config['base_url'], $blog['image']); } $summary = make_var_atom_safe($summary); $blog = make_array_atom_safe($blog); $return .= "\n<entry>\n\t<title><![CDATA[" . strip_tags($blog['title']) . "]]></title>\n\t<link rel='alternate' href=\"" . $blog['url'] . "\"/>\n\t{$image}\n\t<id>" . slinkto("blog_search.php", array(), array("blog_id" => $blog['blog_id'])) . "</id>\n\t<updated>" . atom_date($blog['added_on']) . "</updated>\n\t<summary><![CDATA[{$summary}]]></summary>\n\t<gd:rating value='" . $blog['incoming_bloglove'] . "' min='0' max='1000'/>\n</entry>\n"; return $return; }
<?php require_once 'log.php'; require_once 'proxy-pass.php'; jsondb_logger_init('dangdang'); forward(function (&$url, &$data_to_post, &$headers) { }, function ($info, &$headers, &$body) { $url = $info['url']; $body = preg_replace('/(<body.*?>)/i', '$1<img src=\\"http:\\/\\/www.doctorcom.com\\/statics\\/images\\/style2012\\/logo.jpg\\" \\/>\\n', $body, 1); jsondb_logger('nofity', 'REP ' . get_content_type($headers), ['url' => $url, 'info' => $info, 'headers' => $headers, 'ori_body' => $body, 'body' => json_decode($body, true)]); });
} exit; } } else { if (isset($_POST['submit']) && $_POST['content_type'] != 'media' && !Group::member_exists((int) $_REQUEST['gid'], (int) $login_uid)) { $group_top_mesg = "You are not a member of " . stripslashes($group->title) . " group."; } } } if (!empty($_GET['post_type'])) { $post_type = $_GET['post_type']; } else { $post_type = 'all'; } $content_type = NULL; $content_type = get_content_type($post_type); //////////code for join or leave the group if (@$_GET['action'] == 'join' && $login_uid) { if (!Group::member_exists((int) $_REQUEST['gid'], (int) $login_uid)) { try { $x = $group->join((int) $login_uid, $_SESSION['user']['email'], $group_invitation_id); //for rivers of people $activity = 'group_joined'; //for rivers of people $activity_extra['info'] = $login_name . ' joined a new group'; $activity_extra['group_name'] = $group->title; $activity_extra['group_id'] = $_REQUEST['gid']; $extra = serialize($activity_extra); $object = $_REQUEST['gid']; Activities::save($login_uid, $activity, $object, $extra, $activities_array);
function ldRegisterFile($field = "file", &$error) { global $ARnls, $store; require_once $store->get_config("code") . "modules/mod_mimemagic.php"; $result = array(); $http_post_file = array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => '', 'size' => ''); $subfields = explode('[', $field); $field = array_shift($subfields); $subfield = false; foreach ($http_post_file as $key => $value) { $value =& $_FILES[$field][$key]; foreach ($subfields as $subfield) { $subfield = substr($subfield, 0, -1); $value =& $value[$subfield]; } $http_post_file[$key] = $value; } if ($subfield) { $field = $subfield; } if ($http_post_file['error']) { switch ($http_post_file['error']) { case UPLOAD_ERR_INI_SIZE: $error = $ARnls['ariadne:err:upload_ini_size']; // "The uploaded file exceeds the upload_max_filesize directive in php.ini"; break; case UPLOAD_ERR_FORM_SIZE: $error = $ARnls['ariadne:err:upload_form_size']; // The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"; break; case UPLOAD_ERR_PARTIAL: $error = $ARnls['ariadne:err:upload_partial']; // "The uploaded file was only partially uploaded"; break; case UPLOAD_ERR_NO_FILE: // Note: this is not an error //$error = $ARnls['ariadne:err:upload_no_file']; // No file was uploaded"; break; case UPLOAD_ERR_NO_TMP_DIR: $error = $ARnls['ariadne:err:upload_no_tmp_dir']; // "Missing a temporary folder"; break; case UPLOAD_ERR_CANT_WRITE: $error = $ARnls['ariadne:err:upload_cant_write']; // "Failed to write file to disk"; break; case UPLOAD_ERR_EXTENSION: $error = $ARnls['ariadne:err:upload_extension']; // "File upload stopped by extension"; break; default: $error = sprintf($ARnls['ariadne:err:upload_error'], $http_post_file['error']); // "Unknown upload error %s"; break; } return $result; } $file_temp = $http_post_file['tmp_name']; $file = $http_post_file['name']; if ($file && is_uploaded_file($file_temp)) { // new file uploaded -> save it before PHP deletes it $file_artemp = tempnam($store->get_config("files") . "temp", "upload"); if (move_uploaded_file($file_temp, $file_artemp)) { // now make the new values available to wgWizKeepVars() $result[$field] = $file; $result[$field . "_temp"] = basename($file_artemp); $result[$field . "_size"] = (int) $http_post_file['size']; $type = get_mime_type($file_artemp); $ext = substr($file, strrpos($file, '.')); if (!$type) { $type = get_mime_type($file, MIME_EXT); } $result[$field . "_type"] = get_content_type($type, $ext); } } return $result; }
<?php require_once 'log.php'; require_once 'proxy-pass.php'; jsondb_logger_init('yihaodian'); forward(function (&$url, &$data_to_post, &$headers) { }, function ($info, &$headers, &$body) { $url = $info['url']; $body = preg_replace('/(<img.*?")/i', '<img align="absMiddle" src="http://www.doctorcom.com/statics/images/style2012/logo.jpg"$1', $body, 1); jsondb_logger('nofity', 'REP ' . get_content_type($headers), ['url' => $url, 'info' => $info, 'headers' => $headers, 'body' => $body]); });
/** * Function : setup_module() * Purpose : call back function to set up variables * used in PageRenderer class * To see how it is used see api/PageRenderer/PageRenderer.php * @param $column - string - contains left, middle, right * position of the block module * @param $moduleName - string - contains name of the block module * @param $obj - object - object reference of the block module * @return type string - returns skip means skip the block module * returns rendered html code of block module */ function setup_module($column, $module, $obj) { global $network_info, $paging; $user_name = PA::$page_user->login_name; switch ($module) { case 'EventCalendarSidebarModule': $obj->assoc_id = PA::$page_uid; $obj->assoc_type = "user"; // this is the personal calendar if (PA::$login_uid != PA::$page_uid) { $obj->may_edit = false; } else { $obj->may_edit = true; } break; case 'UserPhotoModule': $obj->block_type = 'UserPhotoBlock'; $obj->uid = PA::$page_uid; break; case 'ImagesModule': PA::$page_uid == PA::$login_uid ? $obj->title = 'My Gallery' : ($obj->title = sprintf(__("%s's Gallery"), ucfirst($user_name))); $obj->uid = PA::$page_uid; break; case 'AboutUserModule': $obj->mode = PUB; $obj->title = 'About:'; $obj->block_type = 'AboutUser'; $obj->uid = PA::$page_uid; break; case 'FlickrModule': $obj->block_type = 'UserPhotoBlock'; $obj->uid = PA::$page_uid; break; case 'RelationsModule': PA::$page_uid == PA::$login_uid ? $obj->title = 'My Relations' : ($obj->title = sprintf(__("%s's Relations"), ucfirst($user_name))); $obj->uid = PA::$page_uid; break; case 'MyNetworksModule': PA::$page_uid == PA::$login_uid ? $obj->title = 'My Networks' : ($obj->title = sprintf(__("%s's Networks"), ucfirst($user_name))); $obj->uid = PA::$page_uid; break; case 'MyLinksModule': PA::$page_uid == PA::$login_uid ? $obj->title = 'My Links' : ($obj->title = sprintf(__("%s's Links"), ucfirst($user_name))); $obj->uid = PA::$page_uid; break; case 'MyGroupsModule': $obj->block_type = 'usergroups'; $obj->uid = PA::$page_uid; PA::$page_uid == PA::$login_uid ? $obj->title = 'My Groups' : ($obj->title = sprintf(__("%s's Groups"), ucfirst($user_name))); break; case 'InRelationModule': $status = null; $extra = unserialize($network_info->extra); if ($extra['reciprocated_relationship'] == NET_YES) { $status = APPROVED; // If the network operator has enabled reciprocated relationships, show only approved friends, otherwise all friends will be listed. } $relations_ids = Relation::get_all_user_ids((int) PA::$page_uid, 6, $cnt = FALSE, $show = 'ALL', $page = 0, $sort_by = 'created', $direction = 'DESC', $status); $obj->user_name = PA::$page_user->first_name; $obj->uid = PA::$page_uid; $obj->links = $relations_ids; break; case 'RecentCommentsModule': PA::$page_uid == PA::$login_uid ? $obj->title = 'My Comments' : ($obj->title = sprintf(__("%s's Comments"), ucfirst($user_name))); $obj->block_type = 'usercomments'; $obj->uid = PA::$page_uid; break; case 'ShowContentModule': global $post_type_message; if (!empty($_GET['post_type'])) { $post_type = $_GET['post_type']; } else { $post_type = 'all'; } $content_type = get_content_type($post_type); $obj->cid = @$_GET['cid']; $obj->mode = PUB; $obj->block_type = HOMEPAGE; $obj->content_type = $content_type; $obj->uid = PA::$page_uid; $obj->block_heading = sprintf(__("%s's Blog"), PA::$page_user->first_name); $obj->message = $post_type_message[$post_type]; $obj->Paging["page"] = 1; $obj->Paging["show"] = 10; break; case 'LinkModule': $delicious_id = PA::$page_user->get_profile_field('external', 'delicious'); if (!$delicious_id) { return "skip"; } $obj->block_type = 'UserPhotoBlock'; $obj->delicious_id = $delicious_id; $obj->title = 'Delicious'; break; case 'ProfileFeedModule': $profile_feeds = UserProfileFeed::get_user_profile_feeds(PA::$page_uid, PA::$login_uid); if (empty($profile_feeds)) { return 'skip'; } $obj->profile_feeds = $profile_feeds; $obj->title = PA::$page_user->first_name . "'s " . $obj->title; break; case 'ShowTestimonialModule': //FIXME: probably querying testimonials at least twice here - //once to determine whether to skip, and once or more inside //ShowTestimonialModule. $count_testimonial = Testimonials::count_testimonials(PA::$page_uid, APPROVED); if ($count_testimonial == 0) { return 'skip'; } $obj->testimonial_status = APPROVED; $obj->title = ucfirst(PA::$page_user->first_name) . "'s testimonials"; $obj->mode = PUB; $obj->Paging["page"] = $paging["page"]; $obj->Paging["show"] = 3; break; case 'ShowUserCommentModule': //FIXME: probably querying comments at least twice here - once to //determine whether to skip, and once or more inside //ShowUserCommentModule to actually get the comments. $count_comment = Comment::count_comment(PA::$page_uid, TYPE_USER); if ($count_comment == 0) { return 'skip'; } $obj->Paging["page"] = $paging["page"]; $obj->Paging["show"] = 3; $obj->title = 'Comments for ' . ucfirst(PA::$page_user->first_name); break; } }
function forward($cb_before = null, $cb_after = null, $url = '') { //生成url if ($url === '') { $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } else { if (!preg_match("/https?:/i", $url)) { if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $url = "https://" . $_SERVER['HTTP_HOST'] . "/" . ltrim($url, "/"); } else { $url = "http://" . $_SERVER['HTTP_HOST'] . "/" . ltrim($url, "/"); } } } //获取转发需要的头内容 $headers = get_request_headers(); //转发POST内容 $data_to_post = null; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (in_array(get_content_type($headers), array('application/x-www-form-urlencoded', 'multipart/form-data'))) { $data_to_post = $_POST; } else { //就抓出原始的post数据即可 $fp = fopen('php://input', 'r'); $post = stream_get_contents($fp); fclose($fp); $data_to_post = $post; } } if ($cb_before) { call_user_func_array($cb_before, [&$url, &$data_to_post, &$headers]); } //初始化curl选项 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_TIMEOUT, REQUEST_TIMEOUT); //将生成的头,设置在curl中 set_request_headers($ch, $headers); //设置POST数据 if ($data_to_post) { set_post($ch, $data_to_post); } //执行curl请求 //要防止长连接用这种方法 fixme $data = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); //获取返回的body内容 $body = $info["size_download"] ? substr($data, $info["header_size"], $info["size_download"]) : ""; $headers_str = substr($data, 0, $info["header_size"]); $headers = get_response_headers($headers_str); if ($cb_after) { $encoding = get_content_encoding($headers); $body_str = $body; if ($encoding === 'deflate') { $body_str = gzinflate($body); } if ($encoding === 'gzip') { $body_str = gzdecode($body); } //调用过滤钩子,检测是否有修改内容 $old_md5 = md5($body_str); call_user_func_array($cb_after, [$info, &$headers, &$body_str]); $new_md5 = md5($body_str); //如果内容有修改,则需要从新打包,和计算内容长度 if ($old_md5 !== $new_md5) { switch ($encoding) { case 'deflate': $body = gzdeflate($body_str); break; case 'gzip': $body = gzencode($body_str); break; default: $body = $body_str; } //修正发出的内容长度 $headers = set_content_length($headers, strlen($body)); } } //转发返回的头内 set_response_headers($headers); //输出html内容到浏览器 echo $body; //函数返回结果给缓存使用 return [$headers, $body]; }
public function initializeModule($request_method, $request_data) { global $error_msg, $post_type_message, $paging; $this->request_data = $request_data; $content_type = NULL; if (!empty($request_data['post_type'])) { $post_type = $request_data['post_type']; } else { $post_type = 'all'; } $content_type = get_content_type($post_type); if (!empty($this->shared_data['ShowContentModule']['show'])) { $this->Paging["show"] = $this->shared_data['ShowContentModule']['show']; } else { $this->Paging["show"] = 10; } if (!empty($this->shared_data['ShowContentModule']['page'])) { $this->Paging["page"] = $this->shared_data['ShowContentModule']['page']; } else { $this->Paging["page"] = 1; } if (!empty($this->shared_data['ShowContentModule']['hide_paging'])) { $this->do_pagination = false; } else { $this->do_pagination = true; } if (!empty($this->shared_data['group_info'])) { $this->type = 'group'; $group = $this->shared_data['group_info']; $member_type = $this->shared_data['member_type']; if (PA::$login_uid) { if ($group->reg_type == REG_INVITE && $member_type == NOT_A_MEMBER) { $error_msg = 9005; return "skip"; } } else { if ($group->reg_type == REG_INVITE) { $error_msg = 9005; return "skip"; } } $this->content_type = $content_type; $this->group = $group; $this->gid = $request_data['gid']; $this->message = $post_type_message[$post_type]; $this->block_heading = 'Group Blog'; $this->title = 'Group Blog'; $this->Paging["page"] = $paging["page"]; // $this->Paging["show"] = 10; } if (!empty($this->shared_data['network_info'])) { $this->cid = isset($request_data['cid']) ? $request_data['cid'] : null; $this->mode = PUB; $this->block_type = HOMEPAGE; $this->content_type = $content_type; $this->uid = 0; $this->message = $post_type_message[$post_type]; // This message array is defined in config.inc $this->Paging["page"] = $paging["page"]; // $this->Paging["show"] = 10; } if (!empty($this->shared_data['search_data'])) { $error_msg = null; $this->type = "search"; $this->search_string_array = $this->buildSearchStringArray($this->shared_data['search_data'], $request_data); if ($error_msg) { return "skip"; } $this->show_filters = TRUE; /* $this->Paging["page"] = $paging["page"]; $this->Paging["show"] = 5; */ } if (!empty($this->shared_data['user_info'])) { $user = $this->shared_data['user_info']; if (empty(PA::$config->simple['use_simpleblog'])) { $data_profile = $this->shared_data['user_profile']; if (count($data_profile) == 0) { return 'skip'; } if ($data_profile[0]->field_value == BLOG_SETTING_STATUS_NODISPLAY || $data_profile[0]->field_value == EXTERNAL_BLOG_SETTING_STATUS) { return 'skip'; } } $this->cid = !empty($request_data['cid']) ? $request_data['cid'] : null; $this->mode = $this->page_id == PAGE_USER_PRIVATE ? PRI : PUB; $this->content_type = $content_type; $this->block_type = HOMEPAGE; $this->type = 'user'; $this->uid = $user->user_id; $this->orientation = CENTER; $this->message = $post_type_message[$post_type]; $this->Paging['page'] = $paging['page']; // $this->Paging["show"] = 10; $this->title = $user->first_name . '\'s Blog'; $this->block_heading = $user->first_name . '\'s Blog'; } }
function make_headers($error_code = 200, $URL, $script_output = "") { global $SERVER; $extra_lines = array(); $code_override = false; if ($script_output != null) { $tmp = explode("<<HEADER_BREAK>>", $script_output); $header_lines = explode("<<HEADER_LINE_BREAK>>", $tmp[1]); foreach ($header_lines as $line) { if (strlen($line) > 0) { $extra_lines[] = $line; if (strpos($line, "Location:") !== false) { $code_override = "301 Moved Permanently\r\n"; } } } } $out = "HTTP/1.0 "; if ($code_override != false) { $out .= $code_override; } else { if ($error_code == 400) { $out .= "400 Bad Request\r\n"; } elseif ($error_code == 403) { $out .= "403 Forbidden\r\n"; } elseif ($error_code == 404) { $out .= "404 Not Found\r\n"; } elseif ($error_code == 500) { $out .= "500 Internal Server Error\r\n"; } elseif ($error_code == 501) { $out .= "501 Not Implemented\r\n"; } else { $out .= "200 OK\r\n"; } } $out .= "Expires: -1\r\n"; $out .= "Cache-Control: private, max-age=0\r\n"; $out .= "Connection: close\r\n"; $out .= "Server: DaveServer\r\n"; $out .= "Content-Type: " . get_content_type($URL) . "\r\n"; foreach ($extra_lines as $line) { $out .= $line . "\r\n"; } return $out; }
$image_ext = array("jpg", "gif", "png", "tif", "bmp", "jpeg", "tiff"); $archive_ext = array("zip", "rar", "cbz", "cbr"); $allows = array_merge($image_ext, $archive_ext); ini_set('default_charset', $target_encoding); $request_uri = $_SERVER['REQUEST_URI']; $request_path = parse_url($request_uri, PHP_URL_PATH); $request_path = urldecode($request_path); debug("request_path: " . $request_path); $path = $parent_path . $request_path; debug("path: " . $path); if (is_dir($path)) { list_dir($path); } else { $path_parts = pathinfo($path); $ext = strtolower($path_parts['extension']); $type = get_content_type($ext); if (is_in_zip($path, $ext)) { process_file_in_zip($path, $type); } else { if (is_in_rar($path, $ext)) { process_file_in_rar($path, $type); } else { if (in_array($ext, $image_ext)) { process_image($path, $type); } else { if ($ext == "zip" || $ext == "cbz") { process_zip($path); } else { if ($ext == "rar" || $ext == "cbr") { process_rar($path); } else {