php

PHP - a different open_basedir per each virtual host

Hi I've came across on this problem, I have a sever running apache and php. We have many virtual hosts but we've noticed that a potentially malicious user could use his web space to browse other user's files(via a simple php script) and even system files, this could happens due to the php permissions. A way to avoid it is to set the open...

Theming Drupal Add Block form via forms API.

Hiya, Can anyone advise me on customising the Add Block form? (/admin/build/block/add) I want to hide the "User specific visibility settings" and "Role specific visibility settings" from users. This is what i've got so far, but obviously it's not right and I can't figure out what the array is. Anyone got the experience on this? functi...

Common constants file for PHP and JavaScript

How do guys suggest to share a constants file between PHP and JavaScript, in order not to repeat code? XML file? I am assuming mixing up javascipt inside PHP would not be the right solution!? Thanks ...

Is there limit of "join" or the "where" or length of SQL query ?

Actually i was trying to get data from elgg database based on multiple joins. It generated very big query with lots of JOIN statements and query never respond back. SELECT distinct e.* from test_entities e JOIN test_metadata m1 on e.guid = m1.entity_guid JOIN test_metastrings ms1 on ms1.id = m1.name_id JOIN test_metastrings mv1 on mv...

JavaScript two-dimensional Array to PHP

Hi I have to send a two-dimensional JavaScript Array to a PHP page. Indeed, I'm working on a form-builder, in which the user can add or remove fields. These fields are added (or removed) using JavaScript (jQuery). When the user is done and hit a 'publish' button, I have to get all the fields concerned and send them to a PHP page which w...

PHP code to compare two large text files with ~300,000 entries and output differences

hi, i've got two lists A and B, B = A + C - D. All elements are unique, no duplicates. How do i get the lists of: (1) the new items added, C (2) the old items removed, D C and D aren't more than 10000 elements or so. Edit Crap, sorry guys - forgot the important detail - these are both text files, not in memory elements. ...

Allow only certain domains being able to load an iFrame

I'm building some widgets for a charity. Due to some logo licensing malarkey, I've got to find some way of only allowing white-listed sites from running the code, or to send a error message (or something like that) rather than the widget. We've got to use iFrames as a fair few sites have already embedded them. Ideally, a PHP solution wo...

Removing blank output before opening tag to prevent "quirks" mode

I have a html template as a php string. To prevent output, all blank characters and line breaks before the html opening or doctype definition should be removed. What is the simplest and fastest way to do this with PHP? ...

IMAP Php bug - Workaround for this?

Any work around for this problem? http://bugs.php.net/bug.php?id=28419 ...

How to fix the size of the printing area while using window.print?

Hi I'm creating a invoice and have option to print the invoice. While printing i use a stylesheet (using media=print) to block the display of elements which should not be printed... But while printing it takes the full size of the window and uses that much paper.. I want to restrict the size of the printing area.... How can i do that...

Translating PHP language file

Hello. I have a language file like this: <?php $lng_imagepath = "images/"; $lng_imageext = "gif"; $lng_characset = "iso-8859-1"; $lng_prefix = "en_"; $lng_tabhome = "Home"; $lng_tabmyavenue = "My Profile"; $lng_tabregister = "Register"; $lng_tabhelp = "Help"; $lng_tabbuybids = "Buy Bids"; ?> ...

php tool - Extracting domain names from a zone file?

hi, i have access to the zone file for a tld. How can I extract just the domain names in the fastest possible way? Any suggestions on how to store them in a database/file? There are millions of them. ...

rookie MySql question about paging; Is one query enough?

I have managed to get paging to work, almost. I want to display to the user, total nr of records found, and the currently displayed records. Ex: 4000 found, displaying 0-100. I am testing this with the nr 2 (because I don't have that many records, have like 20). So I am using LIMIT $start, $nr_results; Do I have to make two queries i...

mysql_fetch_object on complex objects

Say for example I have the follwoing DB structure Table book id title ... Table Author id name ... Table BookAuthor id bookid authorid And in PHP I have the following object class Book { var $id; var $title; var $authors = array(); function Book() {} } class Author { var $id; var $name; function Author(){} ...

Doesn't seem to work: if($_SERVER['REQUEST_METHOD'] == 'GET') for GET requests?

The following code executes whether there are GET variables passed or not: if($_SERVER['REQUEST_METHOD'] == 'GET') { //Do something } The following only executes when GET variables are passed: if($_GET) { //Do something } I was under the impression that the first method was better, but now I am confused. Any ideas? Thanks!...

file_get_contents not working with non english filenames in DRUPAL

Hello. I have a problem. file_get_contents and other file functions (like file, fopen, glob etc) not working when i try to get file with non english symbols. I getting error that file not exist. It is going when i using any of that functions from my simple drupal module. But same time when i try to use file_get_contents outside drupal's ...

How can I use active directory to assign permissions to a web application?

I have several web applications developed using PHP and would like to set these up to allow user authentication through active directory (specifically so that users can authenticate using their domain credentials). I am able to use LDAP to authenticate the user to a group that I have created, but am unsure how I can assign user permissi...

class composition instead of object composition?

I want a class property to be reference to another class, not its object and then use this property to call the class's static methods. class Database { private static $log; public static function addLog($LogClass) { self::$log = $LogClass; } public static function log() { self::$log::write(); // seems ...

What are some ways to identify a logged in user on the web?

Here is the scenario: There are 5 websites (different domain names) that need to share a session. I am using a bit of code on each site which returns a "blank.gif" image and at the same time sets the session (syncing it up to the current session). Each of the sites calls a session-img from each of the other sites. Also, all sites have a...

PHP - Where can I find a simple database tool that is easy for non-technical users to use?

I'm looking for a simple database admin tool that will allow non-technical users to perform data-entry into a database (imagine a striped down version of phpMyAdmin). It would preferably allow the developer to set restrictions on which tables and fields can be modified. Edit: Most of the tools posted, so far, are developer oriented. I'm...