php

working with user input data in php. What's better?

Hello, I am trying to figure out what is the best way to manage the data a user inputs concerning non desirable tags he might insert: strip_tags() - the tags are removed and they are not inserted in the database the tags are inserted in the database, but when reading that field and displaying it to the user we would use htmlspecialcha...

Find out the time between two timeslots?

I have two times start_time=2009-12-01 9.30 pm and end_time=2009-12-01 11.30 pm(YYYY-MM-DD).If the user do any activity between these times ie at 2009-12-01 10.30 pm I need to tell him you are not valid to do this activity... The two times 2009-12-01 9.30 pm and 2009-12-01 11.30 pm is taken from database.The time 2009-12-01 10.30 is giv...

uploading music to server

been trying to upload music onto a server for my website, to no avail, but strangely enough the script works fine when uploading pictures. if(copy($_FILES['musicFile1']['tmp_name'],"uploads/".$_SESSION['username']."/item".$s_id."/".$filename1."")) { if(chmod("uploads/".$_SESSION['username']."/item".$s_id."/".$filename1."", 0664...

Creating a simple custom view in SugarCRM

Hey! I am trying to use the MVC architecture of sugarcrm to add a new action and with that a new view. I have managed to create a controller with the action and also a class view, the only thing I can't figure out is how to create a simple html page. Do I really have to use the metada way of sugarcrm?? I just want a simple form with ...

PHP - complete url parser help

I have been trying to find an effective url parser, php's own does not include subdomain or extension. On php.net a number of users had contributed and made this: function parseUrl($url) { $r = "^(?:(?P<scheme>\w+)://)?"; $r .= "(?:(?P<login>\w+):(?P<pass>\w+)@)?"; $r .= "(?P<host>(?:(?P<subdomain>[-\w\.]+)\.)?" . "(?P<doma...

Underscore in php function

What does it mean when a PHP function name begins with an underscore? for example: __construct() I know what the construct means but I've seen other places where the function begins with an underscore, or a double underscore and I'm just not sure of the significance. ...

Monitoring apache's load with php

UPDATE: thanks to all the answer given, but they are all about the system load, and not the apache. My goal is to understand, inside my php scripts (the templating ones), when apache have an high load and is prefearrable to fork some traffic on lighttpd, that is here just to the long-polling and to light the apache's load. Hi guys, aft...

Where is APC dll for PHP Version 5.2.11 (on Windows)?

Trying to locate the correct APC DLL for my windows machine. All I have tried so far, causes Apache to crash. Short of compiling from the sources (which I dont really want to do), I seem to have come to a dead end. Details are: OS: XP PHP: php-5.2.11-win32-vc6 ...

how to extract data from a raw html file

Is there a way to extract desired data from a raw html which has been written unsemantically with no IDs and classes? I mean, suppose there is a saved html file of a webpage(profile) and I want to extract the data like (say)'hobbies'. Is it possible to do this using PHP? ...

Kohana 3: using maintainable routes

I'm using Kohana v3 for a web project, and today I found myself writing this: echo Html::anchor('user/view/'.$user->id, "See user's profile"); If I rename the action_view method in the User controller, the link will be broken. To avoid this, I created a function in the User model that returns the URL used for viewing the user's profil...

Infrastructure for Running your Zend Queue Receiver

I have a simple messaging queue setup and running using the Zend_Queue object heirarchy. I'm using a Zend_Queue_Adapter_Db back-end. I'm interested in using this as a job queue, to schedule things for processing at a later time. They're jobs that don't need to happen immediately, but should happen sooner rather than later. Is there a...

Zend Framework: Controller class == Page?

Am I right in thinking that in Zend Framework, if I plan to have 5 pages at my site, I'd generally need 5 controllers? Do ZF developers typically create 1 controller per page ("page" as abtract app unit)? The reason I am asking this is that previously for some reason I stuffed a lot of various actions into controllers so that they playe...

how can i controll while loop into another while loop

Suppose I have a while loop like: $sql = mysql_query("SELECT * FROM tablename"); while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $sql_2 = mysql_query("SELECT * FROM secondtable WHERE id != $id "); while($ro = mysql_fetch_array($sql_2)){ $id2 = $ro["id2"]; echo $id2; } } then if first query return 5 results i....

What does "Automatic cleaning is not available/necessary with this backend" mean? (for memcache )

I have installed the memcache in my php zend code. it seems no error. but there is a warning in the log saying Zend_Cache_Core::save() / automatic cleaning is not available/necessary with this backend. what does it really mean? ...

MySQL: SELECT statement with Chinese and Japanese characters (empty result?)

I'm trying to query my database to get some results in Chinese and Japanese languages as follows: $str = '日本'; $get_character = mysql_fetch_array (mysql_query("SELECT id FROM `mytable` WHERE ch = '$str'")); print $get_character[0]; The problem is it returns me nothing. For testing purpose I've changed 日本 in database to test and I do ...

Why doesn't my <script> tag work from php file? (jQuery involved here too)

<!-- According to Meta-SO, editing is a way to politely bump, so I am trying this one more time to see if anyone has any more info. Thanks --> UPDATE: Still haven't solved this issue: Hello again: I have worked away at this issue, and still no luck. I am going to try and clarify what I am doing, and maybe that will bring something to...

How do i use a standard Query String + a Rewriter Route in Zend Framework

I have ZF app that is utilizing a legacy Javascript at for some functionality. In order for this app to work i need to pass it a standard query string. So how can i use a standard Zend Route with a query string on it? for example: domain.com/my/routing/rule?legacyparm1=value&legacyparam2=value It is not possible at this time to rewrit...

How to make php application to require smart card authentication.

I can make browser to force authentication with smart card eg ID-card when php file is protected with SSLVerifyClient in apache conf. Now i need to display index.php usually without requiring smart card authentication and sometimes this same page must get user authenticated. doStuff(); if ($needed==1) authenticateUser(); doMoreStuff...

Dynamically create PHPUnit tests from data-file

I have a data file with input and expected outputs. An example could be: input: output: 2 3 3 5 4 Exception 5 8 ... ... Currently I have a custom solution to read from the data file and perform a test for each {input,output} pair. I would like to convert this into a PHPUnit based solution and I would...

phpInfo: What does "Virtual Server" refer to?

I noticed that in phpinfo under "apache2handler", it says: Virtual Server Yes What does that refer to? Does that mean that apache is on a virtual (i.e. not dedicated) host? What would be a case when it would say: Virtual Server No ? Thanks for any help with this. ...