/**
  * 
  *
  * @param int $width
  * @param int $height
  * @param ImageHandler $imageHandler
  */
 public function __construct($width, $height, ImageHandler $imageHandler)
 {
     $img = $imageHandler->createImage($width, $height);
     $color = imagecolorallocate($img, self::$backgroundColor['r'], self::$backgroundColor['g'], self::$backgroundColor['b']);
     imagefilledrectangle($img, 0, 0, $width, $height, $color);
     $crossColor = imagecolorallocate($img, self::$crossColor['r'], self::$crossColor['g'], self::$crossColor['b']);
     imageline($img, 0, 0, $width, $height, $crossColor);
     imageline($img, 0, $height, $width, 0, $crossColor);
     imageline($img, 0, 0, $width - 1, 0, $crossColor);
     imageline($img, $width - 1, 0, $width - 1, $height, $crossColor);
     imageline($img, $width - 1, $height - 1, 0, $height - 1, $crossColor);
     imageline($img, 0, $height - 1, 0, 0, $crossColor);
     $stringColor = imagecolorallocate($img, self::$stringColor['r'], self::$stringColor['g'], self::$stringColor['b']);
     imagestring($img, 2, 0, 0, self::$string, $stringColor);
     parent::__construct($img);
 }
 public function update($username)
 {
     $input = array_except(Input::all(), '_method');
     $input['username'] = str_replace('.', '-', $input['username']);
     $user = User::where('username', '=', $username)->first();
     if (Auth::user()->id == $user->id) {
         if (Input::hasFile('avatar')) {
             $input['avatar'] = ImageHandler::uploadImage(Input::file('avatar'), 'avatars');
         } else {
             $input['avatar'] = $user->avatar;
         }
         if ($input['password'] == '') {
             $input['password'] = $user->password;
         } else {
             $input['password'] = Hash::make($input['password']);
         }
         if ($user->username != $input['username']) {
             $username_exist = User::where('username', '=', $input['username'])->first();
             if ($username_exist) {
                 return Redirect::to('user/' . $user->username . '/edit')->with(array('note' => 'Sorry That Username is already in Use', 'note_type' => 'error'));
             }
         }
         $user->update($input);
         return Redirect::to('user/' . $user->username . '/edit')->with(array('note' => 'Successfully Updated User Info', 'note_type' => 'success'));
     }
     return Redirect::to('user/' . Auth::user()->username . '/edit ')->with(array('note' => 'Sorry, there seems to have been an error when updating the user info', 'note_type' => 'error'));
 }
 /**
  * saves image file for given tile
  *
  * @param resource $image
  * @param int $x
  * @param int $y
  * @param int $zoom
  */
 public function addTile($image, $x, $y, $zoom)
 {
     $this->_imageHandler->saveImage($image, $this->_getFileName($x, $y, $zoom));
     if ($this->_getSizeOfCache() > $this->_cacheSize) {
         $this->_cleanCache();
     }
 }
Beispiel #4
0
 function normaliseParams($image, &$params)
 {
     global $wgMaxImageArea;
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     $mimeType = $image->getMimeType();
     $srcWidth = $image->getWidth($params['page']);
     $srcHeight = $image->getHeight($params['page']);
     # Don't thumbnail an image so big that it will fill hard drives and send servers into swap
     # JPEG has the handy property of allowing thumbnailing without full decompression, so we make
     # an exception for it.
     if ($mimeType !== 'image/jpeg' && $srcWidth * $srcHeight > $wgMaxImageArea) {
         return false;
     }
     # Don't make an image bigger than the source
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     if ($params['physicalWidth'] >= $srcWidth) {
         $params['physicalWidth'] = $srcWidth;
         $params['physicalHeight'] = $srcHeight;
         return true;
     }
     return true;
 }
Beispiel #5
0
 /**
  * @param $image File
  * @param $params array Transform parameters. Entries with the keys 'width'
  * and 'height' are the respective screen width and height, while the keys
  * 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
  * @return bool
  */
 function normaliseParams($image, &$params)
 {
     global $wgMaxImageArea;
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     $mimeType = $image->getMimeType();
     # Obtain the source, pre-rotation dimensions
     $srcWidth = $image->getWidth($params['page']);
     $srcHeight = $image->getHeight($params['page']);
     # Don't make an image bigger than the source
     if ($params['physicalWidth'] >= $srcWidth) {
         $params['physicalWidth'] = $srcWidth;
         $params['physicalHeight'] = $srcHeight;
         # Skip scaling limit checks if no scaling is required
         # due to requested size being bigger than source.
         if (!$image->mustRender()) {
             return true;
         }
     }
     # Don't thumbnail an image so big that it will fill hard drives and send servers into swap
     # JPEG has the handy property of allowing thumbnailing without full decompression, so we make
     # an exception for it.
     # @todo FIXME: This actually only applies to ImageMagick
     if ($mimeType !== 'image/jpeg' && $srcWidth * $srcHeight > $wgMaxImageArea) {
         return false;
     }
     return true;
 }
 /**
  * @param File $image
  * @param array $params Transform parameters. Entries with the keys 'width'
  * and 'height' are the respective screen width and height, while the keys
  * 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
  * @return bool
  */
 function normaliseParams($image, &$params)
 {
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     # Obtain the source, pre-rotation dimensions
     $srcWidth = $image->getWidth($params['page']);
     $srcHeight = $image->getHeight($params['page']);
     # Don't make an image bigger than the source
     if ($params['physicalWidth'] >= $srcWidth) {
         $params['physicalWidth'] = $srcWidth;
         $params['physicalHeight'] = $srcHeight;
         # Skip scaling limit checks if no scaling is required
         # due to requested size being bigger than source.
         if (!$image->mustRender()) {
             return true;
         }
     }
     # Check if the file is smaller than the maximum image area for thumbnailing
     $checkImageAreaHookResult = null;
     wfRunHooks('BitmapHandlerCheckImageArea', array($image, &$params, &$checkImageAreaHookResult));
     if (is_null($checkImageAreaHookResult)) {
         global $wgMaxImageArea;
         if ($srcWidth * $srcHeight > $wgMaxImageArea && !($image->getMimeType() == 'image/jpeg' && self::getScalerType(false, false) == 'im')) {
             # Only ImageMagick can efficiently downsize jpg images without loading
             # the entire file in memory
             return false;
         }
     } else {
         return $checkImageAreaHookResult;
     }
     return true;
 }
 function normaliseParams($image, &$params)
 {
     global $wgMaxThumbnailArea;
     wfProfileIn(__METHOD__);
     if (!ImageHandler::normaliseParams($image, $params)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     // Video files can be bigger than usuall images. We are alowing them to stretch up to WikiaFileHelper::maxWideoWidth px.
     if ($params['physicalWidth'] > WikiaFileHelper::maxWideoWidth) {
         $srcWidth = $image->getWidth($params['page']);
         $srcHeight = $image->getHeight($params['page']);
         $params['physicalWidth'] = WikiaFileHelper::maxWideoWidth;
         $params['physicalHeight'] = round($params['physicalWidth'] * $srcHeight / $srcWidth);
     }
     # Same as srcWidth * srcHeight above but:
     # - no free pass for jpeg
     # - thumbs should be smaller
     if ($params['physicalWidth'] * $params['physicalHeight'] > $wgMaxThumbnailArea) {
         wfProfileOut(__METHOD__);
         return false;
     }
     wfProfileOut(__METHOD__);
     return true;
 }
 public function save_settings()
 {
     $input = Input::all();
     $settings = Setting::first();
     $demo_mode = Input::get('demo_mode');
     $enable_https = Input::get('enable_https');
     if (empty($demo_mode)) {
         $input['demo_mode'] = 0;
     }
     if (empty($enable_https)) {
         $input['enable_https'] = 0;
     }
     if (Input::hasFile('logo')) {
         $input['logo'] = ImageHandler::uploadImage(Input::file('logo'), 'settings');
     } else {
         $input['logo'] = $settings->logo;
     }
     if (Input::hasFile('favicon')) {
         $input['favicon'] = ImageHandler::uploadImage(Input::file('favicon'), 'settings');
     } else {
         $input['favicon'] = $settings->favicon;
     }
     $settings->update($input);
     return Redirect::to('admin/settings')->with(array('note' => 'Successfully Updated Site Settings!', 'note_type' => 'success'));
 }
 /**
  * Override BitmapHandler::doTransform() making sure we do not generate
  * a thumbnail at all. That is merely returning a ThumbnailImage that
  * will be consumed by the unit test.  There is no need to create a real
  * thumbnail on the filesystem.
  * @param ImageHandler $that
  * @param File $image
  * @param string $dstPath
  * @param string $dstUrl
  * @param array $params
  * @param int $flags
  * @return ThumbnailImage
  */
 static function doFakeTransform($that, $image, $dstPath, $dstUrl, $params, $flags = 0)
 {
     # Example of what we receive:
     # $image: LocalFile
     # $dstPath: /tmp/transform_7d0a7a2f1a09-1.jpg
     # $dstUrl : http://example.com/images/thumb/0/09/Bad.jpg/320px-Bad.jpg
     # $params:  width: 320,  descriptionUrl http://trunk.dev/wiki/File:Bad.jpg
     $that->normaliseParams($image, $params);
     $scalerParams = ['physicalWidth' => $params['physicalWidth'], 'physicalHeight' => $params['physicalHeight'], 'physicalDimensions' => "{$params['physicalWidth']}x{$params['physicalHeight']}", 'clientWidth' => $params['width'], 'clientHeight' => $params['height'], 'comment' => isset($params['descriptionUrl']) ? "File source: {$params['descriptionUrl']}" : '', 'srcWidth' => $image->getWidth(), 'srcHeight' => $image->getHeight(), 'mimeType' => $image->getMimeType(), 'dstPath' => $dstPath, 'dstUrl' => $dstUrl];
     # In some cases, we do not bother generating a thumbnail.
     if (!$image->mustRender() && $scalerParams['physicalWidth'] == $scalerParams['srcWidth'] && $scalerParams['physicalHeight'] == $scalerParams['srcHeight']) {
         wfDebug(__METHOD__ . ": returning unscaled image\n");
         // getClientScalingThumbnailImage is protected
         return $that->doClientImage($image, $scalerParams);
     }
     return new ThumbnailImage($image, $dstUrl, false, $params);
 }
 /**
  * Add an image to the file.
  *
  * @param string $url Url to the image
  *
  * @return int The reference of the image, false if the image couldn't be downloaded
  */
 public function addImageFromUrl($url)
 {
     $image = ImageHandler::DownloadImage($url);
     if ($image === false) {
         return false;
     }
     return $this->addImage($image);
 }
 function normaliseParams($image, &$params)
 {
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     return true;
 }
 /**
  * return the logo image which fits the best to the size of the map
  *
  * @return resource
  */
 private function _chooseLogoFile()
 {
     $mapWidth = imagesx($this->_img);
     $mapHeight = imagesy($this->_img);
     foreach ($this->_logoFiles as $logoFile) {
         $logoImageHandler = ImageHandler::createImageHandlerFromFileExtension($logoFile);
         $logoImage = $logoImageHandler->loadImage($logoFile);
         $logoWidth = imagesx($logoImage);
         $logoHeight = imagesy($logoImage);
         if ($logoWidth < $mapWidth && $logoHeight < $mapHeight) {
             return $logoImage;
         }
     }
     return $logoImage;
 }
 public function process($imageResource = null, $imageUrl = null)
 {
     // Check if post has a suitable image
     try {
         $imageUrl = (new ImageExtractor($this->post->url))->get(399);
     } catch (\Exception $e) {
         $imageUrl = (new ImageExtractor($this->post->url, $this->post->content))->get(399);
     }
     if ($imageUrl) {
         $imageResource = \ImageHandler::make($imageUrl);
         // store it
         (new StoreImage($this->post))->process($imageResource, $imageUrl);
         // cache it
         (new CacheImage($this->post))->process($imageResource);
     }
 }
Beispiel #14
0
 function normaliseParams($image, &$params)
 {
     global $wgSVGMaxSize;
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     # Don't make an image bigger than wgMaxSVGSize
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     if ($params['physicalWidth'] > $wgSVGMaxSize) {
         $srcWidth = $image->getWidth($params['page']);
         $srcHeight = $image->getHeight($params['page']);
         $params['physicalWidth'] = $wgSVGMaxSize;
         $params['physicalHeight'] = File::scaleHeight($srcWidth, $srcHeight, $wgSVGMaxSize);
     }
     return true;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     $data = Input::all();
     $id = $data['id'];
     $post = Post::findOrFail($id);
     $validator = Validator::make($data, Post::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     if (empty($data['image'])) {
         unset($data['image']);
     } else {
         $data['image'] = ImageHandler::uploadImage($data['image'], 'images');
     }
     $post->update($data);
     return Redirect::to('admin/posts/edit' . '/' . $id)->with(array('note' => 'Successfully Updated Post!', 'note_type' => 'success'));
 }
 public function execute()
 {
     $this->_configure();
     try {
         $mapRequest = new MapRequest($this->_get);
         $leftUpCorner = $mapRequest->getLeftUpCornerPoint();
         $rightDownCorner = $mapRequest->getRightDownCornerPoint();
         $mapProcessor = MapProcessor::factory($mapRequest);
         // create map object
         $bboxRespons = BboxRespons::factory($mapRequest->getBboxReturnType());
         $mapProcessor->getTileSource()->useImages($bboxRespons == null);
         $map = $mapProcessor->createMap($bboxRespons);
         if ($bboxRespons != null) {
             $bboxRespons->setData($map);
             $bboxRespons->send();
             die;
         }
         $map->setImageHandler(ImageHandler::factory($mapRequest->getImageType()));
         $drawHandle = new DrawHandle($map);
         $drawRequest = new DrawRequest($mapRequest);
         $drawHandle->draw($drawRequest);
         $mapWithLogo = new LogoMap($map, $this->_conf);
         $mapWithLogo->setLogoLayout(LogoLayout::factoryFromUrl($mapRequest->getLogoLayoutName()));
         $scaleBar = new ScaleBar($mapWithLogo, $this->_conf);
         $scaleBar->setUnit($mapRequest->getScaleBarUnit());
         $scaleBar->putOnMap(ScaleBarLayout::factoryFromUrl($mapRequest->getScaleBarLayoutName()));
         // send output image
         $mapWithLogo->send();
         die;
     } catch (NoMapProcessorException $e) {
         $map = new WrongRequestMap($this->_conf->get('wrong_map_request_file'));
         $map->send();
         die;
     } catch (WrongMapRequestDataException $e) {
         $map = new WrongRequestMap($this->_conf->get('wrong_map_request_file'));
         $map->send();
         die;
     }
     /*
     		 header('Content-Type: image/png');
     		 $img = imagecreatefrompng('http://tile.openstreetmap.org/12/2048/1362.png');
     
     		 imagepng($img);*/
 }
 /**
  * @param File $image
  * @param array $params Transform parameters. Entries with the keys 'width'
  * and 'height' are the respective screen width and height, while the keys
  * 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
  * @return bool
  */
 function normaliseParams($image, &$params)
 {
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     # Obtain the source, pre-rotation dimensions
     $srcWidth = $image->getWidth($params['page']);
     $srcHeight = $image->getHeight($params['page']);
     # Don't make an image bigger than the source
     if ($params['physicalWidth'] >= $srcWidth) {
         $params['physicalWidth'] = $srcWidth;
         $params['physicalHeight'] = $srcHeight;
         # Skip scaling limit checks if no scaling is required
         # due to requested size being bigger than source.
         if (!$image->mustRender()) {
             return true;
         }
     }
     return true;
 }
 public function update()
 {
     $input = Input::all();
     $id = $input['id'];
     $user = User::find($id);
     if (Input::hasFile('avatar')) {
         $input['avatar'] = ImageHandler::uploadImage(Input::file('avatar'), 'avatars');
     } else {
         $input['avatar'] = $user->avatar;
     }
     if (empty($input['active'])) {
         $input['active'] = 0;
     }
     if ($input['password'] == '') {
         $input['password'] = $user->password;
     } else {
         $input['password'] = Hash::make($input['password']);
     }
     $user->update($input);
     return Redirect::to('admin/user/edit/' . $id)->with(array('note' => 'Successfully Updated User Settings', 'note_type' => 'success'));
 }
 /**
  * draw point on map
  *
  * @param Map $map
  */
 public function draw(Map $map)
 {
     $image = $map->getImage();
     $color = $this->_getDrawColor($image);
     $pointImage = false;
     if ($this->hasImageUrl()) {
         $size = HelpClass::getSizeOfRemoteFile($this->_imageUrl->getUrl());
         if ($size <= self::$maxSizeOfPointImage) {
             try {
                 $imageHandler = ImageHandler::createImageHandlerFromFileExtension($this->_imageUrl->getUrl());
                 $pointImage = $imageHandler->loadImage($this->_imageUrl->getUrl());
             } catch (ImageHandlerException $e) {
             }
         }
     }
     if ($pointImage !== false) {
         $map->putImage($pointImage, $this->getLon(), $this->getLat());
     } else {
         $color = $this->_getDrawColor($image);
         $point = $map->getPixelPointFromCoordinates($this->getLon(), $this->getLat());
         $vertices = array($point['x'], $point['y'], $point['x'] - 10, $point['y'] - 20, $point['x'] + 10, $point['y'] - 20);
         imagefilledpolygon($map->getImage(), $vertices, 3, $color);
     }
 }
 /**
  *
  * @param DOMElement $dom
  * @return array
  */
 private function handleImages($dom, $url)
 {
     $images = array();
     $parts = parse_url($url);
     $savedImages = array();
     $imgElements = $dom->getElementsByTagName('img');
     foreach ($imgElements as $img) {
         $src = $img->getAttribute("src");
         $is_root = false;
         if (substr($src, 0, 1) == "/") {
             $is_root = true;
         }
         $parsed = parse_url($src);
         if (!isset($parsed["host"])) {
             if ($is_root) {
                 $src = http_build_url($url, $parsed, HTTP_URL_REPLACE);
             } else {
                 $src = http_build_url($url, $parsed, HTTP_URL_JOIN_PATH);
             }
         }
         $img->setAttribute("src", "");
         if (isset($savedImages[$src])) {
             $img->setAttribute("recindex", $savedImages[$src]);
         } else {
             $image = ImageHandler::DownloadImage($src);
             if ($image !== false) {
                 $images[$this->imgCounter] = new FileRecord(new Record($image));
                 $img->setAttribute("recindex", $this->imgCounter);
                 $savedImages[$src] = $this->imgCounter;
                 $this->imgCounter++;
             }
         }
     }
     return $images;
 }
Beispiel #21
0
include_once 'db.inc.php';
$db = new PDO(DB_INFO, DB_USER, DB_PASS);
// Initial check.
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['submit'] == 'Save Entry' && !empty($_POST['page']) && !empty($_POST['title']) && !empty($_POST['entry'])) {
    // Create an URL to be saved in the database.
    $url = makeUrl($_POST['title']);
    // Retrieves entries for the given URL.
    $e = retrieveEntries($db, $_POST['page'], $url);
    // We run a check to see if there already is an image saved for the entry.
    // Otherwise we upload one if needed.
    if (empty($e['image'])) {
        // We check if there is an image to upload.
        if (!empty($_FILES['image']['tmp_name'])) {
            try {
                // Instantiate the class and set a save path.
                $img = new ImageHandler("/files/");
                // Process the file and store the returned path.
                $img_path = $img->processUploadedImage($_FILES['image']);
                // Output the uploaded image as it was saved.
                echo '<img src=" ', $img_path, ' "/><br/>';
            } catch (Exception $e) {
                // If an error occurred, output your custom error message.
                die($e->getMessage());
            }
        } else {
            // Avoids a notice if no image was uploaded.
            $img_path = NULL;
        }
    } else {
        // If there is already an image just save its current already processed path.
        $img_path = $e['image'];
    ?>

<?php 
    $post_description = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', strip_tags($post->body));
    ?>

<div class="col-md-3 col-sm-6 col-xs-12">
	<article class="block">
		<a class="block-thumbnail" href="<?php 
    echo $settings->enable_https ? secure_url('post') : URL::to('post');
    echo '/' . $post->slug;
    ?>
">
			<div class="thumbnail-overlay"></div>
			<img src="<?php 
    echo ImageHandler::getImage($post->image, 'medium');
    ?>
">
			<div class="details">
				<h2><?php 
    echo $post->title;
    ?>
</h2>
				<span><?php 
    echo TimeHelper::convert_seconds_to_HMS($post->duration);
    ?>
</span>
			</div>
		</a>
		<div class="block-contents">
			<p class="date"><?php 
	<div class="clear"></div>


	<table class="table table-striped posts-table">
		<tr class="table-header">
			<th>Post</th>
			<th>URL</th>
			<th>Active</th>
			<th>Actions</th>
			@foreach($posts as $post)
			<tr>
				<td>
				
				<a href="{{ URL::to('post') . '/' . $post->slug }}" target="_blank" class="post-link">
					<img src="<?php 
echo ImageHandler::getImage($post->image, 'small');
?>
" style="height:100px;" />
					<span>{{ TextHelper::shorten($post->title, 80) }}</span>
				</a></td>
				<td valign="bottom"><p>{{ $post->slug }}</p></td>
				<td><p>{{ $post->active }}</p></td>
				<td>
					<p>
						<a href="{{ URL::to('admin/posts/edit') . '/' . $post->id }}" class="btn btn-xs btn-info"><span class="fa fa-edit"></span> Edit</a>
						<a href="{{ URL::to('admin/posts/delete') . '/' . $post->id }}" class="btn btn-xs btn-danger delete"><span class="fa fa-trash"></span> Delete</a>
					</p>
				</td>
			</tr>
			@endforeach
	</table>
        $id_masjid = $selectMasjid[0]['id_masjid'];
        var_dump($selectMasjid);
        $targetfile = "../../../View/img/Upload/fotoProfil/";
        $allowedExts = array("gif", "jpeg", "jpg", "png", "JPG");
        $temp = explode(".", $_FILES["uploadfoto"]["name"]);
        $extension = end($temp);
        if (($_FILES["uploadfoto"]["type"] == "image/gif" || $_FILES["uploadfoto"]["type"] == "image/jpeg" || $_FILES["uploadfoto"]["type"] == "image/jpg" || $_FILES["uploadfoto"]["type"] == "image/JPG" || $_FILES["uploadfoto"]["type"] == "image/pjpeg" || $_FILES["uploadfoto"]["type"] == "image/x-png" || $_FILES["uploadfoto"]["type"] == "image/png") && $_FILES["uploadfoto"]["size"] < 8000000 && in_array($extension, $allowedExts)) {
            if ($_FILES["uploadfoto"]["error"] > 0) {
                echo "Return Code: " . $_FILES["uploadfoto"]["error"] . "<br>";
            } else {
                $mime = explode("/", $_FILES["uploadfoto"]["type"]);
                $mime = $mime[1];
                $imageName = $nama_masjid . $id_masjid . "." . $mime;
                move_uploaded_file($_FILES["uploadfoto"]["tmp_name"], $targetfile . $imageName);
            }
            try {
                $foto = ImageHandler::getProfilePicture($imageName);
                echo "sukses upload";
            } catch (Exception $ex) {
                echo $ex;
            }
        }
        $insert_masjid = queryUpdate('masjid', 'foto="' . $foto . '"', 'id_masjid=' . $id_masjid);
        if ($insert_user && $insert_masjid) {
            header('location:http://localhost/SIMasjid/view/AdminUtama/tambahAdminMasjid.php?status=true');
        }
    }
    echo '<br>';
} else {
    header('location:http://localhost/SIMasjid/view/AdminUtama/tambahAdminMasjid.php?&status=false');
}
     $targetfile = "../../../View/img/Upload/galeri/";
     $allowedExts = array("gif", "jpeg", "jpg", "png", "JPG");
     for ($i = 0; $i < $nFile; $i++) {
         $temp = explode(".", $listGaleri[$i]["name"]);
         $extension = end($temp);
         if (in_array($listGaleri[$i]['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/JPG', 'image/pjpeg', 'image/x-png', 'image/png')) && $listGaleri[$i]["size"] < 2048000 && in_array($extension, $allowedExts)) {
             if ($listGaleri[$i]["error"] > 0) {
                 echo "Return Code: " . $listGaleri[$i]["error"] . "<br>";
             } else {
                 $mime = explode("/", $listGaleri[$i]["type"]);
                 $mime = $mime[1];
                 $imageName = $nama_masjid . "_" . $id_masjid . "_" . $listGaleri[$i]["name"];
                 move_uploaded_file($listGaleri[$i]["tmp_name"], $targetfile . $imageName);
             }
             try {
                 $finalImg = ImageHandler::getGalleryPicture($imageName);
                 $insertGallery = queryInsert('galeri (id_masjid, alamat_foto)', $id_masjid . ',"' . $finalImg . '"');
                 echo "sukses upload";
             } catch (Exception $ex) {
                 echo $ex;
             }
         }
     }
 }
 $updateFotoGaleri = null;
 if (isset($_POST['judulGaleri'])) {
     $judulGaleri = $_POST['judulGaleri'];
     $idGaleri = $_POST['idGaleri'];
     for ($j = 0; $j < count($judulGaleri); $j++) {
         $updateFotoGaleri = queryUpdate('galeri', 'judul_foto="' . $judulGaleri[$j] . '"', 'id_foto=' . $idGaleri[$j]);
     }
Beispiel #26
0
<?php

include 'includes/header.php';
?>


	<div class="container">

		<div class="row">

			<div class="col-md-8 post">
				
				<div class="post-img">
					<img src="<?php 
echo ImageHandler::getImage($post->image);
?>
" style="width:100%;" />
					<h3><?php 
echo $post->title;
?>
</h3>
					<h6><?php 
if (isset($author->username)) {
    echo 'by ' . $author->username;
}
?>
 on <?php 
echo date("F j, Y, g:i a", strtotime($post->created_at));
?>
</h6>
				</div>
 /**
  * Set the data to use
  * @param string $data Data to put in the file
  */
 public function setData($data)
 {
     //$data = utf8_encode($data);
     $data = CharacterEntities::convert($data);
     //$data = utf8_decode($data);
     //$this->source = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $data);
     $images = array();
     // image handling stuff
     $dom = new DOMDocument();
     $dom->loadHTML($data) or die($data);
     $dom->normalizeDocument();
     //exit();
     $savedImages = array();
     $imgElements = $dom->getElementsByTagName('img');
     foreach ($imgElements as $img) {
         $src = $img->getAttribute("src");
         $is_root = false;
         if (substr($src, 0, 1) == "/") {
             $is_root = true;
         }
         /*$parsed = parse_url($src);
         	
         				if(!isset($parsed["host"])){
         					if($is_root){
         						$src = http_build_url($url, $parsed, HTTP_URL_REPLACE);
         					}else{
         						$src = http_build_url($url, $parsed, HTTP_URL_JOIN_PATH);
         					}
         				}*/
         $img->setAttribute("src", "");
         if (isset($savedImages[$src])) {
             $img->setAttribute("recindex", $savedImages[$src]);
         } else {
             $image = ImageHandler::DownloadImage($src);
             if ($image !== false) {
                 $images[$this->imgCounter] = new FileRecord(new Record($image));
                 $img->setAttribute("recindex", $this->imgCounter);
                 $savedImages[$src] = $this->imgCounter;
                 $this->imgCounter++;
             }
         }
     }
     $this->images = $images;
     //end image stuff
     $data = $dom->saveXML();
     $data = str_replace("<pagebreak/>", "<mbp:pagebreak/>", $data);
     $data = str_replace("<pagebreak></pagebreak>", "<mbp:pagebreak/>", $data);
     //			echo $data;
     //			print_r($this->images);
     $this->source = $data;
     $this->prc = false;
 }
    $idberita = $dataBerita[0]['id_berita_umum'];
    $targetfile = "../../../View/img/Upload/beritaUmum/";
    $allowedExts = array("gif", "jpeg", "jpg", "png", "JPG");
    $temp = explode(".", $_FILES["uploadgambarberita"]["name"]);
    $extension = end($temp);
    if (($_FILES["uploadgambarberita"]["type"] == "image/gif" || $_FILES["uploadgambarberita"]["type"] == "image/jpeg" || $_FILES["uploadgambarberita"]["type"] == "image/jpg" || $_FILES["uploadgambarberita"]["type"] == "image/JPG" || $_FILES["uploadgambarberita"]["type"] == "image/pjpeg" || $_FILES["uploadgambarberita"]["type"] == "image/x-png" || $_FILES["uploadgambarberita"]["type"] == "image/png") && $_FILES["uploadgambarberita"]["size"] < 8000000 && in_array($extension, $allowedExts)) {
        if ($_FILES["uploadgambarberita"]["error"] > 0) {
            echo "Return Code: " . $_FILES["uploadgambarberita"]["error"] . "<br>";
        } else {
            $mime = explode("/", $_FILES["uploadgambarberita"]["type"]);
            $mime = $mime[1];
            $imageName = "BeritaUmum_" . $idberita . "." . $mime;
            move_uploaded_file($_FILES["uploadgambarberita"]["tmp_name"], $targetfile . $imageName);
        }
        try {
            $gambarBerita = ImageHandler::getFotoBeritaUmum($imageName);
            echo "sukses upload";
        } catch (Exception $ex) {
            echo $ex;
        }
    }
    $updateBerita = queryUpdate('berita_umum', 'gambar="' . $gambarBerita . '"', 'id_berita_umum=' . $idberita);
    if ($insert_berita && $updateBerita) {
        header('location:http://localhost/SIMasjid/view/AdminUtama/tambahBeritaUmum.php?status=true');
    }
} else {
    header('location:http://localhost/SIMasjid/view/AdminUtama/tambahBeritaUmum.php?&status=false');
}
?>

 /**
  * @param File $image
  * @param array $params
  * @return bool
  */
 function normaliseParams($image, &$params)
 {
     return ImageHandler::normaliseParams($image, $params);
 }
Beispiel #30
0
 public function update($id)
 {
     $input = array_except(Input::all(), '_method');
     $input['username'] = str_replace('.', '-', $input['username']);
     $validation = Validator::make($input, User::$update_rules);
     if ($validation->passes()) {
         $user = $this->user->find($id);
         if (Input::hasFile('avatar')) {
             $input['avatar'] = ImageHandler::uploadImage(Input::file('avatar'), 'avatars');
         } else {
             $input['avatar'] = $user->avatar;
         }
         if ($input['password'] == '') {
             $input['password'] = $user->password;
         } else {
             $input['password'] = Hash::make($input['password']);
         }
         if ($user->username != $input['username']) {
             $username_exist = User::where('username', '=', $input['username'])->first();
             if ($username_exist) {
                 return Redirect::to('user/' . $user->username)->with(array('note' => Lang::get('lang.username_in_use'), 'note_type' => 'error'));
             }
         }
         $user->update($input);
         return Redirect::to('user/' . $user->username)->with(array('note' => Lang::get('lang.update_user'), 'note_type' => 'success'));
     }
     return Redirect::to('user/' . Auth::user()->username)->with(array('note' => Lang::get('lang.validation_errors'), 'note_type' => 'error'));
 }