예제 #1
0
 function handle()
 {
     if (isset($_GET['behav'])) {
         if ($_GET['behav'] == 'uploadimg') {
             $name = uniqid() . '.jpg';
             move_uploaded_file($_FILES["pic"]["tmp_name"], './jae/' . $name);
             upoadTmpFile('./jae/' . $name);
             $tmp = array();
             $tmp['url'] = getTmpFileUrl($name);
             $tmp['id'] = $name;
             echo json_encode($tmp);
             exit;
         }
     }
     $smarty = new Smarty();
     $smarty->assign('logined', isLogined());
     $smarty->display('libs/view/head.ctp');
     if (isset($_POST['bookname'])) {
         $name = explode('.', $_FILES["file"]["name"]);
         $name = $name[count($name) - 1];
         if ($name == 'mobi') {
             $id = $this->doUpload();
             header("location:index.php?action=detail&bid={$id}");
             //$smarty->assign('type','success');
             //$smarty->assign('message','上传成功');
         } else {
             $smarty->assign('type', 'error');
             $smarty->assign('message', '上传失败,文件类型错误');
         }
         //$smarty->display('libs/view/alert.ctp');
     }
     $smarty->display('libs/view/upload.ctp');
     $smarty->display('libs/view/tail.ctp');
 }
예제 #2
0
파일: test.php 프로젝트: andy-sheng/ebook
<?php

require 'libs/controller/function.php';
$name = $_GET['name'];
$data = getHtml("https://api.douban.com/v2/book/search?q={$name}&start=0&count=1");
$json = json_decode($data);
if (isset($json->{'books'}[0])) {
    $book = $json->{'books'}[0];
    $result = array();
    $result['name'] = $book->{'title'};
    $result['author'] = $book->{'author'};
    $result['author_intro'] = $book->{'author_intro'};
    $result['isbn'] = $book->{'isbn13'};
    $result['pic-id'] = downloadImg($book->{'image'});
    $result['img'] = getTmpFileUrl($result['pic-id']);
    $result['publisher'] = $book->{'publisher'};
    $result['summary'] = $book->{'summary'};
    echo json_encode($result);
} else {
    echo 'error';
}