php

Java Servlet Filter Equivalent in Ruby [on Rails] and PHP ?

Not sure if the terminology is correct, but are there rough equivalents to Java Servlet Filters in Ruby and PHP ? Are they actual concrete classes ? I assume there is also a number of common web app libraries/frameworks in Python. Is there an equivalent there ? Thanks. === ADDENDUM === On the good advice of Kevin Davis, I just want t...

HTML special code to ASCII

Hey, is there any built in functions or something like that in php that will allow me to turn HTML special code like: <(;), >(;), Á(;) and ©(;) etc... into <, >, Á and © Lets say I have the value: $fileName = "Gibt es eine schö(;)ne Offroadstrecke? (;)"; And I want this: $fileName = "Gibt es eine schöne Offroadstrecke? "; Any eas...

PHP: Apply a function to multiple variables without using an array.

I have a function (for ease, I'll just use count()) that I want to apply to maybe 4-5 different variables. Right now, I am doing this: $a = count($a); $b = count($b); $c = count($c); $d = count($d); Is there a better way? I know arrays can use the array_map function, but I want the values to remain as separate values, instead of value...

Why doesn't StackOverflow.com let me login with an OpenID delegate with a defined XRDS location?

My personal site defines my OpenID delegate in the HEAD like so: <meta content="http://claimid.com/nicksergeant/xrds" http-equiv="x-xrds-location" /> <link rel="openid.server" href="http://openid.claimid.com/server" /> <link rel="openid.delegate" href="http://openid.claimid.com/nicksergeant" /> The XRDS location definition is required...

How do you convert a page-based PHP application to MVC?

Hello Everyone, I've been struggling for some time now with exactly how to recode a page-based php application I have to an MVC framework. (Just for background, I am having to move the app into MVC because my boss is making me :) Anyway, I've sat down and printed out the directory structure and started trying to plan how I can convert...

Capturing file output in PHP (fputcsv)

I'm attempting to capture the output of fputcsv() in order to use gzwrite() to actually write to a tab-delimited file. Basically, I'm querying a database and I want to put these rows into a gzipped CSV file and I'd rather use fputcsv() than actually append "\t" and "\n" everywhere. Can I somehow do this with output buffering or somethi...

HTTP_REFERER substitute that IE 6 will provide?

So IE (6, at least) won't help me with $_SERVER["HTTP_REFERER"] that I request with PHP. But I'm new to Javascript and have just used a little routine in a pop-up to refresh the page from which the popup was called (i.e. parent). Works beautifully in FireFox, Safari, etc. There's NO security issue - I'd just like to the user loaded ...

Best way to test for a variable's existence in PHP; isset() is clearly broken

From the isset() docs: isset() will return FALSE if testing a variable that has been set to NULL. Basically, isset() doesn't check for whether the variable is set at all, but whether it's set to anything but NULL. Given that, what's the best way to actually check for the existence of a variable? I tried something like: if(isset($v)...

MySql and inserting data in a link table, how to?

What is the trick in MySql (Version 4) to write from PHP thtree Inserts and to be sure that we can link tables properly. [Table1]-[LinkTable]-[Table2] In the PHP code I create an Insert that add 1 row in table 1 and an other Insert that add an other row in table 2. I get both rows PK (primary key) with two SELECTs that return me the l...

Why does the CakePHP Authorization Componentent automatically logout when openeing two sites in parallel?

Hi, i have a problem within my CakePHP application: I use the Authorization Component for the login/logout mechanisms. Unfortunately users are logged out automatically when they try to open two or more php pages at the same moment. Thats happening very often because we tend to use the middle mouse button to open many tabs in short inter...

What's wrong with my MySQL query?

I'm not getting any errors as such just a minor performance issue. EXPLAIN SELECT a.nid, a.title, a.uid, b.parent, b.weight, c.name, d.value FROM table1 AS a INNER JOIN table2 AS b ON a.vid = b.vid AND a.status = 1 INNER JOIN table3 AS c ON c.uid = a.uid INNER JOIN table4 AS d ON d.content_id = a.nid AND d.value_type = 'percent' AND d.f...

Java and .net for PHP programmer

Hey! I have been programming with php for a few years. I do like php and hope to keep working with it for a few more years, but I see that my company is going into the java world. Can anyone recommend any good books, tutorials, podcast´s, whatever that will help me learn java? Something basic and intermediate would be nice. Also if ther...

Setting iso-8859-1 instead of utf-8 in oscommerce / sts template website ?

In an oscommerce site I have the following: Server response = Content-type: text/html;charset=UTF-8 and I want: Content-type: text/html;charset=ISO-8859-1 How and where do I set this up. Html looks like this on the page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html dir="LTR" lang="nl"> <head> <meta ht...

PHP's create_function() versus just using eval()

In PHP you have the create_function() function which creates a unique named lambda function like this: $myFunction = create_function('$foo', 'return $foo;'); $myFunction('bar'); //Returns bar Is this actually any better (apart from being more easy) then just doing: do{ $myFunction = 'createdFunction_'.rand(); } while(function_exist...

Why CakePHP doesn't support a foreign key with multiple columns

I searched in google for this without a good result. The only topic I found in the cakephp trac, was closed without a "real" explanation. Since CakePhp is like one of the rails ports for php and rails does support this. I would like to know why wont be sopport to this feature. ...

How to get javascript function data into Php variable

Dear all I am using PHP and Javascript, My Javascript conatains function get_data() function get_Data(){ var name; var job; ..... return buffer; } Now I have PHP with following <?php $i=0; $buffer_data; /*here I need to get the Value from Javascript get_data() of buff...

Make submit work by pressing enter on PHP and Javascript login page

I'm pretty new to Javascript and I'm sure this is an easy fix, but I can't figure it out. I'm using a slightly modified version of the code from this page and I want to make the form work by entering the information and pressing enter rather than having to click the button. FYI I've read this thread and can't work out my own answer f...

PHP classes: Need help to inherit two classes

I need help in designing my PHP classes where I need to extend from multiple classes. I have a general class, Pagination.php that does all sort of pagination and sorting. All other classes will use this for pagination. To make my life easier, I made a class generator that generates a class from MySQL table. All the properties, getters,...

Do you consider foreach((array)$foo as $bar) a code smell?

Do you consider this a code smell? foreach((array)$foo as $bar) { $bar->doStuff(); } Should i use that instead? if (isset($foo) && is_array($foo)) { foreach($foo as $bar) { $bar->doStuff(); } } Any other good practices to cover not set variables and assert an array? ...

PHP - securing parameters passed in the URL

Hi, I have an application which makes decisions based on part of URL: if ( isset($this->params['url']['url']) ) { $url = $this->params['url']['url']; $url = explode('/',$url); $id = $this->Provider->getProviderID($url[0]); $this->providerName = $url[0]; //set the provider name return $id; } This happens...