php

REGEX (in PHP).. remove non-alphanumeric characters at ends?

$test = "!!! sdfsdf sd$$$fdf ___"; $test = str_replace(' ', '_', $test); // Turn all spaces into underscores. echo $test."<br />"; // Output: !!!___sdfsdf___sd$$$fdf______ $test = preg_replace('/[^a-zA-Z0-9_-]/', '-', $test); // Replace anything that isn't alphanumeric, or _-, with a hyphen. echo $test."<br />"; // Output: !!!___s...

cron info sent a weird email

Hi I got this email from cron info of my server. "`client_errors' has different size in shared object, consider re-linking" what is this ? this cron job is just a simple email script this is the script include("../admin/connect.php"); require("../class.phpmailer.php"); $from = "[email protected]"; $fromname = "Me"; $mail = new PHPM...

Scan current folder using PHP

I have a folder structure like this: /articles .index.php .second.php .third.php .fourth.php If I'm writing my code in second.php, how can I scan the current folder(articles)? Thanks ...

MySQL datetime fields and daylight savings time -- how do I reference the "extra" hour?

I'm using the America/New York timezone. In the Fall we "fall back" an hour -- effectively "gaining" one hour at 2am. At the transition point the following happens: it's 01:59:00 -04:00 then 1 minute later it becomes: 01:00:00 -05:00 So if you simply say "1:30am" it's ambiguous as to whether or not you're referring to the first tim...

PHP Gettext problems (like non-thread-safe?)

I want to start using gettext to handle my translations on web projects (PHP 5). Since it is a widely used standard with a good reputation it seems to be the best choice. However, I'm also hearing things about server incompatibly and it being non-thread-safe. What does this mean for my projects that use it then? Since I build things tha...

OO PHP protected properties not available in foreach loop?

Hi, I have a validation class which I would like to use to check all values in my application are within allowed constraints. I am passing an object to a static function within the validation class, from another class (in this case User) function validate() { $errors = Validation::validate($this); } In the validation class, I cre...

PHP and Visual Basic 2008 Conversion Help!

Hello Everybody! I need help converting this into PHP: Public Function Encrypt(ByVal text As String) As String Dim charSet1 As String, charSet2 As String, i As Long Dim pos As Long, encryptedChar, encryptedText charSet1 = " ?!@#$%^&*()_+|0123456789abcdefghijklmnopqrstuvwxyz.,-~ABCDEFGHIJKLMNOPQRSTUVWXYZ¿¡²³ÀÁÂÃÄ...

Apache reverse proxy authentication via PHP

I have two apache servers set up. One is public facing, the other is behind a firewall. The one behind the firewall is used to serve up content (vids, pics, etc). I've set up a reverse proxy so that any requests to http://mysite.com/content/ actually go to the server inside my firewall. See my serverfault question. My site uses PHP ...

Streaming Media Authentication in PHP

We are adding streamed media to our website using a third-party service. The basic workflow is intended to go something like this: User logs into our site User clicks a link to load a streamed podcast / video. The link points to a PHP script that verifies that this user has access to the requested resource. The php script exits and th...

Sending file contents in $_POST with PHP

Hi, I'm developing a PHP script to send the content of a file from one script to another. In PHP usually it's used the $_FILE array that contains any uploaded file submitted in a form. But I didn't needed a form so I came up with something a little different: // pseudo function names ahead $content = file_get_contents(FILE_TO_SEND); s...

Help in optimizing a query for a Postgresql database

I'm trying to find some suggestions in optimizing a query that I'm using to fetch a large group of data. The original code that I'm working on looped through a large set of users, and calculated a date range for each one of them. It would then take that date range and query how many questions they answered and how many they got correct...

Facebook Connect Site Like Digg (PHP)

I'm looking for a PHP tutorial or example of how to set up a facebook connect site like digg. Basically allowing local users to connect their facebook accounts to their local accounts indefinitely (until they opt out). This would then automatically reconnect them to facebook every time they log in with their local accounts. I've been tr...

PHP: Stop a Form from being accidentally reprocessed when Back is pressed

What is the best way to stop a form from being reprocessed when a user hits a Back button? I'm following the Post/Redirect/Get pattern, so I don't have a problem if F5 is pushed, but the back button still provides the opportunity to resubmit the form. If this form is a credit card processing page, this is bad. This question has been a...

scriptkiddie flooding my website with this snippit

hey, someone outthere is trying to flood my website with some script. luckly my application caught it i just wanna know what this code is doing <script> <!-- document.write(unescape("<?php //================================= // // scan inb0x hotmail v3.0 // // coded by FilhOte_Ccs and LOST // re-c0d3d by delet // // //================...

PHP integer exponentiation (super large numbers)

Using PHP I want to do millions of 2^n exponentiation but so far I only got up to n^1023 before PHP printed INF. Any ideas? ...

PHP request handler script and SEO

Would using a central "page handler" affect SEO negatively? eg A page request comes in for www.mysite.com/index.php, which mod_rewrite passes on as www.mysite.com/handler.php?page=index. Handler.php gathers the page-specific includes, language files and templates, and outputs the resultant html. My understanding is that the page handle...

How to make MySQL return empty day when doing a group by date?

I have a MySQL query like this: SELECT DAYNAME(CreatedAt) AS TheDay, SUM(Amount) AS TheSum FROM OrderTransactions GROUP BY TheDay # Returns an array like: # Array # ( # [0] => Array # ( # [TheDay] => Thursday # [TheSum] => 0.02 # ) # # [1] => Array # ( # [TheDay] => W...

Echo SQL query on new page with PHP

I know this is probably a really amateur question, but I can't figure this out and I don't know much about PHP or MySQL. So I have a really simple script that basically allows a user to submit a couple lines of text and their zipcode, then it write it to a database and returns the results on the site. It's a shoutbox essentially. My c...

php constructors

public function __construct($input = null) { if (empty($input)){ return false; } and then there's some constructor code... what I would like to do is for the class to not initialize if I pass an empty variable $classinstance = new myClass(); I want $classinstance to be empty (or false) I think this is not possible like this, Wha...

Easy way to load HTML content from XML?

EDIT: What I mean is displaying the XML data through HTML, not trying to get HTML into XML. Is there a simple way to load content from XML into HTML? To give you an idea, here is my DTD for the XML files: <!DOCTYPE bookreport [ <!ELEMENT page (title,author,image?,section+)> <!ELEMENT title (#PCDATA)> <!ELEMENT author ...