php

Object Oriented Design issue

Hey, I have been designing a site locally in PHP 5, but have come across a few design issues I'd like advice now. Currently there are three features of the site and each feature has a class . These features are as follows : a blog a friends list a set of images I have a class for each but in each class I basically define a similar...

ReSharper-like addon for NetBeans

Hello, is there any ReSharper-like addon for NetBeans (preferably 6.8)? I'm using NetBeans for PHP. I need following features: add some kind of code analysis add some intelligent refactoring interface enhance current code completion system add more options to code highlighting Currently I'm using multiple external tools, which aren...

PHP - count my quantity item in session array

How to count the item-qty and current code :- $q = $_POST['item-qty']; $i = count($q); $k = 0; while ($k < $i) { $select = 'SELECT * FROM location'; $query = $db->rq($select); $price = $db->fetch($query); if ($_POST['item-qty'][$k] < 3) { $get = $price['normal_price']; $price = $get * $_POST['item-qty'][$k]; ...

determine if a string contains one of a set of words in an array

I need a simple word filter that will kill a script if it detects a filtered word in a string. say my words are as below $showstopper = array(badword1, badword2, badword3, badword4); $yourmouth = "im gonna badword3 you up"; if(something($yourmouth, $showstopper)){ //stop the show } ...

PHP 301 Redirect Idea

I posted this earlier http://stackoverflow.com/questions/1915824/301-redirect-of-static-html-to-dynamic-php-page But have a new idea, and am wondering if there are any issues why I should NOT do this... If someone tries to go to a dead page on our site like: (domain)/somepage.html That now exists here: (domain)/dynamic.php?id=1 It...

VIM: How to select entire function definition in php

In php, if I have a function such as: function test($b) { var $a = 0; while ($a < b) { $a += 3; } return $a; } If the cursor is on the $a += 3 line, is it possible to quickly select the entire function? "v2aB" would select everything including the function braces but not the declaration "function test($b) " ...

How do I preg_match for words in Hebrew.

Hey, I need a function that matches full words in hebrew in php. Please help. ...

PHP CURL: Manually setting the content-length header

Say I upload a file with PHP, CURL: $postData = array(); $postData['file_name'] = "test.txt"; $postData['submit'] = "UPLOAD"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData ); Now assume I have to...

What is the best practice to pass many server side information to JavaScript?

Let say that I have many Javascript inside pages. At this moment is pretty easy to initialize variable by simply using some Print/Echo statement to initialize JavaScript value. Example: var x = <?php echo('This is a value');?> I first thought that I could pass all variables value by parameter of function BUT it's impossible because we...

php preg_match tab separated

I need a regular expression to look for the first N chars on an array until a tab or comma separation is found. array look like: array ( 0 => '001,Foo,Bar', 1 => '0003,Foo,Bar', 2 => '3000,Foo,Bar', 3 => '3333433,Foo,Bar', ) I'm looking for the first N chars, so for instance, pattern to search is 0003, get array index 1... ...

If statement question in php

I have an if statement that needs to check if a series of items exist AND if any other items exist. So for example foreach($id_cart as $id) { if(($id == 4 || $id == 5) && **IF ANY OTHER ITEM EXISTS**){ echo "Yes"; } Is there a simple way of doing that? An item exists or it does not. $id_cart will have, let's say, ids: 4,5,6,8,12...

Are Ioncube encoded files decodable by any chance?

hi, I am a php developer, my client planning to distribute a software which is developed using Php. Planning to encode the files using ioncube or similar software. While googling i came to know few people decoded the files, which enocoded using ioncube and even other softwares. please help me. ...

How to query full page from a phpbb forum?

I want to write an app that parse particular threas on a phpbb forum. So if a thread has 200 pages with 10 posts (that doesn't give you the ability to adjust the post count per page), and has an address like this: http://www.forum.com/viewtopic.php?t=10&amp;postdays=0&amp;postorder=asc&amp;start=0 where start parameter changes when yo...

Grouped Routes in Symfony

I'm starting a new project - my first with Symfony - and I'm trying to figure out how to construct a route that incorporates information about an associated object. The documentation that I can find is light, to say the least, and I'm struggling. I'm using v1.4.1 w/ Propel (backwards compatibility with some existing stuff) and have: A n...

Is there a way to create different sub/forms using Zend_Form and bring them all together into 1 form?

I'm trying to create 1 base form in Zend which is a part of many other forms. Eg: the following 3 elements could be a sub form or a mini form that is a part of a larger form : -Name -Age -Address I just want to re-use the same form in different places - at times adding elements like 'shipping address' etc I'm getting stuck at the data s...

Developing a secure PHP login and authentication strategy

Hi, I'm developing a login and authentication system for a new PHP site and have been reading up on the various attacks and vulnerabilities. However, it's a bit confusing, so I want to check that my approach makes sense. I plan on storing the following data: In the session: user-id, hashed + salted HTTP_USER_AGENT In the cookie and i...

Why having both str_replace() and preg_replace()?

I came to know PHP after Perl, so when I first found preg_* function I basically just used those. Later I read that str_replace() is faster when dealing with literal text. So my question is, can't preg_replace() be as efficient as str_replace() when the search pattern does not use special characters? Maybe just analyzing the pattern to c...

PHP - Eliminate results from an XML result set

I think this might be more accurately called "paging"... not sure. I am getting a chunk of XML (lets say 100 nodes) I then want to display only a set number of them at a time on a page. How do you do this? For reference, in .NET it would be something like this: // Get some results. These are an XPathExpression XPathNodeIterator...

Help me parse this file with PHP

Fri Nov 27 10:00:01 EST 2009 974 12506 Fri Nov 27 11:00:01 EST 2009 988 12655 Fri Nov 27 12:00:01 EST 2009 1005 12886 Fri Nov 27 13:00:01 EST 2009 1026 13115 Fri Nov 27 14:00:01 EST 2009 1042 13429 I tried to explode on \n and then \t, but it looks like there are ...

How to get the value after the hash in "somepage.php#name"?

Hi guys, I need experts to help me solve this problem. Let me explain: For a given url, I want to get the name-after-hash's age from the database. so for url like thepage.php#Madonna, you'll see "119!". How can I extract the value after the hash in a url? (i need a safe all-browser-compatible-NON-JAVASCRIPT way). I want to do that lik...