Archive for the ‘PHP’ Category
Install Fonts in Fedora
- Log in as root or use su at command line
$ su - Go to the font storage directory:
# cd /usr/share/fonts - Create a subdirectory for the Arial fonts:
# mkdir arial - Copy the Arial fonts into this directory from font sites or windows FONTS folder.
- Make the font files accessible systemwide:
# chmod 0775 -R arial - Run fc-cache to cache the arial fonts on system:
# fc-cache arial
http://www.myvirtualdisplay.com/2009/06/28/installing-fonts-in-fedora/
Install the Alternative PHP Cache (APC)
The Alternative PHP Cache (APC) is a free, open, and robust framework for caching and optimizing PHP intermediate code.
yum install php-pear
yum install php-devel httpd-devel
yum groupinstall ‘Development Tools’
yum groupinstall ‘Development Libraries’
pecl install apc
http://si2.php.net/manual/en/install.pecl.php
Regular Expressions (REX)
‘|<title>([^<]*?)</title>|is’
‘#<body[^>]*>(.*)</body>#siU’
‘#(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$#i’
‘#\.swf$#i’
‘/xcf|odg|gif|jpg|png|bmp/i’
‘/{([A-Za-z\-_]+)}/’
‘/<a[^>]+href=”([^"]*)”[^>]*>([^<]*)<\/a>/ui’
‘/; (120×160|240×280|240×320|320×320)\)/’
‘/opera/i’
‘/<category>(.+?)<\/category>/is’
“#href=\”(.*?)\”#s”
‘|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i’
“/youtube\.com\/watch/i”
“/username=\”([^\"]+)\”/i”
‘/^[a-zA-Z0-9]+$/’
“‘<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>’i”
“‘<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))’Usi”
‘/(\b)GLOBALS|_REQUEST|_SERVER|_ENV|_COOKIE|_GET|_POST|_FILES|_SESSION(\b)/i’
‘/<input type\=”hidden” name\=”([^"]+)”.*?value\=”([^"]*)”[^>]*>/si’
‘#[?&](p|page_id|attachment_id)=(\d+)#’
‘/<!–more(.*?)?–>/’
XML – SVG
Why XML?
*XML is a standardized format
* Can be read and written by most languages
* XML is human-readable (if written well)
* XML is flexible
* Can be altered with style sheets
* Transformations between different types of XML
* e.g. HTML table to chart
* Supports records, lists, and trees
* Plain text; platform independent
Why XML … Not
* Verbose and redundant
* Can be difficult to read
* Inefficient to parse, store, and transmit
* Parsers must deal with arbitrary levels of nesting and errors
* No concept of data types
* Hierarchical not relational
SVG: Scalable Vector Graphics
#A vector-based graphics format in XML
#Graphics consist of lines, shapes, colors (not pixels)
#Can be viewed by most modern browsers
#XML format, like HTML
#Can use JavaScript for animation / interactivity
#CSS for style
SVG Example
SVG example <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg"> <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red"/> <circle cx="200" cy="50" r="40" stroke="black" stroke-width="2" fill="green"/> <circle cx="300" cy="50" r="40" stroke="black" stroke-width="2" fill="yellow"/> </svg>
PHP vs. Java/JSP
Java is…
* Strictly object oriented
* Strongly typed
* More clearly structured
* More complex
* JSP requires special server (Tomcat)
PHP is…
*Procedural (like C), with some objects
* Weakly typed, generally more flexible
* Generally faster to develop in
* Available on most web servers
* Easier to make messy code
* No namespaces
* Vague function definitions
Protect file uploads via PHP
Check server-side MIME type of uploaded files
The PHP form variable $_FILES['file']['type'] does not return correct mime type, so we have to use some php functions like…….
> finfo_file()
> getimagesize()
> exif_imagetype()
if(version_compare(substr(PHP_VERSION,0,1),5) == -1)
{
$san = finfo_open(FILEINFO_MIME);
$mime = finfo_file($san,$FileName);
$tmpvar = explode(";", $mime);
finfo_close($san);
if($mime == "image/jpeg")
{
echo "this is jpeg";
}
else
{
echo "this is not jpeg";
}
}
One can use getID3 [http://getid3.sourceforge.net/] classes to get mime type other than images….
Don’t upload to a web accessible directory
Protect your directory to execute perticular file type by putting a .htacces file in directory
AddType text/plain .php .js .cgi
more help here:
http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html
SOAP vs REST
A set of functions that can be called remotely using HTTP
> Used by other programs and programmers
> Define functions and arguments
> Return data rather than a Web page
|
SOAP
|
REST
|
| > Requires WSDL files to publish resources
> XML in request and response > Developer needs to know the XML syntax for the service > Uses Remote Procedure Calls (RPCs) over HTTP > XML-wrapped RPC difficult to “sniff” |
> Uses a URI to locate objects
> Passes method calls as GET parameters > Uses well-known calls (GET, POST, PUT, DELETE) > Uses plain HTTP > Calls can be secured by the firewall or via certificates |
Zend Framework with xampp
The leading open-source PHP framework has a flexible architecture that lets you easily build modern web applications and web services.
This is the practical information about zend framework with xampp, I want to use zend library with xampp but
Error: ” Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in D:\xampp\htdocs\zendframework\htdocs\index.php on line 2
Fatal error: require_once() [function.require]: Failed opening required ‘Zend/Loader.php’ (include_path=’.;\xampp\php\pear\’) in D:\xampp\htdocs\zendframework\htdocs\index.php on line 2 “
Solution: Zend Framework requires no special installation steps. Simply download the framework,
extract it to the folder you would like to keep it in, and add the /library directory to your PHP include_path.
Just set include path in main php file where you want to access zend framework classes like….
<?php
//set include path to /library
set_include_path("D:\xampp\php\ZendFramework-1.8.0\library");
/* remaining php code here */
//..........
//..........
?>
Happy zend + xampp
WordPress Plugins
http://www.bestwpthemes.com/
http://blog.lunarpages.com/2008/12/09/10-best-photo-and-image-wordpress-plugins/
http://cool-javascripts.com/galleries/10-jquery-plugins-for-showing-image-gallery.html
http://www.dhtmlgoodies.com/scripts/image-slideshow-vertical/image-slideshow-vertical.html
http://particletree.com/examples/lightbox/
http://www.1stwebdesigner.com/resources/57-free-image-gallery-slideshow-and-lightbox-solutions/
http://www.ajaxline.com/
http://devkick.com/lab/galleria/demo_01.htm#img/flowing-rock.jpg
http://spaceforaname.com/galleryview
http://www.spaceforaname.com/jquery/galleryview/gallery-customized.html
http://www.mytestbox.com/tips-tricks/8-wordpress-blog-photo-image-gallery-plugins-widgets/
http://blueprintds.com/2009/01/20/top-14-jquery-photo-slideshow-gallery-plugins/
http://wordpress.org/extend/plugins/made-by-simple-slideshow/screenshots/
http://slideshow.hohli.com/
http://www.featuredcontentgallery.com/
http://wordpress.org/extend/plugins/tags/slideshow/page/3
http://skyje.com/2009/05/120-wordpress-plugins-for-images/
doc2pdf – unoconv
Convert between any document format supported by OpenOffice
unoconv is a utility which can be used for can be used to convert any OpenOffice supported file to and from to other format…..
<code>/usr/bin/unoconv --server localhost --port 2002 --stdout -f pdf input.doc</code>
Reference:
http://dag.wieers.com/home-made/unoconv/
http://www.lampdeveloper.co.uk/tag/unoconv/
http://www.livedocx.com/
Comments (2)
Comments (1)
Leave a Comment
