コード例 #1
0
ファイル: Webpage.php プロジェクト: 119155012/kals
 protected function _set_field_filter($cond)
 {
     if (is_array($cond) && array_key_exists('url', $cond)) {
         $cond['uri'] = parse_uri($cond['url']);
         $this->_CI_load('library', 'kals_resource/Domain');
         //$domain = new Domain();
         //$cond['domain_id'] = $domain->filter_domain_id($cond['url']);
         $cond['domain_id'] = $this->CI->domain->filter_domain_id($cond['url']);
     }
     return $cond;
 }
コード例 #2
0
ファイル: ut_kals_helper.php プロジェクト: 119155012/kals
 function test()
 {
     $this->load->library('unit_test');
     //$test = 1 + 1;
     //$expected_result = 2;
     //$test_name = 'Adds one plus one';
     //$this->unit->run($test, $expected_result, $test_name);
     $this->load->helper('kals');
     $this->unit->run(get_referer_url(), 'http://localhost/CodeIgniter_1.7.2/unit_test', '取得參考的網址!' . get_referer_url());
     $this->unit->run(parse_host(get_referer_url()), $this->host, '取得參考的HOST!' . parse_host());
     $this->unit->run(parse_uri('http://localhost/CodeIgniter_1.7.2/index.php/ut_misc/ut_kals_helper/test'), '/CodeIgniter_1.7.2/index.php/ut_misc/ut_kals_helper/test', '取得參考的URI!' . parse_uri());
     $this->unit->run(url_is_link('http://images.plurk.com/1422855_79bdc93f1317c2a7b8c9f0c5d51586c9.jpg'), TRUE, '確認是否是連結');
     $this->unit->run(url_is_image('http://images.plurk.com/1422855_79bdc93f1317c2a7b8c9f0c5d51586c9.jpg'), TRUE, '確認是否是圖片');
     $this->unit->run(url_is_link('http://www.plurk.com/p/5u89gi#response-1629050986'), TRUE, '確認是否是連結');
     $this->unit->run(url_is_image('http://www.plurk.com/p/5u89gi#response-1629050986'), FALSE, '確認是否是圖片');
     $this->unit->run(parse_email_name('*****@*****.**'), 'puddingchen.35', '取出email的名字');
     $this->unit->run(retrieve_title('http://www.plurk.com/p/5uuz7o#response-1632175301'), 'JS布丁 正在 [CODING D2] http://www.youtube.com/watch?v=c8I_WPonFHE  進度:2/182 - #5uuz7o', '取得網頁的title');
     $data = array('title' => get_class($this), 'unit' => $this->unit);
     $this->load->view('misc/unit_test', $data);
 }
コード例 #3
0
ファイル: ut_annotation.php プロジェクト: 119155012/kals
 function index()
 {
     $url = 'http://www.plurk.com/p/67k6st#response-1739920625';
     $text1 = '[CODING D17] 晚上睡覺時天氣、室溫、冷氣、電扇、被子的厚度與蓋的方法,組合起來就可以預測隔天會不會一整天過敏。但我還沒有明顯地分辨出他們的關聯。';
     $text2 = '變項太多,這回歸的組合也不知道要排到什麼時候orz';
     $note = '「西瓜牛奶去冰的話可能沒有滿杯喔」由於店員這樣說,所以我改口跟他說不用去冰好了……結果還是一樣沒有滿杯orz';
     $email = '*****@*****.**';
     $email_siroma = '*****@*****.**';
     $scope1 = $this->annotation_scope->create_scope(3, 20, $text1, $url);
     $scope2 = $this->annotation_scope->create_scope(26, 40, $text2, $url);
     $scope_coll = new Annotation_scope_collection();
     $scope_coll->add_scope($scope1);
     $scope_coll->add_scope($scope2);
     $len = $scope_coll->get_scope_length();
     $user = $this->user->create_user($url, $email);
     $user_siroma = $this->user->create_user($url, $email_siroma);
     $annotation = $this->annotation->create_annotation($user, $scope_coll);
     $this->unit->run($annotation->get_id(), 9999, '是否有正確地存入資料庫?');
     $scope_coll2 = $annotation->get_scopes();
     $this->unit->run($scope_coll2->get_scope_length(), $len, '測試get_scopes()');
     $annotation->set_note($note);
     $this->unit->run($annotation->get_note(), $note, '測試get_note()');
     $annotation->set_type(3);
     $type = $annotation->get_type();
     $this->unit->run($type->get_name(), 'annotation.type.confusion', '測試get_type()');
     $user = $annotation->get_user();
     $this->unit->run($user->get_email(), $email, '測試get_user()');
     $this->unit->run($user->get_email(), $email, '測試get_user()');
     $annotation_topic = $this->annotation->create_annotation($user_siroma, $scope2);
     $annotation_topic_id = $annotation_topic->get_id();
     $annotation->set_respond_to_topic($annotation_topic);
     $topic = $annotation->get_respond_to_topic();
     $this->unit->run($topic->get_id(), $annotation_topic_id, '測試respond_to_topic()');
     //來測試respond_to_coll
     $scope3 = $this->annotation_scope->create_scope(104, 135, $note, $url);
     $annotation_respond = $this->annotation->create_annotation($user_siroma, $scope3);
     //$annotation_coll = new Annotation_collection($annotation_respond);
     $annotation->set_respond_to_coll($annotation_respond);
     $coll = $annotation->get_respond_to_coll();
     $this->unit->run($coll->length(), 1, '測試respond_to_coll()的length');
     ///$this->unit->run($coll->get_item(0)->get_id()
     //        , $annotation_respond->get_id()
     //        , '測試respond_to_coll()的get_id() | '.$annotation->get_id());
     $annotation->set_feature(1, 1);
     $feature = $annotation->get_feature(1);
     $this->unit->run($feature->get_name(), 'annotation.feature.location', 'set_feature之後又get_feature->get_name()');
     $this->unit->run($feature->get_value(), '1', 'set_feature之後又get_feature->get_value()');
     $annotation->set_feature(1, 2);
     $feature = $annotation->get_feature(1);
     $this->unit->run($feature->get_value(), '2', '再一次set_feature之後又get_feature->get_value()');
     $score_number = 2.36978;
     $score_number2 = 1.36978;
     $annotation->set_score(0, $score_number);
     $score = $annotation->get_score(0);
     $this->unit->run($score->get_name(), 'annotation.score.integrated', 'set_score之後又get_score->get_name()');
     $this->unit->run($score->get_score(), $score_number, 'set_score之後又get_score->get_value()');
     $annotation->set_score(0, $score_number2);
     $score = $annotation->get_score(0);
     $this->unit->run($score->get_score(), $score_number2, '再一次set_score之後又get_score->get_score()');
     $email_like = '*****@*****.**';
     $user_like = $this->user->create_user($url, $email_like);
     $this->unit->run_false($user->get_id(), $user_like->get_id(), '建立一個user_like,跟user不同人吧?');
     $this->unit->run_false($annotation->get_user()->get_id(), $user_like->get_id(), 'user_like,跟標註的作者user不同人吧?');
     $this->unit->run($annotation->get_like_count(), 0, 'like測試,加入user_like之前 get_like_count()');
     $annotation->add_like($user_like);
     $this->unit->run($annotation->get_like_count(), 1, 'like測試,加入user_like之後 get_like_count()');
     $annotation->remove_like($user_like);
     $this->unit->run($annotation->get_like_count(), 0, 'like測試,移除user_like之後 get_like_count()');
     $annotation->add_like($user_like);
     $this->unit->run($annotation->get_like_count(), 1, 'like測試,再加入user_like之後 get_like_count()');
     $this->unit->run($annotation->get_user()->get_unread_notification_count(), 1, '更新之前,到底annotation的作者收到幾封未讀通知呢?應該是有like的一封');
     $annotation->update();
     $this->unit->run(TRUE, TRUE, '======================更新完畢======================');
     $this->unit->run($user_siroma->get_unread_notification_count(), 1, '更新之後,由於user_siroma被設為topic跟respond的對象,所以user_siroma應該只會收到1封通知');
     $db = $this->db;
     $db->from('annotation2like_count');
     $db->where('annotation_id', $annotation->get_id());
     $db->select('like_count');
     $query = $db->get();
     $row = $query->row_array();
     $like_count = intval($row['like_count']);
     $this->unit->run($like_count, 1, '測試annotation2like_count');
     //----------------------------------------------------------------------------
     //搜尋看看吧
     $id = $annotation->get_id();
     $annotation2 = new Annotation($id);
     $scope_coll3 = $annotation2->get_scopes();
     $this->unit->run($annotation2->get_id(), $id, '$annotation2的id是否跟當初設定的相同?');
     $this->unit->run($scope_coll3->get_scope_length(), $len, '取出$annotation2之後,測試scopes');
     $this->unit->run($scope_coll3->length(), 2, '取出$annotation2之後,測試scopes有幾個');
     $this->unit->run($scope_coll3->get_anchor_speech(), $scope_coll2->get_anchor_speech(), '取出$annotation2之後,測試scopes的get_anchor_speech()');
     $this->unit->run($annotation2->get_note(), $note, '取出$annotation2之後,測試note');
     $type2 = $annotation2->get_type();
     $this->unit->run($type2->get_name(), 'annotation.type.confusion', '取出$annotation2之後,測試type');
     $user2 = $annotation2->get_user();
     $this->unit->run($user2->get_email(), $email, '取出$annotation2之後,測試get_user()');
     $text2 = '雖然這邊太吵了應該聽不到尖叫聲,不過應該是會有人間叫';
     $this->unit->run($annotation2->get_like_count(), 1, '搜尋之後,like測試,已經加入user_like');
     $this->unit->run_false($annotation2->get_user()->get_id(), $user_like->get_id(), '確認一下兩個標註應該是不同人吧?');
     $annotation2->set_note($text2);
     $annotation2->update();
     $this->unit->run(TRUE, TRUE, '<h4>======================更新完畢======================</h4>');
     //----------------------------------------------------------------------
     $annotation3 = new Annotation($annotation2->get_id());
     $this->unit->run($annotation3->get_note(), $text2, '更新note,取出$annotation3之後,測試get_note()');
     $webpages = $annotation3->get_append_to_webpages();
     $this->unit->run(count($webpages), 1, '測試get_append_to_webpages()');
     $this->unit->run($webpages[0]->get_uri(), parse_uri($url), '測試get_append_to_webpages()是否相符');
     $topic = $annotation3->get_respond_to_topic();
     $this->unit->run($topic->get_id(), $annotation_topic_id, '測試respond_to_topic()');
     $coll = $annotation3->get_respond_to_coll();
     $this->unit->run($coll->length(), 1, '測試respond_to_coll()的length');
     //$this->unit->run($coll->get_item(0)->get_id()
     //        , $annotation_respond->get_id()
     //        , '測試respond_to_coll()的get_id(),應該只有找到一個,並且就是剛剛插入的那一個 | '.$annotation3->get_id());
     $this->unit->run($annotation2->get_id(), $annotation3->get_id(), 'annotation2跟3的id是否相同呢?應該一樣才是');
     $topic_respond_coll = $topic->get_topic_respond_coll();
     $this->unit->run($topic_respond_coll->length(), 1, '測試get_topic_responded_coll()的length');
     $this->unit->run($topic_respond_coll->get_item(0)->get_id(), $annotation3->get_id(), '測試get_topic_responded_coll()的length');
     $feature = $annotation3->get_feature(1);
     $this->unit->run($feature->get_value(), '2', '搜尋之後,get_feature->get_value()');
     $feature = $annotation3->get_feature(2);
     $this->unit->run($feature->get_value(), NULL, '搜尋之後,get_feature沒設定的id,應該會有屬性,但是沒有值');
     $feature = $annotation3->get_feature(3);
     $this->unit->run($feature, NULL, '搜尋之後,get_featur不再factory_item範圍內的id,應該直接是null');
     $score = $annotation3->get_score(0);
     $this->unit->run($score->get_name(), 'annotation.score.integrated', '搜尋之後,get_score->get_name()');
     $this->unit->run($score->get_score(), $score_number2, '搜尋之後,get_score->get_value()');
     $query = $this->db->select('score')->limit(1)->where('annotation_id', $annotation3->get_id())->get('score');
     $row = $query->row_array();
     $this->unit->run($row['score'], $score_number2, '以資料庫查看是否有存入score');
     $this->unit->run_false($annotation3->get_field('create_timestamp'), $annotation3->get_field('update_timestamp'), 'Annotation更新過後,create_timestamp跟update_timestamp應該要不同才對');
     $this->unit->run($annotation->get_like_count(), 1, '搜尋之後,like測試,已經加入user_like');
     $this->unit->run_false($annotation->get_user()->get_id(), $user_like->get_id(), '確認一下兩個標註應該是不同人吧?');
     //        $annotation->remove_like($user2);
     //        $this->unit->run($annotation->get_like_count()
     //                , 0
     //                , '搜尋之後,like測試,移除user2之後');
     //context_complete();
     //        $this->unit->run($test_result
     //                , $expected_result
     //                , $test_name);
     unit_test_report($this);
 }
コード例 #4
0
<?php

error_reporting(E_ALL);
@ini_set('display_errors', true);
$pages = array('0' => array('id' => '1', 'alias' => 'Home', 'file' => '1.php'), '1' => array('id' => '2', 'alias' => 'Products', 'file' => '2.php'), '2' => array('id' => '3', 'alias' => 'Contacts', 'file' => '3.php'), '3' => array('id' => '4', 'alias' => 'People', 'file' => '4.php'), '4' => array('id' => '5', 'alias' => 'Bugs', 'file' => '5.php'));
$forms = array('3' => array('271ad889' => array('email' => '*****@*****.**', 'subject' => 'Inquiry from the web page', 'sentMessage' => 'Form was sent.', 'smtpEnable' => false, 'smtpHost' => null, 'smtpPort' => null, 'smtpEncryption' => null, 'smtpUsername' => null, 'smtpPassword' => null, 'fields' => array(array('fidx' => '0', 'name' => 'Name', 'type' => 'input', 'options' => ''), array('fidx' => '1', 'name' => 'E-mail', 'type' => 'input', 'options' => ''), array('fidx' => '2', 'name' => 'Message', 'type' => 'textarea', 'options' => '')))), '5' => array('e22011f5' => array('email' => '*****@*****.**', 'subject' => 'Inquiry from the web page', 'sentMessage' => 'Form was sent.', 'smtpEnable' => false, 'smtpHost' => null, 'smtpPort' => null, 'smtpEncryption' => null, 'smtpUsername' => null, 'smtpPassword' => null, 'fields' => array(array('fidx' => '0', 'name' => 'Name', 'type' => 'input', 'options' => ''), array('fidx' => '1', 'name' => 'E-mail', 'type' => 'input', 'options' => ''), array('fidx' => '2', 'name' => 'Message', 'type' => 'textarea', 'options' => '')))));
$langs = null;
$def_lang = null;
$base_dir = dirname(__FILE__);
$base_url = '/';
$user_domain = 'verticeinteractive.esy.es';
$show_comments = false;
include dirname(__FILE__) . '/functions.inc.php';
$home_page = '1';
list($page_id, $lang) = parse_uri();
$user_key = "c94/4bulFKXdjb3Qejln1Er5Dk1GgSzbyQ==";
$user_hash = "ab3cc0380c8e5cc0";
$comment_callback = "http://uk.zyro.com/comment_callback/";
$preview = false;
$mod_rewrite = true;
$page = isset($pages[$page_id]) ? $pages[$page_id] : null;
if (!is_null($page)) {
    handleComments($page['id']);
    if (isset($_POST["wb_form_id"])) {
        handleForms($page['id']);
    }
}
ob_start();
if (isset($_REQUEST['view']) && $_REQUEST['view'] == 'news') {
    include dirname(__FILE__) . '/news.php';
} else {
コード例 #5
0
if (DEBUG === TRUE) {
    ini_set('display_errors', 1);
    error_reporting(E_ALL ^ E_STRICT);
} else {
    ini_set('display_errors', 0);
    error_reporting(0);
}
// Sets the timezone to avoid a notice
date_default_timezone_set(APP_TIMEZONE);
// Registers class_loader() as the autoload function
spl_autoload_register('class_autoloader');
//-----------------------------------------------------------------------------
// Loads and processes view data
//-----------------------------------------------------------------------------
// Parses the URI
$uri_array = parse_uri();
$class_name = get_controller_classname($uri_array);
$options = $uri_array;
// Sets a default view if nothing is passed in the URI (i.e. on the home page)
if (empty($class_name)) {
    $class_name = 'Home';
}
// Tries to initialize the requested view, or else throws a 404 error
try {
    $controller = new $class_name($options);
} catch (Exception $e) {
    $options[1] = $e->getMessage();
    $controller = new Error($options);
}
//-----------------------------------------------------------------------------
// Outputs the view
コード例 #6
0
ファイル: _bomb.php プロジェクト: boxcore/xspider
// 载入框架数据库操作函数
require BOMB . 'core' . DS . 'db.fn.php';
// 载入程序全局函数(程序公用函数库)
require APP . 'funcs' . DS . 'app.fn.php';
// 取消自动转义
transcribe();
// 如果用户没有设置site_domain,则自动配置生成site_domain
if (!($site_domain = conf('app', 'site_domain'))) {
    $GLOBALS['app']['site_domain'] = gen_site_domain();
}
// 获取当前请求URL
$GLOBALS['request']['url'] = get_current_url();
// 获取请求URI
$GLOBALS['request']['uri'] = get_current_uri();
// 解析URI,如果不存在则响应404
if (!parse_uri($GLOBALS['request']['uri'])) {
    show_404();
}
// 挂载钩子
mount_hooks($GLOBALS['request']['uri']);
/**
 * base controller
 */
abstract class _Control
{
    public function __construct()
    {
    }
}
// Controller预处理
$__cont_file = APP . $GLOBALS['request']['file'];
コード例 #7
0
ファイル: common.php プロジェクト: kid2682/SMZDM
function mall_url($mall_info)
{
    if (empty($mall_info['url']) || empty($mall_info['url_' . $mall_info['url']])) {
        return $mall_info['domain'];
    }
    if ($mall_info['url'] == 'yqf') {
        $urls = parse_uri($mall_info['url_' . $mall_info['url']]);
        $url = $urls['scheme'] . "://" . $urls['host'] . $urls['path'] . "?";
        foreach (array('s', 'w', 'c', 'i', 'l', 'e', 't') as $val) {
            if ($val == 'w') {
                $url .= "{$val}=" . C('pin_cps_' . $mall_info['url']) . "&";
            } else {
                $url .= "{$val}=" . $urls['_query'][$val] . "&";
            }
        }
        return trim($url, '&');
    } else {
        return $mall_info['url_' . $mall_info['url']] . '&sid=' . C('pin_cps_' . $mall_info['url']);
    }
}
コード例 #8
0
ファイル: admin.php プロジェクト: TuffLuck/status2
<?php

require_once "includes/config.php";
require_once "includes/template.php";
require_once "includes/database.php";
require_once "includes/controller.php";
$uri = parse_uri();
// Pass it off to the controller methods
handle_controller(dirname(__FILE__) . '/admin', array_slice($uri, 1));
コード例 #9
0
ファイル: uri_util.php プロジェクト: jphpsf/gregarius
function set_query_string_vars($uri, $array)
{
    $parsed_uri = parse_uri($uri);
    if (empty($parsed_uri['query'])) {
        $qs = array();
    } else {
        $qs = parse_query_string($parsed_uri['query']);
    }
    foreach ($array as $key => $value) {
        if (is_null($value)) {
            unset($qs[$key]);
        } else {
            $qs[$key] = $value;
        }
    }
    $parsed_uri['query'] = unparse_query_string($qs);
    return unparse_uri($parsed_uri);
}