コード例 #1
0
     $db->rollback();
     //回滚
     $db->close();
     Log::error_log('database error:' . "查询id出错" . ' in ' . basename(__FILE__));
     exit;
 }
 if (!empty($_FILES)) {
     //上传文件
     $config1 = array('maxSize' => 2100000, 'allowExts' => array('png', 'jpg'), 'allowTypes' => array('image/png', 'image/jpeg'), 'savePath' => '../uploads/comments/');
     $up = new UploadFile($config1);
     for ($i = 1; $i <= 4; $i++) {
         $name = 'imagefile' . $i;
         if (isset($_FILES[$name])) {
             $res1 = $up->uploadOne($_FILES[$name]);
             if ($res1 !== false) {
                 $savePath = 'http://' . getServerIp() . '/uploads/complaints/' . $res1['savename'];
                 $savePath = stringToDb($savePath);
                 if ($db->execute("insert into canteen_complaints_images values({$complaint_id},'{$savePath}');") === false) {
                     echo getJsonResponse(1, $db->error, null);
                     Log::error_log('database error:' . $db->error . ' in ' . basename(__FILE__));
                     $db->rollback();
                     $db->close();
                     exit;
                 }
             } else {
                 //上传图片失败
                 echo getJsonResponse(4, $uf->errorMsg, null);
                 $db->rollback();
                 //回滚
                 $db->close();
                 exit;
コード例 #2
0
            <td width="300px;">
            <div class="logo">
                <img src="http://ani-shell.sourceforge.net/banner.jpg" />
            </div>
            </td>
            <td>
            <div class="header">
            <?php 
    getSoftwareInfo();
    ?>
<br />
Your IP : <?php 
    getClientIp();
    ?>
 <font color="silver" >|</font> Server IP : <?php 
    getServerIp();
    ?>
 <br />
            Safe Mode : <?php 
    getSafeMode();
    ?>
<br />
            <?php 
    if ($os == 'Windows') {
        echo showDrives();
    }
    ?>
 <?php 
    echo getcwd();
    ?>
            </div>
コード例 #3
0
 try {
     $db->connect();
 } catch (Exception $e) {
     echo getJsonResponse(1, '数据库连接错误', null);
     Log::error_log("数据库连接错误");
     exit;
 }
 if (!checkUserToken($db, $_POST['user_id'], $_POST['access_token'])) {
     echo getJsonResponse(2, '用户token错误', null);
     exit;
 }
 $config1 = array('maxSize' => 2100000, 'allowExts' => array('png', 'jpg'), 'allowTypes' => array('image/png', 'image/jpeg'), 'savePath' => '../images/users/');
 $uf = new UploadFile($config1);
 $res = $uf->uploadOne($_FILES['image']);
 if ($res) {
     $savePath = 'http://' . getServerIp() . '/images/users/' . $res['savename'];
     if (false !== $db->execute("update users set imageurl='{$savePath}' where user_id={$_POST['user_id']};")) {
         echo getJsonResponse(0, '上传成功', null);
     } else {
         echo getJsonResponse(1, $db->error, null);
     }
     $db->close();
 } else {
     if ($uf->errorNo == 1 || $uf->errorNo == 2 || $uf->errorNo == 8) {
         echo getJsonResponse(3, $uf->errorMsg, null);
     } else {
         if ($uf->errorNo == 9) {
             echo getJsonResponse(4, $uf->errorMsg, null);
         } else {
             echo getJsonResponse(2, $uf->errorMsg, null);
         }
コード例 #4
0
ファイル: getThumb.php プロジェクト: xiaoqinzhe/eatBetter
<?php

require_once 'common/common_func.php';
/* $_GET['width']=20;
$_GET['height']=20;
$_GET['imageurl']="http%3A%2F%2Flocalhost%2Fimages%2Fuser%2Fdefault.jpg"; */
if (isset($_GET['imageurl'])) {
    $_GET['imageurl'] = urldecode($_GET['imageurl']);
    $urlinfo = parse_url($_GET['imageurl']);
    $imagepath;
    if ($urlinfo['host'] == getServerIp()) {
        $imagepath = '..' . $urlinfo['path'];
    } else {
        exit;
    }
    if (!file_exists($imagepath)) {
        exit;
    }
    $fileinfo = pathinfo($imagepath);
    if (isset($_GET['width']) && isset($_GET['height'])) {
        $thumbname = md5($imagepath . "width={$_GET['width']}height={$_GET['height']}") . '.' . $fileinfo['extension'];
    } else {
        $thumbname = md5($imagepath) . '.' . $fileinfo['extension'];
    }
    $savepath = '../images/thumb' . '/' . $thumbname;
    list($src_w, $src_h, $imagetype) = getimagesize($imagepath);
    $mime = image_type_to_mime_type($imagetype);
    header("Content-Type:" . $mime);
    $createfunc = str_replace('/', 'createfrom', $mime);
    $outfunc = str_replace('/', null, $mime);
    if (file_exists($savepath)) {
コード例 #5
0
/**
 * 食物做法步骤
 * @param unknown $db
 * @param unknown $foodid
 * @param unknown $content
 */
function setContent(&$db, $recid, $content, $imagefile)
{
    if ($content == null) {
        return;
    }
    //$method=explode("||", $content);
    $method = json_decode($content, true);
    for ($i = 1; $i <= sizeof($method); $i++) {
        if (empty($imagefile[$i - 1])) {
            $imagefile[$i - 1] = 'http://' . getServerIp() . '/uploads/recommendedfood/default.jpg';
        }
        $sql = "insert into foodmethod values({$recid},{$i},'" . stringToDb($method[$i - 1]) . "','{$imagefile[$i - 1]}');";
        $res = $db->execute($sql);
        if (!$res) {
            echo getJsonResponse(1, $db->error, null);
            Log::error_log('database error:' . $db->error . ' in ' . basename(__FILE__));
            $db->rollback();
            $db->close();
            exit;
        }
    }
}