php

Only execute script if entered email is from a specific domain

I am trying to create a script that will only execute its actions if the email address the user enters is from a specific domain. I created a regex that seems to work when testing it via regex utility, but when its used in my PHP script, it tells me that valid emails are invalid. In this case, I want any email that is from @secondgear...

Combine pairs to groups [PHP / Arrays]

I have pairs of items in an PHP array. Example: <?php $elements = array( 'tiger'=>'lion', 'car'=>'bike', 'lion'=>'zoo', 'truck'=>'plane' ); ?> Now I want to combine these items so that all items which are connected in any way go to one group. Continuation of the example above: <?php $groups = array( 0=>array('tiger', 'lion', 'zo...

Why are CodeIgniter application files in the public_html folder?

Isn't having all of the files in public view a bad thing? Surely things such as /system/application/config/database.php should not be publicly visible! ...

implode basket products - PHP

Hey .. Im trying to list all added products from my session['cart'] and implode them, I just don't know how to list the implode, please help! $list = ''; foreach($_SESSION['cart'] AS $key => $qyt){ $items[] = array('size_id' => $qyt['size']); } $res = $db->Execute("SELECT s.name, p.item_num, p.name AS product_name, p.d...

html and php date input field

I am having issues trying to figure out how, to create an html input box for the date: like this: YYYY-MM-DD I was wondering if there is a better method of doing this than me manually creating something like this, and then using the - separators to separate the YYYY-MM-DD. I will be using regex to do some validation after the user h...

Yahoo Weather API WOEID retrieval.

I'm creating an app (PHP) that takes yahoo weather data from the free RSS feed and correlates it with a colour hex based on data retrieved from the RSS feed. The issue I'm having is finding a way to grab the location code or WOEID without doing it manually. Yahoos API sends back an RSS feed as long as you provide a WOEID -> http://weath...

Am I reinventing the wheel? PHP/Mysql User reigstration and payment processing.

I'm about to code a php/mysql platform that does the following: Admin panel User registration Paypal payment processing Paypal subscription handling via api so that the user doesnt have to have a paypal account Does something like this already exist that I can use? If nothing exists like this, I'm going to code it fresh in the zend ...

Php abstract class site configuration

Hi, i have a config class which is an abstract class. I would like to set it up so it automatically detects which server the site is on and then assigns appropriate constants. I get an error on line ten $this->hostName = $_SERVER['SERVER_NAME']; expecting `T_FUNCTION. What is the correct way to do this and is there a better way to do thi...

Isolating picture attachment from email with php

I'm using the following php script to receive and process emails, putting the various pieces into variables to handle later on. #!/usr/bin/php -q <?php // read from stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); } fclose($fd); // handle email $lines = explode("\n", $email); // emp...

Preg matching and counting the resulting match in a short string

I already have a function that counts the number of items in a string ($paragraph) and tells me how many characters the result is, ie tsp and tbsp present is 7, I can use this to work out the percentage of that string is. I need to reinforce this with preg_match because 10tsp should count as 5. $characters = strlen($paragraph); $items ...

[apc-error] Cannot redeclare class sfconfig

I am running Symfony (1.2.9) with PHP Version 5.2.11 on Windows XP. I have APC installed (Version 3.0.19) I can run PHP script to prove that apc is working correctly (works). However, when I try to use APC calls in a symfony action, I get this error (in the apache error.log file): [apc-error] Cannot redeclare class sfconfig Which pro...

How to extract an email address from multiple text files.

I have approximately 96K text emails that I want to extract the sender's address for. I believe that I can use domdoc for this but need someone to start me off. Can someone please advise whether there is a better way of doing this? Thanks, Jim ...

Project conversion from ISO 8859-1 to UTF-8

I coded a php project under ISO 8859-1, and for some technical reasons I want to encode the project under UTF-8. what is a better way to do it? I am afraid of loosing special characters like french accents and so on. thanks for you advice. ...

PHP strategies for retrofitting a namespace around 3rd party code

I'm attempting to utilize a 3rd-party PHP library in a semi-developed web project. Unfortunately, as I am beginning to use the 3rd party code, I'm realizing that there is a number of variable and class name collisions. I was curious to know if there existed a strategy to retrofit a namespace around this new code. ...and yes, there's e...

Magento - Custom Payment Module

This is a very general question, but here goes: I'm trying to create a custom payment module in Magento. I've created a 'regular' module that hooks into the Magento event/observer model. But how do I tell Magento to treat a module as a payment module, so it shows up in the admin backend AND on the checkout page? ...

Finding a newline not immediately followed by a newline

(in PHP ... ) I'm trying to take a block of text and remove all hard line breaks so it can be re-wrapped to a specific line length using wordwrap(). However, since its possible to have multiple paragraphs, I'm assuming I need a way to remove a single newline, but not two in a row. If this is right, how can I say find \n but not \n\n in...

image position and clipping

hi, does anybody knows how to place an image in the webpage, but both position and clipping (maybe also resizing) are interactively done by user ?, i need it for my registration page, i've done some clipping and resizing from css and javascript, and it's not really solve the problem. If it's can be done by php, it will be perfect ! thx. ...

stop php processing file

Is there any way to make php stop processing a file and make it just work with the part it already parsed. I mean like this: <some data here> <?php phpinfo(); [IS THERE ANY THING I CAN PUT HERE] ?> <more data> [IS THERE ANY THING I CAN PUT HERE] <?HOW CAN I MAKE PHP NOT PARSE THIS?> is there anyway to make php ignore data after the fi...

View in MVC, what is a layout and how to create one

I dont understand what the layout is, in the view. I asked a question previously on the subject of templating in PHP, but I still dont quite understand. I assume that you create a general layout for the site and then include each specific view within that layout.... I would like to know how to go about doing this. Also, are should the te...

Mp3 Download not functioning

I'm offering a sermon downloading site and I have a user experiencing an issue with his download. Anyone have any ideas on how I can improve this code, or perhaps send better headers... $path = "http://www.domain.com/sermon_files/".date("Y", $array["preached"])."/".$array["filename"]; $corePath = "/home/user/public_html/sermon_files/"....