php

Codeigniter security - mysql database

I'm in the final stages of implementing a codeigniter site which requires a really simple login system: one user and one password, to protect the admin area. I think I will be using one of the many CI authentication libraries, which should allow me to ensure that people can't read from the database without being logged in as admin(I hop...

how do you separate presentation(XHTML) and functionality (PHP code)?

What is better...make classes specially for rendering html, sth. like this: class IndexHTML { public $doctype = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"&gt;"; public $title = "<title>MICE</title>"; //title of document public $contentType = "<meta http-e...

Access a static variable by $var::$reference

I am trying to access a static variable within a class by using a variable class name. I'm aware that in order to access a function within the class, you use call_user_func(): class foo { function bar() { echo 'hi'; } } $class = "foo"; all_user_func(array($class, 'bar')); // prints hi However, this does not work when trying to ...

Looping Through All a Server's Sessions in PHP

Is there a way in PHP to get a list of all sessions (and the variables within each) on the server? Basically, we have a maintenance function which needs to know which users are currently logged into the site. We already store data for each user in a session variable, but I am hoping that I can loop through each of these sessions and pl...

How to Implement multi language in PHP application?

I'm posting this question on it's own as I found post one which lacks full explanation or the best way to do it. Should I use a language file to name items like: $first_name= 'name'; $last_name = 'last_name'; and then include this file depending on selection? I have an app which I need to have in two languages. Will like something i...

Best or optimum Web Server set up with Two servers,development practices

Hi I am having our company websites (x8 total 500,000per month) on a 1/3 share of a virtual server upgraded to 1 live server and 1 hot backup server. These two will be all our own, and run Debian, A2,M5,P5.2. The live one is more meaty than the spare. What would be the best way to setup and use these servers? We do not have a local de...

iPhone Uploading unique images to a server running PHP / MYSQL

Hi All, I'm working on an iPhone app that will upload images to a web server. I was wondering if anyone had any tips on how to generate unique names for each image file that gets uploaded. I'm sure there are a million ways to do this, but if anyone has any suggestions I'd really appreciate it! Thanks. ...

PHP: Adding elements to empty array

If I define an array in PHP such as (I don't define its size): $cart = array(); Do I simply add elements to it using?: cartData[] = 13; cartData[] = "foo"; cartData[] = obj; Don't arrays in PHP have a add method, i.e. cart.add(13)? ...

How to calculate the date difference between 2 dates using php

Hi, I have to dates of the form Start Date: 2007-03-24 End Date: 2009-06-26 Now I need to find the difference between these two in the below form: 2 years, 3 months and 2 days Can someone please help me with this ...

Do AJAX requests retain PHP Session info?

If I had a user logged onto my site, having his id stored in $_SESSION, and from his browser he clicked a 'Save' button which would make an AJAX request to the server. Will his $_SESSION and cookies be retained in this request, and can I safely rely on the id being present in the $_SESSION? ...

PHP - Alfresco integration

Hi, I am currently receiving a Strict Standards error when trying to make an alfresco web service call. I am using the Zend Framework. The tutorial works fine when not using the Zend Framework. If i use the Zend_Soap_Client i get a segmentation error, when i use the PHP Soap_Client i get the following error message: Strict Stand...

best way to determine if a URL is an image in PHP

Using PHP, given a URL, how can I determine whether it is an image? There is no context for the URL - it is just in the middle of a plain text file, or maybe just a string on its own. I don't want high overhead (e.g. reading the content of the URL) as this could be called for many URLs on a page. Given this restriction, it isn't esse...

Having an image stripped of metadata upon upload in PHP

A certain site I know recently upgraded their bandwith from 2,5 TB monthly to 3,5 TB. Reason is they went over the 2,5 limit recently. They're complaining they don't know how to get down the bandwidth usage. One thing I haven't seen them consider is the fact that JPEG and other images that are displayed on the site(and it is an image-h...

MYSQL ERROR

Bear with me I am a bit new to all this, I have this query running in my PHP script: $insertQuery = "INSERT INTO blog_articles VALUES '$title', $tags', '$category', '$blog', '$author', '$date'"; I then run this script: if ($result = $connector->query($insertQuery)){ // It worked, give confirmation echo '<center><b>Artic...

Opening a notepad from PHP

i want to open a notepad from php file and the notepad should contain the text which i declare as string in php file. essentially a notepad should open with the text I pass from php file. ...

Which one is a more reliable matching scheme, EREGI or STRIPOS?

Which scheme according to you is a better one in case of matching? Is it eregi or stripos or any other method? ...

How does the equivalence operator work with arrays in PHP?

Code: $arr = array( 10, 20, 30 ); $arr1 = array( 1=>30, 2=>20, 0=>10 ); var_dump( $arr == $arr1 ); $a = array( 1, 2, 3); $b = array( 1=>2, 2=>3, 0=>1 ); var_dump($a == $b); This outputs: bool(false) bool(true) ...

What are alternatives to SQL database storage for a web site?

An SQL database is overkill if your storage needs are small. When I was young and dumb, I used a text file and flock()ed it when I needed to access it. This doesn't scale, but I still feel that non-database solutions have been completely ignored in Web 2.0. Does anyone not use an SQL database for storage? What are the alternatives? ...

how to detect search engine bots with php??

How can one detect the search engine bots using php?? ...

Create and Save XML file to Server Using PHP

Hello, I'm using PHP to extract data from a MySQL database. I am able to build an XML file using DOM functions. Then using echo $dom->saveXML(); , I am able to return the XML from an AJAX call. Instead of using AJAX to get the XML, how would I save the XML file to a spot on the server? Thanks ...