<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5079136477863596220</id><updated>2011-04-21T13:33:30.205-07:00</updated><title type='text'>Logic is art</title><subtitle type='html'>do you like the art?</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>31</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-1147393707134895792</id><published>2009-01-27T01:36:00.000-08:00</published><updated>2009-01-27T01:42:04.979-08:00</updated><title type='text'>alexandermakhno.com</title><content type='html'>Hi :) it seems blogging is a good idea.&lt;br /&gt;As from today we are moving on a professional hosting.&lt;br /&gt;Nice domain name, file storage for code snippets etc.&lt;br /&gt;As usual you are welcome on this new address, thank you :)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;a href="http://alexandermakhno.com/"&gt;alexandermakhno.com&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-1147393707134895792?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/1147393707134895792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/alexandermakhnocom.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1147393707134895792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1147393707134895792'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/alexandermakhnocom.html' title='alexandermakhno.com'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-3030990216060721285</id><published>2009-01-23T02:21:00.000-08:00</published><updated>2009-01-23T02:33:27.804-08:00</updated><title type='text'>PHP - Upload Progress Meter extension</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_coCosk4H_Mo/SXmc8uqbKoI/AAAAAAAAAG8/SmJgv_BktLI/s1600-h/1.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 238px;" src="http://1.bp.blogspot.com/_coCosk4H_Mo/SXmc8uqbKoI/AAAAAAAAAG8/SmJgv_BktLI/s400/1.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5294435404082784898" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Yesterday Christian Stocker - Developer at PHP developers group released uploadprogress 0.9.2 extension. The main new function since 0.9.1 is uploadprogress_get_contents($id) which allows you to analyse the content of an uploading file during the upload and do appropriate measure (for example warn the use, that he doesn't upload a supported video format).&lt;br /&gt;&lt;br /&gt;Let's try it... We can download it from here&lt;br /&gt;http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/examples/&lt;br /&gt;Also we have to install uploadprogress extension. Let's see how to do it for Windows:&lt;br /&gt;The extension provides the VisualStudio V6 project file: uploadprogress.dsp&lt;br /&gt;http://cvs.php.net/viewvc.cgi/pecl/uploadprogress/&lt;br /&gt;To compile the extension we open this file using VisualStudio, select the apropriate configuration for our installation (either "Release_TS" or "Debug_TS") and create "php_uploadprogress.dll" - put it to the directory (C:\PHP\extensions).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-3030990216060721285?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/3030990216060721285/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php-upload-progress-meter-extension.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3030990216060721285'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3030990216060721285'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php-upload-progress-meter-extension.html' title='PHP - Upload Progress Meter extension'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_coCosk4H_Mo/SXmc8uqbKoI/AAAAAAAAAG8/SmJgv_BktLI/s72-c/1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-983720729410812503</id><published>2009-01-21T03:57:00.000-08:00</published><updated>2009-01-22T02:59:06.749-08:00</updated><title type='text'>What are podcasts?</title><content type='html'>A podcast is a series of audio or video digital media files which is destributed over the Internet by syndicated download. Basically it's like an RSS feed only the information is in digital format :) Very usefull if you are planning trip and want to listen some about the IT news whatever )) Interesting that podcast is distinguished from most other digital media formats by its ability to be syndicated, subscribed to, and downloaded automatically when new content is added. It's better to try on vacations or a trip.&lt;br /&gt;&lt;br /&gt;I actually use these podcasts:&lt;br /&gt;&lt;a href="http://feeds2.feedburner.com/WSwIPodcasts?format=xml"&gt;from Dustin Diaz&lt;/a&gt; and&lt;br /&gt;&lt;a href="http://feeds2.feedburner.com/boagworldpodcast/"&gt;from Paul&lt;/a&gt; (this second one seems to be more complex).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-983720729410812503?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/983720729410812503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/what-is-podcasts.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/983720729410812503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/983720729410812503'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/what-is-podcasts.html' title='What are podcasts?'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-2904568287678282577</id><published>2009-01-15T06:09:00.001-08:00</published><updated>2009-01-20T07:37:06.240-08:00</updated><title type='text'>Filestore for a new blog</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_coCosk4H_Mo/SXXth4Y0gTI/AAAAAAAAAG0/Cy06RtIlSdk/s1600-h/j.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 256px;" src="http://3.bp.blogspot.com/_coCosk4H_Mo/SXXth4Y0gTI/AAAAAAAAAG0/Cy06RtIlSdk/s400/j.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5293398103371841842" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It seems blogging is a good idea, actually you get a chance to be criticized by the entire world :) So, the better your next thoughts will be. Just planning to get a nice domain name for a new blog. Seems &lt;span style="font-weight:bold;"&gt;.com&lt;/span&gt; will serve well :) &lt;br /&gt;Now create a simple filestore for the blog. Feeling that it's not totally safe but will see how it works for now. I've used some classes for file managing from Zend Framework snippets (Edit -&gt; Show Snippets) to save the time.&lt;br /&gt;&lt;br /&gt;I've used Zend Snippets class for representing files list.&lt;br /&gt;Also used class for file uploading. The function &lt;span style="font-weight:bold;"&gt;move_uploaded_file&lt;/span&gt; is used on the upload stage. This function checks whether the file was uploaded by the HTTP POST protocol. If yes - it will be moved to a new place. If no - the false will be returned and file won't be moved anywhere. &lt;br /&gt;&lt;br /&gt;Believe the mini filestore will serve well for code snippets and some pdf files :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-2904568287678282577?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/2904568287678282577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/khg.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2904568287678282577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2904568287678282577'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/khg.html' title='Filestore for a new blog'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_coCosk4H_Mo/SXXth4Y0gTI/AAAAAAAAAG0/Cy06RtIlSdk/s72-c/j.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-8986447535288753187</id><published>2009-01-15T05:17:00.000-08:00</published><updated>2009-01-15T05:23:34.780-08:00</updated><title type='text'>SimpleXML library in PHP5</title><content type='html'>SimpleXML is good if we work with not mixed content. SimpleXML is much easier then DOM. It's good if we explicitely know structure of the document, but if not - XPath can make good help in that.&lt;br /&gt;&lt;br /&gt;For the first we analize XML document and save it in variable:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$rss =  simplexml_load_file('http://partners.userland.com/nytRss/nytHomepage.xml');&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And now we can call for the title of the channel with:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$title =  $rss-&gt;channel-&gt;title;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The same with other nodes :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-8986447535288753187?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/8986447535288753187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/simplexml-library-in-php5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/8986447535288753187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/8986447535288753187'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/simplexml-library-in-php5.html' title='SimpleXML library in PHP5'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-624897073086216885</id><published>2009-01-15T02:22:00.000-08:00</published><updated>2009-01-15T03:40:11.992-08:00</updated><title type='text'>PHP5 (exceptions)</title><content type='html'>As from PHP5 we have possibility to throw and catch exceptions in try blocks. There is support "catch all" but not "finally".&lt;br /&gt;&lt;br /&gt;On one "try" block can be many "catch" blocks and its will be viewed till the first coincidence with class of the exception and class pointed in the "catch" block. Comparison is done with "instanceof" operator. &lt;br /&gt;&lt;br /&gt;As an example we can use the code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;class MyException extends Exception {&lt;br /&gt;    function display() {&lt;br /&gt;        echo &amp;#039;MyException: &amp;#039; . $this-&amp;gt;getMessage() . &amp;quot;\n&amp;quot;;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class MyExceptionFoo extends MyException {&lt;br /&gt;    function display() {&lt;br /&gt;        echo &amp;#039;MyExceptionFoo: &amp;#039; . $this-&amp;gt;getMessage() . &amp;quot;\n&amp;quot;;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;try {&lt;br /&gt;    throw new MyExceptionFoo("the exception");&lt;br /&gt;} catch (MyException $exception) {&lt;br /&gt;    $exception-&amp;gt;Display();&lt;br /&gt;} catch (Exception $exception) {&lt;br /&gt;    echo $exception;&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The result will be:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;MyExceptionFoo: the exception&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;So, just an object of the exception was created it was catched in the first comparison block. The function display() were overloaded in MyExceptionFoo class and so this function were called. Any user exception-class should have Exception class as a parent.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Exception with database connection:&lt;/span&gt; usually we handle error with database connections like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$query = mysql_query("SELECT * FROM table") or die(mysql_error());&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now we try to alter the message. Look on the code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;Class DatabaseException extends Exception {&lt;br /&gt;    public function __construct($msg) {&lt;br /&gt;        parent::__construct($msg);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;try {&lt;br /&gt;    if (!@$query = mysql_query(&amp;quot;SELECT * FROM table&amp;quot;)) {&lt;br /&gt;        throw new DatabaseException(&amp;quot;Database Query Failed!&amp;quot;);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;catch (DatabaseException $e) {&lt;br /&gt;    echo $e;&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Constructor of Database Exception class is:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;parent::__construct($msg);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Use see that it calls to parent Class Exception and get the message from here. Go ahead, we try to execute query and if it fails an object of the DatabaseException class is created with the message "Database Query Failed!". Go next and on the first (and one :) block "catch" the exception is catched. So the result we'll on the page like:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;exception 'DatabaseException' with message 'Database Query Failed!' in T:\home\virtual\second\index.php:9 Stack trace: #0 {main}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;As from PHP5 it's quite simple to debug our logic ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-624897073086216885?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/624897073086216885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php5-exceptions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/624897073086216885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/624897073086216885'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php5-exceptions.html' title='PHP5 (exceptions)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-4436141575269709051</id><published>2009-01-14T04:34:00.001-08:00</published><updated>2009-01-14T09:58:34.276-08:00</updated><title type='text'>PHP5 new features</title><content type='html'>Now in PHP5 we can enjoy using public/private/protected access modifiers for methods and properties.&lt;br /&gt;&lt;br /&gt;Also we got unified constructor name __construct()&lt;br /&gt;&lt;br /&gt;Method that triggers every time the object is destroyed __destructor()&lt;br /&gt;&lt;br /&gt;Interfaces - very usefull if some people work on a big project and we need classes to be specified so needed methods will present in the class. The syntax is intuitive enough.&lt;br /&gt;&lt;br /&gt;To check if the object is an entity of the class we can use &lt;bold&gt;instanceof&lt;/bold&gt;&lt;br /&gt;&lt;br /&gt;The "final" keyword say that the method will not be overloaded in inheriting class:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;final function getBase() {&lt;br /&gt; //some logic here&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Final classes. After declaring a class as final it can't be inherited. If try we'll get an error:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Fatal error: Class BogusClass may not inherit from final class (FinalClass) in T:\home\virtual\second\index.php on line 6&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now we can declare __clone() method which will be called during the clone process (after the properties have been copied from the original object). Let's try it with the code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;class MyClass {&lt;br /&gt;    private $var;&lt;br /&gt;    &lt;br /&gt;    function __clone() {&lt;br /&gt;        print &amp;quot;Object is being &lt;br /&gt;&lt;br /&gt;cloned&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    function __set($name, $value) {&lt;br /&gt;        $this-&amp;gt;var = $value;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    function __get($name) {&lt;br /&gt;        return $this-&amp;gt;var;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;$obj = new MyClass();&lt;br /&gt;$obj-&amp;gt;__set(&amp;#039;one&amp;#039;, &amp;#039;some &lt;br /&gt;&lt;br /&gt;value&amp;#039;);&lt;br /&gt;echo($obj-&amp;gt;__get(&amp;#039;one&amp;#039;).&amp;quot&lt;br /&gt;&lt;br /&gt;;&amp;lt;br /&amp;gt;&amp;quot;);&lt;br /&gt;&lt;br /&gt;$obj2 = clone $obj;&lt;br /&gt;$obj2-&amp;gt;__set(&amp;#039;two&amp;#039;, &amp;#039;new &lt;br /&gt;&lt;br /&gt;value&amp;#039;);&lt;br /&gt;echo($obj2-&amp;gt;__get(&amp;#039;two&amp;#039;).&amp;quo&lt;br /&gt;&lt;br /&gt;t;&amp;lt;br /&amp;gt;&amp;quot;);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Class constants. We include constant value into the class definition and then use it while referencing the class:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class MyClass {&lt;br /&gt;    const SUCCESS = "Success";&lt;br /&gt;    const FAILURE = "Failure";&lt;br /&gt;}&lt;br /&gt;print MyClass::SUCCESS;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Classes definitions can not include static members (properties), accessible via class:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;class Singleton {&lt;br /&gt;    static private $instance = NULL;&lt;br /&gt;&lt;br /&gt;    private function __construct() {&lt;br /&gt;        echo(&amp;#039;Object created.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;#039;); &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    static public function getInstance() {&lt;br /&gt;        if (self::$instance == NULL) {&lt;br /&gt;            self::$instance = new Singleton();&lt;br /&gt;        }&lt;br /&gt;        return self::$instance;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;echo(&amp;#039;&amp;lt;pre&amp;gt;&amp;#039;);&lt;br /&gt;print_r(Singleton::getInstance());&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now we can define static methods and call then from non-object context. We don't use $this with it cause they don't bound to any specific object.&lt;br /&gt;&lt;br /&gt;We have now abstract classes :) and abstract methods which defer its definition to an inheriting class. And class that includes abstract methods must be declared as abstract.&lt;br /&gt;&lt;br /&gt;Class type hints. If the function are called with an incorrect class type an derror occurs. Let's try it:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;Class MyClass {&lt;br /&gt;    function expectsMyClass(MyClass $obj, ClassTwo $var) {&lt;br /&gt;        echo(&amp;#039;&amp;lt;pre&amp;gt;&amp;#039;); &lt;br /&gt;        print_r($obj);&lt;br /&gt;        print_r($var); &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Class ClassTwo {&lt;br /&gt;    function __construct() {&lt;br /&gt;        echo(&amp;#039;Object of ClassTwo created!&amp;lt;br /&amp;gt;&amp;#039;); &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$obj = new MyClass();&lt;br /&gt;$obj2 = new ClassTwo();&lt;br /&gt;$obj-&amp;gt;expectsMyClass($obj, $obj2);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now we can dereference object which are returned from method:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$obj-&gt;method()-&gt;method2();&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;PHP classes and PHP extension classes can implement an Iterator interface now. There is SimpleXML - a library that simplifies almost all XML-related operations. The iterator returns a SimpleXML object on each loop, making it more convenient to access XML elements. Let's create an XML document cookbook.xml:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;cookbook&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;recipe&amp;gt;&lt;br /&gt;    &amp;lt;name&amp;gt;Chocolate Muffins&amp;lt;/name&amp;gt;&lt;br /&gt;    &amp;lt;rating&amp;gt;Yummy&amp;lt;/rating&amp;gt;&lt;br /&gt;    &amp;lt;ingredients&amp;gt;Flour, Cocao, Sugar&amp;lt;/ingredients&amp;gt;&lt;br /&gt;  &amp;lt;/recipe&amp;gt;&lt;br /&gt;  &lt;br /&gt;  &amp;lt;recipe&amp;gt;&lt;br /&gt;    &amp;lt;name&amp;gt;Caramel Cake&amp;lt;/name&amp;gt;&lt;br /&gt;    &amp;lt;rating&amp;gt;Sweet&amp;lt;/rating&amp;gt;&lt;br /&gt;    &amp;lt;ingredients&amp;gt;Caramel, Flour, lots of love&amp;lt;/ingredients&amp;gt;&lt;br /&gt;  &amp;lt;/recipe&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/cookbook&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And next use the iterator:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;$data = file_get_contents(&amp;#039;cookbook.xml&amp;#039;);&lt;br /&gt;&lt;br /&gt;foreach ( new SimpleXMLIterator($data) as $recipe ) {&lt;br /&gt;    echo $recipe-&amp;gt;name . &amp;quot;\n&amp;quot;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Many include_once we can replace with such function now:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;function __autoload($class_name) {&lt;br /&gt;    include_once($class_name . &amp;quot;.php&amp;quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$obj  = new MyClass1();&lt;br /&gt;$obj2 = new MyClass2();&lt;br /&gt;&lt;br /&gt;echo(&amp;#039;&amp;lt;pre&amp;gt;&amp;#039;); &lt;br /&gt;print_r($obj);&lt;br /&gt;print_r($obj2);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The scripting engine is giving a last chance to load the class before PHP get an error. Very nice:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;function __autoload($class_name) {&lt;br /&gt;    include_once($class_name . &amp;quot;.php&amp;quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$obj  = new MyClass1();&lt;br /&gt;$obj2 = new MyClass2();&lt;br /&gt;&lt;br /&gt;echo(&amp;#039;&amp;lt;pre&amp;gt;&amp;#039;); &lt;br /&gt;print_r($obj);&lt;br /&gt;print_r($obj2);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;As from PHP5 there is an ability for the well known try/throw/catch structured exception handling paradigm. We are allowed to throw objects which inherit from the Exception class.&lt;br /&gt;&lt;br /&gt;We can iterate though an array and modify its values now. Let's use the foreach() loop with the &amp;(reference) sign:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;foreach ($array as &amp;$value) {&lt;br /&gt;    if ($value === "NULL") {&lt;br /&gt;        $value = NULL;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Giving values to by-reference parameters is now supported. For example the code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;   function square1($number) {&lt;br /&gt;      return $number * $number;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   $val = square1($val);&lt;br /&gt;&lt;br /&gt;   function square2(&amp;$number) {&lt;br /&gt;      $number = $number * $number;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   square2($val);&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;In the first part we passes a copy of $val in, multiplies the copy, return result and copy it back into $val.&lt;br /&gt;In the second part we passes $val in by reference, and it's modified directly inside the function. So, on the line:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$number = $number * $number;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;the original $number variable was altered. Slyly enough :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-4436141575269709051?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/4436141575269709051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php5-new-features.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/4436141575269709051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/4436141575269709051'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php5-new-features.html' title='PHP5 new features'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-4840528377675492130</id><published>2009-01-13T05:19:00.000-08:00</published><updated>2009-01-13T08:13:37.715-08:00</updated><title type='text'>PHP PEAR framework</title><content type='html'>PEAR is a framework and distribution system for reusable PHP components. Don't invent a cycle just attach and use it :) There are many packages with high quality code available for free. Let's try an Archive_Tar one. Include the code to our page (http://pear.php.net/package/Archive_Tar/download):&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require("Tar.php");&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And use it:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$tar_object = new Archive_Tar("tarname.tar.gz", true);&lt;br /&gt;$v_list[0]="file1.txt";&lt;br /&gt;$v_list[1]="file2.txt";&lt;br /&gt;$tar_object-&gt;add($v_list);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Good. On our root folder we get the archive. Simple, isn't it?&lt;br /&gt;&lt;br /&gt;Now let's try some work with Stream_Var package. Below we open a stream with our variable (foo). Read some info than write some info (4 symbols). And finally read that variable again, four symbols were replaced ;) Here is the code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;require_once &amp;quot;Stream/Var.php&amp;quot;;&lt;br /&gt;stream_wrapper_register( &amp;quot;var&amp;quot;, &amp;quot;Stream_Var&amp;quot; );&lt;br /&gt;&lt;br /&gt;$foo = &amp;quot;I really like tomatoes.&amp;quot;;&lt;br /&gt;echo &amp;quot;Content of foo: $foo&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;&lt;br /&gt;$fp = fopen(&amp;#039;var://GLOBALS/foo&amp;#039;,&amp;#039;r+&amp;#039;);&lt;br /&gt;$data = fread($fp, 9);&lt;br /&gt;echo &amp;quot;Read from stream: $data&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;&lt;br /&gt;fwrite($fp,&amp;quot;hate&amp;quot;);&lt;br /&gt;fclose($fp);&lt;br /&gt;echo &amp;quot;Content of foo: $foo&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;On the page we can see the following:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Content of foo: I really like tomatoes.&lt;br /&gt;Read from stream: I really&lt;br /&gt;Content of foo: I really hate tomatoes.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And here is an example shows how to use opendir() to access an array:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;require_once &amp;quot;Stream/Var.php&amp;quot;;&lt;br /&gt;stream_wrapper_register( &amp;quot;var&amp;quot;, &amp;quot;Stream_Var&amp;quot; );&lt;br /&gt;$dirname = &amp;#039;var://_SERVER&amp;#039;;&lt;br /&gt;$dir = opendir($dirname);&lt;br /&gt;echo    &amp;quot;&amp;lt;strong&amp;gt;opening directory &amp;#039;$dirname&amp;#039;&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;&lt;br /&gt;while ($entry = readdir($dir)) {&lt;br /&gt;    echo &amp;quot;opening file $dirname/$entry&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;    if (!$fp = @fopen($dirname.&amp;quot;/&amp;quot;.$entry,&amp;quot;r&amp;quot;)) {&lt;br /&gt;        echo &amp;quot;seems to be a directory&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;        continue;&lt;br /&gt;    }&lt;br /&gt;       &lt;br /&gt;    echo &amp;quot;reading from $entry&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;    while (!feof($fp)) {&lt;br /&gt;        echo fread($fp, 16);&lt;br /&gt;    }&lt;br /&gt;    fclose($fp);&lt;br /&gt;    echo    &amp;quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;}&lt;br /&gt;closedir($dir);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-4840528377675492130?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/4840528377675492130/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php-pear-framework.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/4840528377675492130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/4840528377675492130'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php-pear-framework.html' title='PHP PEAR framework'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-1228702054649902427</id><published>2009-01-13T03:29:00.001-08:00</published><updated>2009-01-13T03:37:54.275-08:00</updated><title type='text'>JSON-PHP utility from Michal Migurski</title><content type='html'>http://www.json.org/&lt;br /&gt;&lt;br /&gt;And one more utility :) We need PEAR (PHP Extension and Application Repository) library for work with the utility.&lt;br /&gt;&lt;br /&gt;We can download utility from here: http://pear.php.net/pepr/pepr-proposal-show.php?id=198&lt;br /&gt;&lt;br /&gt;Let's create an html page and include JSON.php file of the utility:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html; charset=utf-8&amp;quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;class Auto {&lt;br /&gt; public $firm;&lt;br /&gt; public $model;&lt;br /&gt; public $year;&lt;br /&gt; public $price;&lt;br /&gt; public $sellers;&lt;br /&gt; &lt;br /&gt; function Auto($firm, $model, $year, $price) {&lt;br /&gt;  $this-&gt;firm = $firm;&lt;br /&gt;  $this-&gt;model = $model;&lt;br /&gt;  $this-&gt;year = $year;&lt;br /&gt;  $this-&gt;price = $price;&lt;br /&gt;  $this-&gt;sellers = array();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$oAuto = new Auto("Audi", "A6", 2008, 78000);&lt;br /&gt;$oAuto-&gt;sellers[0] = "Фирма А";&lt;br /&gt;$oAuto-&gt;sellers[1] = "Фирма Б";&lt;br /&gt;$oAuto-&gt;sellers[2] = "Фирма В";&lt;br /&gt;&lt;br /&gt;echo "Исходный объект: ";&lt;br /&gt;print_r($oAuto);&lt;br /&gt;&lt;br /&gt;require_once('JSON.php');&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Create an object and get encoded line in format JSON:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$json = new Services_JSON();&lt;br /&gt;&lt;br /&gt;$sJSONText = $json-&gt;encode($oAuto);&lt;br /&gt;&lt;br /&gt;echo "Строка в формате JSON: ".$sJSONText;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And decode it back to the object:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$value = $json-&gt;decode($sJSONText);&lt;br /&gt;&lt;br /&gt;echo "Объект из строки JSON: ";&lt;br /&gt;print_r($value);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Work nice :) on the page we'll get something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Исходный объект: Auto Object ( [firm] =&gt; Audi [model] =&gt; A6 [year] =&gt; 2008 [price] =&gt; 78000 [sellers] =&gt; Array ( [0] =&gt; Фирма А [1] =&gt; Фирма Б [2] =&gt; Фирма В ) )&lt;br /&gt;&lt;br /&gt;Строка в формате JSON: {"firm":"Audi","model":"A6","year":2008,"price":78000,"sellers":["\u0424\u0438\u0440\u043c\u0430 \u0410","\u0424\u0438\u0440\u043c\u0430 \u0411","\u0424\u0438\u0440\u043c\u0430 \u0412"]}&lt;br /&gt;&lt;br /&gt;Объект из строки JSON: stdClass Object ( [firm] =&gt; Audi [model] =&gt; A6 [year] =&gt; 2008 [price] =&gt; 78000 [sellers] =&gt; Array ( [0] =&gt; Фирма А [1] =&gt; Фирма Б [2] =&gt; Фирма В ) ) &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Here is some info: http://www.json.org/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-1228702054649902427?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/1228702054649902427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/json-utility-from-douglas-crockford_13.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1228702054649902427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1228702054649902427'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/json-utility-from-douglas-crockford_13.html' title='JSON-PHP utility from Michal Migurski'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-2837298246582195309</id><published>2009-01-13T02:36:00.000-08:00</published><updated>2009-01-13T02:54:08.991-08:00</updated><title type='text'>JSON utility from Douglas Crockford</title><content type='html'>JSON is a lightweight computer data interchange format. It's a text-based, human-readable format for representing simple data structures and associative arrays (called objects).&lt;br /&gt;&lt;br /&gt;The JSON format is specified by Douglas Crockford. The JSON file extension is .json.&lt;br /&gt;&lt;br /&gt;Data in JSON format is more readable and takes less bytes then XML.&lt;br /&gt;&lt;br /&gt;Douglas Crockford created an utility for work with converting data from and to JSON format. Let's try it now :)&lt;br /&gt;&lt;br /&gt;Original code can be downloaded from here: http://www.linkexchanger.su/example_json/json.zip&lt;br /&gt;&lt;br /&gt;On our html page put link to the utility code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;json.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Then we create an Object OAuto using literal notation:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;var oAuto = new Object();&lt;br /&gt;oAuto.firm = "Audi";&lt;br /&gt;oAuto.model = "A6";&lt;br /&gt;oAuto.year = 2008;&lt;br /&gt;oAuto.price = 78000;&lt;br /&gt;oAuto.sellers = new Array(&lt;br /&gt;  "Фирма А",&lt;br /&gt;  "Фирма Б",&lt;br /&gt;  "Фирма В"&lt;br /&gt;);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Give object to the method JSON.stringify()&lt;br /&gt;&lt;code&gt;&lt;br /&gt;document.write(JSON.stringify(oAuto));&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;We'll get string in JSON format which can send to any address :)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;{"firm":"Audi","model":"A6","year":2008,"price":78000,&lt;br /&gt;"sellers":["Фирма А","Фирма Б","Фирма В"]}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And lets do it the other: we got answer from the server and convert it to JavaScript object:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;var oAuto = JSON.parse(sAuto);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And get JavaScript Object. Great ;)&lt;br /&gt;&lt;br /&gt;The result will be something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;{"firm":"Audi","model":"A6","year":2008,"price":78000,"sellers":["Фирма А","Фирма Б","Фирма В"]}&lt;br /&gt;&lt;br /&gt;Автомобиль Audi A6 2008 года выпуска, цена 78000 евро.&lt;br /&gt;Продавцы: Фирма А, Фирма Б, Фирма В. &lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-2837298246582195309?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/2837298246582195309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/json-utility-from-douglas-crockford.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2837298246582195309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2837298246582195309'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/json-utility-from-douglas-crockford.html' title='JSON utility from Douglas Crockford'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-3156970138266504259</id><published>2009-01-12T08:05:00.001-08:00</published><updated>2009-01-13T08:15:11.025-08:00</updated><title type='text'>PHP5 overload set(), get(), call()</title><content type='html'>One more new feature in PHP5 has become overloading. Using magic methods __set(), __get(), __call() we can overload calls to properties and methods. __get() and __set() are called while setting and getting the value, and __call() while calling the method that doesn't exist in the class.&lt;br /&gt;But the magic functions will be called only when target method / property doesn't exist.&lt;br /&gt;&lt;br /&gt;Here is some example (I've grabbed it from the internet) of usage __set() and __get:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;class Setter {&lt;br /&gt;    public $n;&lt;br /&gt;    public $x = array(&amp;#039;a&amp;#039; =&amp;gt; 1, &amp;#039;b&amp;#039; =&amp;gt; 2, &amp;#039;c&amp;#039; =&amp;gt; 3);&lt;br /&gt;&lt;br /&gt;    function __set($nm, $val) {&lt;br /&gt;        echo &amp;quot;Set [$nm] to $val\n&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;        if (isset($this-&amp;gt;x[$nm])) {&lt;br /&gt;            $this-&amp;gt;x[$nm] = $val;&lt;br /&gt;            echo &amp;quot;Good!\n&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;        }&lt;br /&gt;        else { echo &amp;quot;Bad!\n&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;quot;; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function __get($nm) {&lt;br /&gt;        echo &amp;quot;Get [$nm]\n&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;        if (isset($this-&amp;gt;x[$nm])) {&lt;br /&gt;            $r = $this-&amp;gt;x[$nm];&lt;br /&gt;            echo &amp;quot;Return: $r\n&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;quot;;&lt;br /&gt;            return $r;&lt;br /&gt;        }&lt;br /&gt;        else { echo &amp;quot;Empty!\n&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;quot;; }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$foo = new Setter();&lt;br /&gt;$foo-&amp;gt;n = 1;&lt;br /&gt;$foo-&amp;gt;a = 100;&lt;br /&gt;$foo-&amp;gt;a++;&lt;br /&gt;$foo-&amp;gt;z++;&lt;br /&gt;&lt;br /&gt;echo(&amp;#039;&amp;lt;pre&amp;gt;&amp;#039;);&lt;br /&gt;var_dump($foo);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Result will be the next:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Set [a] to 100&lt;br /&gt;Good!&lt;br /&gt;&lt;br /&gt;Get [a]&lt;br /&gt;Return: 100&lt;br /&gt;&lt;br /&gt;Set [a] to 101&lt;br /&gt;Good!&lt;br /&gt;&lt;br /&gt;Get [z]&lt;br /&gt;Empty!&lt;br /&gt;&lt;br /&gt;Set [z] to 1&lt;br /&gt;Bad!&lt;br /&gt;&lt;br /&gt;object(Setter)#1 (2) {&lt;br /&gt;  [&amp;quot;n&amp;quot;]=&amp;gt;&lt;br /&gt;  int(1)&lt;br /&gt;  [&amp;quot;x&amp;quot;]=&amp;gt;&lt;br /&gt;  array(3) {&lt;br /&gt;    [&amp;quot;a&amp;quot;]=&amp;gt;&lt;br /&gt;    int(101)&lt;br /&gt;    [&amp;quot;b&amp;quot;]=&amp;gt;&lt;br /&gt;    int(2)&lt;br /&gt;    [&amp;quot;c&amp;quot;]=&amp;gt;&lt;br /&gt;    int(3)&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And magic __call() method is called with two parameters: name of the method and array of the parameters:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;class Caller {&lt;br /&gt;    public $x = array(1, 2, 3);&lt;br /&gt;&lt;br /&gt;    function __call($m, $a) {&lt;br /&gt;        echo &amp;quot;Method $m called:\n&amp;quot;;&lt;br /&gt;        echo(&amp;#039;&amp;lt;pre&amp;gt;&amp;#039;); &lt;br /&gt;        var_dump($a);&lt;br /&gt;        echo(&amp;#039;&amp;lt;hr&amp;gt;&amp;#039;); &lt;br /&gt;        return $this-&amp;gt;x;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$foo = new Caller();&lt;br /&gt;$a = $foo-&amp;gt;test(1, &amp;quot;2&amp;quot;, 3.4, true);&lt;br /&gt;echo &amp;quot;Returned value:\n&amp;quot;;&lt;br /&gt;echo(&amp;#039;&amp;lt;pre&amp;gt;&amp;#039;); &lt;br /&gt;var_dump($a);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And the result is next:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Method test called:&lt;br /&gt;&lt;br /&gt;array(4) {&lt;br /&gt;  [0]=&amp;gt;&lt;br /&gt;  int(1)&lt;br /&gt;  [1]=&amp;gt;&lt;br /&gt;  string(1) &amp;quot;2&amp;quot;&lt;br /&gt;  [2]=&amp;gt;&lt;br /&gt;  float(3.4)&lt;br /&gt;  [3]=&amp;gt;&lt;br /&gt;  bool(true)&lt;br /&gt;}&lt;br /&gt;Returned value:&lt;br /&gt;&lt;br /&gt;array(3) {&lt;br /&gt;  [0]=&amp;gt;&lt;br /&gt;  int(1)&lt;br /&gt;  [1]=&amp;gt;&lt;br /&gt;  int(2)&lt;br /&gt;  [2]=&amp;gt;&lt;br /&gt;  int(3)&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;What is the good from all of this? And again less and more laconic code. Good...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-3156970138266504259?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/3156970138266504259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php5-overload-set-get-call.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3156970138266504259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3156970138266504259'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/php5-overload-set-get-call.html' title='PHP5 overload set(), get(), call()'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-3838874781713830139</id><published>2009-01-08T09:47:00.000-08:00</published><updated>2009-01-09T06:05:56.893-08:00</updated><title type='text'>GD library (russian text on the image)</title><content type='html'>&lt;span style="font-style:italic;"&gt;This post is an improvement of the previous post in December "GD library (text on the image)". Just felt it should be enhanced :) &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hi! While working on the interesting project we needed a function which will create many lines from the one. For example we have "one two three four five" and want to get:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;one two&lt;br /&gt;three four&lt;br /&gt;five&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Just decided to write down created function for the future :) feeling that it's not the best but that's it :)&lt;br /&gt;So the function is something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;protected function _line_to_lines($line, $letters_in_line = 40, $font_size) {&lt;br /&gt;        if (mb_strlen($line, &amp;quot;UTF-8&amp;quot;) &amp;lt; $letters_in_line) {&lt;br /&gt;            $res_lines = $this-&amp;gt;_replace_cyr(trim($line));&lt;br /&gt;        }&lt;br /&gt;        else {&lt;br /&gt;            $ar_lines = explode(&amp;quot; &amp;quot;, $line);&lt;br /&gt;            $how_many = count($ar_lines);&lt;br /&gt;            $num_lines = 0;&lt;br /&gt;            $k = 0;&lt;br /&gt;            $one_line = $ar_lines[0];&lt;br /&gt;            for ($i = 1; $i &amp;lt; $how_many; $i++) {&lt;br /&gt;                if (mb_strlen($one_line.&amp;quot; &amp;quot;.$ar_lines[$i], &amp;quot;UTF-8&amp;quot;) &amp;lt; $letters_in_line) {&lt;br /&gt;                    $one_line .= &amp;quot; &amp;quot;.$ar_lines[$i];&lt;br /&gt;                }&lt;br /&gt;                else {&lt;br /&gt;                    $res_lines[$k] = $this-&amp;gt;_replace_cyr(trim($one_line));&lt;br /&gt;                    $one_line = $ar_lines[$i];&lt;br /&gt;                    $k++;&lt;br /&gt;                }&lt;br /&gt;                $end_line = $one_line;&lt;br /&gt;            }&lt;br /&gt;            $res_lines[$k] = $this-&amp;gt;_replace_cyr(trim($end_line));&lt;br /&gt;            $num_lines = count($res_lines);&lt;br /&gt;            $res_lines = implode(&amp;quot;\n\r&amp;quot;, $res_lines);&lt;br /&gt;&lt;br /&gt;            //this check for russian encoded text only&lt;br /&gt;            if (mb_strstr($res_lines, &amp;quot;&amp;amp;#&amp;quot;, 0, &amp;quot;UTF-8&amp;quot;) &amp;amp;&amp;amp; (mb_strlen($res_lines, &amp;quot;UTF-8&amp;quot;) &amp;gt; 1000)) { &lt;br /&gt;                //cut off all symbols after 1000&lt;br /&gt;                $res_lines = mb_substr($res_lines, 0, 1000, &amp;quot;UTF-8&amp;quot;);&lt;br /&gt;                $last_amp = mb_strrpos($res_lines, &amp;quot;&amp;amp;&amp;quot;);&lt;br /&gt;                $res_lines = mb_substr($res_lines, 0, $last_amp, &amp;quot;UTF-8&amp;quot;);&lt;br /&gt;&lt;br /&gt;                ($num_lines &amp;gt; 5) ? ($num_lines = 5) : &amp;#039;&amp;#039; ;          //set cutted height&lt;br /&gt;            }&lt;br /&gt;            $height = $num_lines * ($font_size + 8);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        return array($res_lines, $height);&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;and notice that one more function is called here &lt;span style="font-weight:bold;"&gt;_replace_cyr&lt;/span&gt;. This function convers russian letters to their HTML entities. Cause if we want to put some russian text on the image with GD library in PHP. So we have to convert russian letters and only then put it on the image:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;protected function _replace_cyr($path){&lt;br /&gt;   $search = array (&amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;nbsp;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;iexcl;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;cent;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;pound;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;curren;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;yen;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;brvbar;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;sect;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;uml;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;copy;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;ordf;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;laquo;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;not;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;shy;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;reg;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;macr;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;deg;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;plusmn;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;sup2;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;sup3;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;acute;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;micro;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;para;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;middot;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;cedil;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;sup1;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;ordm;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;raquo;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;frac14;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;frac12;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;frac34;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;iquest;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;0&amp;#039;e&amp;quot;);&lt;br /&gt;   $replace = array (&amp;#039;&amp;amp;#1025;&amp;#039;, &amp;#039;&amp;amp;#1040;&amp;#039;, &amp;#039;&amp;amp;#1041;&amp;#039;, &amp;#039;&amp;amp;#1042;&amp;#039;, &amp;#039;&amp;amp;#1043;&amp;#039;, &amp;#039;&amp;amp;#1044;&amp;#039;, &amp;#039;&amp;amp;#1045;&amp;#039;, &amp;#039;&amp;amp;#1046;&amp;#039;, &amp;#039;&amp;amp;#1047;&amp;#039;, &amp;#039;&amp;amp;#1048;&amp;#039;, &amp;#039;&amp;amp;#1049;&amp;#039;, &amp;#039;&amp;amp;#1050;&amp;#039;, &amp;#039;&amp;amp;#1051;&amp;#039;, &amp;#039;&amp;amp;#1052;&amp;#039;, &amp;#039;&amp;amp;#1053;&amp;#039;, &amp;#039;&amp;amp;#1054;&amp;#039;, &amp;#039;&amp;amp;#1055;&amp;#039;, &amp;#039;&amp;amp;#1056;&amp;#039;, &amp;#039;&amp;amp;#1057;&amp;#039;, &amp;#039;&amp;amp;#1058;&amp;#039;, &amp;#039;&amp;amp;#1059;&amp;#039;, &amp;#039;&amp;amp;#1060;&amp;#039;, &amp;#039;&amp;amp;#1061;&amp;#039;, &amp;#039;&amp;amp;#1062;&amp;#039;, &amp;#039;&amp;amp;#1063;&amp;#039;, &amp;#039;&amp;amp;#1064;&amp;#039;, &amp;#039;&amp;amp;#1065;&amp;#039;, &amp;#039;&amp;amp;#1066;&amp;#039;, &amp;#039;&amp;amp;#1067;&amp;#039;, &amp;#039;&amp;amp;#1068;&amp;#039;, &amp;#039;&amp;amp;#1069;&amp;#039;, &amp;#039;&amp;amp;#1070;&amp;#039;, &amp;#039;&amp;amp;#1071;&amp;#039;, &amp;#039;&amp;amp;#1072;&amp;#039;, &amp;#039;&amp;amp;#1073;&amp;#039;, &amp;#039;&amp;amp;#1074;&amp;#039;, &amp;#039;&amp;amp;#1075;&amp;#039;, &amp;#039;&amp;amp;#1076;&amp;#039;, &amp;#039;&amp;amp;#1077;&amp;#039;, &amp;#039;&amp;amp;#1078;&amp;#039;, &amp;#039;&amp;amp;#1079;&amp;#039;, &amp;#039;&amp;amp;#1080;&amp;#039;, &amp;#039;&amp;amp;#1081;&amp;#039;, &amp;#039;&amp;amp;#1082;&amp;#039;, &amp;#039;&amp;amp;#1083;&amp;#039;, &amp;#039;&amp;amp;#1084;&amp;#039;, &amp;#039;&amp;amp;#1085;&amp;#039;, &amp;#039;&amp;amp;#1086;&amp;#039;, &amp;#039;&amp;amp;#1087;&amp;#039;, &amp;#039;&amp;amp;#1088;&amp;#039;, &amp;#039;&amp;amp;#1089;&amp;#039;, &amp;#039;&amp;amp;#1090;&amp;#039;, &amp;#039;&amp;amp;#1091;&amp;#039;, &amp;#039;&amp;amp;#1092;&amp;#039;, &amp;#039;&amp;amp;#1093;&amp;#039;, &amp;#039;&amp;amp;#1094;&amp;#039;, &amp;#039;&amp;amp;#1095;&amp;#039;, &amp;#039;&amp;amp;#1096;&amp;#039;, &amp;#039;&amp;amp;#1097;&amp;#039;, &amp;#039;&amp;amp;#1098;&amp;#039;, &amp;#039;&amp;amp;#1099;&amp;#039;, &amp;#039;&amp;amp;#1100;&amp;#039;, &amp;#039;&amp;amp;#1101;&amp;#039;, &amp;#039;&amp;amp;#1102;&amp;#039;, &amp;#039;&amp;amp;#1103;&amp;#039;, &amp;#039;&amp;amp;#1105;&amp;#039;, &amp;#039;0&amp;#039;);&lt;br /&gt;   return preg_replace ($search,$replace,$path);&lt;br /&gt;  }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;That strange symbols are russian letters ;)&lt;br /&gt;&lt;br /&gt;So as a result we'll get many lines from one line. The lines will be encoded to HTML entities. And also we'll get total height of that lines - for the allocation on the image :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-3838874781713830139?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/3838874781713830139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/function-to-lines-from-line.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3838874781713830139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3838874781713830139'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2009/01/function-to-lines-from-line.html' title='GD library (russian text on the image)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-1659921751641797597</id><published>2008-12-30T02:44:00.000-08:00</published><updated>2008-12-30T02:54:45.495-08:00</updated><title type='text'>Firefox3 (create an extension)</title><content type='html'>&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_coCosk4H_Mo/SVn7719c-jI/AAAAAAAAAGk/CkS6lnwoYcA/s1600-h/pic.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 230px; height: 58px;" src="http://3.bp.blogspot.com/_coCosk4H_Mo/SVn7719c-jI/AAAAAAAAAGk/CkS6lnwoYcA/s400/pic.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5285532643211672114" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Let's create an extension for the Firefox browser. Firefox's user interface is written in XUL and JavaScript. XUL files are used in Firefox to describe overlays. For example if we print in address bar something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;chrome://browser/content/browser.xul&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Yep :) one more browser in our browser )) There is an overlay of Firefox browser.&lt;br /&gt;OK. And we go...&lt;br /&gt;We create a folder for our extension somewhere on hard disk C:\extensions\myextension insite create a folder called chrome and inside the chrome folder create a folder called content. Inside the root directory create two new empty text files, one called chrome.manifest and the other called install.rdf. Finally we'll get something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;ext path&gt;\&lt;br /&gt;          install.rdf&lt;br /&gt;          chrome.manifest&lt;br /&gt;          chrome\&lt;br /&gt;             content\&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now create the install manifest. Open install.rdf file and put this code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;RDF xmlns=&amp;quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&amp;quot;&lt;br /&gt;     xmlns:em=&amp;quot;http://www.mozilla.org/2004/em-rdf#&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;Description about=&amp;quot;urn:mozilla:install-manifest&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;em:id&amp;gt;sample@example.net&amp;lt;/em:id&amp;gt;&lt;br /&gt;    &amp;lt;em:version&amp;gt;1.0&amp;lt;/em:version&amp;gt;&lt;br /&gt;    &amp;lt;em:type&amp;gt;2&amp;lt;/em:type&amp;gt;&lt;br /&gt;   &lt;br /&gt;    &amp;lt;!-- Target Application this extension can install into, &lt;br /&gt;         with minimum and maximum supported versions. --&amp;gt; &lt;br /&gt;    &amp;lt;em:targetApplication&amp;gt;&lt;br /&gt;      &amp;lt;Description&amp;gt;&lt;br /&gt;        &amp;lt;em:id&amp;gt;{ec8030f7-c20a-464f-9b0e-13a3a9e97384}&amp;lt;/em:id&amp;gt;&lt;br /&gt;        &amp;lt;em:minVersion&amp;gt;1.5&amp;lt;/em:minVersion&amp;gt;&lt;br /&gt;        &amp;lt;em:maxVersion&amp;gt;3.0.*&amp;lt;/em:maxVersion&amp;gt;&lt;br /&gt;      &amp;lt;/Description&amp;gt;&lt;br /&gt;    &amp;lt;/em:targetApplication&amp;gt;&lt;br /&gt;   &lt;br /&gt;    &amp;lt;!-- Front End MetaData --&amp;gt;&lt;br /&gt;    &amp;lt;em:name&amp;gt;sample&amp;lt;/em:name&amp;gt;&lt;br /&gt;    &amp;lt;em:description&amp;gt;A test extension&amp;lt;/em:description&amp;gt;&lt;br /&gt;    &amp;lt;em:creator&amp;gt;Your Name Here&amp;lt;/em:creator&amp;gt;&lt;br /&gt;    &amp;lt;em:homepageURL&amp;gt;http://www.example.com/&amp;lt;/em:homepageURL&amp;gt;&lt;br /&gt;  &amp;lt;/Description&amp;gt;      &lt;br /&gt;&amp;lt;/RDF&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Notice: sample@example.net - the ID of our extension. And {ec8030f7-c20a-464f-9b0e-13a3a9e97384} - Firefox's application ID. Please set maximum ver. of the Firefox as your one. About this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;em:maxVersion&amp;gt;3.0.*&amp;lt;/em:maxVersion&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now add some data to chrome.manifest file. Add lines:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;content     sample    chrome/content/&lt;br /&gt;overlay chrome://browser/content/browser.xul chrome://sample/content/sample.xul&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;In folrder chrome/content create your layout sample.xul with code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;overlay id=&amp;quot;sample&amp;quot; &lt;br /&gt;         xmlns=&amp;quot;http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&amp;quot;&amp;gt;&lt;br /&gt; &amp;lt;statusbar id=&amp;quot;status-bar&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;statusbarpanel id=&amp;quot;my-panel&amp;quot; label=&amp;quot;Happy New Year!!!&amp;quot;/&amp;gt;&lt;br /&gt; &amp;lt;/statusbar&amp;gt;&lt;br /&gt;&amp;lt;/overlay&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And tell Firefox to add the extension create a file. For this lets open current Firefox profiles. Just print in "Run" (command line in Windows) somethins like this: %appdata%. Actually on my machine the path is:&lt;br /&gt;C:\Documents and Settings\amak\Application Data\Mozilla\Firefox\Profiles\66q2ksw1.default\extensions&lt;br /&gt;Create there a file "sample@example.net" name like id of our extention. And put in the file line: &lt;br /&gt;&lt;code&gt;&lt;br /&gt;C:\extensions\myextension\&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Restart Firefox and look into the status bar of our browser.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-1659921751641797597?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/1659921751641797597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/firefox3-create-extension.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1659921751641797597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1659921751641797597'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/firefox3-create-extension.html' title='Firefox3 (create an extension)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_coCosk4H_Mo/SVn7719c-jI/AAAAAAAAAGk/CkS6lnwoYcA/s72-c/pic.JPG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-7708806294375505087</id><published>2008-12-29T05:31:00.001-08:00</published><updated>2008-12-29T06:53:25.378-08:00</updated><title type='text'>Firefox3 (create search plugin)</title><content type='html'>&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_coCosk4H_Mo/SVjkMvcaQhI/AAAAAAAAAGc/5XGfiv2uF0g/s1600-h/pic.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 316px; height: 81px;" src="http://3.bp.blogspot.com/_coCosk4H_Mo/SVjkMvcaQhI/AAAAAAAAAGc/5XGfiv2uF0g/s400/pic.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5285225070264467986" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;&lt;br /&gt;There is a convenient search bar in the right top corner of the Firefox. There is limited number of search plugins, sometimes we want to add one more. Very good that it's easy and quick :)&lt;br/&gt;For example we want to have search on our blog. Let's do it now. In Firefox3 search plugins are in installation folder: Mozilla Firefox\searchplugins. Just look on the existent one and alter it a little. For example google search: &lt;br/&gt;&lt;code&gt;&lt;br/&gt;&amp;lt;SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/"&amp;gt;&lt;br/&gt;&amp;lt;ShortName&amp;gt;Google&amp;lt;/ShortName&amp;gt;&lt;br/&gt;&amp;lt;Description&amp;gt;Google Search&amp;lt;/Description&amp;gt;&lt;br/&gt;&amp;lt;InputEncoding&amp;gt;UTF-8&amp;lt;/InputEncoding&amp;gt;&lt;br/&gt;&amp;lt;Image width="16" height="16"&amp;gt;data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAaRJREFUeNpiVIg5JRURw0A0YAHio943kYV%2B%2Ff33%2BdvvX7%2F%2FMjEx8nKycrGzwKXOiPKzICvdeezLhCV3jp15%2Bfv%2FX0YGhv8MDDxMX2qKTIw0RK10eYD6QYqATvoPBkt3f5K0W9Ew4fjTFz%2F%2Bw8Dm3W8UPeZxqFa%2BevsFyD0twgfVsOfkRxHrtfV9u5BVQ8Crd98%2FffkGYQM1QJ20%2FfSPv79eNxQGYfpSVJADmcvEAHbr7oOX2dj%2FERNKIA2%2F%2F%2Fz%2FxfCDhYVoDUDw5P6vf9%2B5iY0HVmZGQWm%2BN3fff%2Fn2k4eLHS739x%2FDiRs%2Ff%2F%2F5x8HO%2FOHzN3djfqgNjIwMgc6qzLx%2Fpy47j2zY%2Feff06tXhOUucgxeun33AUZGpHh4%2Bvo7t8EyIJqz%2FhpasD59%2B5dNrqdnznZIsEL9ICXCsWuBCwvTv%2FymS5PWPP32ExEALz%2F%2BB5r848cPCJcRaMP9xaYQzofPPzfuvrnj0Jst%2B5%2F8%2Bc4sLPeDkYlRgJc93VPE18NIXkYUmJYQSQMZ%2FP3379uPH7%2F%2F%2FEETBzqJ0WqLGvFpe2LCC4AAAwAyjg7ENzDDWAAAAABJRU5ErkJggg%3D%3D&amp;lt;/Image&amp;gt;&lt;br/&gt;&amp;lt;Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&amp;amp;client=firefox&amp;amp;hl={moz:locale}&amp;amp;q={searchTerms}"/&amp;gt;&lt;br/&gt;&amp;lt;Url type="text/html" method="GET" template="http://www.google.com/search"&amp;gt;&lt;br/&gt;  &amp;lt;Param name="q" value="{searchTerms}"/&amp;gt;&lt;br/&gt;  &amp;lt;Param name="ie" value="utf-8"/&amp;gt;&lt;br/&gt;  &amp;lt;Param name="oe" value="utf-8"/&amp;gt;&lt;br/&gt;  &amp;lt;Param name="aq" value="t"/&amp;gt;&lt;br/&gt;  &amp;lt;!-- Dynamic parameters --&amp;gt;&lt;br/&gt;  &amp;lt;Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/&amp;gt;&lt;br/&gt;  &amp;lt;MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/&amp;gt;&lt;br/&gt;&amp;lt;/Url&amp;gt;&lt;br/&gt;&amp;lt;SearchForm&amp;gt;http://www.google.com/firefox&amp;lt;/SearchForm&amp;gt;&lt;br/&gt;&amp;lt;/SearchPlugin&amp;gt;&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;XML document ;) tags names are nice. Maybe the most interesting for us are tag IMG. The image is embedded inside a PHP script. There is a magic program that base64-encodes images and generated PHP code that represents the image. So, now we don't need keep pic image just encode it and paste into the plugin code :)&lt;br/&gt;Here is the program: http://php.holtsmark.no/base64img/&lt;br/&gt;The result of the program will something like this:&lt;br/&gt;&lt;code&gt;&lt;br/&gt;&amp;lt;?&lt;br/&gt;# Copy and paste this code&lt;br/&gt;# into the TOP of your&lt;br/&gt;# php-script!&lt;br/&gt;&lt;br/&gt;  function img() &lt;br/&gt;  {&lt;br/&gt;    header("Content-type: image/png");&lt;br/&gt;    header("Content-length: 676");&lt;br/&gt;    echo base64_decode(&lt;br/&gt;'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAX'.&lt;br/&gt;'NSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYA'.&lt;br/&gt;'AICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAiJJRE'.&lt;br/&gt;'FUOE+llEtIVFEYx88UMzlZQhAktGiRuK0WbaJyUbloHUWY44w6'.&lt;br/&gt;'L5uJwjaBG3e2ylpF1KLJKattLyipbClYmFIalUwvQWigpjJ1/P'.&lt;br/&gt;'V9XYc7N+dO2Rz4w+Xcc37ne3uMrJuH6vdsr57q3+T7st4s6M4y'.&lt;br/&gt;'lseYvMdnxr6vS29JTQXMnaa6xlzYlyNuIFKBEh5eB2tSJhNa+9'.&lt;br/&gt;'kV1i4PtBUpXObBqCHX5s0bYiUOtcpesyi6ApJrLHWsghbZU7l5'.&lt;br/&gt;'IlCz5KdeOFkL98/A5BB8HBONQuYZDPVDzw4IuEOdQLWscyO8k8'.&lt;br/&gt;'tuayYHvftcoU6gujlw1h1W+JMZlhCstuL7h/s2UBMQ9TqtG7wg'.&lt;br/&gt;'Lu4S7YTrx2H+p4XMz0HXZjgod/ReEdQG6mvHJPgas8IaOAfd20'.&lt;br/&gt;'RbIdVuA/X/vR44vdtKWBHUCUxWw4fnf3e5+MSlI1ZFLFpZOfDq'.&lt;br/&gt;'0WUAp9/AyC0YvWtp5DZMPIa5GdvGvngZYMLvjOG1JBwWd0KLUt'.&lt;br/&gt;'cSkt1PL4uAMRegtlXIAy8e2Iez72H8oVg1aEm/30qxz8/aZ3r3'.&lt;br/&gt;'ugA1qNoB5w/8e1JePYG4sx6dhf3bStGNE/AtWx48/ghO1UHQrQ'.&lt;br/&gt;'4Lxak1pf3cVQ8XmyDdAX0SJ1VaEnAlIq3XKJ1StQSmpWPyMV/p'.&lt;br/&gt;'6aEvaxLcVKLtdDqZp4ENaWQ4IqOnsgFrmG71Z0xDQ0vVZLDm8t'.&lt;br/&gt;'eI98f/QheiK8mG/RPDzbX7fwF4qkabb2dNhgAAAABJRU5ErkJg'.&lt;br/&gt;'gg=='.&lt;br/&gt;'');&lt;br/&gt;  }&lt;br/&gt;# Above is the code of&lt;br/&gt;# your image..&lt;br/&gt;&lt;br/&gt;# Here is a Example:&lt;br/&gt;# This is the phpcode to&lt;br/&gt;# execute function img(); :&lt;br/&gt;  if ( array_key_exists("image", $_REQUEST) &amp;amp;&amp;amp; $_REQUEST["image"]==1) { img(); die(); }&lt;br/&gt;&lt;br/&gt;# End PHP ?&amp;gt;&lt;br/&gt;  &amp;lt;img src=&amp;lt;?php echo $_SERVER["PHP_SELF"]; ?&amp;gt;?image=1&amp;gt;&amp;lt;br&amp;gt; &lt;br/&gt;  Created with &amp;lt;a href=http://php.holtsmark.no&amp;gt;&lt;br/&gt;  base64img.php&amp;lt;/a&amp;gt;&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;And we'll need that some encoded lines. I've joined that lines in one line and get something like this:&lt;br/&gt;&lt;code&gt;&lt;br/&gt;iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAiJJREFUOE+llEtIVFEYx88UMzlZQhAktGiRuK0WbaJyUbloHUWY44w6L5uJwjaBG3e2ylpF1KLJKattLyipbClYmFIalUwvQWigpjJ1/PV9XYc7N+dO2Rz4w+Xcc37ne3uMrJuH6vdsr57q3+T7st4s6M4ylseYvMdnxr6vS29JTQXMnaa6xlzYlyNuIFKBEh5eB2tSJhNa+9kV1i4PtBUpXObBqCHX5s0bYiUOtcpesyi6ApJrLHWsghbZU7l5IlCz5KdeOFkL98/A5BB8HBONQuYZDPVDzw4IuEOdQLWscyO8k8tuayYHvftcoU6gujlw1h1W+JMZlhCstuL7h/s2UBMQ9TqtG7wgLu4S7YTrx2H+p4XMz0HXZjgod/ReEdQG6mvHJPgas8IaOAfd20RbIdVuA/X/vR44vdtKWBHUCUxWw4fnf3e5+MSlI1ZFLFpZOfDq0WUAp9/AyC0YvWtp5DZMPIa5GdvGvngZYMLvjOG1JBwWd0KLUtcSkt1PL4uAMRegtlXIAy8e2Iez72H8oVg1aEm/30qxz8/aZ3r3ugA1qNoB5w/8e1JePYG4sx6dhf3bStGNE/AtWx48/ghO1UHQrQ4Lxak1pf3cVQ8XmyDdAX0SJ1VaEnAlIq3XKJ1StQSmpWPyMV/p6aEvaxLcVKLtdDqZp4ENaWQ4IqOnsgFrmG71Z0xDQ0vVZLDm8teI98f/QheiK8mG/RPDzbX7fwF4qkabb2dNhgAAAABJRU5ErkJggg==&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;Then paste this code into the img tag something like this:&lt;br/&gt;&lt;code&gt;&lt;br/&gt;&amp;lt;Image width="16" height="16"&amp;gt;data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAiJJREFUOE+llEtIVFEYx88UMzlZQhAktGiRuK0WbaJyUbloHUWY44w6L5uJwjaBG3e2ylpF1KLJKattLyipbClYmFIalUwvQWigpjJ1/PV9XYc7N+dO2Rz4w+Xcc37ne3uMrJuH6vdsr57q3+T7st4s6M4ylseYvMdnxr6vS29JTQXMnaa6xlzYlyNuIFKBEh5eB2tSJhNa+9kV1i4PtBUpXObBqCHX5s0bYiUOtcpesyi6ApJrLHWsghbZU7l5IlCz5KdeOFkL98/A5BB8HBONQuYZDPVDzw4IuEOdQLWscyO8k8tuayYHvftcoU6gujlw1h1W+JMZlhCstuL7h/s2UBMQ9TqtG7wgLu4S7YTrx2H+p4XMz0HXZjgod/ReEdQG6mvHJPgas8IaOAfd20RbIdVuA/X/vR44vdtKWBHUCUxWw4fnf3e5+MSlI1ZFLFpZOfDq0WUAp9/AyC0YvWtp5DZMPIa5GdvGvngZYMLvjOG1JBwWd0KLUtcSkt1PL4uAMRegtlXIAy8e2Iez72H8oVg1aEm/30qxz8/aZ3r3ugA1qNoB5w/8e1JePYG4sx6dhf3bStGNE/AtWx48/ghO1UHQrQ4Lxak1pf3cVQ8XmyDdAX0SJ1VaEnAlIq3XKJ1StQSmpWPyMV/p6aEvaxLcVKLtdDqZp4ENaWQ4IqOnsgFrmG71Z0xDQ0vVZLDm8teI98f/QheiK8mG/RPDzbX7fwF4qkabb2dNhgAAAABJRU5ErkJggg==&amp;lt;/Image&amp;gt;&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;Also there are two types of tag URL:&lt;br/&gt;&lt;b&gt;text/html&lt;br/&gt;application/x-suggestions+json&lt;/b&gt;&lt;br/&gt;&lt;br/&gt;text/html for our search query&lt;br/&gt;application/x-suggestions+json for drop down list with search suggestions (like in Google)&lt;br/&gt;I've deleted second one cause seems there is no such service on my blog.&lt;br/&gt;And first one is like this:&lt;br/&gt;&lt;code&gt;&lt;br/&gt;&amp;lt;Url type="text/html" method="GET" template="http://www.google.com/search"&amp;gt;&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;Google search page address.&lt;br/&gt;And in params we have one with name="q". This is query that will be added to the search line. So lets put there our code:&lt;br/&gt;&lt;code&gt;&lt;br/&gt;&amp;lt;Param name="q" value="logic-is-art.blogspot.com: {searchTerms}"/&amp;gt;&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;It's not a secret that if we want Google to search within only one website we can do it like this&lt;br/&gt;&lt;code&gt;&lt;br/&gt;oursite.com: searchme&lt;br/&gt;&lt;/code&gt;&lt;br/&gt;So, this {searchTerms} will be a word that we'll type into the search field.&lt;br/&gt;That's all. Don't forget to restart a fox. Enjoy :)&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;And one more plugin Lingvo online dictionary. Here is a code:&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;SearchPlugin xmlns=&amp;quot;http://www.mozilla.org/2006/browser/search/&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;ShortName&amp;gt;Lingvo&amp;lt;/ShortName&amp;gt;&lt;br /&gt;&amp;lt;Description&amp;gt;Lingvo&amp;lt;/Description&amp;gt;&lt;br /&gt;&amp;lt;InputEncoding&amp;gt;UTF-8&amp;lt;/InputEncoding&amp;gt;&lt;br /&gt;&amp;lt;Image width=&amp;quot;16&amp;quot; height=&amp;quot;16&amp;quot;&amp;gt;data:image/x-icon;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QCURXhpZgAASUkqAAgAAAADADEBAgAcAAAAMgAAADIBAgAUAAAATgAAAGmHBAABAAAAYgAAAAAAAABBZG9iZSBQaG90b3Nob3AgQ1MzIFdpbmRvd3MAMjAwODowODoxMiAwOTozOTozNgADAAGgAwABAAAA//8AAAKgBAABAAAANwEAAAOgBAABAAAALAEAAAAAAAD/2wBDAAICAgICAQICAgIDAgIDAwYEAwMDAwcFBQQGCAcJCAgHCAgJCg0LCQoMCggICw8LDA0ODg8OCQsQERAOEQ0ODg7/2wBDAQIDAwMDAwcEBAcOCQgJDg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg7/wAARCAAUABQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD2r9vb4n/EbwZ8XvD0Hgb4ja94NW6027M9tpmrS24mddQuIxJhXHIWNVB7DA4r4B8FftP/ALROofFaw834v+MLuyhjYyQXOu3LxTEDHzKH5BYrkA+2a/VT9qH4TeH/AIj/ABt0Q67Y2NwsNtdR25m0ya7uP+P+8chFS4iUgsUyrZ9QeMH5g1P9nD4Y2+kwanbPrI09YntYo9CsNPsY5G3b2YyXV+2WUBeh/i6V8liY1pYifs38r+R/SfDeOyGhkEFXhHmS96Timk23a76dNND6y/Za+JPxB8c/BbxXq/ivxFfXN/F4rmtoR50qJHEtrbEKgd2IXLMevUk0V1v7MPwk1DwN8A9W0nTdI1O1t5tekuiNburSSdy9vANwNsxQJ8owM54Oe1Fe3h41VRip7n5DmlbBTzCpKk48t9LWS+S1/NnU/E34T6d8R/2ndN1G88Ua/wCG7rTLeW3t30Oe3iJDXMkhLGSGQk5cjggY7Z5rr7H9kzwBHpkdrqvi7x34itFIaOC/8VSJFGRz8qQLGq9B0HYelFFcyhD6zPTdnrUf9myWEqPuOWra0bd93bd+Z7L4T+GPhDwV4cm0rQbS7itJbg3En2nU7i4dpCqqTukdj0ReM4/M0UUV7KjFKyR+eVatWdRylJtvuz//2Q==&amp;lt;/Image&amp;gt;&lt;br /&gt;&amp;lt;Url type=&amp;quot;text/html&amp;quot; method=&amp;quot;GET&amp;quot; template=&amp;quot;http://www.abbyyonline.ru/Translate.aspx&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;Param name=&amp;quot;words&amp;quot; value=&amp;quot;{searchTerms}&amp;quot;/&amp;gt;&lt;br /&gt;  &amp;lt;Param name=&amp;quot;ie&amp;quot; value=&amp;quot;utf-8&amp;quot;/&amp;gt;&lt;br /&gt;  &amp;lt;Param name=&amp;quot;oe&amp;quot; value=&amp;quot;utf-8&amp;quot;/&amp;gt;&lt;br /&gt;  &amp;lt;Param name=&amp;quot;aq&amp;quot; value=&amp;quot;t&amp;quot;/&amp;gt;&lt;br /&gt;  &amp;lt;!-- Dynamic parameters --&amp;gt;&lt;br /&gt;  &amp;lt;Param name=&amp;quot;rls&amp;quot; value=&amp;quot;{moz:distributionID}:{moz:locale}:{moz:official}&amp;quot;/&amp;gt;&lt;br /&gt;  &amp;lt;MozParam name=&amp;quot;client&amp;quot; condition=&amp;quot;defaultEngine&amp;quot; trueValue=&amp;quot;firefox-a&amp;quot; falseValue=&amp;quot;firefox&amp;quot;/&amp;gt;&lt;br /&gt;&amp;lt;/Url&amp;gt;&lt;br /&gt;&amp;lt;SearchForm&amp;gt;http://www.google.com/firefox&amp;lt;/SearchForm&amp;gt;&lt;br /&gt;&amp;lt;/SearchPlugin&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-7708806294375505087?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/7708806294375505087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/firefox3-create-search-plugin.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/7708806294375505087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/7708806294375505087'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/firefox3-create-search-plugin.html' title='Firefox3 (create search plugin)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_coCosk4H_Mo/SVjkMvcaQhI/AAAAAAAAAGc/5XGfiv2uF0g/s72-c/pic.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-8914375097626481892</id><published>2008-12-23T08:02:00.000-08:00</published><updated>2008-12-23T08:11:36.010-08:00</updated><title type='text'>PHP bug (mb_substr)</title><content type='html'>Function mb_substr has optional parameters.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;string mb_substr  ( string $str  , int $start  [, int $length  [, string $encoding  ]] )&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;If we have to substr line from 3rd character to the end we can write something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mb_substr('foobar', 3)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;If we have to do the same and also to point encoding explicitly, so the 3rd optional parameter in function will be missed &lt;br /&gt;&lt;code&gt;&lt;br /&gt;mb_substr('foobar', 3, null, "UTF-8")&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;We'll get empty string. It's a bug: http://bugs.php.net/bug.php?id=40531&amp;edit=1&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Reproduce code:&lt;br /&gt;---------------&lt;br /&gt;var_dump(mb_substr(&amp;#039;foobar&amp;#039;, 3));&lt;br /&gt;var_dump(mb_substr(&amp;#039;foobar&amp;#039;, 3, null));&lt;br /&gt;&lt;br /&gt;Expected result:&lt;br /&gt;----------------&lt;br /&gt;&amp;#039;bar&amp;#039; (length=3)&lt;br /&gt;&amp;#039;bar&amp;#039; (length=3)&lt;br /&gt;&lt;br /&gt;Actual result:&lt;br /&gt;--------------&lt;br /&gt;&amp;#039;bar&amp;#039; (length=3)&lt;br /&gt;&amp;#039;&amp;#039; (length=0)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;I've used it something like this in my code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;//this count for next line because of the bug http://www.mail-archive.com/php-bugs@lists.php.net/msg94686.html&lt;br /&gt;   $count_it = mb_strlen($line, &amp;quot;UTF-8&amp;quot;);&lt;br /&gt;            $line = mb_substr($line, $letters_in_line, $count_it, &amp;quot;UTF-8&amp;quot;);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;One superfluous operation because of it...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-8914375097626481892?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/8914375097626481892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/php-bug-mbsubstr.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/8914375097626481892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/8914375097626481892'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/php-bug-mbsubstr.html' title='PHP bug (mb_substr)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-6904848431796591059</id><published>2008-12-23T07:23:00.000-08:00</published><updated>2008-12-23T08:01:55.638-08:00</updated><title type='text'>GD library (text on the image)</title><content type='html'>Let's add some text to the image. We can use functions imagestring() and imagettftext(). What is the difference? Function imagestring() can add only one line text. So to add many lines we have to divide the text on lines add it to the massive and than to run in cycle function imagestring(). Also this function requires special php-coverted fonts. There is good program for that http://mysitez.km.ua/Downloads/&lt;br /&gt;Function imagettftext() can work with &lt;b&gt;.ttf&lt;/b&gt; fonts from Windows folder. Also this function can write multiline text like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;first line\n\rsecond line&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;There is some info on the website about this functions. But... Not on every machine it'll be work. Why? I've spent a lot of time searching for the problem. On different machines it works quite different. Actually it don't work at all on some one. Very nice :)&lt;br /&gt;Interesting that if source file is ANSI it works sometimes. So let's find more universal code.&lt;br /&gt;Finally we've get a code that works on UTF-8, ANSI and all other...&lt;br /&gt;There is some interesting functions in it. There is a function for dividing text on the lines:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;protected function _line_to_lines($line, $letters_in_line = 40, $font_size) {&lt;br /&gt;        $count_lines = ceil(mb_strlen($line, &amp;quot;UTF-8&amp;quot;) / $letters_in_line);&lt;br /&gt;        $height = $count_lines * ($font_size + 8);&lt;br /&gt;        $res = &amp;quot;&amp;quot;;&lt;br /&gt;        for ($i = 0; $i &amp;lt; $count_lines; $i++) {&lt;br /&gt;            $one_line = mb_substr($line, 0, $letters_in_line, &amp;quot;UTF-8&amp;quot;);&lt;br /&gt;   $one_line = $this-&amp;gt;_replace_cyr($one_line);&lt;br /&gt;            $res .= $one_line.&amp;quot;\n\r&amp;quot;;&lt;br /&gt;&lt;br /&gt;   //this count for next line because of the bug http://www.mail-archive.com/php-bugs@lists.php.net/msg94686.html&lt;br /&gt;   $count_it = mb_strlen($line, &amp;quot;UTF-8&amp;quot;);&lt;br /&gt;&lt;br /&gt;            $line = mb_substr($line, $letters_in_line, $count_it, &amp;quot;UTF-8&amp;quot;);&lt;br /&gt;        }&lt;br /&gt;        return array($res, $height);&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;In this code we created a bibb for the PHP bug (about that bug in the next post)&lt;br /&gt;Also we do have to use "mb_" prefix for functions for working with strings. And do not forget to set encoding so the string symbols will be cutted correctly.&lt;br /&gt;&lt;br /&gt;In next function we convert string from cyrilic symbols to codes&lt;br /&gt;&lt;code&gt;&lt;br /&gt;protected function _replace_cyr($path){&lt;br /&gt;        $search = array (&amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;nbsp;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;iexcl;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;cent;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;pound;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;curren;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;yen;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;brvbar;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;sect;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;uml;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;copy;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;ordf;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;laquo;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;not;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;shy;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;reg;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;macr;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;deg;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;plusmn;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;sup2;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;sup3;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;acute;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;micro;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;para;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;middot;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;cedil;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;sup1;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;ordm;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;raquo;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;frac14;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;frac12;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;frac34;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;ETH;&amp;iquest;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;Ntilde;�&amp;#039;&amp;quot;, &amp;quot;&amp;#039;0&amp;#039;e&amp;quot;);&lt;br /&gt;        $replace = array (&amp;#039;&amp;amp;#1025;&amp;#039;, &amp;#039;&amp;amp;#1040;&amp;#039;, &amp;#039;&amp;amp;#1041;&amp;#039;, &amp;#039;&amp;amp;#1042;&amp;#039;, &amp;#039;&amp;amp;#1043;&amp;#039;, &amp;#039;&amp;amp;#1044;&amp;#039;, &amp;#039;&amp;amp;#1045;&amp;#039;, &amp;#039;&amp;amp;#1046;&amp;#039;, &amp;#039;&amp;amp;#1047;&amp;#039;, &amp;#039;&amp;amp;#1048;&amp;#039;, &amp;#039;&amp;amp;#1049;&amp;#039;, &amp;#039;&amp;amp;#1050;&amp;#039;, &amp;#039;&amp;amp;#1051;&amp;#039;, &amp;#039;&amp;amp;#1052;&amp;#039;, &amp;#039;&amp;amp;#1053;&amp;#039;, &amp;#039;&amp;amp;#1054;&amp;#039;, &amp;#039;&amp;amp;#1055;&amp;#039;, &amp;#039;&amp;amp;#1056;&amp;#039;, &amp;#039;&amp;amp;#1057;&amp;#039;, &amp;#039;&amp;amp;#1058;&amp;#039;, &amp;#039;&amp;amp;#1059;&amp;#039;, &amp;#039;&amp;amp;#1060;&amp;#039;, &amp;#039;&amp;amp;#1061;&amp;#039;, &amp;#039;&amp;amp;#1062;&amp;#039;, &amp;#039;&amp;amp;#1063;&amp;#039;, &amp;#039;&amp;amp;#1064;&amp;#039;, &amp;#039;&amp;amp;#1065;&amp;#039;, &amp;#039;&amp;amp;#1066;&amp;#039;, &amp;#039;&amp;amp;#1067;&amp;#039;, &amp;#039;&amp;amp;#1068;&amp;#039;, &amp;#039;&amp;amp;#1069;&amp;#039;, &amp;#039;&amp;amp;#1070;&amp;#039;, &amp;#039;&amp;amp;#1071;&amp;#039;, &amp;#039;&amp;amp;#1072;&amp;#039;, &amp;#039;&amp;amp;#1073;&amp;#039;, &amp;#039;&amp;amp;#1074;&amp;#039;, &amp;#039;&amp;amp;#1075;&amp;#039;, &amp;#039;&amp;amp;#1076;&amp;#039;, &amp;#039;&amp;amp;#1077;&amp;#039;, &amp;#039;&amp;amp;#1078;&amp;#039;, &amp;#039;&amp;amp;#1079;&amp;#039;, &amp;#039;&amp;amp;#1080;&amp;#039;, &amp;#039;&amp;amp;#1081;&amp;#039;, &amp;#039;&amp;amp;#1082;&amp;#039;, &amp;#039;&amp;amp;#1083;&amp;#039;, &amp;#039;&amp;amp;#1084;&amp;#039;, &amp;#039;&amp;amp;#1085;&amp;#039;, &amp;#039;&amp;amp;#1086;&amp;#039;, &amp;#039;&amp;amp;#1087;&amp;#039;, &amp;#039;&amp;amp;#1088;&amp;#039;, &amp;#039;&amp;amp;#1089;&amp;#039;, &amp;#039;&amp;amp;#1090;&amp;#039;, &amp;#039;&amp;amp;#1091;&amp;#039;, &amp;#039;&amp;amp;#1092;&amp;#039;, &amp;#039;&amp;amp;#1093;&amp;#039;, &amp;#039;&amp;amp;#1094;&amp;#039;, &amp;#039;&amp;amp;#1095;&amp;#039;, &amp;#039;&amp;amp;#1096;&amp;#039;, &amp;#039;&amp;amp;#1097;&amp;#039;, &amp;#039;&amp;amp;#1098;&amp;#039;, &amp;#039;&amp;amp;#1099;&amp;#039;, &amp;#039;&amp;amp;#1100;&amp;#039;, &amp;#039;&amp;amp;#1101;&amp;#039;, &amp;#039;&amp;amp;#1102;&amp;#039;, &amp;#039;&amp;amp;#1103;&amp;#039;, &amp;#039;&amp;amp;#1105;&amp;#039;, &amp;#039;0&amp;#039;);&lt;br /&gt;        return preg_replace ($search,$replace,$path);&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;not nice here. Original code is http://omsk777.ru/all.php?act=ttf&lt;br /&gt;&lt;br /&gt;And in code we'll create an image like this&lt;br /&gt;&lt;code&gt;&lt;br /&gt;header(&amp;#039;Content-type: image/png&amp;#039;);&lt;br /&gt;        $im = imagecreatefrompng($source_image);&lt;br /&gt;        $font = str_replace ( &amp;quot;\\&amp;quot;, &amp;quot;/&amp;quot;, getcwd () ).&amp;quot;/fonts/verdana.ttf&amp;quot;;&lt;br /&gt;        $black = imagecolorallocate($im_large, 0, 0, 0);&lt;br /&gt;&lt;br /&gt;        ImageTtfText ($im_large, $this-&amp;gt;fontSize, 0, 5, $this-&amp;gt;fontSize + 2, $black, $font, $text[0]);&lt;br /&gt;        imagecopymerge($im_large, $im, $this-&amp;gt;thumbTextWidth, 0, 0, 0, $source_size[0], $source_size[1], 100);&lt;br /&gt;&lt;br /&gt;        imagepng($im_large, $res_image);&lt;br /&gt;        imagedestroy($im);&lt;br /&gt;        imagedestroy($im_large);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;It works very good. I'm happy ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-6904848431796591059?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/6904848431796591059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/gd-library-text-on-image.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/6904848431796591059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/6904848431796591059'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/gd-library-text-on-image.html' title='GD library (text on the image)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-1542297049219076772</id><published>2008-12-19T14:04:00.000-08:00</published><updated>2008-12-19T14:28:20.134-08:00</updated><title type='text'>TinyMCE (right click context menu)</title><content type='html'>And now we want to manage right click context menu. In our case we want to do it for the image. For example, we insert image to text editor and want to get customized menu after clicking right button.&lt;br /&gt;Maybe the most interesting thing to find it by yourself, no Google. Just think :)&lt;br /&gt;The way I've used: open Total Commander and find files with text like "paste" like one of the points in context menu. So in results we see that there is plugin context menu. Nice, go there. Open file editor_plugin_src.js and at the end there is structure of our menu&lt;br /&gt;&lt;code&gt;&lt;br /&gt;t._menu = m;&lt;br /&gt;&lt;br /&gt;   m.add({title : &amp;#039;advanced.cut_desc&amp;#039;, icon : &amp;#039;cut&amp;#039;, cmd : &amp;#039;Cut&amp;#039;}).setDisabled(col);&lt;br /&gt;   m.add({title : &amp;#039;advanced.copy_desc&amp;#039;, icon : &amp;#039;copy&amp;#039;, cmd : &amp;#039;Copy&amp;#039;}).setDisabled(col);&lt;br /&gt;   m.add({title : &amp;#039;advanced.paste_desc&amp;#039;, icon : &amp;#039;paste&amp;#039;, cmd : &amp;#039;Paste&amp;#039;});&lt;br /&gt;&lt;br /&gt;   if ((el.nodeName == &amp;#039;A&amp;#039; &amp;amp;&amp;amp; !ed.dom.getAttrib(el, &amp;#039;name&amp;#039;)) || !col) {&lt;br /&gt;    m.addSeparator();&lt;br /&gt;    m.add({title : &amp;#039;advanced.link_desc&amp;#039;, icon : &amp;#039;link&amp;#039;, cmd : ed.plugins.advlink ? &amp;#039;mceAdvLink&amp;#039; : &amp;#039;mceLink&amp;#039;, ui : true});&lt;br /&gt;    m.add({title : &amp;#039;advanced.unlink_desc&amp;#039;, icon : &amp;#039;unlink&amp;#039;, cmd : &amp;#039;UnLink&amp;#039;});&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   m.addSeparator();&lt;br /&gt;   m.add({title : &amp;#039;advanced.image_desc&amp;#039;, icon : &amp;#039;image&amp;#039;, cmd : ed.plugins.advimage ? &amp;#039;mceAdvImage&amp;#039; : &amp;#039;mceImage&amp;#039;, ui : true});&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;we can add some points, link some event to it and use for our needs :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-1542297049219076772?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/1542297049219076772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-right-click-context-menu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1542297049219076772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1542297049219076772'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-right-click-context-menu.html' title='TinyMCE (right click context menu)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-6836005543107157980</id><published>2008-12-19T13:35:00.000-08:00</published><updated>2008-12-23T07:17:58.275-08:00</updated><title type='text'>TinyMCE (image managing)</title><content type='html'>There is no image loader in TinyMCE installation package. We have to point internet location of the image and than a pic will be uploaded. We were looking for a tool for managing images right from the editor interface. Really good and handy one is TinyMCE Image Manager 1.0 plugin from Antonov Andrey&lt;br /&gt;http://tinymce.ru/plugins/tinymce-image-manager-1-0&lt;br /&gt;Let's try it :) Installation process is usual as for the plugin. After that we can see that it seems not to work in FF. Actually on my machine I never see that :)) [WinXP, Firefox 3.0.4, Flash10]&lt;br /&gt;OK, in comments there is some info that we should to use Flash9. And even with that it seems not to work. The same situation is with IE. The plugin is unstable. So, wait for the update...&lt;br /&gt;&lt;br /&gt;Let's try something without a flash.&lt;br /&gt;&lt;br /&gt;Finally I've selected ibrowser. It's a free plugin for uploading and managing images via timymce interface. Interesting that ibrowser works well with TinyMCE ver.3 also it's good idea to add code like this to file browser/config.inc&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$cfg[&amp;#039;ilibs&amp;#039;] = array (&lt;br /&gt;         array (&lt;br /&gt;                 &amp;#039;value&amp;#039; =&amp;gt; &amp;#039;&amp;#039;,&lt;br /&gt;                 &amp;#039;text&amp;#039; =&amp;gt; &amp;#039;Please select folder &amp;amp;darr;&amp;#039;,&lt;br /&gt;         ),&lt;br /&gt;         array (&lt;br /&gt;                 &amp;#039;value&amp;#039; =&amp;gt; &amp;#039;images/&amp;#039;,&lt;br /&gt;                 &amp;#039;text&amp;#039; =&amp;gt; &amp;#039;&amp;ETH;�&amp;ETH;&amp;plusmn;&amp;Ntilde;�&amp;ETH;&amp;cedil;&amp;ETH;&amp;micro;&amp;#039;,&lt;br /&gt;         ),&lt;br /&gt;         array (&lt;br /&gt;                 &amp;#039;value&amp;#039; =&amp;gt; &amp;#039;gallery/&amp;#039;,&lt;br /&gt;                 &amp;#039;text&amp;#039; =&amp;gt; &amp;#039;&amp;ETH;�&amp;ETH;&amp;deg;&amp;ETH;&amp;raquo;&amp;ETH;&amp;micro;&amp;Ntilde;�&amp;ETH;&amp;micro;&amp;Ntilde;�&amp;#039;,&lt;br /&gt;         ),&lt;br /&gt;  );&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;So when we open the window first selected point in the select box is "Please select folder".&lt;br /&gt;This is cause just after opening the plugin window there are no images in it. We do have to select any folder for images be shown.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-6836005543107157980?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/6836005543107157980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-image-managing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/6836005543107157980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/6836005543107157980'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-image-managing.html' title='TinyMCE (image managing)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-2127967600249081979</id><published>2008-12-17T09:48:00.000-08:00</published><updated>2008-12-18T04:38:27.757-08:00</updated><title type='text'>TinyMCE (source code journey)</title><content type='html'>Do you like a journey? Today we'll go on a tour under a veil of secrecy of TinyMCE source code...&lt;br /&gt;In the previous post "TinyMCE (alter plugin)" we tried to add some functionality. Out task was: to make so that while viewing source code tags like img... be replaced with other one. And after saving the changes it should be replaced back. We took a plugin from here http://danielinsley.com and altered it a little. But the plugin doesn't work for IE.&lt;br /&gt;So, there is obvious two ways: to make it work in IE or to change source code. We selected second one.&lt;br /&gt;The source code is about 11000 lines. Nice one :) jscripts\tiny_mce\tiny_mce.js It's interesting the part as from line 3537. The function with words "getContent" (please, notice there are more than one function with such words :) on this line we get a content for our editor:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;h = this.doc.xml || new XMLSerializer().serializeToString(this.doc);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;than delete some start and end HTML and PHP tags:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;h = h.replace(/&amp;lt;\?[^?]+\?&amp;gt;|&amp;lt;html&amp;gt;|&amp;lt;\/html&amp;gt;|&amp;lt;html\/&amp;gt;|&amp;lt;!DOCTYPE[^&amp;gt;]+&amp;gt;/g, &amp;#039;&amp;#039;);&lt;br /&gt;   h = h.replace(/ ?\/&amp;gt;/g, &amp;#039; /&amp;gt;&amp;#039;);&lt;br /&gt;   if (this.valid) &lt;br /&gt;    h = h.replace(/\%MCGT%/g, &amp;#039;&amp;amp;gt;&amp;#039;);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Interesting the function is called every time the content is place to the and from the text area. How to get when we have to replace img tag and when we have to replace back. Lets put some check like indexOf. So we'll get something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;getContent : function() { &lt;br /&gt;   var h;&lt;br /&gt; &lt;br /&gt;   h = this.doc.xml || new XMLSerializer().serializeToString(this.doc);&lt;br /&gt;&lt;br /&gt;   //ereg for test&lt;br /&gt;   var istest = h.indexOf(&amp;quot;test id=&amp;quot;);&lt;br /&gt;   if(istest &amp;gt;= 0) {&lt;br /&gt;    h = h.replace(/&amp;lt;test[^&amp;gt;]*id=\&amp;quot;([0-9]*)\&amp;quot;[^&amp;gt;]*type=\&amp;quot;([^\&amp;quot;]*)\&amp;quot;[^&amp;gt;]*&amp;gt;/g, &amp;#039;&amp;lt;img test=&amp;quot;$1&amp;quot; src=&amp;quot;$2&amp;quot; /&amp;gt;&amp;#039;);&lt;br /&gt;   }&lt;br /&gt;   else {&lt;br /&gt;    h = h.replace(/&amp;lt;img[^&amp;gt;]*test=\&amp;quot;([0-9]*)\&amp;quot;[^&amp;gt;]*src=\&amp;quot;([^\&amp;quot;]*)\&amp;quot;[^&amp;gt;]*&amp;gt;/g, &amp;#039;&amp;lt;test id=&amp;quot;$1&amp;quot; type=&amp;quot;$2&amp;quot; /&amp;gt;&amp;#039;);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   h = h.replace(/&amp;lt;\?[^?]+\?&amp;gt;|html|&amp;lt;\/html&amp;gt;|&amp;lt;html\/&amp;gt;|&amp;lt;!DOCTYPE[^&amp;gt;]+&amp;gt;/g, &amp;#039;&amp;#039;);&lt;br /&gt;   h = h.replace(/ ?\/&amp;gt;/g, &amp;#039; /&amp;gt;&amp;#039;);&lt;br /&gt;&lt;br /&gt;   if (this.valid) &lt;br /&gt;    h = h.replace(/\%MCGT%/g, &amp;#039;&amp;amp;gt;&amp;#039;);&lt;br /&gt;  &lt;br /&gt;   return h;&lt;br /&gt;  }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;That's all ))&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-2127967600249081979?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/2127967600249081979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-add-quantifier-in-source-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2127967600249081979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2127967600249081979'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-add-quantifier-in-source-code.html' title='TinyMCE (source code journey)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-8646336749109663733</id><published>2008-12-16T02:42:00.001-08:00</published><updated>2008-12-16T06:00:21.614-08:00</updated><title type='text'>Java Script mystery</title><content type='html'>We can get a nice help on js programming language with just couple lines of code.&lt;br /&gt;Well, lets try this one:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function addtext() { &lt;br /&gt;  var result = "";&lt;br /&gt;  var x = window;&lt;br /&gt;  for(n in x) {&lt;br /&gt;   result += "window." + n + " \t\t= " + x[n] + "\n";&lt;br /&gt;  }&lt;br /&gt;  document.form.textarea.value = result;&lt;br /&gt; }&lt;br /&gt;...&lt;br /&gt;a href="javascript:addtext();&lt;br /&gt;...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;In IE we have a modest list of objects. It's very usefull if you'll forget any of that :) In IE 4.01 the list is shorter than in subsequent versions of IE. &lt;br /&gt;So look on that code in FF browser. It's a great help there, like a book :) and in the Opera. We can see something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;window.i   = 4&lt;br /&gt;window.addEventListener = function addEventListener() {&lt;br /&gt;    [native code]&lt;br /&gt;}&lt;br /&gt;window.location  = http://www.arachnoid.com/javascript/interactiveJavaScript.html&lt;br /&gt;window.navigator = [object Navigator]&lt;br /&gt;window.n   = n&lt;br /&gt;window.toNewPage = function toNewPage(t) {&lt;br /&gt;    location.href = t.options[t.selectedIndex].value;&lt;br /&gt;}&lt;br /&gt;window.onload   = function onload(event) {&lt;br /&gt;    jsInit();&lt;br /&gt;}&lt;br /&gt;window.onerror   = function jsHandleError(e, f, ln) {&lt;br /&gt;    document.myForm.output.value = "JavaScript Error: " + e + " (" + ln + ")";&lt;br /&gt;    return true;&lt;br /&gt;}&lt;br /&gt;window.window   = [object Window]&lt;br /&gt;...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;There is a website for testing simple scripts online: http://www.arachnoid.com/javascript/interactiveJavaScript.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-8646336749109663733?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/8646336749109663733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/java-script-mystery.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/8646336749109663733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/8646336749109663733'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/java-script-mystery.html' title='Java Script mystery'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-5946486405631282389</id><published>2008-12-15T07:25:00.000-08:00</published><updated>2008-12-16T01:14:20.872-08:00</updated><title type='text'>TinyMCE (create plugin)</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_coCosk4H_Mo/SUdvtV0GNnI/AAAAAAAAAEI/1diN9j6mf7w/s1600-h/pic2.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 84px;" src="http://1.bp.blogspot.com/_coCosk4H_Mo/SUdvtV0GNnI/AAAAAAAAAEI/1diN9j6mf7w/s400/pic2.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5280311912855647858" /&gt;&lt;/a&gt;&lt;br /&gt;And create a plugin. We need a plugin for inserting images after select from the name list. So, go to folder jscripts\tiny_mce\plugins and create there your plugin folder with data like on the pic (just copy the data and folder structure from the similar plugin):&lt;br /&gt;&lt;br /&gt;Then go to img folder and put there pic for the button (small pic). I've copied the data from the plugin with pop-up window. We have to alter some file dialog.htm:&lt;br /&gt;(some tags were cleaned in order to pass the verification of this blog, still don't get clue how to put here html code :)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;...&lt;br /&gt;  a href="javascript:;" &lt;br /&gt;  onmousedown='tinyMCE.execCommand("mceInsertContent",false,"img src=\"code.jpg\" alt=\"test\"")'; &lt;br /&gt;  onclick='tinyMCEPopup.close();' &gt;image1&lt;br /&gt;...&lt;br /&gt;  a href="javascript:;" &lt;br /&gt;  onmousedown='tinyMCE.execCommand("mceInsertContent",false,"img src=\"url.jpg\" alt=\"test\"")'; &lt;br /&gt;  onclick='tinyMCEPopup.close();' &gt;image2&lt;br /&gt;...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;There is a list of links and after the click on the link the pop-up window closes and the image is inserted to the html area. Images are stored in the root folder. Also please don't forget to add to init code your new button. That's it :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-5946486405631282389?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/5946486405631282389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-create-plugin.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/5946486405631282389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/5946486405631282389'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-create-plugin.html' title='TinyMCE (create plugin)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_coCosk4H_Mo/SUdvtV0GNnI/AAAAAAAAAEI/1diN9j6mf7w/s72-c/pic2.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-4656645136930879872</id><published>2008-12-15T07:24:00.001-08:00</published><updated>2008-12-16T06:33:13.424-08:00</updated><title type='text'>TinyMCE (alter plugin)</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_coCosk4H_Mo/SUds82CkTrI/AAAAAAAAAEA/ShCAFmTowRY/s1600-h/pic.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 219px;" src="http://1.bp.blogspot.com/_coCosk4H_Mo/SUds82CkTrI/AAAAAAAAAEA/ShCAFmTowRY/s400/pic.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5280308880669429426" /&gt;&lt;/a&gt;&lt;br /&gt;Today we'll try to alter the existent plugin in order to suit it for our needs. Please, look on the plugin http://danielinsley.com/ created by Canadian programmer. This plugin has lines numeration and highlighted code presentation. Will add it to TinyMCE and replace old HTML button with new one (advcode).&lt;br /&gt;&lt;code&gt;&lt;br /&gt;tinyMCE.init({&lt;br /&gt;...&lt;br /&gt;theme_advanced_buttons2 : "cut,copy,...cleanup,help,advcode,|,insertdate,inserttime,preview,|,forecolor,backcolor",&lt;br /&gt;...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;We want the code to be altered while representation in HTML mode. For example we would like the [img] tag be replaced by test and then will be replaced back when we press Insert button.&lt;br /&gt;Go to folder jscripts\tiny_mce\plugins\advcode\js and edit dialog.js file (lines in comments //edited were altered):&lt;br /&gt;&lt;code&gt;&lt;br /&gt;tinyMCEPopup.requireLangPack();&lt;br /&gt;var CodeDialog = {&lt;br /&gt;  init : function() {&lt;br /&gt;    var f = document.forms[0];&lt;br /&gt;    f.codepress.value = tinyMCEPopup.editor.getContent();&lt;br /&gt; //edited&lt;br /&gt; k = f.codepress.value;&lt;br /&gt; alert('DATA WILL BE CONVERTED FROM:\n\n' + k);&lt;br /&gt; var re = new RegExp('img(.*)?testdata="?([0-9]*)"?.*src="([^"]*)"[^&gt;]*', 'gi');&lt;br /&gt; result = k.replace(re, '&lt;testdata id="$2" type="$3" /&gt;');&lt;br /&gt; //end edited&lt;br /&gt;&lt;br /&gt; f.codepress.value = result;&lt;br /&gt;  },&lt;br /&gt;&lt;br /&gt;  insert : function() {&lt;br /&gt;    //tinyMCEPopup.editor.setContent(codepress.getCode());&lt;br /&gt; //edited&lt;br /&gt; k = codepress.getCode();&lt;br /&gt; var re = new RegExp('testdata id="([0-9]*)"(.*)?type="([^"]*)"[^&gt;]*', 'gi');&lt;br /&gt; result = k.replace(re, '&lt;img testdata="name:$1" src="$3" /&gt;');&lt;br /&gt; alert('DATA WILL BE CONVERTED TO:\n\n' + result); &lt;br /&gt; //end edited&lt;br /&gt;&lt;br /&gt; tinyMCEPopup.editor.setContent(result);&lt;br /&gt;    tinyMCEPopup.close();&lt;br /&gt;  }&lt;br /&gt;};&lt;br /&gt;tinyMCEPopup.onInit.add(CodeDialog.init, CodeDialog);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;There is a good website for testing your regular expressions on Jscript: http://www.regular-expressions.info/javascriptexample.html&lt;br /&gt;&lt;br /&gt;Interestin that many buttons in TinyMCE editor have very similar structure (they are plugins) and altering process is quick and usefull.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-4656645136930879872?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/4656645136930879872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-alter-plugin.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/4656645136930879872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/4656645136930879872'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-alter-plugin.html' title='TinyMCE (alter plugin)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_coCosk4H_Mo/SUds82CkTrI/AAAAAAAAAEA/ShCAFmTowRY/s72-c/pic.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-2337536910003534659</id><published>2008-12-12T05:28:00.001-08:00</published><updated>2008-12-15T07:18:11.115-08:00</updated><title type='text'>TinyMCE3 battle</title><content type='html'>TineMCE is a platform-independent web-based JavaScript/HTML WYSIWYG editor control, released as open source software under the LGPL by Moxiecode Systems AB.&lt;br /&gt;//wikipedia&lt;br /&gt;&lt;br /&gt;Installing:&lt;br /&gt;Getting work TinyMCE. It's really quick and simple :) Page where the TinyMCE editor will be place should contain following code.&lt;br /&gt;Correct link to folder with js scripts:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Some jscript for editor initialization. Sometimes people think this code should be in separate file. As in version 3 the code is in the page.&lt;br /&gt;It strarts with something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;tinyMCE.init({...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And sure the text area should have id like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;textarea id="elm1" ...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;In js folder we have two interesting folders: langs and plugins.&lt;br /&gt;Later in plugins folder we'll get our joy of creation :)&lt;br /&gt;&lt;br /&gt;Plugin Image Manager 1.0:&lt;br /&gt;There is a free plugin for TinyMCE editor for uploading and managing images. The name is not very secret, it's Image Manager 1.0&lt;br /&gt;It's good, better say it's going to be good after some updatings. Everybody waits for it so well.&lt;br /&gt;Cause the plugin works quite incorrect with Flash Player 10. And even with Flash Player 9 I had some mysterious times for what is the problem... So for now we'll just wait for updating and then try it again.&lt;br /&gt;How to install it? Place folder images to modules\tinymce\tinymce\jscripts\tiny_mce\plugins&lt;br /&gt;Create in root folder "storage" and give rights for writing/reading&lt;br /&gt;Edit to code of the page with editor these lines:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;plugins: …,images,…&lt;br /&gt;theme_advanced_buttons1: …,images,…&lt;br /&gt;relative_urls : false&lt;br /&gt;remove_script_host : true&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The button will appear in the first row. That's all.&lt;br /&gt;Also some intersting info. In every plugin folder there are file like editor_plugin_src.js and editor_plugin.js&lt;br /&gt;So first file is source file with tabs in code and comments. And the second one is only code in one line. The system takes last one.&lt;br /&gt;I used to alter first file and then copy and rename it like the second one. Only when all is done I create correct second file with code in one line.&lt;br /&gt;&lt;br /&gt;Add language:&lt;br /&gt;Download language pack from the site (not just a xml file, you'll need it if would like to alter the language, add new words etc.) So I mistakenly tried to manage that xml file :) We just download language package for russian it's about 17Kb. And then copy info from the package to appropriate folders with same names. Choose option to rewrite files when you'll be asked about.&lt;br /&gt;Also in code of the page with editor form point that language was changed with language: 'ru' line:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;// General options&lt;br /&gt;mode : "textareas",&lt;br /&gt;language : 'ru',&lt;br /&gt;theme : "advanced",&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The editor is quite simple to manage. It's really nice one&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-2337536910003534659?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/2337536910003534659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-battle.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2337536910003534659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2337536910003534659'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/tinymce-battle.html' title='TinyMCE3 battle'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-6935945510863071021</id><published>2008-12-11T01:40:00.000-08:00</published><updated>2008-12-11T01:43:16.438-08:00</updated><title type='text'>.htaccess directives</title><content type='html'>//tip list of .htaccess directives&lt;br /&gt;&lt;code&gt;&lt;br /&gt;=============================================================================#&lt;br /&gt;          MAIN SETTINGS AND OPTIONS&lt;br /&gt;=============================================================================#&lt;br /&gt; Options: ALL,FollowSymLinks,Includes,IncludesNOEXEC,SymLinksIfOwnerMatch&lt;br /&gt;##########&lt;br /&gt; &lt;br /&gt;## MAIN DEFAULTS ###&lt;br /&gt;Options +ExecCGI -Indexes&lt;br /&gt;DirectoryIndex index.html index.htm index.php&lt;br /&gt;DefaultLanguage en-US&lt;br /&gt;AddDefaultCharset UTF-8&lt;br /&gt;ServerSignature Off&lt;br /&gt; &lt;br /&gt;## ENVIRONMENT VARIABLES ###&lt;br /&gt;SetEnv PHPRC /webroot/includes&lt;br /&gt;SetEnv TZ America/Indianapolis&lt;br /&gt;SetEnv SERVER_ADMIN webmaster@domain.tld&lt;br /&gt; &lt;br /&gt;## MIME TYPES ###&lt;br /&gt;AddType video/x-flv .flv&lt;br /&gt;AddType application/x-shockwave-flash .swf&lt;br /&gt;AddType image/x-icon .ico&lt;br /&gt; &lt;br /&gt;## FORCE FILE TO DOWNLOAD INSTEAD OF APPEAR IN BROWSER ###&lt;br /&gt;-&gt; http://www.htaccesselite.com/addtype-addhandler-action-vf6.html&lt;br /&gt;AddType application/octet-stream .mov .mp3 .zip&lt;br /&gt; &lt;br /&gt;## ERRORDOCUMENTS ###&lt;br /&gt; &lt;br /&gt;-&gt; http://askapache.com/htaccess/apache-status-code-headers-errordocument.html&lt;br /&gt; &lt;br /&gt;======== 1xx&lt;br /&gt;ErrorDocument 100 /error-100/&lt;br /&gt;ErrorDocument 101 /error-101/&lt;br /&gt;ErrorDocument 102 /error-102/&lt;br /&gt;======== 2xx&lt;br /&gt;ErrorDocument 200 /error-200/&lt;br /&gt;ErrorDocument 201 /error-201/&lt;br /&gt;ErrorDocument 202 /error-202/&lt;br /&gt;ErrorDocument 203 /error-203/&lt;br /&gt;ErrorDocument 204 /error-204/&lt;br /&gt;ErrorDocument 205 /error-205/&lt;br /&gt;ErrorDocument 206 /error-206/&lt;br /&gt;ErrorDocument 207 /error-207/&lt;br /&gt;======== 4xx&lt;br /&gt;ErrorDocument 400 /error-400/&lt;br /&gt;ErrorDocument 401 /error-401/&lt;br /&gt;ErrorDocument 402 /error-402/&lt;br /&gt;ErrorDocument 403 /error-403/&lt;br /&gt;ErrorDocument 404 /error-404/&lt;br /&gt;ErrorDocument 405 /error-405/&lt;br /&gt;ErrorDocument 406 /error-406/&lt;br /&gt;ErrorDocument 407 /error-407/&lt;br /&gt;ErrorDocument 408 /error-408/&lt;br /&gt;ErrorDocument 409 /error-409/&lt;br /&gt;ErrorDocument 410 /error-410/&lt;br /&gt;ErrorDocument 411 /error-411/&lt;br /&gt;ErrorDocument 412 /error-412/&lt;br /&gt;ErrorDocument 413 /error-413/&lt;br /&gt;ErrorDocument 414 /error-414/&lt;br /&gt;ErrorDocument 415 /error-415/&lt;br /&gt;ErrorDocument 416 /error-416/&lt;br /&gt;ErrorDocument 417 /error-417/&lt;br /&gt;ErrorDocument 418 /error-418/&lt;br /&gt;ErrorDocument 419 /error-419/&lt;br /&gt;ErrorDocument 420 /error-420/&lt;br /&gt;ErrorDocument 421 /error-421/&lt;br /&gt;ErrorDocument 422 /error-422/&lt;br /&gt;ErrorDocument 423 /error-423/&lt;br /&gt;ErrorDocument 424 /error-424/&lt;br /&gt;ErrorDocument 425 /error-425/&lt;br /&gt;ErrorDocument 426 /error-426/&lt;br /&gt;======== 5xx&lt;br /&gt;ErrorDocument 500 /error-500/&lt;br /&gt;ErrorDocument 501 /error-501/&lt;br /&gt;ErrorDocument 502 /error-502/&lt;br /&gt;ErrorDocument 503 /error-503/&lt;br /&gt;ErrorDocument 504 /error-504/&lt;br /&gt;ErrorDocument 505 /error-505/&lt;br /&gt;ErrorDocument 506 /error-506/&lt;br /&gt;ErrorDocument 507 /error-507/&lt;br /&gt;ErrorDocument 508 /error-508/&lt;br /&gt;ErrorDocument 509 /error-509/&lt;br /&gt;ErrorDocument 510 /error-510/&lt;br /&gt; &lt;br /&gt;AddLanguage aa .aa # Afar&lt;br /&gt;AddLanguage ab .ab # Abkhazian&lt;br /&gt;AddLanguage af .af # Afrikaans&lt;br /&gt;AddLanguage am .am # Amharic&lt;br /&gt;AddLanguage ar .ar # Arabic&lt;br /&gt;AddLanguage as .as # Assamese&lt;br /&gt;AddLanguage ay .ay # Aymara&lt;br /&gt;AddLanguage az .az # Azerbaijani&lt;br /&gt;AddLanguage ba .ba # Bashkir&lt;br /&gt;AddLanguage be .be # Byelorussian&lt;br /&gt;AddLanguage bg .bg # Bulgarian&lt;br /&gt;AddLanguage bh .bh # Bihari&lt;br /&gt;AddLanguage bi .bi # Bislama&lt;br /&gt;AddLanguage bn .bn # Bengali; Bangla&lt;br /&gt;AddLanguage bo .bo # Tibetan&lt;br /&gt;AddLanguage br .br # Breton&lt;br /&gt;AddLanguage ca .ca # Catalan&lt;br /&gt;AddLanguage co .co # Corsican&lt;br /&gt;AddLanguage cs .cs # Czech&lt;br /&gt;AddLanguage cy .cy # Welsh&lt;br /&gt;AddLanguage da .da # Danish&lt;br /&gt;AddLanguage de .de # German&lt;br /&gt;AddLanguage dz .dz # Bhutani&lt;br /&gt;AddLanguage el .el # Greek&lt;br /&gt;AddLanguage en .en # English&lt;br /&gt;AddLanguage eo .eo # Esperanto&lt;br /&gt;AddLanguage es .es # Spanish&lt;br /&gt;AddLanguage et .et # Estonian&lt;br /&gt;AddLanguage eu .eu # Basque&lt;br /&gt;AddLanguage fa .fa # Persian&lt;br /&gt;AddLanguage fi .fi # Finnish&lt;br /&gt;AddLanguage fj .fj # Fiji&lt;br /&gt;AddLanguage fo .fo # Faeroese&lt;br /&gt;AddLanguage fr .fr # French&lt;br /&gt;AddLanguage fy .fy # Frisian&lt;br /&gt;AddLanguage ga .ga # Irish&lt;br /&gt;AddLanguage gd .gd # Scots Gaelic&lt;br /&gt;AddLanguage gl .gl # Galician&lt;br /&gt;AddLanguage gn .gn # Guamni&lt;br /&gt;AddLanguage gu .gu # Gujarati&lt;br /&gt;AddLanguage ha .ha # Hausa&lt;br /&gt;AddLanguage he .he # Hebrew&lt;br /&gt;AddLanguage hi .hi # Hindi&lt;br /&gt;AddLanguage hr .hr # Croatian&lt;br /&gt;AddLanguage hu .hu # Hungarian&lt;br /&gt;AddLanguage hy .hy # Armenian&lt;br /&gt;AddLanguage ia .ia # Interlingua&lt;br /&gt;AddLanguage id .id # Indonesian&lt;br /&gt;AddLanguage ie .ie # lnteriingue&lt;br /&gt;AddLanguage ik .ik # Knupiak&lt;br /&gt;AddLanguage is .is # Icelandic&lt;br /&gt;AddLanguage it .it # Italian&lt;br /&gt;AddLanguage iu .iu # Inuktitut (Eskimo)&lt;br /&gt;AddLanguage ja .ja # Japanese&lt;br /&gt;AddLanguage jw .jw # Javanese&lt;br /&gt;AddLanguage ka .ka # Georgian&lt;br /&gt;AddLanguage kk .kk # Kazakh&lt;br /&gt;AddLanguage kl .kl # Greaenlandic&lt;br /&gt;AddLanguage km .km # Cambodian&lt;br /&gt;AddLanguage kn .kn # Kannada&lt;br /&gt;AddLanguage ko .ko # Korean&lt;br /&gt;AddLanguage ks .ks # Kashmiri&lt;br /&gt;AddLanguage ku .ku # Kurdish&lt;br /&gt;AddLanguage ky .ky # Kirghiz&lt;br /&gt;AddLanguage la .la # Latin&lt;br /&gt;AddLanguage ln .ln # Lingala&lt;br /&gt;AddLanguage lo .lo # Laothian&lt;br /&gt;AddLanguage lt .lt # Lithuainnian&lt;br /&gt;AddLanguage lv .lv # Latvian, Lettish&lt;br /&gt;AddLanguage mg .mg # Malagasy&lt;br /&gt;AddLanguage mi .mi # Maori&lt;br /&gt;AddLanguage mk .mk # Macedonian&lt;br /&gt;AddLanguage ml .ml # Malayalam&lt;br /&gt;AddLanguage mn .mn # Mongolian&lt;br /&gt;AddLanguage mo .mo # Moldavian&lt;br /&gt;AddLanguage mr .mr # Marathi&lt;br /&gt;AddLanguage ms .ms # Malay&lt;br /&gt;AddLanguage mt .mt # Maltese&lt;br /&gt;AddLanguage my .my # Burmese&lt;br /&gt;AddLanguage na .na # Nauru&lt;br /&gt;AddLanguage ne .ne # Nepali&lt;br /&gt;AddLanguage nl .nl # Dutch&lt;br /&gt;AddLanguage no .no # Norwegian&lt;br /&gt;AddLanguage oc .oc # Occitan&lt;br /&gt;AddLanguage om .om # (Afan) Oromo&lt;br /&gt;AddLanguage or .or # Oriya&lt;br /&gt;AddLanguage pa .pa # Punjabi&lt;br /&gt;AddLanguage pl .po # Polish (use .po instead .pl to avoid problems with perl files)&lt;br /&gt;AddLanguage ps .ps # Pashto, Pushto&lt;br /&gt;AddLanguage pt .pt # Portuguese&lt;br /&gt;AddLanguage qu .qu # Ouechua&lt;br /&gt;AddLanguage rm .rm # Rhaeto-Romance&lt;br /&gt;AddLanguage rn .rn # Kirundi&lt;br /&gt;AddLanguage ro .ro # Romanian&lt;br /&gt;AddLanguage ru .ru # Russian&lt;br /&gt;AddLanguage rw .rw # Kinya, Rwanda&lt;br /&gt;AddLanguage sa .sa # Sanskrit&lt;br /&gt;AddLanguage sd .sd # Sindhi&lt;br /&gt;AddLanguage sg .sg # Sangro&lt;br /&gt;AddLanguage sh .sh # Serbo-Croatian&lt;br /&gt;AddLanguage si .si # Singhalese&lt;br /&gt;AddLanguage sk .sk # Slovak&lt;br /&gt;AddLanguage sl .sl # Slovenian&lt;br /&gt;AddLanguage sm .sm # Samoan&lt;br /&gt;AddLanguage sn .sn # Shona&lt;br /&gt;AddLanguage so .so # Somali&lt;br /&gt;AddLanguage sq .sq # Albanian&lt;br /&gt;AddLanguage sr .sr # Serbian&lt;br /&gt;AddLanguage ss .ss # Siswati&lt;br /&gt;AddLanguage st .st # Sesotho&lt;br /&gt;AddLanguage su .su # Sundanese&lt;br /&gt;AddLanguage sv .sv # Swedish&lt;br /&gt;AddLanguage sw .sw # Swahili&lt;br /&gt;AddLanguage ta .ta # Tamil&lt;br /&gt;AddLanguage te .te # Tegulu&lt;br /&gt;AddLanguage tg .tg # Tajik&lt;br /&gt;AddLanguage th .th # Thai&lt;br /&gt;AddLanguage ti .ti # Tigrinya&lt;br /&gt;AddLanguage tk .tk # Turkmen&lt;br /&gt;AddLanguage tl .tl # Tagalog&lt;br /&gt;AddLanguage tn .tn # Setswana&lt;br /&gt;AddLanguage to .to # Tonga&lt;br /&gt;AddLanguage tr .tr # Turkish&lt;br /&gt;AddLanguage ts .ts # Tsonga&lt;br /&gt;AddLanguage tt .tt # Tatar&lt;br /&gt;AddLanguage tw .tw # Twi&lt;br /&gt;AddLanguage ug .ug # Uigur&lt;br /&gt;AddLanguage uk .uk # Ukrainian&lt;br /&gt;AddLanguage ur .ur # Urdu&lt;br /&gt;AddLanguage uz .uz # Uzbek&lt;br /&gt;AddLanguage vi .vi # Vietnamese&lt;br /&gt;AddLanguage vo .vo # Volapuek&lt;br /&gt;AddLanguage wo .wo # Wolof&lt;br /&gt;AddLanguage xh .xh # Xhosa&lt;br /&gt;AddLanguage yi .yi # Yiddish&lt;br /&gt;AddLanguage yo .yo # Yoruba&lt;br /&gt;AddLanguage za .za # Zhuang&lt;br /&gt;AddLanguage zh .zh # Chinese&lt;br /&gt;AddLanguage zu .zu # Zulu&lt;br /&gt; &lt;br /&gt;=============================================================================#&lt;br /&gt;          SCRIPTING, ACTION, ADDHANDLER&lt;br /&gt;=============================================================================#&lt;br /&gt; Handlers be builtin, included in a module, or added with Action directive&lt;br /&gt; default-handler: default, handles static content (core)&lt;br /&gt;      send-as-is: Send file with HTTP headers (mod_asis)&lt;br /&gt;      cgi-script: treat file as CGI script (mod_cgi)&lt;br /&gt;       imap-file: Parse as an imagemap rule file (mod_imap)&lt;br /&gt;     server-info: Get server config info (mod_info)&lt;br /&gt;   server-status: Get server status report (mod_status)&lt;br /&gt;        type-map: type map file for content negotiation (mod_negotiation)&lt;br /&gt;  fastcgi-script: treat file as fastcgi script (mod_fastcgi)&lt;br /&gt;##########&lt;br /&gt; &lt;br /&gt;-&gt; http://www.askapache.com/php/custom-phpini-tips-and-tricks.html&lt;br /&gt; &lt;br /&gt;## PARSE AS CGI ###&lt;br /&gt;AddHandler cgi-script .cgi .pl .spl&lt;br /&gt; &lt;br /&gt;## RUN PHP AS APACHE MODULE ###&lt;br /&gt;AddHandler application/x-httpd-php .php .htm&lt;br /&gt; &lt;br /&gt;## RUN PHP AS CGI ###&lt;br /&gt;AddHandler php-cgi .php .htm&lt;br /&gt; &lt;br /&gt;## CGI PHP WRAPPER FOR CUSTOM PHP.INI ###&lt;br /&gt;AddHandler phpini-cgi .php .htm&lt;br /&gt;Action phpini-cgi /cgi-bin/php5-custom-ini.cgi&lt;br /&gt; &lt;br /&gt;## FAST-CGI SETUP WITH PHP-CGI WRAPPER FOR CUSTOM PHP.INI ###&lt;br /&gt;AddHandler fastcgi-script .fcgi&lt;br /&gt;AddHandler php-cgi .php .htm&lt;br /&gt;Action php-cgi /cgi-bin/php5-wrapper.fcgi&lt;br /&gt; &lt;br /&gt;## CUSTOM PHP CGI BINARY SETUP ###&lt;br /&gt;AddHandler php-cgi .php .htm&lt;br /&gt;Action php-cgi /cgi-bin/php.cgi&lt;br /&gt; &lt;br /&gt;## PROCESS SPECIFIC FILETYPES WITH CGI-SCRIPT ###&lt;br /&gt;Action image/gif /cgi-bin/img-create.cgi&lt;br /&gt; &lt;br /&gt;## CREATE CUSTOM HANDLER FOR SPECIFIC FILE EXTENSIONS ###&lt;br /&gt;AddHandler custom-processor .ssp&lt;br /&gt;Action custom-processor /cgi-bin/myprocessor.cgi&lt;br /&gt; &lt;br /&gt;=============================================================================#&lt;br /&gt;          HEADERS, CACHING AND OPTIMIZATION&lt;br /&gt;=============================================================================#&lt;br /&gt;-&gt; http://www.htaccesselite.com/cache-control-http-headers-vt65.html&lt;br /&gt;      300   5 M&lt;br /&gt;     2700  45 M&lt;br /&gt;     3600   1 H&lt;br /&gt;    54000  15 H&lt;br /&gt;    86400   1 D&lt;br /&gt;   518400   6 D&lt;br /&gt;   604800   1 W&lt;br /&gt;  1814400   3 W&lt;br /&gt;  2419200   1 M&lt;br /&gt; 26611200  11 M&lt;br /&gt; 29030400   1 Y (never expire)&lt;br /&gt;##########&lt;br /&gt; &lt;br /&gt;### HEADER CACHING ####&lt;br /&gt;-&gt; http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html&lt;br /&gt;&lt;FilesMatch "\.(flv|gif|jpg|jpeg|png|ico)$"&gt;&lt;br /&gt;   Header set Cache-Control "max-age=2592000"&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt;&lt;FilesMatch "\.(js|css|pdf|swf)$"&gt;&lt;br /&gt;   Header set Cache-Control "max-age=604800"&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt;&lt;FilesMatch "\.(html|htm|txt)$"&gt;&lt;br /&gt;   Header set Cache-Control "max-age=600"&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt;&lt;FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$"&gt;&lt;br /&gt;   Header unset Cache-Control&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt; &lt;br /&gt;## ALTERNATE EXPIRES CACHING ###&lt;br /&gt;-&gt; htaccesselite.com/d/use-htaccess-to-speed-up-your-site-discussion-vt67.html&lt;br /&gt;ExpiresActive On&lt;br /&gt;ExpiresDefault A604800&lt;br /&gt;ExpiresByType image/x-icon A2592000&lt;br /&gt;ExpiresByType application/x-javascript A2592000&lt;br /&gt;ExpiresByType text/css A2592000&lt;br /&gt;ExpiresByType text/html A300&lt;br /&gt;&lt;FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$"&gt;&lt;br /&gt;   ExpiresActive Off&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt; &lt;br /&gt;## META HTTP-EQUIV REPLACEMENTS ###&lt;br /&gt;&lt;FilesMatch "\.(html|htm|php)$"&gt;&lt;br /&gt;   Header set imagetoolbar "no"&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt; &lt;br /&gt;=============================================================================#&lt;br /&gt;          REWRITES AND REDIRECTS&lt;br /&gt;=============================================================================#&lt;br /&gt; REQUEST METHODS: GET,POST,PUT,DELETE,CONNECT,OPTIONS,PATCH,PROPFIND,&lt;br /&gt;                  PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK&lt;br /&gt;##########&lt;br /&gt; &lt;br /&gt;## REWRITE DEFAULTS ###&lt;br /&gt;RewriteEngine On&lt;br /&gt;RewriteBase /&lt;br /&gt; &lt;br /&gt;## REQUIRE SUBDOMAIN ###&lt;br /&gt;RewriteCond %{HTTP_HOST} !^$&lt;br /&gt;RewriteCond %{HTTP_HOST} !^subdomain\.domain\.tld$ [NC]&lt;br /&gt;RewriteRule ^/(.*)$ http://subdomain.domain.tld/$1 [L,R=301]&lt;br /&gt; &lt;br /&gt;## SEO REWRITES ###&lt;br /&gt;RewriteRule ^(.*)/ve/(.*)$    $1/voluntary-employee/$2 [L,R=301]&lt;br /&gt;RewriteRule ^(.*)/hsa/(.*)$     $1/health-saving-account/$2 [L,R=301]&lt;br /&gt; &lt;br /&gt;## WORDPRESS ###&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-f    # Existing File&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-d    # Existing Directory&lt;br /&gt;RewriteRule . /index.php [L]&lt;br /&gt; &lt;br /&gt;## ALTERNATIVE ANTI-HOTLINKING ###&lt;br /&gt;RewriteCond %{HTTP_REFERER} !^$&lt;br /&gt;RewriteCond %{HTTP_REFERER} !^http://(subdomain\.)?domain.tld/.*$ [NC]&lt;br /&gt;RewriteRule ^.*\.(bmp|tif|gif|jpg|jpeg|jpe|png)$ - [F]&lt;br /&gt; &lt;br /&gt;## REDIRECT HOTLINKERS ###&lt;br /&gt;RewriteCond %{HTTP_REFERER} !^$&lt;br /&gt;RewriteCond %{HTTP_REFERER} !^http://(subdomain\.)?domain.tld/.*$ [NC]&lt;br /&gt;RewriteRule ^.*\.(bmp|tif|gif|jpg|jpeg|jpe|png)$ http://google.com [R]&lt;br /&gt; &lt;br /&gt;## DENY REQUEST BASED ON REQUEST METHOD ###&lt;br /&gt;RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD)$ [NC]&lt;br /&gt;RewriteRule ^.*$ - [F]&lt;br /&gt; &lt;br /&gt;## REDIRECT UPLOADS ###&lt;br /&gt;RewriteCond %{REQUEST_METHOD} ^(PUT|POST)$ [NC]&lt;br /&gt;RewriteRule ^(.*)$ /cgi-bin/form-upload-processor.cgi?p=$1 [L,QSA]&lt;br /&gt; &lt;br /&gt;## REQUIRE SSL EVEN WHEN MOD_SSL IS NOT LOADED ###&lt;br /&gt;RewriteCond %{HTTPS} !=on [NC]&lt;br /&gt;RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]&lt;br /&gt; &lt;br /&gt;### ALTERNATATIVE TO USING ERRORDOCUMENT ###&lt;br /&gt;-&gt; http://www.htaccesselite.com/d/htaccess-errordocument-examples-vt11.html&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-f&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-d&lt;br /&gt;RewriteRule ^.*$ /error.php [L]&lt;br /&gt; &lt;br /&gt;## SEO REDIRECTS ###&lt;br /&gt;Redirect 301 /2006/oldfile.html http://subdomain.domain.tld/newfile.html&lt;br /&gt;RedirectMatch 301 /o/(.*)$ http://subdomain.domain.tld/s/dl/$1&lt;br /&gt; &lt;br /&gt;=============================================================================#&lt;br /&gt;          AUTHENTICATION AND SECURITY&lt;br /&gt;=============================================================================#&lt;br /&gt; http://www.htaccesselite.com/basic-authentication-example-vt17.html&lt;br /&gt; &lt;br /&gt; Require (user|group|valid-user) (username|groupname)&lt;br /&gt;##########&lt;br /&gt; &lt;br /&gt;## BASIC PASSWORD PROTECTION ###&lt;br /&gt;AuthType basic&lt;br /&gt;AuthName "prompt"&lt;br /&gt;AuthUserFile /.htpasswd&lt;br /&gt;AuthGroupFile /dev/null&lt;br /&gt;Require valid-user&lt;br /&gt; &lt;br /&gt;## ALLOW FROM IP OR VALID PASSWORD ###&lt;br /&gt;Require valid-user&lt;br /&gt;Allow from 192.168.1.23&lt;br /&gt;Satisfy Any&lt;br /&gt; &lt;br /&gt;## PROTECT FILES ###&lt;br /&gt;&lt;FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$"&gt;&lt;br /&gt;  Order Allow,Deny&lt;br /&gt;  Deny from all&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt; &lt;br /&gt;## PREVENT HOTLINKING ###&lt;br /&gt;SetEnvIfNoCase Referer "^http://subdomain.domain.tld/" good&lt;br /&gt;SetEnvIfNoCase Referer "^$" good&lt;br /&gt;&lt;FilesMatch "\.(png|jpg|jpeg|gif|bmp|swf|flv)$"&gt;&lt;br /&gt;   Order Deny,Allow&lt;br /&gt;   Deny from all&lt;br /&gt;   Allow from env=good&lt;br /&gt;   ErrorDocument 403 http://www.google.com/intl/en_ALL/images/logo.gif&lt;br /&gt;   ErrorDocument 403 /images/you_bad_hotlinker.gif&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt; &lt;br /&gt;## LIMIT UPLOAD FILE SIZE TO PROTECT AGAINST DOS ATTACK ###&lt;br /&gt;LimitRequestBody 10240000 #bytes, 0-2147483647(2GB)&lt;br /&gt; &lt;br /&gt;=============================================================================#&lt;br /&gt;          SSL SECURITY&lt;br /&gt;=============================================================================#&lt;br /&gt;-&gt; http://www.askapache.com/htaccess/ssl-example-usage-in-htaccess.html&lt;br /&gt;##########&lt;br /&gt; &lt;br /&gt;## MOST SECURE WAY TO REQUIRE SSL ###&lt;br /&gt;-&gt; http://www.askapache.com/htaccess/apache-ssl-in-htaccess-examples.html&lt;br /&gt;SSLOptions +StrictRequire&lt;br /&gt;SSLRequireSSL&lt;br /&gt;SSLRequire %{HTTP_HOST} eq "domain.tld"&lt;br /&gt;ErrorDocument 403 https://domain.tld&lt;br /&gt; &lt;br /&gt;=============================================================================#&lt;br /&gt;          SITE UNDER CONSTRUCTION&lt;br /&gt;=============================================================================#&lt;br /&gt; Heres some awesome htaccess to use when you are developing a site&lt;br /&gt;##########&lt;br /&gt; &lt;br /&gt;## COMBINED DEVELOPER HTACCESS CODE-USE THIS ###&lt;br /&gt;&lt;FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|js|css|pdf|swf|html|htm|txt)$"&gt;&lt;br /&gt;   Header set Cache-Control "max-age=5"&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt;AuthType basic&lt;br /&gt;AuthName "Ooops! Temporarily Under Construction..."&lt;br /&gt;AuthUserFile /.htpasswd&lt;br /&gt;AuthGroupFile /dev/null&lt;br /&gt;Require valid-user           # password prompt for everyone else&lt;br /&gt;Order Deny,Allow&lt;br /&gt;Deny from all&lt;br /&gt;Allow from 192.168.64.5      # Your, the developers IP address&lt;br /&gt;Allow from w3.org            # css/xhtml check jigsaw.w3.org/css-validator/&lt;br /&gt;Allow from googlebot.com     # Allows google to crawl your pages&lt;br /&gt;Satisfy Any                  # no password required if host/ip is Allowed&lt;br /&gt; &lt;br /&gt;## DONT HAVE TO EMPTY CACHE OR RELOAD TO SEE CHANGES ###&lt;br /&gt;ExpiresDefault A5 #If using mod_expires&lt;br /&gt;&lt;FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|js|css|pdf|swf|html|htm|txt)$"&gt;&lt;br /&gt;   Header set Cache-Control "max-age=5"&lt;br /&gt;&lt;/FilesMatch&gt;&lt;br /&gt; &lt;br /&gt;## ALLOW ACCESS WITH PASSWORD OR NO PASSWORD FOR SPECIFIC IP/HOSTS ###&lt;br /&gt;AuthType basic&lt;br /&gt;AuthName "Ooops! Temporarily Under Construction..."&lt;br /&gt;AuthUserFile /.htpasswd&lt;br /&gt;AuthGroupFile /dev/null&lt;br /&gt;Require valid-user           # password prompt for everyone else&lt;br /&gt;Order Deny,Allow&lt;br /&gt;Deny from all&lt;br /&gt;Allow from 192.168.64.5      # Your, the developers IP address&lt;br /&gt;Allow from w3.org            # css/xhtml check jigsaw.w3.org/css-validator/&lt;br /&gt;Allow from googlebot.com     # Allows google to crawl your pages&lt;br /&gt;Satisfy Any                  # no password required if host/ip is Allowed&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-6935945510863071021?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/6935945510863071021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/htaccess-directives.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/6935945510863071021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/6935945510863071021'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/htaccess-directives.html' title='.htaccess directives'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-3828595006113262577</id><published>2008-12-10T08:27:00.000-08:00</published><updated>2008-12-10T13:28:39.402-08:00</updated><title type='text'>MySQL (foreign key)</title><content type='html'>Foreign keys are used to keep integrity data if it exists in different tables.&lt;br /&gt;For example, we have books and authors tables:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;CREATE TABLE /*!32312 IF NOT EXISTS*/ "authors" (&lt;br /&gt;  "id" int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;  "book_id" int(10) unsigned default NULL,&lt;br /&gt;  "name" varchar(50) default NULL,&lt;br /&gt;  KEY "id" ("id")&lt;br /&gt;) /*!40100 DEFAULT CHARSET=utf8*/;&lt;br /&gt;&lt;br /&gt;CREATE TABLE /*!32312 IF NOT EXISTS*/ "books" (&lt;br /&gt;  "id" int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;  "name" varchar(50) default NULL,&lt;br /&gt;  KEY "id" ("id")&lt;br /&gt;) /*!40100 DEFAULT CHARSET=utf8*/;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;We want to prevent inserting / updating records in books table if there is no proper record in authors table. Actually, why we need to create book with author_id that is absent in authors table? MySQL can keep checking that itself. Let's try.&lt;br /&gt;Create foreign key:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;alter table books add foreign key(author_id) references authors(id)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now we have foreign key author_id in books table.&lt;br /&gt;We can turn on/off foreign key checking by MySQL engine with command like&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SET foreign_key_checks = 0;&lt;br /&gt;SET foreign_key_checks = 1;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;This command will be active to the end of the current MySQL session.&lt;br /&gt;Also we can use the commang like:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ALTER TABLE books WITH NOCHECK add foreign key(author_id) references authors(id)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;This is an example of turning off checking while only the current query.&lt;br /&gt;&lt;br /&gt;We can control child tables while updating / altering data in parent table using ON UPDATE and ON DELETE. Also we can use 5 expressions with on update and on delete:&lt;br /&gt;CASCADE: related records in child tables will be updated if parent record was altered.&lt;br /&gt;SET NULL: related records in child tables will be set to NULL value in parent record was altered.&lt;br /&gt;NO ACTION, RESTRICT: prohibit altering / deleting records from parent table with values that present in child table. We'll get an error like "Foreign key constraint..."&lt;br /&gt;SET DEFAULT: the command is recognized by parser but InnoDB engine doesn't react to it.&lt;br /&gt;&lt;br /&gt;Note: if we want to add ON UPDATE / ON DELETE expression to our foreign key, we run the command again with this expressions:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ALTER TABLE books add foreign key(author_id) references authors(id) on update cascade&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Now let's test how it works:&lt;br /&gt;Will add record to books table with authors_id that is absent in authors table:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SQL-запрос: Изменить&lt;br /&gt;&lt;br /&gt;INSERT INTO `fkey`.`books` (&lt;br /&gt;`id` ,&lt;br /&gt;`author_id` ,&lt;br /&gt;`name`&lt;br /&gt;)&lt;br /&gt;VALUES (&lt;br /&gt;NULL , '1', 'Oleg'&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;Ответ MySQL: Документация&lt;br /&gt;#1216 - Cannot add or update a child row: a foreign key constraint fails &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;It's right. Now create author in authors table:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;INSERT INTO `fkey`.`authors` (&lt;br /&gt;`id` ,&lt;br /&gt;`name`&lt;br /&gt;)&lt;br /&gt;VALUES (&lt;br /&gt;'1', 'Author Valentin'&lt;br /&gt;);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And rerun the query:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;INSERT INTO `fkey`.`books` (&lt;br /&gt;`id` ,&lt;br /&gt;`author_id` ,&lt;br /&gt;`name`&lt;br /&gt;)&lt;br /&gt;VALUES (&lt;br /&gt;NULL , '1', 'Oleg'&lt;br /&gt;);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;It was allowed. MySQL is clever, isn't it :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-3828595006113262577?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/3828595006113262577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/mysql-foreign-key.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3828595006113262577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3828595006113262577'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/mysql-foreign-key.html' title='MySQL (foreign key)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-1887193860025450175</id><published>2008-12-10T07:48:00.000-08:00</published><updated>2008-12-10T13:33:04.373-08:00</updated><title type='text'>PHP5 (base connect)</title><content type='html'>//some class for database interaction&lt;br /&gt;&lt;br /&gt;It's usefull to have a class for interaction with database. We can ofter use it in our projects. It's simple and handy :)&lt;br /&gt;&lt;br /&gt;Will create two inc files: db_connect.inc&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class DB_Mysql {&lt;br /&gt; protected $user;&lt;br /&gt; protected $pass;&lt;br /&gt; protected $dbhost;&lt;br /&gt; protected $dbname;&lt;br /&gt; protected $dbh; // Database connection handle&lt;br /&gt; public function __construct($user, $pass, $dbhost, $dbname) {&lt;br /&gt;  $this-&gt;user = $user;&lt;br /&gt;  $this-&gt;pass = $pass;&lt;br /&gt;  $this-&gt;dbhost = $dbhost;&lt;br /&gt;  $this-&gt;dbname = $dbname;&lt;br /&gt; }&lt;br /&gt; protected function connect() {&lt;br /&gt;  $this-&gt;dbh = mysql_pconnect($this-&gt;dbhost, $this-&gt;user, $this-&gt;pass);&lt;br /&gt;  if(!is_resource($this-&gt;dbh)) {&lt;br /&gt;   throw new Exception;&lt;br /&gt;  }&lt;br /&gt;  if(!mysql_select_db($this-&gt;dbname, $this-&gt;dbh)) {&lt;br /&gt;   throw new Exception;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; public function execute($query) {&lt;br /&gt;  if(!$this-&gt;dbh) {&lt;br /&gt;   $this-&gt;connect();&lt;br /&gt;  }&lt;br /&gt;  $ret = mysql_query($query, $this-&gt;dbh);&lt;br /&gt;  if(!$ret) {&lt;br /&gt;   //throw new Exception;&lt;br /&gt;  }&lt;br /&gt;  else if(!is_resource($ret)) {&lt;br /&gt;   return TRUE;&lt;br /&gt;  }&lt;br /&gt;  else {&lt;br /&gt;   $stmt = new DB_MysqlStatement($this-&gt;dbh, $query);&lt;br /&gt;   $stmt-&gt;result = $ret;&lt;br /&gt;   return $stmt;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;and file db_statement.inc&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class DB_MysqlStatement {&lt;br /&gt; public $result;&lt;br /&gt; public $query;&lt;br /&gt; protected $dbh;&lt;br /&gt; public function __construct($dbh, $query) {&lt;br /&gt;  $this-&gt;query = $query;&lt;br /&gt;  $this-&gt;dbh = $dbh;&lt;br /&gt;  if(!is_resource($dbh)) {&lt;br /&gt;   throw new Exception("Not a valid database connection");&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; public function fetch_row() {&lt;br /&gt;  if(!$this-&gt;result) {&lt;br /&gt;   throw new Exception("Query not executed");&lt;br /&gt;  }&lt;br /&gt;  return mysql_fetch_row($this-&gt;result);&lt;br /&gt; }&lt;br /&gt; public function fetch_assoc() {&lt;br /&gt;  return mysql_fetch_assoc($this-&gt;result);&lt;br /&gt; }&lt;br /&gt; public function fetchall_assoc() {&lt;br /&gt;  $retval = array();&lt;br /&gt;  while($row = $this-&gt;fetch_assoc()) {&lt;br /&gt;   $retval[] = $row;&lt;br /&gt;  }&lt;br /&gt;  return $retval;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And that's cool. Now we can use it:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;include("db_connect.php");&lt;br /&gt;include("db_statement.php");&lt;br /&gt;&lt;br /&gt;$dbh = new DB_Mysql("root", "admin", "localhost", "base");&lt;br /&gt;$query = "SELECT * FROM `users` ";&lt;br /&gt;$stmt = $dbh-&gt;execute($query);&lt;br /&gt;while ($row = $stmt-&gt;fetch_assoc()) {&lt;br /&gt; print_r($row);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;very nice ))&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-1887193860025450175?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/1887193860025450175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/php5-database-connect.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1887193860025450175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/1887193860025450175'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/php5-database-connect.html' title='PHP5 (base connect)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-176788098808693265</id><published>2008-12-09T11:51:00.000-08:00</published><updated>2008-12-10T05:26:16.155-08:00</updated><title type='text'>CakePHP (lang/url)</title><content type='html'>Yes, we want to have the language in url. Let's make use of Cake url:&lt;br /&gt;http://hostname/controller/action/param1/param2/...&lt;br /&gt;&lt;br /&gt;Well, can we create a controller like "en" or "ru"? It's a deal.&lt;br /&gt;Create two controllers: "en_controller.php", "ru_controller.php" with content like this (for en_controller.php):&lt;br /&gt;&lt;code&gt;&lt;br /&gt;include_once("site_controller.php");&lt;br /&gt;class EnController extends SiteController {&lt;br /&gt;var $lang = "en";&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And in site_controller we add the function:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function beforeRender() {&lt;br /&gt;$lang = $this-&gt;lang;&lt;br /&gt;$this-&gt;set('lang', $lang);&lt;br /&gt;if ($this-&gt;Session-&gt;read('Config.language') != $lang) {&lt;br /&gt;$this-&gt;Session-&gt;write('Config.language', $lang);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Go to file app/config/routes.php and add line:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Router::connect('/', array('controller' =&gt; 'ru', 'action' =&gt; 'index'));&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Folders app/locale/eng and app/locale/rus - are like in the previous post.&lt;br /&gt;So, navigating address like: http://hostname/en/books/2 we'll activate en_controller.php. In this controller the variable $lang will be declared and used in site_controller.php in function beforeRender(). The proper session variable will be created.&lt;br /&gt;&lt;br /&gt;P.S. also we need links for switching between languages, the link address in view will be something like:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/lang/ru&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;So, if click it - site_controller will be activated, function lang in this case. Value "en" will be written to the session variable and than should redirect back to the referrer. As a aresult while rendering view new session variable will be read (function beforeRender) and proper language phrases will be placed to the view. It works :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-176788098808693265?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/176788098808693265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/cakephp-multilanguages-in-url.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/176788098808693265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/176788098808693265'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/cakephp-multilanguages-in-url.html' title='CakePHP (lang/url)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-4478073460580431018</id><published>2008-12-08T12:59:00.000-08:00</published><updated>2008-12-10T05:25:24.772-08:00</updated><title type='text'>CakePHP (lang)</title><content type='html'>//With session vars and cookies&lt;br /&gt;&lt;br /&gt;Today we go to app/locale/. There are one folder like "eng". We want to add second language "rus".&lt;br /&gt;Ok, create second folder "rus". Than go to Eng folder and copy folder LC_MESSAGES with language file to our new folder Rus. Finally we have two folders Eng and Rus in app/locale/ and there are folder LC_MESSAGES and language file in both.&lt;br /&gt;The language file for eng language is something like this: "default.po" and it's content:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;msgid "start_page"&lt;br /&gt;msgstr "Start page (english language)"&lt;br /&gt;&lt;br /&gt;msgid "catalog"&lt;br /&gt;msgstr "Catalog"&lt;br /&gt;&lt;br /&gt;msgid "some_books"&lt;br /&gt;msgstr "Books with id &lt;&gt;change($lang);&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now we create p28n_controller.php:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class P28nController extends AppController {&lt;br /&gt;   var $name = 'P28n';&lt;br /&gt;   var $uses = null;&lt;br /&gt;   var $components = array('P28n');&lt;br /&gt;&lt;br /&gt;   function change($lang = null) {&lt;br /&gt;       $this-&gt;P28n-&gt;change($lang);&lt;br /&gt;&lt;br /&gt;       $this-&gt;redirect($this-&gt;referer(null, true));&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   function shuntRequest() {&lt;br /&gt;       $this-&gt;P28n-&gt;change($this-&gt;params['lang']);&lt;br /&gt;&lt;br /&gt;       $args = func_get_args();&lt;br /&gt;       $this-&gt;redirect("/" . implode("/", $args));&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;and than create a component "app/controllers/components/p28n.php":&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class P28nComponent extends Object {&lt;br /&gt;    var $components = array('Session', 'Cookie');&lt;br /&gt;&lt;br /&gt;    function startup() {&lt;br /&gt;        if (!$this-&gt;Session-&gt;check('Config.language')) {&lt;br /&gt;            $this-&gt;change(($this-&gt;Cookie-&gt;read('lang') ? $this-&gt;Cookie-&gt;read('lang') : 'en-us'));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function change($lang = null) {&lt;br /&gt;        if (!empty($lang)) {&lt;br /&gt;            $this-&gt;Session-&gt;write('Config.language', $lang);&lt;br /&gt;            $this-&gt;Cookie-&gt;write('lang', $lang, null, '+350 days');&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;OK. In our controller declare the variable like our component:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;var $components = array('P28n');&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now we can use it in our controller like:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$this-&gt;pageTitle = __('pageTitle_home', true);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Note, that if second parameter is true - the message will be returned as a value (use it in controller)&lt;br /&gt;And if false - the message will be echo'd (use it this way in a template)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;__('pageTitle_home');&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And that's all. It's sad that we don't have the language prefix in url. Will do more in the next post :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-4478073460580431018?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/4478073460580431018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/4478073460580431018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/4478073460580431018'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/c.html' title='CakePHP (lang)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-2110875823191646021</id><published>2008-12-06T05:28:00.000-08:00</published><updated>2008-12-06T06:24:49.381-08:00</updated><title type='text'>Python, Zope, Plone</title><content type='html'>Today we'll try some Python, Zope and Plone.&lt;br /&gt;Python supports several programming styles. Object oriented and structured programming. There is dynamic typing and a cycle detecting garbage collector for memory management. Python supports dynamic name resolution, large standard library.&lt;br /&gt;Download installation package from python.org site, it's about 13Mb. Installation process is simple enough. Now we have in programs menu shortcuts for GUI and command line consoles. Start it. There is &gt;&gt;&gt; sign at the begin of the line (can be altered on any other sign). The interpreter is waiting for your commands.&lt;br /&gt;&lt;br /&gt;Zope - object-oriented web server in the Python programming language. Is free and open-source. Download installation package from zope.org website and install it. On default the port 127.0.0.1 localhost will be used. Open web browser and navigate to that address. Nothing seems to work. To make it create DTML method in index file of the web folder (there is description how to create that method on zope official website). DTML - it's something like Smarty. OK, navigate to http://localhost again, no result. For now just type http://localhost/index.html or something like that to test if your DTML method works well. Cause there is no automatic redirecting to index file just after installation.&lt;br /&gt;&lt;br /&gt;Plone - open source CMS for internal sites built on the Zope server. All information stored in Plone is stored in Zope built-in transaction object database (ZODB). There are templates writing with CSS for customizing a website look. OK, download installation package from plone.org website. It's about 24Mb. After installation it we can see that python language and zope framework were installed with it. In programs menu we can see Plone shortcut. Start it. The small window appears. It's something like IIS for management. Press button "Start Plone" and navigate to localhost address. After login we can create manage the cms, create items (types: text, file, folder etc.), set rules for navigating and redirecting. Also don't forget about workflow system, so the item after creating won't be visible on frontend if not approved yet. As for me, it's accurate and handy cms :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-2110875823191646021?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/2110875823191646021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/python-zope-plone.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2110875823191646021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/2110875823191646021'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/python-zope-plone.html' title='Python, Zope, Plone'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-3162439274031680527</id><published>2008-12-05T13:51:00.000-08:00</published><updated>2008-12-10T05:01:25.998-08:00</updated><title type='text'>CMS (about)</title><content type='html'>And now cms. It's great deal for huge companies and even for small portals. The idea - to automatize most primitive work and fix on management and representation of the content. Also to divide security rights and stages of publishing new materials. One deal - to alter content. The other - to make it presentation flow simple and clear.&lt;br /&gt;&lt;br /&gt;Case one. We have very complicated cms. It consists of every probable needed module / functionality. After in-depth study we get universal remedy for our needs. Yes, sometimes support team of that cms is only one way option to implement the needs.&lt;br /&gt;&lt;br /&gt;Case two. We have simple cms. It's not waste time to learn but this tool cannot implement every your idea. Just for simple portal / website. And yes, it's not perspective because of it's simplicity.&lt;br /&gt;&lt;br /&gt;Case three. We have open source cms with modular architecture. So, the time for learning depends of our plans and it's so easy to enlarge such cms.&lt;br /&gt;&lt;br /&gt;Some words about Bitrix (1c-bitrix.ru). It's a cms for websites and e-stores. It's not open source, you can be suprised a little that some system files are enciphered :) yes just have tried to find some text in source files and without any success )) it was funny. Declared functionality is wide enought. Especially for e-stores - we already have all components for that. Just put it on the page and that's it. But, if we want to change the declared functionality - we have some interesting time. In some cases it's hard to get clue what was done on this or that stage. We cannot look into the code, maybe it's like a game in a black box :) Great help we can get on the forum, that's a deal.&lt;br /&gt;&lt;br /&gt;Also for simple websited we have something like admin-part. Very ofter it's the same code just with some addition in functionality. Usual functionality - rich text pages, different files, images, video, etc. In logic we have division into users with different rights for altering the content. Also sending emails, getting information from the site's forms. No any workflow system, weak security protection. That's enough for simple websites.&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-3162439274031680527?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/3162439274031680527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/cakephp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3162439274031680527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/3162439274031680527'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/cakephp.html' title='CMS (about)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5079136477863596220.post-7884705799459779914</id><published>2008-12-05T13:43:00.001-08:00</published><updated>2008-12-10T05:24:30.838-08:00</updated><title type='text'>CakePHP (install)</title><content type='html'>CakePHP is an open source web application framework for producing web applications written in PHP. It is written in PHP, is modeled after the concepts of Ruby on Rails, and is distributed under the MIT License.&lt;br /&gt;//wikipedia&lt;br /&gt;&lt;br /&gt;Yes, it's easy and effective enough for websites that are thought not to be very overladen. It's not the best variant for chat, multimedia portal, etc.&lt;br /&gt;We can download the package from the site cakephp.org and try to install it. It's a quick deal.&lt;br /&gt;&lt;br /&gt;Folder "app" - it's a folder for our site. Other folders: cake, docs, vendors - are system for the framework. And we go... Copy all that that folders and files in the root directory of your host.&lt;br /&gt;&lt;br /&gt;Go to app/config/core.php&lt;br /&gt;For the first time set Configure::write('debug', 2); //it's a level of error / notice reporting&lt;br /&gt;Best variant to use utf-8: Configure::write('App.encoding', 'UTF-8');&lt;br /&gt;Your can be asked to set random string used in security hashing methods: Configure::write('Security.salt', 'justyourandomsymbolshere');&lt;br /&gt;&lt;br /&gt;Go to app/config/routes.php&lt;br /&gt;Later you would like to change redirecting rules on you website.&lt;br /&gt;&lt;br /&gt;Copy app/config/database.php.default file to database.php&lt;br /&gt;Usually I set there something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;var $default = array(&lt;br /&gt;    'driver' =&gt; 'mysql',&lt;br /&gt;    'persistent' =&gt; false,&lt;br /&gt;    'host' =&gt; 'localhost',&lt;br /&gt;    'login' =&gt; 'sasha',&lt;br /&gt;    'password' =&gt; 'magicduck',&lt;br /&gt;    'database' =&gt; 'test_base',&lt;br /&gt;    'prefix' =&gt; 'tt_',&lt;br /&gt;    'encoding' =&gt; 'utf8'&lt;br /&gt;);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;prefix - if you're planning to add forum with many other tables to the website it's good way to add prefix to your cakephp tables.&lt;br /&gt;encoding - just set encoding for your pages. utf8 works fine and you'll shouldn't get stange symbols any more.&lt;br /&gt;&lt;br /&gt;Now folder "controllers" - there will be your controllers files.&lt;br /&gt;Folder "models" - your models files. Good idea to name model files in singular mode.&lt;br /&gt;Folder "views" - views for your pages. There is folder "elements" - elements for pages, folder "layouts" - layouts for your site.&lt;br /&gt;Folder "webroot" - folder "files" there will be files for your site content: images, sounds, movies, etc. Also "css" - styles and "js" - scripts folders are there.&lt;br /&gt;Folder "locale" - can be used for multilanguage for your site.&lt;br /&gt;&lt;br /&gt;And please, don't forget use Ctrl+F5 while reloading the page and also to clear "\tmp\cache\models" folder after altering models files. Happy baking :)&lt;br /&gt;&lt;br /&gt;http://cakephp.org&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5079136477863596220-7884705799459779914?l=logic-is-art.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://logic-is-art.blogspot.com/feeds/7884705799459779914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/vkontaktetxt.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/7884705799459779914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5079136477863596220/posts/default/7884705799459779914'/><link rel='alternate' type='text/html' href='http://logic-is-art.blogspot.com/2008/12/vkontaktetxt.html' title='CakePHP (install)'/><author><name>Alexander Makhno</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://2.bp.blogspot.com/_coCosk4H_Mo/SVaIwE0xL6I/AAAAAAAAAEQ/TQXjPO0AIOc/S220/pic2.jpg'/></author><thr:total>1</thr:total></entry></feed>
