php

PHP list directories and remove .. and .

hi, I created a script that list the directories in the current directory <?php $dir = getcwd(); if($handle = opendir($dir)){ while($file = readdir($handle)){ if(is_dir($file)){ echo "<a href=\"$file\">$file</a><br />"; } } ?> but the problem is, I am seeing this ".." and "." rig...

What is the best way to use Email Template in Zend/PHP

I am working on a website where Users create their accounts. I need to send email to users on many oceans. For example when signup, forgot password, order summary etc. I want to use emails templates for this. I need your suggestions for this. I want to use a way that If I change any email template or login in less time and changes. I ha...

PHP - Snoopy POST request + maintain SESSION?

Using Snoopy I make a request, but it seems that a different SESSION is used for the POST? When I echo the results of the request the SESSION is set but after clicking any link the page returns to a non SESSION-set state. Currently i'm using v.little code to make the request $dashboard = new Snoopy; $dashboard->referer = "URL"; $dashb...

How to escape '\' from a string in PHP?

I am using File IO, to save a file in local system(i.e PC C: drive), URL to save is like this "C:\htmlfiles\".$name_of_file.".html" the "\" in the string "C:\htmlfiles\" is giving the problem, tell me how to escape the '\'. please help. ...

what comes next for me?

hey, i've been running my own gaming website for about 5 years now. It's written in PHP/MySQL. I use some AJAX and have recently started using jQuery. I'm wondering how best to move forward to make my code "better". I've never used a PHP framework, and I once used OOP but didn't really feel the advantages. What could I learn to move for...

Moodle 1.9.7: Uploading file in assignment admin panel

In Moodle 1.9.7, I need to allow the teacher to upload a file in the admin panel of a brand new assignment plugin. When overriding the *setup_elements* function in my assignment.class.php, I'm doing something like: $mform->addElement('file', 'foo', 'Label'); $mform->setHelpButton('foo', array('foo', 'Label', 'assignment/type/my_assignm...

With HipHop for PHP, what happens with PHP errors

HipHop compiles PHP in a C executable. What happens with PHP errors ? Is that harder to debug ? edit : I looked through the documentation but didn't find anything ...

How to merge arrays but no numerical keys in fewest lines in php?

$result = array_merge($arr1,$arr2); I want to exclude numerical values of $arr2,is there an option for this? Edit after comment: $arr1 = array('key' => 1); $arr2 = array('test',1 => 'test', 'key2' => 2); after processing I need the result to be: array('key' => 1,'key2' => 2); Excluding numerical keys ...

Calling ejabberdctl from PHP

I am working on a php social network that requires us to create XMPP accounts for all new members. I have a working Ejabberd server running with mod_admin_extra all working fine. I am trying to call ejabberdctl from a php file like so: exec('sudo /home/user/ejabberd-2.1.2/bin/ejabberdctl register test server pass 2>&1'); but i get t...

php search and insert special string

Hi Am insert the group of string into my table, this is sample one |=|4|=|3|=|5|=|3|=|Yes|=|No comments . Some time my string may like this manner |=|4|=|3|=|5|=|3|=|Yes|=| For this situation i want to append this string (Sorry no data) at the end of |=| this symbol , Also my string may like |=|4|=|3|=|5|=|3|=|Yes|=| That...

How to password protect files (images, video, zip) dynamically from public and allow access to members only?

It's a common problem, solved many times, but for some reason i cannot find the right information. Some constraints and requirements: Technique for LAMP stack. Fine-grained control of which files are accessible. No basic authentication with htpasswd files, i want to provide a custom login frontend. Should be able to securely protect a...

regular expression to parse youtube embed code

I want to take the youtube embed code that youtube provides and use a regex to convert it to valid FBML code i.e. use the fb:swf tag. Has anyone done something like this? So far the regex I've come up with is : preg_replace('/<object(.*)<\/object>/i', "Whatever I need here...", $str); I know its lame but its my first try. Thanks for ...

How to create my Magento productCollection

How can i create my own productCollection from the scratch. So i have a list of products and from those products to creaete collection. Or i need the second variant, if i take the collection with all the products $products = Mage::getModel('catalog/product'); how can i filter them by the ID. What i am trying to do is override the search...

What would i need to do display urls in order the way they are displayed on SO?

I'm really unsure of how ordered results are displayed on a page like stack overflow questions. I know how to get the data from the DB but do i use a for each loop to display the data. And how can i paginate? I know all about display logic on the databse end. What i mean is that i have the data ready but i do not know how to put in on t...

How to split and replace a string?

I have a string $str = 'abcde-da__123123213.xef'; $str2 = 'asdfasd__2342352353.gff'; $str3 = 'twethe__3242323423.pig'; I want to replace anything following __ (2 underscores) and before the . (dot) with a new string (number). For example, the above $str changes to 'abcde-da__23235239.xef'. One of the ways is to $temp = explode('.'...

Working with Delicious API json response...

When I try to find out the total count of delicious bookmarks, Delicious returns a json file which when decoded is: Array ( [0] => stdClass Object ( [hash] => e60558db2d649c8a1933d50f9e5b199a [title] => ISRAEL: Thousands march in Jerusalem rally, Israel still kicking new families out of lan...

CHMOD a linux directory using PHP on an apache server

Has anyone ever used PHP (proven and successful) to CHMOD a directory through a Web Browser? My roadblocks are: (a) PHP script runs as "nobody" from the browser (b) directory above the one I want to CHMOD is owned by the ftp user and "nobody" does not have write permissions to it So when I try to chmod 0666 /usr/www/dirOwnedbyFTPuser/d...

How to override table name andprefix in Magento model?

I need to make Magento read/write data to an existing database table in order to integrate with another party system. The table cannot be renamed. If I specify it in the table tag in the model config as below magento adds the prefix. Is there a way to override the prefixing somehow? <models> <arithmetic> <class>Mc...

regex to parse a URL-type string in PHP

I have a string like so: http://www.youtube.com/v/Nnp82q3b844&amp;hl=en_US&amp;fs=1&amp; and I want to extract the Nnp82q3b844 part of it i.e. the part between /v/ and the first &. Is there and easy way to do this in PHP? ...

TCPDF grey background for few cells?

I'm using TCPDF in CakePHP and trying to make some background (grey) for few cells. Well here the idea: so the grey thing would somehow have to be define outside of the cells containg text. Any ideas? Paul ...