当前位置: 首页>>代码示例>>PHP>>正文


PHP Photo::update方法代码示例

本文整理汇总了PHP中Photo::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::update方法的具体用法?PHP Photo::update怎么用?PHP Photo::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Photo的用法示例。


在下文中一共展示了Photo::update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: trim

		$photo_title = trim($_POST['photo_title']);
		$photo_description = $_POST['photo_description'];
		$photo_approved = $_POST['photo_approved'];

		$photo->_dbo->photo_title = $photo_title;
		$photo->_dbo->photo_description = $photo_description;
		$photo->_cids = array();
		if (!empty($_POST['photo_cids']))
			$photo->_cids = $_POST['photo_cids'];

		$approve = false;
		if (empty($photo->_dbo->photo_approved) && Permissions::checkPerm("approve_photos") && $photo_approved) {
			$approve = true;
		}

		$photo->update();
		if ($approve)
			$photo->approve();

		if (!empty($ref))
			header("Location: " . $ref);

		$pane = new HTML_MessagePane("upd", "Zdjêcie zapisane", "", "a_ok_pane", "a_ok_pane_hdr");
		$pane->show();

	} catch (Exception2 $e) {
		$pane = new HTML_MessagePane("upd", $e->getMessage(), $e->getDescription(), "a_fail_pane", "a_fail_pane_hdr");
		$pane->show();
	}
}
开发者ID:BackupTheBerlios,项目名称:phphoto-svn,代码行数:30,代码来源:edit_photo.php

示例2: create

 public function create($data, $filename, $visibility)
 {
     if ($data == '') {
         // attempt to overcome PHP bug that causes
         // the HTTP POST value to be empty
         // it seems that PHP is trying to urldecode the
         // raw HTTP POST string, but for big enough values
         // this causes a memory overflow and the data
         // item remains unset
         // Here we process the php://input stream directly.
         $vars = explode('&', file_get_contents('php://input'));
         foreach ($vars as $var) {
             $vardata = explode('=', $var);
             $key = $vardata[0];
             $value = $vardata[1];
             if ($key == 'data') {
                 $data = urldecode($value);
                 break;
             }
         }
     }
     if (!isset($_SESSION['user'])) {
         throw new Exception('Not authorized.');
     }
     if ($data == '') {
         echo "Data provided is empty. Dumping {$_POST} variable.\n";
         var_dump($_POST);
         throw new Exception('Data provided is empty.');
     }
     $filename = strtolower($filename);
     $extension = substr($filename, strrpos($filename, '.') + 1);
     switch ($extension) {
         case 'jpg':
         case 'gif':
         case 'png':
             break;
         default:
             throw new Exception('Unrecognized image type. Expected "jpg", "gif", or "png", but got "' . $extension . '".');
     }
     switch ($visibility) {
         case 'public':
         case 'private':
             break;
         default:
             throw new Exception('Invalid visibility; expected "public" or "private", but got "' . $visibility . '"');
     }
     $data = base64_decode($data);
     if ($data === false) {
         throw new Exception('Invalid data supplied: data is not base64-encoded.');
     }
     $im = @imagecreatefromstring($data);
     if ($im !== false) {
         $width = imagesx($im);
         $height = imagesy($im);
     } else {
         echo 'Warning: We believe this is not a valid image file, but we\'re uploading it anyway.';
         $width = 0;
         $height = 0;
     }
     $result = Photo::create($filename, $extension, strlen($data), $_SESSION['user']['id'], $width, $height);
     $id = $result['id'];
     $filename = $result['filename'];
     $uploadfile = 'uploads/' . $filename;
     if (file_exists($uploadfile)) {
         throw new Exception('File already exists.');
     }
     file_put_contents($uploadfile, $data);
     $taken = Photo::timeFromFile($uploadfile);
     Photo::update($id, $taken);
     echo 'File uploaded successfully.';
     Post::create($filename, $_SESSION['user']['id'], 'photo', $visibility, $taken);
 }
开发者ID:natureday1,项目名称:Life,代码行数:72,代码来源:photo.php

示例3: Photo

             echo "ERROR";
         }
     } else {
         echo "ERROR";
     }
 } else {
     if ($_POST['op'] == "edit") {
         if ($contest->status === STATUS_OPEN) {
             $photo = Photo::loadPhotoId($_POST['photoId']);
             if ($photo->contestId == $contestId) {
                 $photo = new Photo();
                 // para no sobreescribir fechas
                 $photo->photoId = $_POST['photoId'];
                 $photo->title = $_POST['title'];
                 $photo->description = $_POST['description'];
                 if ($photo->update()) {
                     echo "OK";
                 } else {
                     echo "ERROR";
                 }
             } else {
                 echo _("ERROR: This photo doesn't belong to the contest");
             }
         } else {
             echo _("ERROR: Not allowed to edit because of the contest status");
         }
     } else {
         if ($_POST['op'] == "vote") {
             if ($contest->status === STATUS_VOTING) {
                 if ($userId == $_POST['user_id']) {
                     if ($contest->vote($userId, $_POST['photo_id'], $_POST['rating'])) {
开发者ID:dpecos,项目名称:photocontest,代码行数:31,代码来源:photo.php


注:本文中的Photo::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。