php

Is my anti XSS method OK for allowing user HTML in PHP?

I am working on finding a good way to make user submitted data, in this case allow HTML and have it be as safe and fast as I can. I know EVERY SINGLE PERSON on this site seems to think http://htmlpurifier.org is the answer here. I do agree partially. htmlpurifier has the best open source code out there for filtering user submitted H...

Require the user to enter the server's superuser/root password in PHP.

Hi all! I'm making a system called NCIV in PHP. In that system you can change a setting in settings.php, which allows the system's admin to enable or disable the usage of MySQL rather then a bunch of text files. However, changing that setting if the site already has content, will move all the data from/to the MySQL Database to/from the ...

My cookies won't bake properly

I have this weird problem with setting up cookies with PHP. Everything worked fine until this morning when i uploaded my script to the server. Here is some of my code if (!isset($_COOKIE["loggedin"])){ show login form } else { show content } This is in my login page setcookie("loggedin", "true", time()+3600,"/","mydomain.com"); ...

DO I need to create a new object to use a classes functions more then 1 time on a page?

I currently call a function to filter some HTML in PHP like this FilterHTML($string) I found a CLASS that I would like to use though and I do not know much about OOP and classes at all. I would like to just use this class in my existing function call because the function is already called sitewide in a lot of file so I would like to ...

question about php code from a CMS

I am trying to fix something in someone's website. Unfortunatley, the website is built on a CMS called GeekPak and is built in PHP. I know php a little but I am no expert in it. I've been trying to resolve the following for quite a while now. Problem: If you go on this page you will see a thumbnail gallery in bottom right. There ar...

PHP: how to avoid redeclaring functions?

I tend to get errors such as: Fatal error: Cannot redeclare get_raw_data_list() (previously declared in /var/www/codes/handlers/make_a_thread/get_raw_data_list.php:7) in /var/www/codes/handlers/make_a_thread/get_raw_data_list.php on line 19 how can I avoid the error? Is it possible to create a IF-clause to check whether a function is ...

PHP file_get_contents

Hello all, I'm looking to create a PHP script where, a user will provide a link to a webpage, and it will get the contents of that webpage and based on it's contents, parse the contents. For example, if a user provides a YouTube link: http://www.youtube.com/watch?v=xxxxxxxxxxx Then, it will grab the basic information about that vid...

How to make a proper mysqli extension class with prepared statements?

I have scoured the web for a good example but I can't find anything. I am trying to extend the mysqli class to make a helper class that will abstract away some of the complexities. One of the main things I want to accomplish is to make use of prepared statements. I don't really know where to start, or how to handle input and output p...

Auto-login with cookies

Hi, I've been trying to make an Auto-login feature to my login script for 2 nights now. So right down to the problem. I have a field in my users table called session_key varchar(255) in which i store the users IP hashed with md5. If the cookie is set, session vars will be set and if not a form will appear. When they login and if the...

Multilingual support with unicode characters. A little confusion.

I am creating a web application framework, in which I am providing support for multilingual content. I mean a content, say a paragraph can have 2 sentences in English and other 2 sentences in Hindi (an indian language). Now I have several doubts about that. 1) User or admin will add that content to the website. They will be presented a ...

How can I use OAuth and PHP without using the oauth-php library?

I need to build a script that uses OAuth authentication to connect to Foursquare's API, but oauth-php library is too complicated. Any one page scripts that don't use MySQL? I would rather just use cookies. ...

Serving file download with python

Hey gang, I'm trying to convert a legacy php script over to python and not having much luck. The intent of the script is to serve up a file while concealing it's origin. Here's what's working in php: <?php $filepath = "foo.mp3"; $filesize = filesize($filepath); header("Pragma: no-cache"); header("Expires: 0"); header("Cache-Control:...

PHP getenv('REMOTE_ADDR') serious side effects?

Hi, I am trying to grab a users' IP address to show them content relevant to their geography. I used the php code $ip = getenv('REMOTE_ADDR'); to grab their IP address. This works fine on my computer but my co-developer tried it and found that he was unable to connect to our site at all and got a "Host Not Accessible" error. He is una...

model access from layout file in CakePHP

I am working on a CMS using CakePHP and I want to create a dynamic menu which is the same on all the pages the user can access. So I figured out to create in the layout (since it shared among so many pages and view) but I don't seem to know how to acces the model and get the data from the database to construct the menu. any help is appre...

PHP Regular Expressions (REGEX) Multipart MIME (NOT-EMAIL)

I'm trying to do a "preg match all" on the response below to get all the binary data. I've tried just about everything imaginable and for the life of me, can't get anything. I was hoping it'd be as simple as doing something like this: preg_match_all("#\n\n(.*)\n--$boundary#",$body,$matches); But I can't get anything. I've tried other...

beginner question about php. how to get back multiple values after submitting form

I am new to php. I want to have a form such as this: Name <TextField> Corresponding pic: <dropdown> hiddenID (not shown to user) Name <TextField> Corresponding pic: <dropdown> hiddenID (not shown to user) Name <TextField> Corresponding pic: <dropdown> hiddenID (not shown to user) Name <TextField> Corresponding p...

i18n Validations

Think Global, Act Local That's what they tell you, however during all my time as I developer I've always seen big companies like Google, Microsoft, Oracle and so do validations in a localized manner: they know which country I'm from so they will try to validate my phone number, postal code and other details such as bank account numb...

writing a php function to verify data in an array

How would i go about writing a function that would handle the data in an array? What i mean is, can i use function CheckStuff($_POST){} instead of function CheckStuff($_POST['var1'], $_POST['var2']){} Reason im asking is i need the function to work through all the values stored in the array and there are quite a few. ...

validating user session in php

I am creating few pages (including login page) which should only be accessible by a sysadmin. In login.php after the user's credentials have been verified. I set a session variable like so: mysql_connect("localhost", $values['uname'], $values['password']) or die(mysql_error()); echo "Connected to MySQL<br />"; mysql_select_db("somedb...

php and postgreSQL installation

Hi Guys, I can't fix this problem. I have installed "php-5.2.10-win32-installer.msi" and "apache_2.2.11-win32-x86-no_ssl.msi", and "mysql-4.1.22-win32" on my XP. When I try to use phpinfo print out database support, I can see mysql is there, but not pgsql. I checked my php.ini, there are entries like these: [PHP_MYSQL] extension=php_mys...