Skip navigation.

my php-driven thoughts

about web and something more

Posts tagged with "coding"

some news with inqueries

, ,

anyways, we've been setting up intranet/internet server for dev-beta-testing usage of various projects.

one of the problems we came up with was... WHAT WOULD BE THE NAME OF THE SERVER? Solution? Name of goddess of fire in Lithuania's pagan religion - Gabija (pronounce: GA-bi-ja). I've read somewhere in orkut.com how system administrators come up with server names. some of them were really original.

from my work experience (at Vilnius University IT center) names were chosen from trees and gods' names. what kind of "naming system" do YOU use to name your servers at home/work?

Best ever PM implementation!

, , , ...

Ok, so we're off with the portal, but at launch moment it didn't have PMs (personal messeges) feature. So my colegue helped me and made an awsome PM implementation (it's still under dev, though).

Of course we could have made it with IMAP back-end, but because of our cut on hosting and servers we're doing it SQL back-ended.

So normally one would do two tables (for inbox and outbox) and stuff one message into both tables. But my colegue came up with very brilliant and unique idea! Make three tables (read on...):
  • One for all the messages (the 'container');
  • One for INBOX (with message ids from first table);
  • One for OUTBOX (with message ids from first table);


The first table with all the messages holds message id, text, sender, time, etc. AND additional field which states where message should be shown (or for a user sight - deleted/kept). If message is indicated as hidden (read: deleted) in both (inbox and outbox) it is deleted from 'container' as well. But to keep our server load as low as possible - there's cron'ed script for deleting all 'hidden' messages at midnight as well with other needless data (users that deleted their account, etc.).

Isn't that awsome?!

some news

, ,

since only 4 days left until launch of the biggest project i was working on it quite hardly. came up on some nice and not-so-nice things while developing.

first off: image cropper. half javascript, other half - php. i was looking for it some time (even two hours with google, which is very much) and found this. very easy customizable. left the licence intact .P

next: lots of bugging with databases. added/removed some keys'n'stuff.

now: back to work.

bug hunting

, ,

yes. today i hunted down about >20 bugs. They were hiding in places i couldn't foreseen as their hide-out. It was kinda fun. Although some of those bugs were very advanced and could be called features, but from user-end it was more of a bug, than a feature.

Thank God no possible xss or sql-injection attacks. Just unfinished business with some data formating and query optimisation. Tweaked lots of classes for data insertion and display. Had a bit of a headache with html_entities(), htmlspecialchars() and str_replace(). But everything seems fine now...

You know, i never liked working with forms for users (read: idiots; no offence, of course). I mean - how hard can it be to write simple text to some input boxes and text areas, mark some checkbox'es or radio buttons and then hit submit? And God, forbid the errors. You know, i think i'll write a warning note saying: 'If you will not follow the rules for entering the text/whatever you will get shocked by the chair you're sitting on!'. Then i will add css style with media="aural" and embed the sound of evil laughter.

When user has form with > 3 input fields and he submits wrong data - he gets redirected to the form page again, but with empty text field values! And there you go again and again, messing with templates, code snippets and debugging global variables.

Oh, and i got to convince me again, that register_globals are ULTIMATE EVIL while being on. It's good to have good sys-admin doing everything you ask him for. Go him!

For the end of the working day i think i'll stay put with my firefox toolbar project. Thank you and have a nice day!

Messing around with arrays and variables

, ,

For long time i've been messing around with $_POST, $_GET, $_SESSION and $_COOKIES auto-global arrays, though typing $_POST['my_variable_from_form'] all the time (especially in encapsed or concatenated strings) isn't the biggest pleasure.

So i thought of a solution. I know that i've invented bycicle:
<?php
...
foreach ( $_POST as $key => $value ) {
    ${$key} = $value;
    /**
    * do any additional juggling with $value
    * like cleaning from unneeded tags, adding slashes 
    * or anything else you might think of
    */
}
...
?>

Now i've been listing php manual after some time and found a function that does all the job for me and is even much more flexible!
<?php
...
import_request_variables('p');
...
?>


More on this on the web: http://lt.php.net/manual/en/function.import-request-variables.php
December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31