php

Singletons and DbSimple

Hi, i'm using DbSimple, but there is some code which i could write into another module. Here is it's code: <?php require_once 'config.php'; require_once 'DbSimple/Generic.php'; class MysqlWorker { private static $instance = NULL; public function getInstance() { if( self::$instance == NULL ) { s...

CMS based PHP Framework

There are lots of PHP framework available in the open-source community. Like: Zend, CakePHP, Codeigniter and .... But I don't find anyone of them as a CMS based framework. All the frameworks follows a particular design pattern and gives a strong PHP library to develop a website. Now most of the sites has a admin panel, user manageme...

Why is REGISTER_GLOBALS so bad?

I'm not a PHP developer but i've seen in a couple of places that people seem to treat it like the plague or something. Why? ...

OOP/PHP5: Calling Class A from Class B - or, Making the horse jump

Say you have two classes, A and B. Is it possible to instantiate both classes once and then let class B call methods in class A, and vice versa? It can be done using double colon (::) ... ... but then the method becomes static - is that a disadvantage? (see example below) Can it be done in other ways? With interfaces? This code shows ...

Upload ZIP-files with CodeIgniter?

Hey! I am using the following code to upload and extract a ZIP-archive in PHP using CodeIgniter. $config['upload_path'] = 'backups/'; $config['allowed_types'] = 'zip'; $config['file_name'] = $project_id; $this->load->library('upload', $config); if ( file_exists('backups/' . $project_id . '.zip') ) { try { delete_file('ba...

What are static and dynamic variables / methods in OOP?

I am trying to better understand basic concepts in OOP. What are static and dynamic variables and methods in object-oriented programming? What is, for instance, the difference between using $this vs. double colon (::)? $this ($this->a_method()) Advantages: ?. Disadvantages: ? ... "this" is not self-documenting as in: $this->method_fr...

Using PHP sessions exclusively for chatting

Hi, I have written a small chat app that uses mysql + php to facilitate 1:1 chatting between users. I was wondering if it would be advisable to use only PHP sessions (using session injection) for chatting and only using mysql to find the session id of the users. Will it be more efficient? Am i missing something out here? Thank you for...

how to check if a file is selected using javascript?

if in php this is how you check if a file is selected: $_FILES['item']['size']>0 what about in javascript? i need to know because i have a function that will only work if a file is selected. ...

PHP and singletons again.

Hi, i have code: class ConfigReader { private static $instance = NULL; protected $configData = array(); public function getInstance() { if( self::$instance == NULL ) { self::$instance == new ConfigReader(); } ...

Geting part of MySql row?

Is there any way to get just a part from MySql cell and ignore everything after predefined character? For example, I have row with cell's "ID, LINK, PHONE". Inside LINK cell DB wrights links like mysite.com/mypicture.jpeg. Is there any way, to get just "mysite.com" from this cell and ignore everything after slash, so I can echo it inside...

PHP plugin to calculate spam assassin spam score?

I have spam assassin on my hosting server. Is there any way to plug into it and calculate the spam score of an e-mail, before it is sent out? Preferably not invoking spam assassin directly. ...

config.php in root hacker safe with permission set to 644?

Hello. I it safe to place config.php in the root of your website even though it has premissions set to 644? ...

Autoload database class

Hello. Can I avoid instantiate a Db object inside of Names object to access it anyways? Would __autoload work for that? Is there another smart solution? I have following classes (They are conceptual so they won't work if executed): Db { function connect($config) { // connect to data base } function query($query) { ...

<head profile="http://gmpg.org/xfn/11"> what is this ?

Hi all I got this code from the wordpress <head profile="http://gmpg.org/xfn/11"&gt; What does this means? what is the use of this code.? :-) ...

How do I create a "todo" list for my web users to tick off?

Hello I'm trying to think of a way to create a list of items that I can display on a webpage that my visitors can tick off, without ever having to log in. The list may be like so: [ ] Buy potatoes [ ] Pickup kids [x] Drink more water [ ] Go for a Run If User A visits the site, and clicks "Drink More Water" I want that to sav...

What is a good easy class to change text to images

As many of you may already know I have been having issues with another site copying text from my site. The data is sports results that at first are not fully accurate because data is submitted at the event and people have to type in people's hand writing that can be difficult to read as well as other issues related to transferring data....

Replacing image src in HTML tags?

I want to use regex to replace src html attributes. The HTML is not malformed and fortunately takes the same form in all the pages in the database - i.e. <img src="http://x.y/z/1.png" /> I have code that works fine if there's only one image in the page. I want to know the best way to replace multiple images, as this one will replace a...

How should I store a date in PHP for use with javascript?

What I want to do is make a script on the server read a text file, sort it, then output it to a javascript object (probably via JSON). The text file in question looks something like this: 13/09/2009,17/09/2009,Arbitrary dates 14/09/2009,18/09/2009,Some random comment 14/09/2010,18/12/2010,A comment to the dates 14/09/2010,18/09/2010,A ...

PHP setcookie() for domain but NOT subdomains

Is there any way to set a cookie that is not readable on subdomains? In other words, have the cookie available on domain.com, but not www.domain.com or xyz.domain.com. //this is what i'm "intending"... setcookie($name,$value,$expires,'/','domain.com'); //however, this is how it behaves: setcookie($name,$value,$expires,'/','.domain.com')...

Flex and PHP code with IE Cache or POST issue

I have a Flex application that uses a rich interface. The user can create data and have it instantly show up in a list of data that they have created. The data is stored in a MySQL database using HTTPService POST requests from the Flex application and PHP forms to handle the data on the server side. For sake of explanation, let's say the...