Showing posts with label PHP Tutorials. Show all posts
Showing posts with label PHP Tutorials. Show all posts

Tuesday, November 4, 2008

PHP Source Code »Using Large Objects in OCI8

In PHP
, LOBs are manipulated using a descriptor. To show this, in SQL*Plus create a table
that has a BLOB column:
SQL> create table mybtab (blobid number, blobdata blob);
PHP code
to insert data into this table is:
navioo_blobinsert.php

$c = oci_connect('hr', 'hrpwd', '//localhost/XE');
$myblobid = 123;
$myv = 'a very large amount of binary data';
$lob = oci_new_descriptor($c, OCI_B_LOB);
$s = oci_parse($c,
'INSERT INTO mybtab (blobid, blobdata) '
. 'VALUES(:myblobid, EMPTY_BLOB()) '
. 'RETURNING blobdata INTO :blobdata');
oci_bind_by_name($s, ':MYBLOBID', $myblobid);
oci_bind_by_name($s, ':BLOBDATA', $lob, -1, OCI_B_BLOB);
oci_execute($s, OCI_DEFAULT);
$lob->save($myv);
oci_commit($c);
?>


Read all..

Tuesday, October 28, 2008

One of the main key features of HttpResponse is HTTP caching

One of the main key features of HttpResponse is HTTP caching. HttpResponse will calculate an ETag based on the http.etag_mode INI setting as well as it will determine the last modification time of the sent entity. It uses those two indicators to decide if the cache entry on the client side is still valid and will emit an "304 Not Modified" response if applicable.




    


HttpResponse
::setCacheControl('public');    

HttpResponse::setCache(true);    

HttpResponse::capture();    

    

print 
"This will be cached until content changes!\n";    

print 
"Note that this approach will only save the clients download time.\n";    

?>    

    


More Examples PHP class HttpResponse

Monday, October 27, 2008

Hiding PHP as another language


In general, security by obscurity is one of the weakest forms of security.
But in some cases, every little bit of extra security is desirable.



A few simple techniques can help to hide PHP, possibly slowing
down an attacker who is attempting to discover weaknesses in your
system. By setting expose_php = off in your php.ini file, you
reduce the amount of information available to them.



Another tactic is to configure web servers such as apache to
parse different filetypes through PHP, either with an .htaccess

directive, or in the apache configuration file itself. You can
then use misleading file extensions:


 Hiding PHP as another language


# Make PHP code look like other code types

AddType application/x-httpd-php .asp .py .pl


Read more about Hiding PHP

Thursday, October 23, 2008

Trimming an image - Imagick

This is a simple example to demonstrate how to easily trim the areas off the image and only display the parts where the object lies. Imagick::trimImage takes one parameter which is "fuzz". Quoting ImageMagick manual: "By default target must match a particular pixel color exactly. However, in many cases two colors may differ by a small amount.

/* Create the object and read the image in */
$im = new Imagick( "test.png" );
/* The background color. This is what we trim. */
$im->setImageBackgroundColor( new ImagickPixel( "rgb(213,213,213)" ) );
/* Trim the image. */
$im->trimImage( 0 );
/* Ouput the image */
header( "Content-Type: image/" . $im->getImageFormat() );
echo $im;
?>

Read more

Monday, October 20, 2008

Thumbnails by combining a drop-in shadow with round corners

Imagick::thumbnailImage also strips all the associated profiles to make the image optimal to use in web applications.
The original image:



And the results:




Read more