php

PHP - Convert all POST data into SESSION variables

Hey all, There's got to be a much more elegant way of doing this. How do I convert all non-empty post data to session variables, without specifying each one line by line? Basically, I want to perform the function below for all instances of X that exist in the POST array. if (!empty($_POST['X'])) $_SESSION['X']=$_POST['X']; I was goi...

Building a CMS for bilingual website - need tips

Hi guys, I'm building a really simple CMS for a bilingual website. The website would have 5+5 pages each of which would have varying content. Its like you have an about us page, services page a news page and contact us page in two languages. I was wondering that on the CMS backend admin panel I would be making .. what is the better opti...

How do I edit an external css file with PHP?

I have a page with an image. I want the client to be able to upload a new image into the database and then be able to switch out the image from within the CMS. Once they switch it in the CMS, I want PHP to edit the background image in the external css file. Is it possible to do that? I know how to have PHP switch out an image tag in th...

CakePHP and CSRF

I'm new to CakePHP and am wondering how to protect my forms from Cross Site Request Forgery, ie adding a nonce to the forms. I've set the salt in the config file. ...

PHP Line Indentation

I'm curious to know, how many spaces of indentation do you prefer in PHP code? function one() { $one; function space() { $space; } } function two() { $two; function spaces() { $spaces; } } function three() { $three; function spaces() { $spaces; } } function four() { $four; function spaces()...

Downloading php files?

Is it possible to download php files from the server where they are located? I am a beginner in web area, and I worry that hackers may have special tools to download, see my code and understand where I have programmed vulnerable codes to hack my site. ...

replace input field with data from mysql php

Hello Gurus I created this layout of successive text input fields, 1- Enter data into empty fields 2- Click on button which submits to a php page that updates into database Now the problem is that i want when i return to the main page again the empty field is replaced with data just added but there are still other empty fields to ente...

webapp vs. CMS - the same or not

I understand the classical definition of a CMS: it's a "webapp" the main purpose of which is to handle "content", probably that's generated by its users (kind of like all of us here at SO and the content we provide is text and code). I also always got the impression that creating a CMS is supposed to be a Really Tough Thing. But how so?...

Incorporating Open ID with my current login System?

I am currently setting up Open ID authentication in my website and I am having troubles incorporating it with my current Login System and database... I've read the article at Plaxo & it recommends this type of table to store the openid info... create table user_openids ( openid_url varchar(255) not null, primary key (openid_url), ...

Diacritic insensitive mysql search?

Hello, How do I make a diacritic insensitive, ex this persian string with diacritics هواى بَر آفتابِ بارِز is not the same as with removed diacritics in mySql هواى بر آفتاب بارز Is there a way of telling mysql to ignore the diacritics or do I have to remove all the diacritics in my fields manually? ...

Debug irrelevant Wordpress search results

On Wordpress, I keep getting irrelevant search results. Some search strings that do not exist on the DB yield All Posts as results. Some search strings that DO exist, works great. What could be the cause of that behavior? I've uninstalled all related plugins. Is there a way to debug the search? Thanks! ...

form updated by javascript missing post values

I have a form that I ad an element to via JavaScript before it is submitted. parent.document.getElementById('submitcomment' + id).innerHTML = '<img class="image_real" src="/images/site.png" alt="Mostly Dirty," /> <input class="real" name="freshness" type="text" size="5" maxlength="6" /> <a href="#" onClick="submitComment('+[id]+'); re...

Referer in php-

Hello everyone, What is the best method of doing the following: I have Page A with 2 buttons(for different things) which both take you to a login page(Page 3), When login details are filled in Page 3, the page that handles the data is page 4. I want page 4 to show things depending on which button was clicked in page a. I have read upon ...

PHP MySQL Transactions

Hi, Is there anyway to carry out an SQL transaction in one command? eg mysql_query(" START TRANSACTION; INSERT INTO table1 ....etc; INSERT INTO table 2.....; COMMIT;"); Or do you always have to use separate commands? eg mysql_query("START TRANSACTION;"); mysql_query("INSERT INTO etc etc Thanks ...

Quickly convert simpleXMLObject to STDClass?

Does anybody know a quick way to convert a SimpleXMLElement to a normal STDClass object, without iterating through each branch manually? I would feel better working with a normal object after fetching the data. ...

MVC (PHP): Do Controllers/Actions map to each and every request?

I've been getting to grips with MVC (in PHP) by way of Zend. My understanding of the Zend Framework is that each type of user request maps to a specific controller (which in turn may or may not map to a model), and each action maps to a view. I've noticed the same pattern in Codeigniter and Kohana, and to some extent also in Symfony. Eff...

Including sample site into php and making it interactive

Hi there, I am working on a small project for learning PHP better. This project has a primary file, which opens another website (e.g. youtube) by using fopen + fread. (or file_get_contents ?) The site will be saved into a variable and after that a function will parse the file's content and should replace certain items with advanced con...

changing from md5 to sha1,salting

my algorithm looks like this: $new_password = sha1($salt . $password . $email); it works good, but Im trying to change to sha1 since ive heard its better but it wont work. Why is that? register: //generate a strong unique salt $salt = uniqid(mt_rand()); $new_password = sha1($salt . $password . $email); and then i rehash it when i...

Help with static class members

I have always used $this in my classes. Now I have to use a static class and I'm lost. Can someone please tell me how to convert this to use static members? I've tried to look at some tutorials but they are not easy to understand. I also have no idea how to "instantiate" a static class so if someone could please provide an example, I'd b...

Best practices to deal with absent/wrongly typed GET variables?

What do you do when you detect your get request is broken or is passing wrong types of data? Say you have a forum-page.php?forum=3 that lists all the topics related to forum 3. What would be a good way to deal with the absence of the "forum" variable? What about if instead of being an integer, you would get a string? How would you respo...