php

How is the Pop up alert which is displayed on stackoverflow when you are answering a question and someone submits another answer created?

Ok, so you know when you're answering a question and are in the middle of typing it, and someone else posts an answer to your question and you get a little popup that says there is a new answer to the question? My question is how do you do that? I think I have the basic concept down... A question is answered, added to the database. The p...

Fix png transparency problem

I use this class to upload images on my server. The problem is that when I upload transparent png images, the transparent parts get black. Is there a way to keep transparency in png images? class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->ima...

Having actions/pages without requiring a login

Hello, I am building an application using cakePHP. Do we have a method where we can allow public users access to certain pages without logging in. There would be a few pages such as about us regarding the whole organisation or a contact us page. Is there a method to avoid login access, something similar to how we have ways to add compone...

Why doesn't PHP support curly-brace expansion of consts in a string?

PHP supports this: $z = 5; $str = "z is $z"; // result: "z is 5" and it supports this: $c = new StdClass(); $c->x = 9; $str = "x is {$c->x}"; // result: "x is 9" but it does NOT support this: class abc { const n = 2; } $str = "x is {abc::n}"; // result: "x is {abc::n}" Why does PHP not support insertion of consts via the c...

where do I store my unit test files in my php project?

I have a php project in subversion, with the typical /project/trunk/, /project/test/, /project/branches/ structure. I want to start writing some unit tests with PHPUnit. Where is a good place to store these files in version control? If I put them in /project/unittests/, I would have to check out the directory they test in parallel, so ...

jQuery Autocomplete not working for Dynamic Form Fields

Hey folks... I am back with another issue... I am using jquery Autocomplete on a form field. It works! The issue is, then dynamically I add another row to the form, it doesn't. Yes, I keep toggle the id of the new field to a new one. Original = exampassed1 Dynamically Added = exampassed2, exampassed3 and so on... I have already add...

excel array column double/triple/etc.. consonant generation

How would I auto generate an array (in PHP) for AA - ZZ and so on like AAA - ZZZ $column_arr2= range("aa", "zz"); // NOT Working $row_arr = range(0,1000); $column_arr = range("a", "z"); echo "Column2<pre>".print_r($column_arr2, true)."</pre><br />"; // prints a - z echo "Row<pre>".print_r($row_arr, true)."</pre><br />"; echo "Column...

soap call error

Hey Guys, I'm trying to call a function via a SOAP webservice. The following code is run: $return_soap = $this->soap->__soapCall($soap_function, $params); I have also tryed: $return_soap = call_user_func_array(array($this->soap,$soap_function),$params); The headers are good, and i'm sending the following parameters: $params = a...

How to detect a delimiter in a string in PHP?

I am curious if you have a string how would you detect the delimiter? We know php can split a string up with explode() which requires a delimiter parameter. But what about a method to detect the delimiter before sending it to explode function? Right now I am just outputting the string to the user and they enter the delimiter. That's ...

Simplepie includes phantom enclosures that don't exist

I am combining two feeds, with enclosures, and items that don't have enclosures are showing up with empty enclosures. Here's the code with the offending bit in bold: <item> <title><?echo $item->get_title(); ?></title> <guid><? echo $item->get_permalink(); ?></guid> <link><? echo $item->get_permalink(); ?></link> **<? if ($enclosure = $...

Deconstructor in PHP

After taking a look at some old code: //Nothing like a destructor!! function destroy() { settype(&$this, 'null'); } And called by $Cache->destroy(); However in PHP 5.3 I get Deprecated: Call-time pass-by-reference has been deprecated in /blah/-cache-.php on line 154 How should I do this? ...

PHP Include Path with Mod_Rewrite

Hi there, I have been trying to find an 'easy' way of including files in my PHP docs that are subject to mod_rewrite address changes. At the moment our config.php file is located in public_html/lib/config.php, and what I have tried to do is include('lib/config.php') but it errors on pages that have had their address changed by mod_rewr...

http://localhost not working

i am using xampp 1.7.1 PHP 5.2.9 pinged localhost on cmd and it showed Reply from ::1: time<1ms Reply from ::1: time<1ms Reply from ::1: time<1ms Reply from ::1: time<1ms hosts file has 127.0.0.1 localhost 127.0.0.1 localhost.com 127.0.0.1 www.localhost.com any other ideas? http://127.0.0.1 and http://ipaddress works ...

Why do my php includes return, "failed to open stream: No such file or directory in..."

I'm using simple include files for common elements on a mostly static website. I do so like this <?php include('/inc/header.php'); ?> But this doesn't work unless i remove the leading slash, and then it only works on pages in the root directory. What am I doing wrong? ...

Dynamic title in php

I am Trying to get the page title (<title>bla..bla..bla..</title>) to be changable in php with a multi-file layout like so: Functions.php is included into index.php, then get_header() is called from functions.php to include the page header.php the title tag is inside the header file. I would like to be able to set the title from index.ph...

PHP: Image uploading if fail

Hello. I am having an upload image system. You upload a image, then you crop it and press save. If you cancel this procedure at after you uploaded the image, the image will remain on the server. So therefore i tried my idea of making a column in db called "failImage", so when you upload the image, it stores the filename e.g 1111.jpg ...

How to access dynamic global information in a static function

I'm setting some global configuration variables in the following manner: $yaml = file_exists('config.yml') ? Spyc::YAMLLoad('config.yml') : array(); $defaults = array( 'hostname' => 'localhost', 'base_uri' => '/wag/' ); $config = array_merge($default, $yaml); Now I'd like to define a function base_url($https) that returns a base...

Case insensitive preg_replace_callback

In the function below, I want to match the keyword case insensitive (should match "Blue Yoga Mats" and "blue yoga mats")... However, it currently only matches if the keyword is the same case. $mykeyword = "Blue Yoga Mats"; $post->post_content = preg_replace_callback("/\b($mykeyword)\b/","doReplace", $post->post_content); // the callb...

implementing an API system to an Uploading system

Hi, I have a upload system , where one can upload images, I want to implement an simple API system, where they can make a POST request, and get the result in simple xml. I currently handle the upload via a php script which has a form, where users can browse and upload the file,the script then redirects to a page where they can get the...

PHP - Sanitize all data?

Hi, I am making a CMS which can be extended by third-party developers. In the past I have had problems with newbie developers ignoring security all together. When they put their modules on my website, they are potentially compromising users websites. I want to create a globals object. This will overwrite all globals with a sanitized co...