[Xerte] Re: database.php
David Goodwin
david at palepurple.co.uk
Sun Apr 29 18:47:12 BST 2012
On 29 Apr 2012, at 18:32, Dave Burnett wrote:
> >Although I can see that requirement being a problem in some educational organisations but as you say the potential risks with still using PHP 4 arguably means that's a good thing!
>
>
> Here's the response from my ISP for a php upgrade:
>
> Dear Dave Burnett,
>
> Thank you for using our service. Let me inform you that your current php version is PHP 4.4, if it is essential for your application to have PHP 5 support we may move your account to a new server with all new features.
>
> Before we can perform a control panel migration for your account, there are several things we need to bring to your attention and require your confirmation. You must ensure you have a complete backup of all web related data which includes the following:
>
> * All files you have uploaded
> * Databases
> * Email content
>
>
> Once you have a backup of your content please let us know and we can continue with the migration. After the migration has been completed you will need to re-upload all content and recreate any databases and email accounts as well as pointing your domain nameservers to a new location.
>
> Your old IP Address and hosting content will remain active for two weeks to avoid downtime due to the propagation of the new nameservers. After two weeks the content will be removed from the old control panel.
>
> If you have Windows account and use ColdFusion please note that Coldfusion is not enabled on the new servers by default. You will have to enable this separately in Account Settings for extra cost $5/mo right after the move is completed. Coldfusion version will be upgraded to Coldfusion MX 7 (7.0.2.142559). We cannot proceed with platform switch if you do not agree with these conditions.
>
> Not much to do there eh?
> So, sure, unilaterally go ahead and force a php upgrade.
> It will satisfy the purists.
>
Hi,
1. That's a strange "migration" if it means you actually have to re-upload everything. What exactly are they migrating for you? It doesn't sound like they're doing much.
2. I'd suggest you stick to using the last release; which presumably you've used with PHP4 and know it works? Just don't touch what's in trunk/svn or the next release - and change the database_library.php file to look like :
function db_query($sql, $params = array())
{
$connection = database_connect('db_query ok', 'db_query fail');
foreach ($params as $key => $value) {
if (isset($value)) {
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
$value = "'" . mysql_real_escape_string($value) . "'";
} else {
$value = 'NULL';
}
// overwrite the $params data with the escaped stuff.
$params[$key] = $value;
}
// following code taken from php.net/mysql_query - axiak at mit dot edu - 24th october 2006
$curpos = 0;
$curph = count($params) - 1;
// start at the end of the string and replace things backwards; this avoids us replacing a replacement
for ($i = strlen($sql) - 1; $i > 0; $i--) {
if ($sql[$i] !== '?') {
continue;
}
if ($curph < 0) {
$sql = substr_replace($sql, 'NULL', $i, 1);
} else {
$sql = substr_replace($sql, $params[$curph], $i, 1);
}
$curph--;
}
_debug("Running : $sql", 1);
$result = mysql_query($sql, $connection);
if (!$result) {
_debug("Failed to execute query : $sql : " . mysql_error());
return false;
}
if (preg_match("/^select/i", $sql)) {
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
return $rows;
}
return $result;
}
Which removes the '&' issue for you.
3. Sorry for being a purist….
thanks
David.
Pale Purple Ltd. (Company No: 5580814)
'Business Web Application Development and Training in PHP'
http://www.palepurple.co.uk
Office: 0845 0046746 Mobile: 07792380669
Follow us on Twitter: @PalePurpleLtd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20120429/02181100/attachment.html>
More information about the Xerte
mailing list