Posts Tagged ‘php’

Joomla Jobline Component Strip Slashes

Thursday, May 1st, 2008

If you have magic_quotes_gpc set to on in php and would like to keep it on but jobline is not removing the slashes on display or edit in the backend then edit the following files to fix it.

Click to continue reading “Joomla Jobline Component Strip Slashes”

Turning off PHP safe mode with Plesk

Sunday, April 20th, 2008

While working on an application that creates it’s own directories on the fly and then inserts images in them I came across some safe mode errors. Basically what they were is that I was creating a folder with the script which would then set the user to be ‘apache’ and then when the script went to write in it again and it didn’t actually own that folder, apache did.

I found some other more complicated solutions on the net where you have to edit the php.ini file and one where you edit the vhosts file. I figured there had to be a way to do it through Plesk and I finally found it so I figured I would share it so that no one else has to deal with it.

This is what the error looks like:

Warning: mkdir() [function.mkdir]: SAFE MODE Restriction in effect. The script whose uid is 10004 is not allowed to access /var/www/vhosts/xxx/xxx/xxxx owned by uid 48 in /var/www/vhosts/xxx/xxx/xxx/upload.php on line 98

So go into plesk and follow these steps…

  • Click Domains over on the left
  • Choose the domain you are wanting to disable safe mode on
  • Under the hosting section choose setup
  • Scroll down and under services find the one that says ‘PHP support’
  • Leave that box checked but uncheck the one to the right of it that says ‘(PHP ’safe_mode’ on )’
  • Click ok and you are done.

Hope this helps.

PHP to Ruby on Rails Translations

Sunday, April 20th, 2008

I used to develop primarily in PHP and dabbled into ASP but then I learned about Ruby and the Rails framework and now I cringe when I need to develop something new that isn’t in Ruby. There are a ton of tutorials on Rails so if you aren’t familiar or want to learn just do some googling. My intention with this post is to compare the differences in chunks of common code between php and ruby. Items such as for loops, array manipulation in ruby, various string functions in ruby and php, etc. I obviously won’t write everything so if you think of something that would be handy to know then leave a comment with it in there. Yes I realize PHP has frameworks that add some of the handy features that Rails.

Create Array:

Ruby: myArray = ["dog","cat","mouse"]

PHP: $myArray = array(”dog”,”cat”,”mouse”)

*With Ruby there’s no need to specify that it’s an array, it knows from the brackets. Also notice that PHP uses parentheses and Ruby uses brackets.

Using element of array by position

Ruby: myArray[1] = “cat”

PHP: $myArray(1) = “cat”

First Elements:

Ruby: myArray.first = “dog”

PHP: first($myArray) = “dog”

Ruby: myArray.first(2) = ["dog","cat"]

PHP: for ($i=0; $i < 1; $i++ ){$first2elements .= myArray($i);} * If there is a better way to do this in PHP let me know if it doesn’t involved a loop.

Print out elements of Array

Ruby: myArray.inspect

PHP: printr($myArray)

Comments

Ruby: # COMMENT

*Ruby doesn’t have multiline comments at the moment, just get a good editor that has a shortcut for it such as Textmate or Aptana.

PHP: // SINGLE LINE COMMENT

/* MULTILINE COMMENT */

Click to continue reading “PHP to Ruby on Rails Translations”