php

Is this a good way to catch bots?

Is this method sufficient? <?php // User pressed "Register" if (!empty($_POST['name']) && $_POST['email']) { if (!empty($_POST['antispam'])) exit("bye"); } ?> <form> <input type="hidden" name="antispam" value="" /> Accname: <input type="text" name="name" value="" /> Email: <input type="text" name="email" value="...

Separating output by line alphabetically

I have the code below that outputs the names of files in a directory. I'd like to separate the file names alphabetically by an additional line space when the first letter of the file changes (say from A to B). Any ideas? Thanks. $dirs = scandir("Dir"); foreach($dirs as $file) { if...

Web service vs Socket connection

To create a client-server GAME applications in Flash, which would be more practical to use and faster in terms of client-server data exchange: a. web services (flash / flex the client and PHP the server) or b. socket connection (flash / flex the client and C / C + + the server) Any help is welcome. Thanks. ...

mysql - get results at mysql prompt, but not through script?

I'm using php to fetch some records from my db and it keeps returning "No results found". But, when I print the query to the screen and copy and paste it at the mysql prompt, I get 1 row. Granted, it's a monster query, but shouldn't I get the same results? What causes that to happen? Any suggestions on what to check? Don't know if...

Doctrine - How to print out the real sql, not just the prepared statment?

We're using Doctrine, a PHP ORM. I am creating a query like this: $q = Doctrine_Query::create()->select('id')->from('MyTable'); and then in the function I'm adding in various where clauses and things as appropriate, like this $q->where('normalisedname = ? OR name = ?', array($string, $originalString)); Later on, before execute()-in...

PHP/WordPress Session CountDown

I have the following code to show how long a user has left before their session will expire, I am using WordPress. How can I do this? Thanks <script> var obj_Span; var n_Seconds = 0; var n_Minutes = 0; var n_Hours = 0; function F_ConvertNumberToString ( n_Num ) { var str_Num = String(n_Num); ...

Are there any issues with using static keyword in a plain php function?

For example: <?php function get_current_user_id(){ static $id; if(!$id){ $id = 5; echo "Id set."; } return $id; } $id = get_current_user_id(); $id2 = get_current_user_id(); $id3 = get_current_user_id(); echo "IDs: ".$id." ".$id2." ".$id3; ?> //Output: Id set.ID...

How to check uniqueness of many-to-many collection?

Here's the desired flow of my PHP app (yes, it's vague, but it's easier that way): User submits a set of, let's say, about 5 objects by integer IDs. (It'll really be more like 15, but let's say 5 for ease.) App checks if this collection has been submitted before, and saves it in a MySQL database if not App saves these objects in the da...

why is php's ini_set function switched off on shared hosts

I am using hosting on VPS and they've not allowed me to use php's ini_set function to set configuration at runtime, on a script by script basis. Instead I must change the settings directly in the php.ini file which is a mission to access via SSH. Why is this? This, although fine, is slightly annoying as I have 12 domains on the shared...

Website Filter using PHP and MySQL Query

Ok, so on my site we have a filter section where a user can select to filter through games by either the game's genre or the model that the game will play on. I'm trying to write a query that will query the database and filter it by genre if genre is the only set item, filter it by model if model is the only set item, or filter both if ...

A PHP web developer comfortable with C# .NET wants to learn ASP.NET but confused with ASP.NET MVC & Webforms

I'm a decent level PHP web programmer with enough real world experience. I'm also a decent level C#.NET developer. So, I don't want to learn the basics of web development. I also don't have to learn C#. Now I want to start with ASP.NET. I don't know even a,b,c's of ASP.NET. I mean don't even know things like what do I need to setup for ...

(syntax trees) recursively iterating over trees bottom-up with current top-down path

Hi I have an abstract syntax tree which I need to iterate. The AST is generated by the lemon port to PHP. Now "normally", I'd do it with the brand new and shiny (PHP 5.3.1) SPL classes, and it would look like this: $it = new \RecursiveIteratorIterator( new \RecursiveArrayIterator($ast['rule']), \RecursiveIteratorIterator::SELF_FI...

php convert datetime to UTC

I am in need of an easy way to convert a date time stamp to UTC (from whatever timezone the server is in) HOPEFULLY without using any libraries. ...

PHP: Regular expression problem too much for my small brain

Hi All, I have been trying to solve a PHP regular expression problem for awhile now but I just can't quite get it done. I need write a regex that will match between 7 and 12 digits (0..9) and there may optionally be either a single hyphen or a single space between adjacent digits. This is what I have so far... $match1 = preg_match('/...

Easiest way to set a PHP CONSTANT in 1 file and access it everywhere?

I have asked similar questions before but here is a full demo example code. In PHP how can I access a Constant value that is set in a config file and then included into every page, Including CLASS FILES? I realize this is some sort of scope issue so what is the best way to access this constant inside my class file below without passi...

space in php mail

mail($email, $subject, "Welcome to **!\n\n The password for your account is:\n $password", $headers); I want the $password to be 2 spaces forward, what should i use? &nbsp; doesnt not work in hotmail at least ...

Is it possible to extract Meta information from MS office files and/or PDFs with PHP?

So I have files.... .doc .docx .xls .xlsx and .pdf that are on the my server. Is it possible (and if it is, how) to extract the meta data from those files using PHP? I'm looking for things like Author, keywords, title, etc... In office documents it's the information stored along with the document properties (File...Properties...Su...

How best to control (issue command signals to) a PHP-based Daemon script?

I've created a PHP Daemon script to continually monitor a particular directory on the server's file system for new files, and then process and archive them. Note: I'm using a php Daemon class provided at: http://www.phpclasses.org/browse/file/8958.html I've got the script running, but I need a way to interface with the daemon and issue...

What methods exist for setting up a large email notification system?

My company has a website built with PHP. We use the built-in PHP email functionality to send thousands of emails to subscribers on a daily basis. This is a terrible idea. It chokes out our server, and takes hours to complete the whole batch. Now I've looked at mass mailing services like MailChimp (which would replace our current system...

What permissions for PHP scripts/directories?

Hi, I am trying to help a friend moving a web-site from one web-hotel to another. The old place is already closed, I have only a flat tar file of what was in it. I apologise if this is a basic question. I am new to this... The web site contained html docs and one could download a little java application (to be loaded on mobile phone) ...