php

From a development standpoint, what are the advantages/disadvantages of the major Content Management Systems?

I'm interested in using a CMS instead of building a website from scratch. However, as a software engineer, if I'm going to be using open-source tools, I'm going to use them to their full extent, including the possibility of developing plugins/extensions/modules and maybe even contributing core code. I'm currently looking at WordPress, D...

PHP - rmdir (permission denied)

Hello, I have an easy script to create and delete a folder, but when I try to delete a folder, it brings up and error. The code: <?php if ($_POST['hidden']) { $key = "../g_test/uploads"; $new_folder = $_POST['nazevS']; $new_dir_path = $key."/".$new_folder; $dir = mkdir($new_dir_path); if($dir) chmod ($new_dir_path, 0777); } if ($_...

PHP newbie security question

<?php $id = intval($_GET['id']); $sql = mysql_query("SELECT username FROM users WHERE id = $id"); $row = mysql_fetch_assoc($sql); $user = htmlspecialchars($row['username']); ?> <h1>User:<?php echo $user ?></h1> Can you see any threats in the above code? Do I have to use htmlspecialchars on everything I output? And should i use i...

Problem installing cake php

I have installed wampserver on my pc. I unzipped the cake php installation files in the "www" folder of wampserver. Now, when I try to run- "http://localhost/cakephp", I get a whole list of errors along with the cake php getting started page. Here are some of the errors: Deprecated: Assigning the return value of new by reference is dep...

How do I rank nodes based on user-rating, number of comments etc. in Drupal 6

I wish all nodes of a certain type to have a rank (or at least be sortable in Views by this rank). This rank is a score based on different criteria: Voting API (5-star rating) average, Voting API number of votes, number of comments etc. Any suggestions on how to achive this? ...

I have HTML comments being wrapped in Li and P tags :(

I have content that is first htmlentities and then stripslashes followed by nl2br. This means a watermark at the end ends up as: <li><p><!-- watermark --></p></li> Not very useful. I have the code below to try and strip the html comments and stop it displaying but its not very good at it! $methodfinal = str_replace('<li><p><!--', '<...

php function move_uploaded_file wont work on my online server but does on localhost

Hi I have been working on a upload file that works fine on localhost (windows) but wont work on my linux server I rent. I want it to move it to a subdir '/files' from where the file is. it gives the errors: Warning: move_uploaded_file(/home/taalhulp/domains/taalhulpmanager.nl/public_html/files/6) [function.move-uploaded-file]: failed ...

How to check if a certain part of the array exists in another array?

I have an two associative arrayes and I want to check if $array1["foo"]["bar"]["baz"] exists in $array2["foo"]["bar"]["baz"] The values doesn't matter, just the "path". Does array_ intersect_ assoc do what I need? If not how can I write one myself? ...

How to receive HTTP cookies from a web server in PHP?

How to receive HTTP cookies from a web server in PHP? ...

Apache's mod_rewrite and %{REQUEST_URI} problem

Hi, suppose we have the following PHP page "index.php": <? if (!isset($_GET['req'])) $_GET['req'] = "null"; echo $_SERVER['REQUEST_URI'] . "<br>" . $_GET['req']; ?> and the following ".htaccess" file: RewriteRule ^2.php$ index.php?req=%{REQUEST_URI} RewriteRule ^1.php$ 2.php Now, let's access "index.php". We get this: /index.php n...

How would I go about writing a simple PHP bot?

How would I go about writing a simple PHP bot that could login in and recieve all the cookies sent by the server? ... and then send them back when required? Any suggestions would be appreciated. ...

Gzipped content expected

Dear folks, I enabled gzip compression on my website, and tested with the following tools: http://www.whatsmyip.org/http_compression/ http://www.gidnetwork.com/tools/gzip-test.php http://web-sniffer.net/ Though, Firefox and all its extensions (Firebug, Yslow and Google Page Speed) say they receive noncompressed content. text/html i...

Change case of nodes in imported XML file via PHP preg_replace

I'm trying to process an imported XML file and make the text in one of the nodes <Name>SOMETHINGTOMAKELOWERCASE</Name> lowercase <Name>somethingtomakelowercase</Name> So far I got: $xml = file_get_contents($xmlfile); $xml = preg_replace('/<Name>(.*)<\/Name>/e', '<Name>' . strtolower($1) . '</Name>',$xml); fwrite(fopen($xmlfile, '...

Remove File After Time in PHP

Hello everyone! I have a php script that provides a link to a temporary file that is created with the script. I want the person to be able to download the file, but I don't want the file to stay on the server for a long time. I would like to remove the file say maybe after 2 minutes. How can this be done? Thanks ...

Pull all jpg's from a folder into a PHP array?

I want to simply pull all the JPG files from a specific folder (on MY server) into an array. I figure it would look something like this. My logic here is that I'd have a folder with images I want in a gallery so I could just upload images with an FTP and they would just show up. Is this a good idea? $dir = 'www.example.com/folder1/'; $...

Process feeds simultaneously

Hi, I am developing a vertical search engine. When a users searches for an item, our site loads numerous feeds from various markets. Unfortunately, it takes a long time to load, parse, and order the contents of the feed quickly and the user experiences some delay. I cannot save these feeds in the db nor can I cache them because the c...

Which is better performance in PHP?

I generally include 1 functions file into the hader of my site, now this site is pretty high traffic and I just like to make every little thing the best that I can, so my question here is, Is it better to include multiple smaller function type files with just the code that's needed for that page or does it really make no difference to j...

How can I add an image onto an image in PHP like a watermark

I am trying to write a small php function to take an image and apply a watermark type image on top of the image and them save them as 1 image, this code runs with 0 errors but does not apply the watermark image, is there anything obvious that stants out on why it won't? <?PHP $source_file_path ='http://cache2.mycrib.net/images/image_gro...

Post to another page within a PHP script

Hello! How can I make a post request to another php page withing a php script? I have one front end computer as the html page server, but when the user clicks a button, I want a backend server to do the processing and then send the information back to the front end server to show the user. I was saying that I can have a php page on the b...

Unified login form for Joomla user and administrator

My client is insistent that there be a single page where both Joomla administrators and users can log in, as opposed to the default Joomla setup where these two groups log in in separate locations (/administrator for the admin). While the reasons for the client's insistence are besides the point, essentially it's a small group where onl...