php

How secure is PHP?

I am somewhat new to PHP coding and I am aware that malicious users can hack a website if you have not sanitized your PHP code. What I am wondering is whether they need a data entry box (like for file submissions, or user-name/password entry fields)?. Do commands like "include (header.php)" also need some sort of security or are they inn...

Any Tournament APIs out there?

Are there any APIs for helping running tournaments that can draw brackets, count scores, etc? Something on PHP/javascript would be nice but I can't find any. Thanks. ...

.htaccess - list URL's to be restricted by ActiveDirectory LDAP Groups

Currently I have a .htaccess file within the directory of the folder I want to restrict, with the appropriate group that has access to it. What I want to do is have one htaccess for the entire site, and restrict groups to specific URL's. So I want staff to have access to: /staff/.. and Students to have access to: /students/.. I wou...

PHP robust include to handle errors?

I have a PHP app "index.php" that, for various reasons, needs to run other PHP scripts by using include_once on that other script. That other script isn't very stable, so is there some way to do a safe include_once that won't halt the caller? i.e.: <?php safely_include_once('badfile.php'); // MAY throw syntax error, parse error, othe...

Ignore the first XML tag in DOMDocument?

I write $xml = new DOMDocument(); and it automatically creates <?xml version="1.0"?>. I need to NOT create it. How do i do that? One solution is to search the first ">" and strsub at the index at the first < found. But i like a nicer way to do this. ...

Listen to chaning text in a Span Element

I have a span element which display's a changing duration value. <span id="vtime">--:--</span> Unfortunately, due to the JS API i am using these is no way to pick up that value other than to listen to the changing text in the Span element. I want to pick up the values and execute a javascript ajax command to fetch a value for the ca...

PHP denying use of short hand "<?"

I just installed php 5.3.0 and it won't run php scripts utilizing short open tags like <?, only <?PHP ...

Authenticate against ldap using PHP, active directory, while using IE/Firefox

This code below checks for the user's credentials against ldap <?php $ldaphost = "ldap.domain.com"; $ldapport = 389; $ds = ldap_connect($ldaphost, $ldapport) or die("Could not connect to $ldaphost"); if ($ds) { $username = "[email protected]"; $upasswd = "pass"; $ldapbind = ldap_bind($ds, $username, $upasswd); if (...

How do you get the object name when using SimpleXML?

If the format is the following, where c is an object array that I must foreach through each iteration: $a->b->c And I do: $z = $a->b foreach($z as $key => $value) echo $value['field']; $key comes up as null, even though I have valid values. How do I get the name of the object? ...

PHP echo question?

Do I really need this many echo's or can I make it shorter? <?php if (!empty($url)) { echo '<p>Job: <span>' . $job .'</span></p>'; echo '<p>Skills: <span class="caps">' . $skills . '</span></p>'; echo '<p>Website: <a href="http://' . $url . '" title="' . $url . '">http://' . $url . '</a></p>'; echo '<p>Pay:' . $pay. '</p...

multiple select values error

I have a form that allows the user to select up to X amount of options from a multi-select field. If the user selects an item greater than the X items it prompts and de-selects the last selected item. There is an issue when the warning message has been thrown by a previous multi-select. The form have 4 mult-selects, so if its thro...

PHP's Session Storage.

Hello, I'm having some trouble understanding PHP's sessions. First off I am saving session data in a database, I used PHP's session_set_save_handler() function to define that. The way I understand when PHP saves the session data to the DB is like so: If I define some session variables then output some text to the user's browser, I bel...

Secure login: public key encryption in PHP and Javascript

I'm trying to make a "normal" username/password login form secure, without needing HTTPS. My idea is this: Server generates a keypair for some kind of assymetric encryption algorithm. It stores this keypair in a temporary table of sorts (or perhaps the local session data). Server sends the form to the client and includes the public key...

Validate an HTML embed code using PHP or javascript or PHP framework (Zend)

Hi, just a simple question.. Is there any good practices to validate an HTML embed code? fyi, I am using Zend Framework and prototype+scriptaculous right now.. it would be great if someone could give a clue around that environment. Thank you! ^^ ...

controlling app flow between different scripts in PHP

Hi i have a php script that accepts a POST request as a listener to a web service then process all the data to two final arrays, I'm looking for a way to initiate a second script that GET's those serialized arrays and do some more processing. include() will not be good for me since i actually want to "free" or "end" the first script afte...

query limit issue with php and mysql (drupal 6)

hi i was trying to do a query in drupal which selects every row in table, i was having an issue with the no of rows i was able to query for the query is working for 300row limit but if i increase it 400 it is going blank page. $total_terms = 300; $query = "SELECT N.nid ,N.tid FROM term_node N "; $query_result = db_query_range($query, $...

Converting time in PHP?

How do i convert the time which I pull from a database 2009-09-27 23:58:54 to the following time using PHP Sep 27, 2009. ...

How to avoid DOM parsing adding html doctype, had and body tags?

<? $string = ' Some photos<br> <span class="naslov_slike">photo_by_ile_IMG_1676-01</span><br /> <span class="naslov_slike">photo_by_ile_IMG_1699-01</span><br /> <span class="naslov_slike">photo_by_ile_IMG_1697-01</span><br /> <span class="naslov_slike">photo_by_ile_IMG_1695-01</span><br /> '; $dom = new ...

PHP includes and POST

I'm developing a website and in my attempt to make friendly URLs without recurring to mod_rewrite (because chances are my client's server doesent allow it), I came up with this system: index.php expects a variable called $seccion, which should contain a relative path to a second file with a particular section. That way I keep the static...

How to implement Enum like functionality in PHP?

How can Enum-like functionality (as provided in Java and other high level languages) be used in PHP? I know PHP doesn't allow you to create enums currently, but what's the closest one could get? ...