Install PHP di Keluarga Buah Buahan
31 Mar 2008 | Kel. Apache, Mac, PHP | 3 Comments »
Berawal dari 24 hari lalu dan ToH Leo yang indah. Dimana telah banyak program terinstall default disana. Seperti Apache dan PHP. Meskipun PHP belum di load secara default oleh Leopard. Untuk meload PHP harus dilakukan secara manual yaitu edit file /private/etc/apache2/httpd.conf. Tinggal hilangkan tanda pagar (#) pada baris
#LoadModule php5_module libexec/apache2/libphp5.so
menjadi
LoadModule php5_module libexec/apache2/libphp5.so
restart web server jadi deh.
Export Data CDS ISIS ke MySQL
11 Dec 2007 | Kel. Apache, Databases, Linux, PHP, The Others, Windows | 7 Comments »
CDS ISIS merupakan produk dari UNESCO yang telah “melegenda” di kalangan para pustakawan. Hal ini bisa dimengerti karena memang sudah dari jaman dahulu kala CDS ISIS ini digunakan. Gratis lagi. Banyak keunggulan nya juga memang CDS ISIS ini, terutama penerapan MARC yang fleksibel. Hanya saja yang membuat saya sendiri “mangkel” adalah format penyimpanan dalam bentuk TEXT ISO (karena berekstensi .ISO tapi berisi file TEXT biasa) tunggal. Pertanyaan muncul kenapa harus file TEXT seh, kan sekarang sudah bukan jaman lagi data disimpan dalam bentuk text. Sudah ada Database server yang jauh lebih handal. Katakan semacam MySQL, PostgreSQL, Oracle, MSSQL, SQLite, EnterpriseDB dll, entah itu berbayar ataupun gratis.
Ok, tutorial ini merupakan “salah satu cara” yang dapat digunakan sebagai referensi bila anda-anda semua ingin mencoba merubah data CDS ISIS yang berbentuk TEXT ISO ke dalam database server MySQL. untuk database yang lain saya rasa tidak akan jauh berdeda. more…
install Apache MySQL PHP plus modul PDFlib
1 Dec 2007 | Kel. Apache, Databases, Linux, PHP | 4 Comments »
Seperti di manual PHP disebutkan bahwa PHP tidak lagi mendukung PDFlib secara builtin semenjak tanggal 9 Maret 2000. Tapi tidak berarti PHP tidak mendukung format PDF, tetapi dengan PECL kita masih bisa membuat PDF dengan PHP tentu saja tetap dengan menggunakan PDFlib yang sudah tidak gratis lagi. eh.. ada ding yang gratis yaitu versi Lite. Tentu saja versi lite ini tidak secanggih versi berbayarnya. kok malah ngelantur neh, kapan configure nya…..????
Tutorial ini saya tulis dengan keyboard tentunya :D. Slackware 12, PHP 5.2.4, Apache 2.2.6, MySQL 5.0.45 dan PDFlib-Lite-7.0.0p3. dan saya yakin bisa untk distro Linux laennya. more…
Fractal di PHP
16 Jul 2007 | Kel. PHP | 12 Comments »
inget fractal (ato apalah) yang tiap di zoom selalu ada dalem nya, seperti ga ada habisnya. ternyata PHP juga bisa digunakan untuk buat gambar seperti fractal juga. meskipun ga isa di zoom seperti aslinya. cuma ngandalin library GD selesai. klik disini untuk contoh nya, dan disini untuk source nya. (sumber dari internet yang lupa URL nya)

swap nilai variabel
9 Jul 2007 | Kel. PHP | 2 Comments »
Ternyata ada beberapa cara melakukan proses pertukaran nilai suatu variabel menggunakan PHP tentunya. Ini baru saya sadari setelah membaca milis phpXperts beberapa hari yang lalu. Berikut cara-cara pertukaran nilai nya: more…
Code Reviewing (part III)
28 Mar 2007 | Kel. PHP | No Comments »
In more detail
In the extended entry I’ll look a bit closer at some of these deviations from the ideal..
Print rather than Echo
This one’s more for consistancy, (we’ve used echo everywhere before, it’s it’s one character shorter ![]()
Grepping for echo in a project, is also quite a handy test for any kind of data injection, since most output is our projects is done via template engines. Grepping for :h and echo will find most potential holes. (althoug grepping for print_r / var_dump is also a good idea..)
Exiting on XMLHttpRequest calls.
Most of the XUL based code, and alot of the new HTML/XUL hybrid code I specifiy uses XMLHttpRequest calls to send update/delete/add requests, more…
Code Reviewing (part II)
28 Mar 2007 | Kel. PHP | No Comments »
Coding Standards
Thankfully, I have managed to cobble together a quite large project coding standard to try and keep projects on track. Without them, Stages III and IV would become unmanagable, as tracing exactly how code was implemented so that both changes and refactoring would become completly impossible.
Unfortunatly, however clear the standards are (or you thought they are), developers have a nack of not following them, either out of habit or just the pressure to deliver so they can get paid.. - So a certian part of the halfway Phase II code review ends up just reiterating where they have missed those elements.
Common mistakes include
- Not following the ‘no if without braces rule’
- not cloning DataObjects, as we develop in both PHP4 and test in PHP5
- creating javascript libraries with functions in them.
- creating PHP includes with functions in them
- Not making the most of the automated url rewriting that FlexyFramework and HTML_Template_Flexy do for CSS, javascript and images.
- Using mysql_real_escape, rather than the more portable DataObjects’ escape() method. (which really wraps PEAR DB/MDB2)
- Incorrect Indentation in javascript files.
- passing strings around as error messages notices, rather than using error and notice flags, so the text of the message is on the templates, rather than in the PHP code.
- Implementing magic constructors on the base controller…
- using $do->whereAdd(’somevar=1′) when $do->somevar = 1 will do..
- adding ?> at the end of the file
- It’s not needed, and will come back to bite you one day. - Hard coding email subjects etc. in the PHP code, rather than using email templates.
- Adding too many config options - especially file locations.
Reviewing the code also is a great opportunity to update and rewrite some of the standards so that things like this should not happen any more. (Although I wonder if making it bigger means there is even less chance they will follow it)
- using ‘print’ rather than ‘echo’
- for xmlHttpRequest called code, using ‘exit’ in the get()/post() methods, rather than trying to get clever with content-type, and modifying the output method.
- don’t do the page processing in the output method()
- stopping the use of javascript shortcuts - ie:
- function ID(n) { return document.getElementById(n); }
- using libraries that where not specified.. or using non-PEAR libraries when PEAR ones are available… - or creating libraries and plonking them in the Application Tree, with the wrong file/class mapping.
- using commandset/command in XUL rathar than simply oncommand and the Javascript call.
- using cwd(), rather than using dirname(__FILE__), for determinig the path for reading data files.
- creating new object/array’s when cloning dataobjects will work.
- working with session variables from classes outside the one you are in (in The Framework, classes own a session variable $_SESSION[__CLASS__]…, and other classes should not access it directly).
- not implementing a 404 return for unknown get’s on the main page.
- passing get/post requests back up to the main page using parent::get()…
- Hard coding options (eg. enums) into controller classes (eg. currencies or statuses etc.) - put them in the DataObjects, so other pages can get the same list.
- Overlaying config var’s into the controller as raw properties..
- Doing PHP calls in the template that involve alot of Database calls (that are critical and could fail) - Which is why we design code to do the processing before any output occurs, so we can redirect and handle issues gracefully.
- Trying to get clever with sessions to pass errors about, when internal redirectors are intended to send notices back to the next page. (eg. HTML_FlexyFramework::run(”,array(’notice’=>array(’user_updated_ok’=>true)));
- excessive nesting of if/while/if/…else etc. - kill that nesting, return, continue or exit from conditions early, eg. negative test, and return, rather than positive test, and if/else.. nested many levels.
- Consistantancy withdataobject methods, in general, dont do updates to a dataobject on a call, unless the method hints’ that it might do it… -> eg. $do->approve() or $do->approveAndUpdate(); …
- Avoid silly code… $obj->is_verified = Project::isAuth() ? 0 : 1 .. either just cast it (int) , or let DataObjects worry about it…
- Making lines so long you can’t read them… Creating an instance of an object to call a method that ‘could’ be static, is not a bad thing, MyProject_DataObjects_Sometable::callaMethod() or $x= DB_DataObject::factory(’Sometable’); $x->callaMethod();
- Expecting me to chmod directories hidden away in the application. If you need to create temporary or semi temporary files, use the Template engines’s temp directory, rather than trying to create them in the Code source somewhere (so that changing file permissions on svn up/checkout is not needed) - We can always change our default temp directory with set ini_set(session.save_path) in the bootstrapper..
- ConfigData/default.ini are generally depreciated in favour of using the bootstrap to define the default options - and we have a slightly different bootstrap defined for our servers.
- Assuming it’s ok to delete stuff! instead, it should be a basic assumtion, that nothing get’s deleted from databases (eg. it always get’s flagged), so dont write code that actually deletes it, and always check the deleting flag when searching…
- Forgetting to extend the Project base class - Everything extends the base class, even code run via cron jobs.
And sometimes, you realize that the rules you set down may not be totally the best idea…
In one case I advocated using $do->setFrom() rather than seeing a big list of map’s between $POST[] / or something else and a dataobject. However, in some cases either building the object slowly and clearly or listing what you send to setFrom() makes the code considerably clearer. Continue…>>
/* sumber milis phpXperts */
"Saya adalah Saya" ya memang itu salah satu dari sekian semboyan saya. Sekarang banyak waktu dihabiskan di depan komputer sambil belajar ngetik tentunya. "Ngopi" dan "udud" merupakan kegemaran yang sampai sekarang belom bisa ditinggalkan. Terasa uuuenak tenan...