فهرست منبع

clean the gh-pages dir

slacken 13 سال پیش
والد
کامیت
4684f8cdfe
10فایلهای تغییر یافته به همراه0 افزوده شده و 279 حذف شده
  1. 0 4
      README.md
  2. 0 0
      assets/style.css
  3. 0 9
      config.yaml
  4. 0 105
      include/controller.php
  5. 0 10
      include/lib.php
  6. 0 15
      include/start.php
  7. 0 40
      include/storage.php
  8. 0 32
      include/view.php
  9. 0 53
      index.php
  10. 0 11
      views/welcome.php

+ 0 - 4
README.md

@@ -1,4 +0,0 @@
-##利用SAE来做CDN
-
-
-更多说明档以后加上...

+ 0 - 0
assets/style.css


+ 0 - 9
config.yaml

@@ -1,9 +0,0 @@
-name: mysaecdn
-version: 1
-handle:
-- compress: if ( out_header["Content-type"]=="text/html" ) compress
-- compress: if ( out_header["Content-type"]=="text/javascript" ) compress
-- compress: if ( out_header["Content-type"]=="text/css" ) compress
-- compress: if ( out_header["Content-type"]=="image/jpeg" ) compress
-- compress: if ( out_header["Content-type"]=="image/png" ) compress
-- rewrite: if ( !is_dir() && !is_file() && path ~ "^(.*)$" ) goto "index.php?q=$1"

+ 0 - 105
include/controller.php

@@ -1,105 +0,0 @@
-<?php
-
-if ( ! defined('BASE_PATH')) exit('No direct script access allowed');
-
-class controller{
-	
-	public $content_type;
-	
-	public $succeed ;
-	
-	public $error_type;
-	
-	public function __construct($request = ''){
-		
-		$this->content_type = 'text/plain';
-		$this->error_type = 0;
-		$this->succeed = TRUE;
-		
-		$request = ltrim($request,'/');
-		
-		//是否为SAE环境
-		if(!IS_SAE || !class_exists('SaeStorage')){//
-			$this->error_type = 2;
-			$this->succeed = FALSE;
-		}
-		
-		//请求为空
-		elseif($request === ''){
-			
-			//显示欢迎页面
-			if(WELCOME_DOC){
-				view::show('welcome');
-				return ;
-			}else{
-				$this->error_type = 1;
-				$this->succeed = FALSE;
-			}
-		}
-		
-		else{
-			//匹配文件后缀
-			$temp = array();
-			if(preg_match('/\.(jpg|jpeg|png|pdf|gif|css|js|zip)$/i', $request,$temp)===1){//暂时先就这几种
-				//http://en.wikipedia.org/wiki/Internet_media_type#List_of_common_media_types
-				switch($temp[1]){
-					case 'jpg':{$this->content_type="image/jpeg";}break;
-					case 'gif':{$this->content_type="image/gif";}break;
-					case 'png':{$this->content_type="image/png";}break;
-					case 'css':{$this->content_type="text/css";}break;
-					case 'js':{$this->content_type="text/javascript";}break;
-				}
-			}
-		}
-		
-		//开始处理
-		$this->handle($request);
-		
-	}
-	/**
-	 * 获取内容并输出
-	 * 如果stroage里面不存在,则从URL里面获取
-	 * */
-	private function handle($filename){
-		$content = '';
-		if($this->succeed){
-			$storage = new storage();
-			if($storage->exists($filename)){
-				$content = $storage->read($filename);
-			}else{
-				$content = @file_get_contents(BASE_URL.$filename);
-				$storage->write($filename, $content);
-			}
-			if(empty($content)){
-				$this->error_type = 3;
-				$this->succeed = FALSE;
-			}
-		}
-		//显示内容
-		$this->render($content);
-	}
-	
-	
-	/**
-	 * 输出结果,包括缓存控制等
-	 * */
-	private function render($content=''){
-		if(!$this->succeed){
-			$this->error();
-			return ;
-		}else{
-			header("Expires: " . date("D, j M Y H:i:s GMT", time()+2592000));//缓存一月
-			header('Content-type: '.$this->content_type);
-			echo $content;
-		}
-	}
-	
-	/**
-	 * 处理错误
-	 * */
-	private function error(){
-		echo "<strong>something seems wrong.</strong>";
-	}
-	
-	
-}

+ 0 - 10
include/lib.php

@@ -1,10 +0,0 @@
-<?php
-if ( ! defined('BASE_PATH')) exit('No direct script access allowed');
-/**
- * 公共函数
- * */
-class lib{
-	
-	
-
-}

+ 0 - 15
include/start.php

@@ -1,15 +0,0 @@
-<?php
-//
-if ( ! defined('BASE_PATH')) exit('No direct script access allowed');
-
-/**
- * 自动加载
- * */
-function includeloader($class){
-	$path = BASE_PATH."include/{$class}.php";
-	if (is_readable($path)) require $path;
-}
-
-spl_autoload_register('includeloader');
-
-new controller(isset($_GET['q'])?$_GET['q']:'');

+ 0 - 40
include/storage.php

@@ -1,40 +0,0 @@
-<?php
-
-if ( ! defined('BASE_PATH')) exit('No direct script access allowed');
-
-/**
- * 封装SAE storage
- * */
-class storage{
-	
-	public $instance;
-	
-	public $domain;
-	
-	public function __construct(){
-		
-		$this->domain = DOMAIN;
-		$this->instance = new SaeStorage(SAE_ACCESSKEY,SAE_SECRETKEY);
-	}
-	
-	public function exists($filename){
-		return $this->instance->fileExists($this->domain,$filename);
-	}
-	//这里是效率瓶颈啊!!
-	public function read($filename){
-		return $this->instance->read($this->domain,$filename);
-	}
-	
-	public function write($name,$content){
-		return $this->instance->write($this->domain,$name,$content);
-	}
-	
-	public function url($name){
-		return $this->instance->getUrl($this->domain,$name);
-	}
-	
-	public function error(){
-		return $this->instance->error();
-	}
-	
-}

+ 0 - 32
include/view.php

@@ -1,32 +0,0 @@
-<?php
-
-if ( ! defined('BASE_PATH')) exit('No direct script access allowed');
-
-class view{
-	
-    public function __construct(){
-        ob_start();
-    }
-    
-    public function render(){}
-    
-    public function finish(){
-        $content = ob_get_clean();
-        return $content;
-    }
-    
-    /**
-     * 直接显示
-     * */
-	public static function show($page, $data = array()){
-		$page = BASE_PATH.'views/'.trim($page,'/').'.php';
-		if(is_readable($page)){
-			ob_start();
-			
-	    	include $page;
-	    	ob_end_flush();
-		}
-	}
-	
-}
-?>

+ 0 - 53
index.php

@@ -1,53 +0,0 @@
-<?php
-
-
-/**
- * 设置源静态文件的根目录的URL地址
- * */
-define('STATIC_URL','http://www.baidu.com/');
-
-/**
- * SAE storage的domain
- * */
-define('DOMAIN','cdn');
-
-/**
- * 空请求时是否显示文档
- * */
-define('WELCOME_DOC',TRUE);
-
-/**
- * 运行环境:development/testing/production
- * */
-define('ENVIRONMENT','development');
-
-//========================================================
-
-
-if (defined('ENVIRONMENT'))
-{
-	switch (ENVIRONMENT)
-	{
-		case 'development':
-			error_reporting(E_ALL);
-		break;
-	
-		case 'testing':
-		case 'production':
-			error_reporting(0);
-		break;
-
-		default:
-			exit('The application environment is not set correctly.');
-	}
-}
-
-//本地根目录
-define('BASE_PATH',dirname(__FILE__).'/');
-
-define('BASE_URL', rtrim(STATIC_URL,'/').'/');
-
-define('IS_SAE', defined('SAE_SECRETKEY'));
-
-require_once BASE_PATH.'include/start.php';
-

+ 0 - 11
views/welcome.php

@@ -1,11 +0,0 @@
-<?php if ( ! defined('BASE_PATH')) exit('No direct script access allowed');?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>说明文档</title>
-</head>
-<body>
-这是说明文档啦!!稍候奉上
-</body>
-</html>