예제 #1
0
 /**
  * 会员登录后获取到的自身信息
  */
 public function basic()
 {
     $data = $this->_post();
     $userObj = D('User');
     if (empty($data)) {
         $id = $_SESSION['uid'];
         $fields = array('id', 'avatar', 'name', 'mobile', 'url', 'token', 'appid', 'appsecrect');
         $userInfo = $userObj->field($fields)->where('id=' . $id)->find();
         $userInfo = $userObj->format($userInfo, array('url', 'avatar_name'));
         $fields_all = $userObj->field_list();
         $tpl_data = array('title' => '基本信息', 'form_url' => U('User/basic'), 'field_info' => $userInfo, 'field_list' => $this->get_field_list($fields_all, $fields));
         $this->assign($tpl_data);
         $this->display('Public:info');
         exit;
     }
     if (!empty($_FILES['pic']['name'])) {
         $picList = uploadPic();
         if ($picList['code'] != 'error') {
             $data['avatar'] = D('GalleryMeta')->addImg($picList['pic']['savename']);
         }
     }
     $result = $userObj->save($data);
     if (empty($result)) {
         echo json_encode(array('code' => '0', 'msg' => '更新错误'));
     } else {
         $_SESSION['userInfo'] = D('User')->where('id=' . $_SESSION['uid'])->find();
         file_put_contents('message.log', '您的信息已更新');
         echo json_encode(array('code' => '1', 'msg' => '更新成功'));
     }
 }
예제 #2
0
            } else {
            }
            break;
        case 'addLike':
            if ($ifLogin == 1) {
                $picID = $_POST['picID'];
                addLike($userID, $picID, time());
            } else {
            }
            break;
        case 'uploadPic':
            if ($ifLogin == 1) {
                $picAlbumID = $_POST['upAlbumID'];
                $picAlbumName = $_POST['upAlbumName'];
                $sql = "SELECT * FROM AlbumTable WHERE AlbumID={$picAlbumID} AND UserID={$userID}";
                $res = exeSQL($sql);
                $row = mysql_fetch_array($res);
                if (empty($row)) {
                    $sql = "SELECT AlbumID FROM AlbumTable WHERE UserID={$userID} AND AlbumName='Default'";
                    $res = exeSQL($sql);
                    $row = mysql_fetch_array($res);
                    $_POST['upAlbumID'] = $row[0];
                }
                uploadPic();
            }
            break;
        default:
            print "Error";
            break;
    }
}
예제 #3
0
파일: interact.php 프로젝트: 121mhz/naboor
function uploadNewPics($overRideThumb = false)
{
    global $config;
    $thumbOnly = $config->uploadThumbOnly;
    $PicIDs = array();
    if ($thumbOnly && !$overRideThumb) {
        $query = "select MID,FileName,ThumbUpload,FullUpload,UNIX_TIMESTAMP(MotionTime) MotionTime from Motion where ThumbUpload=0";
        $result = getSQLResult("uploadNewPics 1", $query);
        for ($row = $result->fetch_object(); $row; $row = $result->fetch_object()) {
            $PicIDs[$row->MID] = array('Filename' => $row->FileName, 'PictureTime' => $row->MotionTime);
        }
        foreach ($PicIDs as $PicID => $values) {
            $filename = $values["Filename"];
            make_thumb($filename, "/dev/shm/upload/thumb.jpg", 240);
            $pic = file_get_contents("/dev/shm/upload/thumb.jpg");
            $upload = uploadPic($pic, $values['PictureTime'], true, $PicID);
            if ($upload) {
                $query = "update Motion set ThumbUpload=1 where MID=?";
                $result = execSQL("interact,uploadNewPics {$PicID}", $query, "i", $PicID);
            }
        }
    } else {
        $query = "select MID,FileName,ThumbUpload,FullUpload,UNIX_TIMESTAMP(MotionTime) MotionTime from Motion where FullUpload=0";
        $result = getSQLResult("uploadNewPics 2", $query);
        for ($row = $result->fetch_object(); $row; $row = $result->fetch_object()) {
            $PicIDs[$row->MID] = array('Filename' => $row->FileName, 'PictureTime' => $row->MotionTime);
        }
        foreach ($PicIDs as $PicID => $values) {
            $filename = $values["Filename"];
            $pic = file_get_contents($filename);
            logMessage("Found pic to upload PicID={$PicID} filename={$filename}, size=" . strlen($pic));
            $upload = uploadPic($pic, $values['PictureTime'], false, $PicID);
            if ($upload) {
                $query = "update Motion set ThumbUpload=1,FullUpload=1 where MID=?";
                $result = execSQL("interact,uploadNewPics {$PicID}", $query, "i", $PicID);
            }
        }
    }
}
예제 #4
0
파일: index.php 프로젝트: 117n-n711/pjmgmt
$period = $_POST["period"];
$longitude = $_POST["longitude"];
$latitude = $_POST["latitude"];
$expressType = "";
$itemIntroduction = "";
$itemImageSrc = "";
$address = "";
if (isset($_POST["address"])) {
    $address = $_POST["address"];
}
if (isset($_POST["expressType"])) {
    $expressType = $_POST["expressType"];
}
if (isset($_POST["itemIntroduction"])) {
    $itemIntroduction = $_POST["itemIntroduction"];
}
if (isset($_POST["itemImageSrc"])) {
    $itemImageSrc = $_POST["itemImageSrc"];
}
$arr = array("longitude" => $longitude, "latitude" => $latitude, "itemName" => $itemName, "money" => $money, "period" => $period, "expressType" => $expressType, "itemIntroduction" => $itemIntroduction, "itemImageSrc" => $itemImageSrc, "uid" => $uid, "address" => $address);
$item = new Item($data = $arr);
$iteId = $item->publish($uid, $hash);
if (!$iteId) {
    add_return_data(0, 7, "Error while updating.");
}
$returndata["data"] = array("itemId" => $iteId);
$iteImg = uploadPic("itemPic", $iteId, "itemImageSrc");
if ($item->updateItemImage($uid, $hash, $iteId, $iteImg)) {
    add_return_data(1, 1, "Success");
}
add_return_data(1, 2, "Success uploding data except Image");
예제 #5
0
파일: index.php 프로젝트: 117n-n711/pjmgmt
}
if (!isset($_POST["email"])) {
    add_return_data(0, 5, "E-mail required");
}
$email = $_POST["email"];
if (!$email) {
    add_return_data(0, 5, "E-mail required");
}
if (isset($_POST["contact"])) {
    $contact = $_POST['contact'];
}
if (isset($_POST["role"]) && $_POST["role"]) {
    $role = $_POST['role'];
}
$user = new User($uname);
if ($user->getuser()) {
    add_return_data(0, 2, "User already exists");
}
$data = array("uname" => $uname, "password" => $password, "gender" => $gender, "fname" => $fname, "email" => $email, "contact" => $contact, "role" => $role);
$useId = $user->insert($data);
$cookies = array("uid" => $useId, "hash" => getCookies($useId));
$returndata["cookies"] = $cookies;
if ($useId) {
    $picId = uploadPic("profilePic", $useId, "userFace");
    if ($picId) {
        if ($user->updateProfileImage($useId, $picId)) {
            add_return_data(1, 1, "User successfully created");
        }
    }
    add_return_data(1, 2, "User successfully created but picture cannot be added.");
}
 /**
  * meta info
  */
 public function metaInfo()
 {
     $fields_all = D('GalleryMeta')->field_list();
     $fields = array('id', 'gallery_id', 'title', 'path');
     if (empty($_POST)) {
         $id = intval($_GET['id']);
         if (!empty($id)) {
             $info = D('GalleryMeta')->field($fields)->where('id=' . $id)->find();
         } else {
             $gallery_id = intval($_GET['gallery_id']);
             $info['gallery_id'] = $gallery_id;
         }
         $title = D('Gallery')->where('id=' . $info['gallery_id'])->getField('title');
         $bread_list = array(array('title' => '相册列表', 'url' => U('Gallery/galleryList')), array('title' => $title, 'url' => U('Gallery/metaList', array('gallery_id' => $info['gallery_id']))), array('title' => $info['title'], 'url' => 'javascript:;', 'type' => 'current'));
         $data = array('title' => '图片信息', 'bread_list' => $bread_list, 'field_list' => $this->get_field_list($fields_all, $fields), 'field_info' => $info, 'form_url' => U('Gallery/metaInfo'));
         $this->assign($data);
         $this->display('Public:info');
         exit;
     }
     $data = $_POST;
     $data['date_modify'] = time();
     if (!empty($_FILES['path']['name'])) {
         $picList = uploadPic();
         if ($picList['code'] != 'error') {
             $data['path'] = $picList['path']['savename'];
         }
     }
     if (empty($data['id'])) {
         $data['date_add'] = time();
         if (D('GalleryMeta')->add($data)) {
             echo json_encode(array('code' => '1', 'msg' => '更新成功'));
         } else {
             echo json_encode(array('code' => '0', 'msg' => '更新失败'));
         }
     } else {
         if (D('GalleryMeta')->save($data)) {
             echo json_encode(array('code' => '1', 'msg' => '更新成功'));
         } else {
             echo json_encode(array('code' => '0', 'msg' => '更新失败'));
         }
     }
 }