php

Security of strip_tags() and mysqli_real_escape_string()

I'm in a school project on information security, and one of the assignments is to write some secure pages in PHP. None of the people on my group know PHP, that is not a big problem though, we'll learn enough to create the simple pages needed. One of the tips the students assistants have given is to use the two functions strip_tags() and...

PHP file upload problem

I've got a really annoying problem with file uploads. Users can choose a file in an html file field. When they submit the form, this file will be uploaded. On the serverside I just use standard PHP code (move_uploaded_file). I do nothing weird. Everything works perfectly. I can see the file on the server, I can download it again, ......

PostgreSQL - tree organization

I'm working on a project wich requires a tree of categories, organized as id, parent, title table. Which are the best ways to retrieve category and its subcategories(and a full tree, if root categories have parent=0) in Postgres? I'm looking for a pure database solution, but if there is a way for Ruby and PHP - it will be great too. The...

Listen for multiple messages from the server using AJAX: JQuery

Hi I make an AJAX call to a PHP script like so: function convertNow(validURL){ $.ajax({ type: "GET", url: "main.php", data: 'url=' + validURL, success: function(msg){ alert(msg); }//function });//ajax }//function convertNow From the above all it does is receive a lot of text f...

Sending ByteArray to Zend_Amf

I'm having problems sending a ByteArray over to my Zend_Amf_server. I get a NetConnection.Bad.Call back from the server. If I send a variable with another datatype then ByteArray it works fine. I used the same script before with AMFPHP witouth any problems. But for this project I really need this to work in Zend_Amf. AS3: var path:S...

mysql and php : Data extraction problem

Hi All, I'm stuck trying to figure out a solution for the problem below. Its quite complicated. So stay with me. :-) I retrieve a field from the user table which has his friends' user ids in the form of CSV (3,4,5,6,7) There is another table called transaction which looks something like this tid user1 user2 type_of_trade 1 ...

Implement map in javascript that supports object methods as mapped functions?

I recently tried to use an implementation of map in javascript to create a bunch of items, then apply them to an objects add method. Firstly with a bog standard implementation of map. var map = function (fn, a) { for (i = 0; i < a.length; i++) { a[i] = fn(a[i]); } } Setup. var translateMenu = new Menu; var langu...

How to execute a PHP spider/scraper but without it timing out

Hey guys/girls, Basically I need to get around max execution time. I need to scrape pages for info at varying intervals, which means calling the bot at those intervals, to load a link form the database and scrap the page the link points to. The problem is, loading the bot. If I load it with javascript (like an Ajax call) the browser ...

PHP include numeric

If I build my pages like this do I have to check if news_id is numeric in news.php too? Or is this safe? index.php: if (ctype_digit($_GET['news_id'])) include('news.php'); news.php: $query = mysql_query("SELECT * FROM news WHERE news_id = $_GET[news_id]"); $row = mysql_fetch_assoc($query); if (!mysql_num_rows($query...

mssql_query accent

I hava a problem with this mssql_query in PHP : $query = 'SELECT Ville FROM tblLstManufacturiers where province = "Québec"'; The result is empty because I have an accent in Québec How can I do this? ...

Create Subdomains on the fly with .htaccess (PHP)

I am looking to create a system which on signup will create a subdomain on my website for the users account area. e.g. johndoe.website.com I think it would be something to do with the .htaccess file and possibly redirecting to another location on the website? I don't actually know. But any information to start me off would be greatly ...

install php on server (iis6) when php already exists due to backup exec

I need to install or use php on a windows 2003 server that already has php 5.2.0.0 installed due (I think) to setting up symantec backup exec. I don't want to interfere with backup exec's php.ini settings - and would rather be able to control my own configuration of php. searching for php shows that php.exe and other php files are curr...

How do I replace outbound link URLs in a PDF document, using PHP

I have a PDF document with some external links. I'd like to parse the document, replace the destination of the links then close (and serve) the PDF document, all using PHP I know I can do this with PDFLib but I don't want to incur this cost. I could re-write the document with FPDF or DomPDF, but some of these PDFs are quite complex so...

PHP Class diagram that generates the code

Im looking for an application with the following funcionalities: Creates class diagrams Generates code of the structure that you just diagram The class structure in PHP. Thanks alot in advance, i'm sorry if my writing isn't that great english is not my language. ...

preg_match_all

Could some one explain this to me i am not familiar with preg_match_all filters, this code works fine except it does not return a negative value if one of the latitudes and longitudes is negative. if ( preg_match_all( "#<td>\s+-?(\d+\.\d+)\s+</td>#", $output, $coords ) ) { list( $lat, $long ) = $coords[1]; echo "Latitude: $lat\n...

How should I integrate two PHP applications - via common code, REST, RPC?

I work on two related web applications, developed in PHP, that started independently. Over time, we have started to more tightly integrate their functionality for business reasons. To accomplish this, we setup a directory for common code in a seperate SVN repository so that we can deploy different versions of this code when we deploy e...

jquery: Auto-refreshing a div

I'm having trouble getting this div to automatically update using jquery - it's essentially a "chat" feature that would have the page refresh every 2 seconds. Here's the problematic jquery code - I've tried several variances of this with no luck, so completely rewriting it differently is more than welcomed. function updateChat() { ...

Making file_get_contents() session aware in PHP

Preamble: My app is mod_rewrite enabled and I have index.php page that downloads vaious pages based on Request_URI and prints them as page content. Problem: File() or File_get_contents() function is excellent at downloading my other app pages. But as soon as I try to use it to download a page that is session enabled, I start having prob...

Parsing in PHP

i have variable $result that contains this Country: USA City: NY Latitude: 32.2667 Longitude: 71.9167 How do I parse it so I can get the out put like this: Country=USA&City=NY&Latitude=32.2667&Longitude=71.9167 ...

How do I make the Preview link on a WordPress post or page point somewhere else?

I've done a lot of small projects on the side lately where the client wants a good chunk of the website to stay the same, they just want to be able to edit particular "areas" of the site. Namely, some text in some box somewhere. I've found that WordPress works for this pretty well. The interface is nice and friendly to use, and it's go...