php

filter_var versus preg_match

Morning all I'm converting a site that I'm working on to be compliant with the latest version of PHP, so I'm going through and replacing all instances of ereg with their non-depreciated equivalent. However I was told about a handy built-in function with PHP called filter_var. What my question is, is would it make sense to go with filte...

isolating part of a url with php

Hi, I would like to isolate a certain part of a URL if the structure remains the same: ex. URL - http://www.URL.co.uk/87/318/carrot%5Fcake/ it is the 318 part of the example above, however the number can range between 1 - 999999 - but will always remain between 2 x '/' and to the left of the title (carrot_cake in the example) this is ...

Zend Framework router route regex to match regex controller question

I have a couple of controllers in Zend Framework that starts with p: /p-home/index /p-store/index /p-form/submit I need to write a router configuration file (using INI file) to automatically rewrite the url to other controllers that starts with s: /s-home/index /s-store/index /s-form/submit I have tried the following but doesn't work: ...

Caching data vs. writing in memory table

Which would be the best way to achieve a fast hash / session storage with one of these three ways? Way 1: Create a memory table in MySQL that stores a hash and a timestamp when the entry was created. A MySQL event automatically deletes all entries older than 20 minutes. This should be pretty fast because all data is stored in memory, bu...

Forum vB plugin not working

So I made a plugin/hook <?php ob_start(); include $_SERVER['DOCUMENT_ROOT'] . "/delta/pack_files/other/login.php"; $loginphpp = ob_get_contents(); ob_end_clean(); ?> I enabled hooks/plugins in the settings, and i set this plugin to be at global_start the folder directory is correct and I called this with $loginphpp, but nothing shows...

How to connect to multiple databases in a single PHP page?

Possible Duplicate: How do you connect to multiple MySQL databases on a single webpage? If I want to connect to one db do some query, and then later do another query from another DB. How do I do it? Do I just mysql_pconnect("host:3306", "user", "password") or die(mysql_error()); mysql_select_db("Test") or die(mysql_error());...

PHP - Mask polygon over image

Hi Everyone (this is my first post), I am trying to figure a way of cropping a polygon out of an image. I have been reading other similar code. It seems that most code is based around the following process: -Resize the image to fit the width and height of the polygon shape, -Create a blank image of an unusual colour the same size, -O...

Reading a CSV file in chunks

For a new import feature for my users, I'm using fgetcsv to read CSV files generated by social book cataloging sites like LibraryThing and Shelfari and then I run a series of Amazon queries to look up ISBNs from within the files. I want to be able to have users confirm the titles that match certain criteria, then add them to their local ...

JSON object max size?

Using jquery, I'm able to send json objects from client to server using ajax like this: var strJSON = '{"event":[{ "dates":[ "2009-10-14","2009-10-15"], "teams":[ {"id":"0","country":"USA","state":"CA","name":"California Polytechnic State University","subteam":""}, {"id":"1","country":"USA","state":"CA","n...

How to reset fckeditor with reset button in php or java script?

See the below Image. I have added a reset button at the end of form. When user press "reset" I can clear all inputs. But I don't know, how to clear this fckeditor values. Thanks in advance for helping me. Sagar. ...

What language to use - simple form + MySQL + admin page

Hi everyone, Apologies if this is not the right place to ask but here goes... What should I use to create a simple web application for our website? I'm the IT guy for a small non-profit. On our website we have a page with a large form in which users can fill out information on an application form. The information gets sent to a MySQL ...

pass all select values to php

i have one select box <select name="sub_selected" class="bmarks" id="sub_selected" style="width:400px" size="5"> <option value="1">first value</option> <option value="2">second value</option> <option value="4">other vale</option> </select> i want to pass all values to php i write following ...

How to prevent form replay/man-in-the-middle attack in PHP, csrf, xsrf

I have a web form and I'm using PHP. I'm aware that forms can be manipulated (I believe it's called replay attack or a man-in-the-middle attack). So I'd like to use some authenticity token as a hidden field. The threat possibilities that I'm aware of are: Attacker hijacks the legitimate user's form (this I believe is the man-in-the-m...

Disallowing proxies from POSTing

Hi there! I want to disallow proxies and spambots from posting in my website. What is the best way to do so? I've downloaded a blacklist and my first idea was to disable each of ips in my .htaccess file, but after downloading the list, I found out that it contained almost 9 million entries. My other idea was to split each IP in 4 par...

How to check if a user is logged in in php

I am pretty new to php and I am trying to figure out how to use sessions to check and see if a user is logged into a website so that they would have authorization to access specific pages. Is this something that is complicated or is it because I am a noob that I can't figure it out? Thanks for the help! ...

What is the easiest way to use the HEAD command of HTTP in PHP?

I would like to send the HEAD command of the Hypertext Transfer Protocol to a server in PHP to retrieve the header, but not the content or a URL. How do I do this in an efficient way? The probably most common use-case is to check for dead web links. For this I only need the reply code of the HTTP request and not the page content. Gettin...

Magento guest checkout option not showing up regardless of allow guest checkout setting

I’m having a strange problem with my fresh magento installation. There is no option for guest checkout even though I have Disable Onepage Checkout: NO, and Allow Guest Checkout: YES. I’ve looked at the core_config_data in the db and can’t find anything that would instigate this behavior. I have no template customizations and have disab...

How can I get the call duration of any call in a web application using asterisk?

I have done a Web site using php and which asterisk is used as a Voip system.Now the problem is I want to get the call duration of each call after 'HANG UP'.I googled alot and got an asterisk variable named ${ANSWEREDTIME},but don't know how I can get the value from it and how I can initiate it. Please Help and consider me as new bee to ...

Set Zend_Date Month using User Input

I'm looking for a way to set the month of Zend_Date using a string from the user (could be Jan, January, etc). For example $month = strftime("%m", strtotime($month)); $date->set($month, Zend_Date::MONTH); Will get the month 'number', which then can be used to set the Zend_Date month. Is there a way to do that all with Zend_Date? ...

CakePHP select default value in SELECT input

Using CakePHP: I have a many-to-one relationship, let's pretend it's many Leafs to Trees. Of course, I baked a form to add a Leaf to a Tree, and you can specify which Tree it is with a drop-down box ( tag) created by the form helper. The only thing is, the SELECT box always defaults to Tree #1, but I would like it to default to the Tr...