Search found 15 matches

by bugrush
Sun Jun 07, 2009 9:16 am
Forum: PHP - Theory and Design
Topic: How to route requests in web applications?
Replies: 1
Views: 818

How to route requests in web applications?

What is a good way to route requests in php applications? I keep my code/modules nested in my applications. I use something like:   $route = new RequestRoute('admin.php', 'r', @$_GET['r']); $action = $route->next(array('menu', 'contents', 'galleries'));   if($action == 'menu') {   require('admin/mod...
by bugrush
Mon May 25, 2009 11:44 am
Forum: PHP - Code
Topic: How to find filesystem encoding?
Replies: 0
Views: 72

How to find filesystem encoding?

Hi! I have problems with upload forms. All my html pages are in UTF-8 and all post data is posted in UTF-8. Posted filenames are in UTF-8 but my OS(Windows) treats filenames of uploaded files as ISO-8859-1. So how to find filesystem encoding? Or how can I set the character set of a filename(In Windo...
by bugrush
Fri Feb 13, 2009 5:11 pm
Forum: PHP - Code
Topic: How to know which button was clicked
Replies: 4
Views: 544

Re: How to know which button was clicked

You can check which button was clicked like this: if(isset($_POST['sign_up'])) {     //signup } elseif(isset($_POST['login'])) {     //login } And about form buttons: I prefer using <button type="submit">Button Caption</button> over <input type="submit" value="Button Caption...
by bugrush
Thu Feb 12, 2009 1:32 pm
Forum: PHP - Code
Topic: Retrieve images from database not shown in firefox.
Replies: 5
Views: 884

Re: Retrieve images from database not shown in firefox.

you are setting content type to image/jpeg and outputting html
by bugrush
Thu Feb 12, 2009 12:57 pm
Forum: PHP - Code
Topic: Storing pictures in sessions?
Replies: 7
Views: 369

Re: Storing pictures in sessions?

Ok, I'll do that. Storing files in sessions(or in database) was just a random idea. Never done that before. I was just wondering if it was thinkable to store something bigger in sessions. I'll ask again: How is the session loaded? Does php dump whole session into the memory every time or are the nec...
by bugrush
Thu Feb 12, 2009 12:33 pm
Forum: PHP - Code
Topic: Storing pictures in sessions?
Replies: 7
Views: 369

Re: Storing pictures in sessions?

I know it will cause some overhead, because its a filesystem inside a filesystem, but it's temporary data(max 1-2mb). Files feel a bit messy. Ok, but what about session variables? How are they loaded into memory? I mean if I have a lot of data in sessions and I use only small part of it on every req...
by bugrush
Thu Feb 12, 2009 12:02 pm
Forum: PHP - Code
Topic: Storing pictures in sessions?
Replies: 7
Views: 369

Re: Storing pictures in sessions?

so? waht about php sessions? Are all the session variables loaded from session files into the memory immediately everytime you call session_start?
by bugrush
Thu Feb 12, 2009 11:59 am
Forum: PHP - Code
Topic: PHP Cookie when login help...
Replies: 7
Views: 547

Re: PHP Cookie when login help...

If you had error reporting level set to E_ALL you would have a php notice about undefined variable $passowrd on line 17... do some research.
by bugrush
Thu Feb 12, 2009 6:35 am
Forum: PHP - Code
Topic: PHP Cookie when login help...
Replies: 7
Views: 547

Re: PHP Cookie when login help...

umm yeah... there's a typo in my code.
turn on strict error reporting to find it.
use error_reporting(E_ALL); or change it in php.ini
by bugrush
Wed Feb 11, 2009 6:09 pm
Forum: PHP - Code
Topic: PHP Cookie when login help...
Replies: 7
Views: 547

Re: PHP Cookie when login help...

I would use sessions maybe something like this: <?php session_start();   // Define your username and password $username = "admin"; $password = "password123";   if(isset($_POST['txtUsername']) && isset($_POST['txtPassword'])) {     if($_POST['txtUsername'] == $username &am...
by bugrush
Wed Feb 11, 2009 5:59 pm
Forum: PHP - Code
Topic: Censor last octet of an IP Address
Replies: 5
Views: 958

Re: Censor last octet of an IP Address

Code: Select all

$censored_ip = substr($ip, - strrpos($ip, '.')).'.***';
by bugrush
Wed Feb 11, 2009 5:44 pm
Forum: PHP - Code
Topic: Storing pictures in sessions?
Replies: 7
Views: 369

Storing pictures in sessions?

A quick question: Is it good idea to store images in sessions? Are all session variables loaded from session files into memory immediately when script starts? If they aren't then it might be a good idea? If they are, I'll use database instead. I need a good place to store some temporary stuff - many...
by bugrush
Wed Dec 17, 2008 6:09 am
Forum: PHP - Theory and Design
Topic: Confusion about PHP performance
Replies: 7
Views: 944

Re: Confusion about PHP performance

Thank you matthijs! I have measured the performance of my scripts of course and it runs in milliseconds as you guessed. I started programming in C++ and because of that I feel that even those results in milliseconds are still mocking my processor capabilities. I worry because this could change my PH...
by bugrush
Tue Dec 16, 2008 5:27 pm
Forum: PHP - Theory and Design
Topic: Confusion about PHP performance
Replies: 7
Views: 944

Re: Confusion about PHP performance

Thanks! Premature optimization it is, I know. I haven't had any performance problems but parsing like 2000 lines of code for every request that uses only a small part of it is a waste of resources. I'll check out APC. I don't really care about small websites but right now I'm working on a bigger pro...
by bugrush
Tue Dec 16, 2008 3:04 pm
Forum: PHP - Theory and Design
Topic: Confusion about PHP performance
Replies: 7
Views: 944

Confusion about PHP performance

Hi! I want to ask you about php performance. Not that I have any problems running my php scripts. I'm perfectionist and I just can't sleep if some things are not clear to me. Does parsed and compiled php code get cached somewhere or the server has to parse the unchanged code over and over again for ...