php

Maybe a dumb question on timezones

Hello all, I have confused myself to a point where I need to double check this with you all. Sorry if this is really a dumb question.. Okay - I have a PHP web application running on Linux that needs to support timezones. I provide a calendar widget that allows the user to set their timezone then select the date and hours/minutes for so...

MVC as best practice for professional level programming?

Long time lurker, first time poster... I'm now at the point where I'd almost call myself a professional grade PHP programmer and have a lot of code I re-use in various projects. Also, a lot of Open Source packages I've worked with use the MVC model and as a result I've done a lot of research recently into how it all works so I can bette...

Error when merging two XML documents using XPath & DOMDocument ...

Hi, everyone. About a year ago I wrote a jQuery-inspired library which allowed you to manipulate the DOM using PHP's XPath and DOMDocument. I recently wanted to clean it up and post it as an open source project. I've been spending the past few days making improvements and implementing some more of PHP's native OO features. Anyhow, I th...

How do I add "friends" function in PHP?

Hello stack overflow I need help with this problem. Ok, I have a flat file database in php it records users , hobbies, fav movies and all. Now i want to add a buddy system so they can have friends and send messages to each other in php without SQL. ...

is there a ceil() alternative to turn 6523.70 to 6523 and not turn 6523.20

Hi, the function of ceil() in php is not useful in my case, because i want if the number contains from 0.50 to 0.99 then it's will ceil it, if it's smaller than 0.50 it's will not do anything. example: 6523.70 will be 6524 but 6523.49 will stay same. i hope you got it guys :) Thanks ...

How to do something if sentence include one of the words in this array ?

Hello, I want to do something if my sentence include one of the words in this array, How to do that ? $sentence = "I dont give a badwordtwo"; $values = array("badwordone","badwordtwo","badwordthree","badwordfour"); Thanks... ...

Sorting by date in reviews

In many reviews, there's usually a feature to sort by date, helpfulness, etc... Essentially these work by querying a new MySQL line right? For example: $sql = "SELECT * FROM TABLE ORDER BY TimeAdded" $sql = "SELECT * FROM TABLE ORDER BY Helpfulness" Or would there be a better way to do it? Secondly, making pages for reviews. Is it a...

Assigning specific menu administration rights for roles in drupal

Hello folks. I'm trying to give one of my roles the administrative rights to add/remove content in a specific menu (but not all menus). I think I found a module that should enable something like this, http://drupalmodules.com/module/delegate-menu-administration I've followed the instructions, added the role to my user, checked the "adm...

PHP round math question?

What will the code below be if value is 2 and counter is 11? What would $rating be? $rating = (@round($rs[value] / $rs[counter],1)) * 10; The complete code is below. function getRating(){ $sql= "select * from vote"; $result=@mysql_query($sql); $rs=@mysql_fetch_array($result); $rating = (@round($rs[value] / $rs[counte...

Unix permissions, read vs. execute (PHP context)

I have a php script which needs to connect to a database. The credentials for the database are stored in another php script. If I set the permissions for the credentials file to 661 so that Public has execute permission but not read permission, does this allow the main script to access the credentials and connect to the DB while prevent...

Lucene with PHP

Can I use Lucene with PHP ? I don't want to use Zend. Can I use in native PHP (not framework) ? ...

Why does the following PHP code fail?

define('test',2); if(isset(test))echo 'hi'; ...

How to group symbols for "not in range" expression in PHP?

How to group symbols for "not in range" expression in PHP? <li class="first">list item 1</li> <li class="second">list item 2</li> <li class="third">list item 3</li> <li class="fourth">list item 4</li> ... I'd like to cath all li elements except one with class="second" This does not work: /(<li[^(class="second")]+</li>)/xsU ...

Strategy for storing and displaying form dropdown data for provinces, states, prefixes?

I'm currently migrating from a class that stores lists of countries, states & provinces in the form of arrays to using Zend's Locale data in the form of ldml xml files. These ldml files provide localised lists of countries, currencies, languages - so I'm not exactly sure where I should store US States, ( Canadian Provinces ), Prefixes - ...

Symfony is-a database schema

Hey, So I am new to symfony and am trying to make a is-a relationship between several tables. I have a media table that has a id field that is the primary key. I then except to have 2 or more additional tables that are "subclasses" of this table such as an article or event table. These are subclasses of the media table and I put a media...

Image processing and output using GD in php

I want to control the display of images with the PHP GD library -- I am going to add some text to the bottom corner of it on the fly when a browser requests the image, rather than saving the text into the image. I know that I can do this: set the MIME type in the header and then call imagepng(...) with the filename to just display the i...

PHP - Blocking of uploaded adult images

We have a setup a product management system where the head of the product development can upload pictures of products and those pictures will instantly show up on our website. Last week, when one person left the job, he uploaded a bunch of XXX-Rated pictures and things showed up immediately on the website. Luckily, we noticed and remove...

How to remove <br> within a <textarea></textarea> only

Hi, I have some articles stored in a text field in my database. There are times when the article includes <textarea>content.....</textarea> The problem is that when the content is displayed on a page using php, it includes the actual <br><br><br>. The <br> is placed there by the text editor (CKEditor) So it looks like the following <...

Performance wise String Matching

I've a generic DB query function that runs the following checks every time an SQL query is issued: if (preg_match('~^(?:UPDATE|DELETE)~i', $query) === 1) if (preg_match('~^(?:UPDATE|DELETE)~iS', $query) === 1) if ((stripos($query, 'UPDATE') === 0) || (stripos($query, 'DELETE') === 0)) I know that a simple strpos() call is way faster ...

List all methods of a given class, excluding parent class's methods in PHP

I'm building a unit testing framework for PHP and I was curious if there is a way to get a list of an objects methods which excludes the parent class's methods. So given this: class Foo { public function doSomethingFooey() { echo 'HELLO THERE!'; } } class Bar extends Foo { public function goToTheBar() { ...