Ejemplo n.º 1
0
Archivo: Test.php Proyecto: rayful/url
 public function test4()
 {
     $url = "http://url.com/doc/index.php?query=1&query2=2#abc=3";
     $domain = URL::domain($url);
     //url.com
     $queryString = URL::queryString($url);
     //query=1&query=2
     $query = URL::query($url);
     //['query'=>1,'query2'=>2]
     $dir = URL::dir($url);
     //http://url.com/doc
     echo $domain;
     echo $queryString;
     print_r($query);
     echo $dir;
 }
Ejemplo n.º 2
0
 /**
  * 设置分类封面图片
  */
 public function action_catetop()
 {
     $pid = (int) $this->getQuery('id');
     $cate_id = (int) $this->getQuery('cate_id');
     $info = DB::select('i.id', 'i.cate_id', 'i.picname', 'i.custom_name', 'i.disk_id', 'i.userid', 'i.click', 'i.is_share', 'd.disk_domain', 'cate.cate_name', array('i.disk_name', 'img_dir'))->from(array('imgs', 'i'))->join(array('img_disks', 'd'), 'LEFT')->on('d.disk_domain', '=', 'i.disk_id')->join(array('img_categories', 'cate'), 'LEFT')->on('cate.cate_id', '=', 'i.cate_id')->where('i.id', '=', $pid)->execute()->current();
     if (!empty($info)) {
         $img = URL::domain() . $this->thumb->create($info['img_dir'] . '/' . $info['picname'], 130, 130);
         DB::update('img_categories')->set(array('index_img' => $img, 'index_img_id' => $pid))->where('cate_id', '=', $cate_id)->execute();
         $this->request->redirect('/category/list?cate_id=' . $cate_id);
     }
     $this->auto_render = false;
 }
Ejemplo n.º 3
0
    </div>
    <div class="bd">

        <ul class="lists">
            <?php 
foreach ($recommend as $key => $item) {
    ?>
            <li>

                <a class="photo" href="/<?php 
    echo $item['id'];
    ?>
.html" target="photo">

                    <img src="<?php 
    echo URL::domain() . Str::changeLoad($thumb->create($item['img_dir'] . '/' . $item['picname'], 130, 130));
    ?>
" />
                </a>
                <span class="info">
                    <a class="photo_id" href="/<?php 
    echo $item['id'];
    ?>
.html" title="<?php 
    echo $item['custom_name'];
    ?>
"target="photo"><?php 
    echo Str::slice($item['custom_name'], 15, '...');
    ?>
</a><br />
                    会员:<?php 
Ejemplo n.º 4
0
 /**
  * 图片集合
  */
 public function action_zoom()
 {
     $this->template->pid = $pid = (int) $this->getQuery('id');
     $this->template->zoom = $zoom = trim($this->getQuery('zoom'));
     $this->template->info = $info = ORM::factory('img')->select('imgs.*', 'u.username', 'd.disk_domain')->join(array('users', 'u'))->on('u.uid', '=', 'imgs.userid')->join(array('img_disks', 'd'))->on('d.disk_domain', '=', 'imgs.disk_id')->where('imgs.id', '=', (int) $pid)->find();
     if (empty($info->picname)) {
         $this->show_message('非法访问', 0, array(), true);
     }
     $url = URL::domain();
     $picname = $info->disk_name . '/' . $info->picname;
     $imRule = Str::changeLoad($picname, true);
     if ($zoom == 'medium') {
         $picname = $this->thumb->create($picname, 640, 640, 's');
         $imRule = Str::changeLoad($picname);
     } elseif ($zoom == 'thumb') {
         $picname = $this->thumb->create($picname, 130, 130);
         $imRule = Str::changeLoad($picname);
     }
     $this->template->picinfo = $picinfo = @getimagesize($picname);
     $this->template->picname = $url . $imRule;
 }
Ejemplo n.º 5
0
?>
</h2>
        <div class="clearfloat"></div>
        <span class="upload_time" style="float:left;">上传用户:【<?php 
echo $imgInfo['username'];
?>
】 上传于<?php 
echo date('Y-m-d', $imgInfo['uploadtime']);
?>
 </span><span class="back"><a href="javascript:" onclick="report(this);">举报</a><a href="/">返回首页</a> </span> </div>
        <div class="clearfloat"></div>
        <div style="border-bottom:4px solid #85C64E;"></div>
      <div class="pic">
      <br />
      <img src="<?php 
echo URL::domain() . Str::changeLoad($thumb->create($imgInfo['img_dir'] . '/' . $imgInfo['picname'], 640, 640, 's'));
?>
"  alt="<?php 
echo $imgInfo['custom_name'];
?>
"/><br />
          <br />
         <a class="img" href="/pic/zoom?id=<?php 
echo $imgInfo['id'];
?>
">查看原图 </a> </div>
    </div>
    <div class="comment">
      <div class="title">
        <h2>留言评论</h2>
        <sub>+Message&nbsp;comment</sub> </div>
Ejemplo n.º 6
0
        <ul class="back">
          <li><a href="/">返回首页</a></li>
        </ul>
      </div>
      <div class="bd">
        <ul class="lists">
         <?php 
foreach ($pagination as $k => $img) {
    ?>
          <li style="height:200px;">
              <a class="photo" href="/<?php 
    echo $img['id'];
    ?>
.html" target="photo" style="height:130px; width:130px;">
                  <img src="<?php 
    echo URL::domain() . Str::changeLoad($thumb->create($img['disk_name'] . '/' . $img['picname'], 130, 130));
    ?>
" />
               </a>
              <span class="info"> <a class="photo_id" href="/<?php 
    echo $img['id'];
    ?>
.html" title='查看图片详情'><?php 
    echo Str::slice($img['custom_name'], 15, '...');
    ?>
</a><br />
            <strong>&nbsp;浏览<?php 
    echo $img['click'];
    ?>
次</strong> </span> </li>
Ejemplo n.º 7
0
 /**
  * Return the formatted source as a link or text.
  * 
  * @param HTML_MUNGER $munger The transformation context.
  * @param string[] $attrs
  * @param string $href
  * @return string
  * @access private
  */
 protected function _calculate_source($munger, $attrs, $href)
 {
     $Result = $munger->apply_non_html_converters($this->_read_attribute($attrs, 'source'));
     if ($Result && $href) {
         $url = new URL($href);
         $domain = $url->domain();
         $Result = "<a href=\"http://{$domain}/\">{$Result}</a>";
     }
     return $Result;
 }
Ejemplo n.º 8
0
 protected function _test_url_class()
 {
     $url_text = 'http://earthli.com/pages/page.php?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/';
     $this->_log('original URL', Msg_type_info);
     $url = new URL($url_text);
     $this->_check_equal('http://earthli.com/pages/page.php?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('page.php', $url->name());
     $this->_check_equal('php', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->query_string());
     $this->_check_equal('page', $url->name_without_extension());
     $this->_check_equal('page.php?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->name_with_query_string());
     $this->_log('replaced extension', Msg_type_info);
     $url->replace_extension('jpg');
     $this->_check_equal('http://earthli.com/pages/page.jpg?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('page.jpg', $url->name());
     $this->_check_equal('jpg', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->query_string());
     $this->_check_equal('page', $url->name_without_extension());
     $this->_check_equal('page.jpg?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->name_with_query_string());
     $this->_log('appended to name', Msg_type_info);
     $url->append_to_name('_tn');
     $this->_check_equal('http://earthli.com/pages/page_tn.jpg?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('page_tn.jpg', $url->name());
     $this->_check_equal('jpg', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->query_string());
     $this->_check_equal('page_tn', $url->name_without_extension());
     $this->_check_equal('page_tn.jpg?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->name_with_query_string());
     $this->_log('replaced name', Msg_type_info);
     $url->replace_name('picture');
     $this->_check_equal('http://earthli.com/pages/picture.jpg?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('picture.jpg', $url->name());
     $this->_check_equal('jpg', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->query_string());
     $this->_check_equal('picture', $url->name_without_extension());
     $this->_check_equal('picture.jpg?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->name_with_query_string());
     $this->_log('emptied name and extension', Msg_type_info);
     $url->replace_name_and_extension('');
     $this->_check_equal('http://earthli.com/pages/?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('', $url->name());
     $this->_check_equal('', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->query_string());
     $this->_check_equal('', $url->name_without_extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->name_with_query_string());
     $url->replace_name_and_extension('picture.jpg');
     $this->_check_equal('http://earthli.com/pages/picture.jpg?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('picture.jpg', $url->name());
     $this->_check_equal('jpg', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->query_string());
     $this->_check_equal('picture', $url->name_without_extension());
     $this->_check_equal('picture.jpg?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->name_with_query_string());
     $this->_log('replaced name and extension', Msg_type_info);
     $url->replace_name_and_extension('picture_ex.png');
     $this->_check_equal('http://earthli.com/pages/picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('picture_ex.png', $url->name());
     $this->_check_equal('png', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->query_string());
     $this->_check_equal('picture_ex', $url->name_without_extension());
     $this->_check_equal('picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/', $url->name_with_query_string());
     $this->_log('added argument', Msg_type_info);
     $url->add_argument('arg4', 'new');
     $this->_check_equal('http://earthli.com/pages/picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('picture_ex.png', $url->name());
     $this->_check_equal('png', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->query_string());
     $this->_check_equal('picture_ex', $url->name_without_extension());
     $this->_check_equal('picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->name_with_query_string());
     $this->_log('replaced argument', Msg_type_info);
     $url->replace_argument('arg2', 'not_2');
     $this->_check_equal('http://earthli.com/pages/picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=not_2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('picture_ex.png', $url->name());
     $this->_check_equal('png', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=not_2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->query_string());
     $this->_check_equal('picture_ex', $url->name_without_extension());
     $this->_check_equal('picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=not_2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->name_with_query_string());
     $this->_log('moved back a folder', Msg_type_info);
     $url->go_back(1);
     $this->_check_equal('http://earthli.com/picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=not_2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/', $url->path());
     $this->_check_equal('/', $url->path_without_domain());
     $this->_check_equal('picture_ex.png', $url->name());
     $this->_check_equal('png', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=not_2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->query_string());
     $this->_check_equal('picture_ex', $url->name_without_extension());
     $this->_check_equal('picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=not_2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->name_with_query_string());
     $this->_log('appended folder', Msg_type_info);
     $url->append_folder('pages');
     $this->_check_equal('http://earthli.com/pages/picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=not_2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('picture_ex.png', $url->name());
     $this->_check_equal('png', $url->extension());
     $this->_check_equal('arg1=http://earthli.com/pages/page.php&arg2=not_2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->query_string());
     $this->_check_equal('picture_ex', $url->name_without_extension());
     $this->_check_equal('picture_ex.png?arg1=http://earthli.com/pages/page.php&arg2=not_2&arg3=user|7d9c2dae9b5b69cbbbdea47f99574ba8/&arg4=new', $url->name_with_query_string());
     $this->_log('removed the name', Msg_type_info);
     $url->strip_name();
     $this->_check_equal('http://earthli.com/pages/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/', $url->path());
     $this->_check_equal('/pages/', $url->path_without_domain());
     $this->_check_equal('', $url->name());
     $this->_check_equal('', $url->extension());
     $this->_check_equal('', $url->query_string());
     $this->_check_equal('', $url->name_without_extension());
     $this->_check_equal('', $url->name_with_query_string());
     $this->_log('appended folders', Msg_type_info);
     $url->append('media/other/');
     $this->_check_equal('http://earthli.com/pages/media/other/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/media/other/', $url->path());
     $this->_check_equal('/pages/media/other/', $url->path_without_domain());
     $this->_check_equal('', $url->name());
     $this->_check_equal('', $url->extension());
     $this->_check_equal('', $url->query_string());
     $this->_check_equal('', $url->name_without_extension());
     $this->_check_equal('', $url->name_with_query_string());
     $this->_log('appended folders (with backticks)', Msg_type_info);
     $url->append('../../images/new/');
     $this->_check_equal('http://earthli.com/pages/images/new/', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/images/new/', $url->path());
     $this->_check_equal('/pages/images/new/', $url->path_without_domain());
     $this->_check_equal('', $url->name());
     $this->_check_equal('', $url->extension());
     $this->_check_equal('', $url->query_string());
     $this->_check_equal('', $url->name_without_extension());
     $this->_check_equal('', $url->name_with_query_string());
     $this->_log('appended a file name', Msg_type_info);
     $url->append('more/file.png');
     $this->_check_equal('http://earthli.com/pages/images/new/more/file.png', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/images/new/more/', $url->path());
     $this->_check_equal('/pages/images/new/more/', $url->path_without_domain());
     $this->_check_equal('file.png', $url->name());
     $this->_check_equal('png', $url->extension());
     $this->_check_equal('', $url->query_string());
     $this->_check_equal('file', $url->name_without_extension());
     $this->_check_equal('file.png', $url->name_with_query_string());
     $this->_log('appended a query string', Msg_type_info);
     $url->replace_query_string('arg1=1&arg2=hello world&arg3=<span class="something">');
     $this->_check_equal('http://earthli.com/pages/images/new/more/file.png?arg1=1&arg2=hello world&arg3=<span class="something">', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/images/new/more/', $url->path());
     $this->_check_equal('/pages/images/new/more/', $url->path_without_domain());
     $this->_check_equal('file.png', $url->name());
     $this->_check_equal('png', $url->extension());
     $this->_check_equal('arg1=1&arg2=hello world&arg3=<span class="something">', $url->query_string());
     $this->_check_equal('file', $url->name_without_extension());
     $this->_check_equal('file.png?arg1=1&arg2=hello world&arg3=<span class="something">', $url->name_with_query_string());
     $this->_check_equal('http://earthli.com/pages/images/new/more/file.png?arg1=1&arg2=hello world&arg3=lt;span class=quot;something&quot;&gt;', $url->as_text(true));
     $this->_log('cleared the extension', Msg_type_info);
     $url->replace_extension('');
     $this->_check_equal('http://earthli.com/pages/images/new/more/file?arg1=1&arg2=hello world&arg3=<span class="something">', $url->as_text());
     $this->_check_equal('earthli.com', $url->domain());
     $this->_check_equal('http://earthli.com/pages/images/new/more/', $url->path());
     $this->_check_equal('/pages/images/new/more/', $url->path_without_domain());
     $this->_check_equal('file', $url->name());
     $this->_check_equal('', $url->extension());
     $this->_check_equal('arg1=1&arg2=hello world&arg3=<span class="something">', $url->query_string());
     $this->_check_equal('file', $url->name_without_extension());
     $this->_check_equal('file?arg1=1&arg2=hello world&arg3=<span class="something">', $url->name_with_query_string());
     $this->_check_equal('http://earthli.com/pages/images/new/more/file?arg1=1&arg2=hello world&arg3=lt;span class=quot;something&quot;&gt;', $url->as_text(true));
     $this->_log('stripped the domain', Msg_type_info);
     $url->strip_domain();
     $this->_check_equal('/pages/images/new/more/file?arg1=1&arg2=hello world&arg3=<span class="something">', $url->as_text());
     $this->_check_equal('', $url->domain());
     $this->_check_equal('/pages/images/new/more/', $url->path());
     $this->_check_equal('/pages/images/new/more/', $url->path_without_domain());
     $this->_check_equal('file', $url->name());
     $this->_check_equal('', $url->extension());
     $this->_check_equal('arg1=1&arg2=hello world&arg3=<span class="something">', $url->query_string());
     $this->_check_equal('file', $url->name_without_extension());
     $this->_check_equal('file?arg1=1&arg2=hello world&arg3=<span class="something">', $url->name_with_query_string());
     $this->_check_equal('/pages/images/new/more/file?arg1=1&arg2=hello world&arg3=lt;span class=quot;something&quot;&gt;', $url->as_text(true));
     $this->_log('set to root', Msg_type_info);
     $url->set_text('/');
     $this->_check_equal('/', $url->as_text());
     $this->_check_equal('', $url->domain());
     $this->_check_equal('/', $url->path());
     $this->_check_equal('/', $url->path_without_domain());
     $this->_check_equal('', $url->name());
     $this->_check_equal('', $url->extension());
     $this->_check_equal('', $url->query_string());
     $this->_check_equal('', $url->name_without_extension());
     $this->_check_equal('', $url->name_with_query_string());
     $this->_check_equal('/', $url->as_text(true));
     $this->_log('set to root with query', Msg_type_info);
     $url->set_text('/?arg1=1&arg2=hello world&arg3=<span class="something">');
     $this->_check_equal('/?arg1=1&arg2=hello world&arg3=<span class="something">', $url->as_text());
     $this->_check_equal('', $url->domain());
     $this->_check_equal('/', $url->path());
     $this->_check_equal('/', $url->path_without_domain());
     $this->_check_equal('', $url->name());
     $this->_check_equal('', $url->extension());
     $this->_check_equal('arg1=1&arg2=hello world&arg3=<span class="something">', $url->query_string());
     $this->_check_equal('', $url->name_without_extension());
     $this->_check_equal('arg1=1&arg2=hello world&arg3=<span class="something">', $url->name_with_query_string());
     $this->_check_equal('/?arg1=1&arg2=hello world&arg3=lt;span class=quot;something&quot;&gt;', $url->as_text(true));
     $this->_log('set to protocol and domain only', Msg_type_info);
     $url->set_text('http://earthli.org');
     $this->_check_equal('http://earthli.org', $url->as_text());
     $this->_check_equal('earthli.org', $url->domain());
     $this->_check_equal('http://earthli.org/', $url->path());
     $this->_check_equal('/', $url->path_without_domain());
     $this->_check_equal('', $url->name());
     $this->_check_equal('', $url->extension());
     $this->_check_equal('', $url->query_string());
     $this->_check_equal('', $url->name_without_extension());
     $this->_check_equal('', $url->name_with_query_string());
     $this->_check_equal('http://earthli.org', $url->as_text(true));
     $this->_log('stripped the protocol', Msg_type_info);
     $url->strip_protocol();
     $this->_check_equal('earthli.org', $url->as_text());
     $this->_check_equal('earthli.org', $url->domain());
     $this->_check_equal('', $url->path());
     $this->_check_equal('', $url->path_without_domain());
     $this->_check_equal('earthli.org', $url->name());
     $this->_check_equal('org', $url->extension());
     $this->_check_equal('', $url->query_string());
     $this->_check_equal('earthli', $url->name_without_extension());
     $this->_check_equal('earthli.org', $url->name_with_query_string());
     $this->_check_equal('earthli.org', $url->as_text(true));
 }
Ejemplo n.º 9
0
 /**
  * 自动远程保存图片
  *
  */
 public function action_saveimg()
 {
     $source = $this->getQuery('src');
     if (!URL::ping($source)) {
         echo $source;
         die;
     }
     $savePath = "books_img/" . $this->auth['uid'] . '/';
     Io::mkdir(DOCROOT . $savePath);
     $data = @file_get_contents($source);
     $filename = basename($source);
     $extension = strtolower(strtolower(substr(strrchr($filename, '.'), 1)));
     $saveName = str_replace('.', '', microtime(true)) . '.' . $extension;
     // 保存的文件名
     $filename = $savePath . $saveName;
     $filesize = @file_put_contents(DOCROOT . $filename, $data);
     //保存文件,返回文件的size
     if ($filesize == 0) {
         //保存失败
         @unlink($savefile);
         throw new Exception('文件保存到本地目录时失败');
     }
     list($w, $h, $t) = getimagesize(DOCROOT . $filename);
     $filetype = image_type_to_mime_type($t);
     if (!preg_match('/^image\\/.+/i', $filetype)) {
         throw new Exception('转存文件并非有效的图片文件');
     }
     $filename = $this->thumb->create($filename, 640, 640);
     echo URL::domain() . $filename;
     $this->auto_render = false;
 }
Ejemplo n.º 10
0
 /**
  * 添加专题
  *
  */
 public function action_add()
 {
     $this->checklogin();
     $this->template->pageTitle = '添加专题';
     $this->_add_css('styles/album/add_topics.css');
     $this->_add_script('scripts/copy.js');
     $specialpic = ORM::factory('specialpic');
     if ($this->isPost()) {
         $post = Validate::factory($this->getPost())->filter(TRUE, 'trim')->rule('title', 'not_empty')->rule('content', 'not_empty');
         if ($post->check()) {
             $specialpic->values($post);
             $specialpic->uid = $this->auth['uid'];
             $specialpic->save();
             $specialpic->sid;
             // 添加专题标签
             $tag = new Tags();
             $tags = trim($this->getPost('tags'));
             $tags = explode(' ', $tags);
             $tag->add($specialpic->sid, 'img_subject', $tags, $this->auth['uid']);
             $links[] = array('text' => '返回专题列表', 'href' => '/picsubject/list');
             $this->show_message('发现专题图片操作成功。', 1, $links, true);
         } else {
             // 校验失败,获得错误提示
             $str = '';
             $this->template->registerErr = $errors = $post->errors('default/pic/pic');
             foreach ($errors as $item) {
                 $str .= $item . '<br>';
             }
             $this->show_message($str);
         }
     }
     $pid = $this->getQuery('id');
     $arr = explode('-', $pid);
     $select = DB::select('imgs.picname', 'imgs.userid', 'imgs.custom_name', 'd.disk_domain', 'd.disk_name', array('imgs.disk_name', 'img_dir'))->from('imgs')->join(array('img_disks', 'd'))->on('d.disk_domain', '=', 'imgs.disk_id')->where('imgs.id', 'in', $arr)->where('imgs.userid', '=', $this->auth['uid']);
     $rows = $select->execute()->as_array();
     $str = '';
     foreach ($rows as $item) {
         $temp_img = $item['img_dir'] . '/' . $item['picname'];
         list($width, $height) = getimagesize($temp_img);
         if ($width >= 640) {
             $temp_img = $this->thumb->create($temp_img, 640, 640, 's');
             $temp_img = Str::changeLoad($temp_img, false);
         } else {
             $temp_img = Str::changeLoad($temp_img, true);
         }
         $str .= '<p>' . "<img src=\"" . URL::domain() . $temp_img . '" alt="' . $item['custom_name'] . '"/></p><p style="text-align:center;">' . $item['custom_name'] . '</p>';
     }
     $this->template->content = $str;
 }