php

How to stop BB Code manipulation (part two)?

I recently discovered an issue where people using BB Code to enter links are able to manipulate them. They are meant to enter something like: [LINK=http://www.domain.com]example text[/LINK] However they can enter something like this to make the link color red: [LINK=http://www.domain.com 'span style="color:red;"']example text[/L...

Multiple returns from function

Is it possible to have a function with 2 returns like this: function test($testvar) { // do something return $var1; return $var2; } If so, how would I be able to get each return separately? ...

Is there any PHP (or similar) version of Google Caja that can be practically run from a shared host environment?

Hi folks, I'd love to use Google Caja to run user-submitted Javascript 'live demos' in a sandboxed, safe environment, however I see it's Java-based and really have no idea how I'd practically set this up on a shared host (specifically, MediaTemple's (gs)). On (gs) I have access to SSH and can install things via command line but it is ob...

Programming language for simple dynamic web site development?

I only know the basics of HTML/CSS. The only experience with web development I have is whatever I learned in Web Development 101 at my university, aka "OMG - CSS u guise, 101". I'm mainly interested in building simple dynamic sites. That's the whole reason I got into this in the first place. I'm at the point now where I realize that it...

number_format doesn't return the same thing on different server

I tried to run the following code on the php console of a development server and a production server, and got the expected ("10.01") results on both console. var_dump(number_format('10.005',2,'.','')); string(5) "10.01" But when I execute the application code that uses the number_format call on the production server, I got "10.00", wh...

getting a value from the array in php

when i say var_dump($this->variables['DEFAULTS_VALUES']); I get the Following array array(1) { ["ABE LOB RPT"]=> string(8) "BEST2" } how do i get the value ["ABE BBB CCC"] from this array when i say in this way $this->variables['DEFAULTS_VALUES'][0] It says UNDEFINED OFFSET: 0 .how do i get the value ["ABE BBB CCC"] from ...

php - if this OR this OR this == this

Hi All Quick PHP question - is there a simpler way to write the following query (to see if any of our three variables are equal to the same value): if ($firstvariable == 'ourvalue' OR $secondvariable == 'ourvalue' OR $thirdvariable == 'ourvalue') ...

Wordpress admin-ajax.php Failure

I have a couple AJAX requests being used in a theme options page. Both worked just fine before, but now the first works and the second fails every time - the failure looks like this in Firebug: http://cl.ly/1w5u and this is in Webkit: cl.ly/1wYn. I'm not getting ANY response of any kind. The thing is, the first one works just fine. Here...

Would you recommend learning Zend framework from a freelance perspective?

I'd like to know what you think. Is it worth it to become proficient with Zend or adapt it as my common solution? Do you find it widely supported enough to build applications with which you can mass distribute? Any input would be great. I am not looking at this from a career perspective, more a business perspective as a freelancer, or...

convert plain text URLs to HTML hyperlinks in PHP

Is there anyway to convert plain text URLs to HTML hyperlinks in PHP? I need to convert URLs of following type: http://example.com http://example.org http://example.gov/ http://example.com?q=sometext&opt=thisandthat http://example.com#path http://example.com?q=querypath#path http://example.com/somepath/index.html https://example.co...

AS3 is not running my PHP script

So I am writing this action script program that will call a php file which will return the filenames inside a folder. My PHP file looks like this <?php $dirname = "thumbs"; $ret =array(); if($dir = opendir($dirname)){ $i=0; while($file = readdir($dir)){ if($file != '.' && $file != '..'){ ...

Reorder the results of a mySQL query using PHP without performing another query

I don't know if this is possible. I display a table of results and want to be able to order the table by any of the columns. I don't need help making such a table; I just need information about reordering the results of a query without repeating it with a different ORDER BY instruction. ...

Function file with 2,000 rows adding to each page. Is it ok?

I have PHP function file with ~2,000 rows and I always include it for each page. Do those many rows make my site slower? Should I separate function file to different files? Thank you. ...

When is it best to use a switch statement in PHP?

In what circumstances should I be using a switch statement rather than if statements in PHP? ...

Terms by vocabulary in node.tpl

I've created a variable in template.php that let's me print terms by vocabulary. The problem is that I want to be able to pass in a vocabulary id to select a specific vocabulary. My code looks like this: function xnalaraart_classic_print_terms($node, $vocabularies){ foreach($vocabularies as $vocabulary){ if($terms = taxonomy...

Accepted Common Pattern for Throttling Login (or other) Requests in a PHP MVC Application

Is there a commonly accepted pattern (or class library, or etc.) for throttling certain form submissions for PHP MVC applications? I'm specifically thinking of the scenario where someone is running a dictionary attack against one of your login forms, and you want to block them after X requests in Y seconds, or if a certain pattern of re...

Community PHP Security Project Effort

Hi guys, I've been looking into PHP security for over a month, after all the posts, tutorials, comments, replies to comments, making fun of comments, and then some more comments, I'm left pulling out my hair, while I admit I have really thick hair at this rate I'll be bald in no time. It seems that there is NO GOOD GUIDE to security, pl...

Where should I place text that I'm trying to abstract in my CakePHP application?

I am writing a CakePHP application and am trying to have text that is frequently displayed (or particularly long) saved in a config file somewhere that we can easily edit it. Where should i put this file and how do I access it? I am also worried about the tradeoff in speed of reading this file when we need to display text, as well as loc...

xslt regular expressions to match xml entries and display

I know it is so simple to some of you. All I want to do is look through an xml doc and print out the xml entries that contain specific string fragments. The string value is passed to the xslt and the xml doc is looked at and if a word begins with the string expression it displays it. What I have errors with the following message... ...

iPhone web app, not storing cookie

Hi Guys, I am working on a web app for the iOS. When the app is opened, it check's to see if the user has a cookie with the users email stored in it, then either lets the user proceed to the homepage, or redirects the user to the authentication page. This works perfectly when using safari. The problem I am experiencing occurs only whe...