php

PHPs htmlspecialcharacters equivalent in .NET?

PHP has a great function called htmlspecialcharacters() where you pass it a string and it replaces all of HTML's special characters with their safe equivalents, it's almost a one stop shop for sanitizing input. Very nice right? Well is there an equivalent in any of the .NET libraries? If not, can anyone link to any code samples or libr...

Accessing html parameter in PHP

I'm trying to do a simple test php script for sessions. Basically it increments a counter (stored in $_SESSION) every time you refresh that page. That works, but I'm trying to have a link to destroy the session which reloads the page with the ?destroy=1 parameter. I've tried a couple of if statements to see if that parameter is set and i...

Implementing permissions in PHP

I've tried to do this several times with no luck. After reading this post, it made me interested in doing this again. So can anyone tell me why the following doesn't work? <?php $guest = 1; $editor = 2; $admin = 4; $user = $editor; if( $user == ($editor | $admin) ) { echo "Test"; } ?> ...

How would you implement FORM based authentication without a backing database?

I have a PHP script that runs as a CGI program and the HTTP Authenticate header gets eaten and spit out. So I would like to implement some kind of FORM based authentication. As an added constraint, there is no database so no session data can be stored. I am very open to having a master username and password. I just need to protect the a...

Email queueing in php

What is the most proper way to sending email of minimal 1000 or more in php? Any reliable email queueing technique that is capable to handle that? ...

WebSVN with VisualSVN Server, anyone gotten authentication to work?

I have a VisualSVN Server installed on a Windows server, serving several repositories. Since the web-viewer built into VisualSVN server is a minimalistic subversion browser, I'd like to install WebSVN on top of my repositories. The problem, however, is that I can't seem to get authentication to work. Ideally I'd like my current reposit...

cURL adding whitespace to post content?

I am attempting to POST against a vendor's server using PHP 5.2 with cURL. I'm reading in an XML document to post against their server and then reading in a response: $request = trim(file_get_contents('test.xml')); $curlHandle = curl_init($servletURL); curl_setopt($curlHandle, CURLOPT_POST, TRUE); curl_setopt($curlHandle, CURLOPT_POSTFI...

Dealing with PHP server and MySQL server in different time zones

For those of us who use standard shared hosting packages, such as GoDaddy or Network Solutions, how do you handle datetime conversions when your hosting server (PHP) and MySQL server are in different time zones? Also, does anybody have some best practice advice for determining what time zone a visitor to your site is in and manipulating...

How to display "12 minutes ago" etc in a PHP webpage?

Can anyone tell me how I can display a status message like "12 seconds ago" or "5 minutes ago" etc in a web page? ...

PHP Script to populate MySQL tables

Is anyone aware of a script/class (preferably in PHP) that would parse a given MySQL table's structure and then fill it with x number of rows of random test data based on the field types? I have never seen or heard of something like this and thought I would check before writing one myself. ...

GOTO command in PHP6?

I've heard rumors that PHP6 is planning on introducing a "goto" command. What is it supposed to be doing, once PHP6 gets out? I've tried searching a bit, but haven't found anything awfully descriptive. I understand that it won't be a "GOTO 10"-like command... ...

Check file permissions

How can I check file permissions, without having to run operating system specific command via passthru() or exec()? ...

Introducing Python

The company I used to work with has two developers working fulltime, and a handful of freelancers. They're in the process of hiring a new lead developer to try to bring order and management to the development. But, currently, one of the developers has seen the light of Django (the company has only developed in PHP to date) while the oth...

Fast(er) way to get file inode using PHP

To grab the inode of a file in PHP, you can use this: $fs = stat($file); echo $fs['ino']; The problem with this is EVERYWHERE says it's slow and you should avoid it. So the question becomes what's the fast(er) way to do it? ...

Tools for PHP code refactoring

Are there any tools which support refactoring PHP code (renaming variables, extracting methods, finding method references, ...)? Thank you. ...

PHP with SQL Server 2005+

Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database. But all the query work is done on the client side, I'd like to move some of this to PHP. What driver and/or connection string is needed to connect to Sql Svr and what is the syntax to use in PHP? Update: OK so I was definitely trying to avoid using an...

How do I log uncaught exceptions in PHP?

I've found out how to convert errors into exceptions, and I display them nicely if they aren't caught, but I don't know how to log them in a useful way. Simply writing them to a file won't be useful, will it? And would you risk accessing a database, when you don't know what caused the exception yet? ...

What is the point of interfaces in PHP?

Interfaces allow you to create code which defines the methods of classes that implement it. You cannot however add any code to those methods. Abstract classes allow you to do the same thing, along with adding code to the method. Now if you can achieve the same goal with abstract classes, why do we even need the concept of interfaces?...

Best Approach to Parse for SQL in PHP Files?

For my senior thesis, I developed a program that would automatically detect and suggest fixes to SQL injection vulnerabilities using prepared statements. Specifically the mysqli extension for PHP. My question for the SO community is this: What would your preferred approach be to detect the SQL in PHP source code? I used an enum contai...

If I have a PHP string in the format YYYY-DD-MM and a timestamp in MySQL, is there a good way to convert between them?

I'm interested in doing comparisons between the date string and the MySQL timestamp. However, I'm not seeing an easy conversion. Am I overlooking something obvious? ...