Fatal error in include/general.php

156 views
Skip to first unread message

Kevin Moloney (cariocakev)

unread,
Jul 31, 2010, 10:04:07 PM7/31/10
to ResourceSpace
Hi kids,

I have some broken php somewhere, perhaps initiated by a disk rescue
in the last few days.

I do a test call of a research request and get this:

Fatal error: Call to undefined function ctype_alpha() in /www/
resourcespace/include/general.php on line 1535

Any suggestions would be great.

Here's the text of the function from that file itself, as well as my
modified research_request.php, which had worked for months:

}


function rs_quoted_printable_encode_subject($string,
$encoding='UTF-8')
{
// use this function with headers, not with the email body as
it misses word wrapping
$len = strlen($string);
$result = '';
$enc = false;
for($i=0;$i<$len;++$i) {
$c = $string[$i];
if (ctype_alpha($c))
$result.=$c;
else if ($c==' ') {
$result.='_';
$enc = true;
} else {
$result.=sprintf("=%02X", ord($c));
$enc = true;
}
}
//L: so spam agents won't mark your email with QP_EXCESS
if (!$enc) return $string;
return '=?'.$encoding.'?q?'.$result.'?=';
}

Another possible culprit is my customized research request form. I
added a few months ago the rudimentary anti-spam key as I was getting
spammed like crazy there. Here's that file:

<?php
include "../include/db.php";
include "../include/authenticate.php";
include "../include/general.php";
include "../include/research_functions.php";

if (getval("save","")!="")
{
$errors=false;
if (getvalescaped("name","")=="") {$errors=true;$error_name=true;}
if (getvalescaped("description","")=="") {$errors=true;
$error_description=true;}
# Check the anti-spam code is correct
if (getval("antispamcode","")!=md5(getval("antispam","")))
{$errors=true;$error_antispam=true;}
if ($errors==false)
{
# Log this
daily_stat("New research request",0);

send_research_request();
redirect("pages/done.php?text=research_request");
}
}

include "../include/header.php";
?>

<div class="BasicsBox">
<h1><?php echo $lang["researchrequest"]?></h1>
<p class="tight"><?php echo text("introtext")?></p>
<form method="post">

<?php if (getval("assign","")!="") { ?>
<div class="Question">
<label><?php echo $lang["requestasuser"]?></label>
<select name="as_user" class="stdwidth">
<?php
$users=get_users(0,"","u.username",true);
for ($n=0;$n<count($users);$n++)
{
?><option value="<?php echo $users[$n]["ref"]?>"><?php echo $users[$n]
["username"] . " - " . $users[$n]["fullname"] . " (" . $users[$n]
["email"] . ")"?></option>
<?php
}
?>
</select>
<div class="clearerleft"> </div>
</div>
<?php } ?>

<div class="Question">
<label><?php echo $lang["nameofproject"]?></label>
<input name="name" class="stdwidth" value="<?php echo
getval("description","")?>">
<div class="clearerleft"> </div>
<?php if (isset($error_name)) { ?><div class="FormError">!! <?php echo
$lang["noprojectname"]?> !!</div><?php } ?>
</div>

<div class="Question">
<label><?php echo $lang["descriptionofproject"]?><br/><span
class="OxColourPale"><?php echo $lang["descriptionofprojecteg"]?></
span></label>
<textarea rows=5 cols=50 name="description" class="stdwidth"><?php
echo getval("description","")?></textarea>
<div class="clearerleft"> </div>

<?php if (isset($error_description)) { ?><div class="FormError">!! <?
php echo $lang["noprojectdescription"]?> !!</div><?php } ?>
</div>

<?php
$code=rand(1000,9999);
?>
<input type="hidden" name="antispamcode" value="<?php echo md5($code)?
>">
<div class="Question">
<label for="antispam"><?php echo $lang["enterantispamcode"] . " " .
$code ?> <sup>*</sup></label>
<input type=text name="antispam" id="antispam" class="stdwidth"
value="">
<div class="clearerleft"> </div>
</div>


<div class="Question">
<label><?php echo $lang["deadline"]?></label>
<select name="deadline" class="stdwidth">
<option value=""><?php echo $lang["nodeadline"]?></option>
<?php for ($n=0;$n<=150;$n++)
{
$date=time()+(60*60*24*$n);
?><option <?php $d=date("D",$date);if (($d=="Sun") || ($d=="Sat")) { ?
>style="background-color:#cccccc"<?php } ?> value="<?php echo date("Y-
m-d",$date)?>"><?php echo nicedate(date("Y-m-d",$date),false,true)?></
option>
<?php
}
?>
</select>
<div class="clearerleft"> </div>
</div>

<div class="Question" id="contacttelephone">
<label><?php echo $lang["contacttelephone"]?></label>
<input name="contact" class="stdwidth" value="<?php echo
getval("contact","")?>">
<div class="clearerleft"> </div>
</div>

<div class="Question" id="finaluse">
<label><?php echo $lang["finaluse"]?><br/><span class="OxColourPale"><?
php echo $lang["finaluseeg"]?></span></label>
<input name="finaluse" class="stdwidth" value="<?php echo
getval("finaluse","")?>">
<div class="clearerleft"> </div>
</div>

<div class="Question" id="resourcetype">
<label><?php echo $lang["resourcetype"]?></label>
<div class="tickset lineup">
<?php $types=get_resource_types();for ($n=0;$n<count($types);$n++) {?
><div class="Inline"><input id="TickBox" type=checkbox name="resource<?
php echo $types[$n]["ref"]?>" value="yes" checked>&nbsp;<?php echo
$types[$n]["name"]?></div><?php } ?>
</div>
<div class="clearerleft"> </div>
</div>

<div class="Question" id="noresourcesrequired">
<label><?php echo $lang["noresourcesrequired"]?></label>
<input name="noresources" class="shrtwidth" value="<?php echo
getval("noresources","")?>">
<div class="clearerleft"> </div>
</div>

<div class="Question" id="shaperequired">
<label><?php echo $lang["shaperequired"]?></label>
<select name="shape" class="stdwidth">
<option><?php echo $lang["portrait"]?></option><option><?php echo
$lang["landscape"]?></option><option selected><?php echo
$lang["either"]?></option>
</select>
<div class="clearerleft"> </div>
</div>

<?php if (file_exists("plugins/research_request.php")) { include
"plugins/research_request.php"; } ?>


<div class="QuestionSubmit">
<label for="buttons"> </label>
<input name="save" type="submit" value="&nbsp;&nbsp;<?php echo
$lang["sendrequest"]?>&nbsp;&nbsp;" />
</div>

</form>
</div>

<?php
include "../include/footer.php";

Kevin Moloney (cariocakev)

unread,
Jul 31, 2010, 10:24:48 PM7/31/10
to ResourceSpace
FYI, just tested with the stock, unaltered reasearch_request.php file
and had the same result. Corrupted general.php?

On Jul 31, 8:04 pm, "Kevin Moloney (cariocakev)"

Dan Huby

unread,
Aug 1, 2010, 2:07:01 PM8/1/10
to ResourceSpace


On 1 Aug, 03:24, "Kevin Moloney (cariocakev)" <k...@kevinmoloney.com>
wrote:
> > Fatal error: Call to undefined function ctype_alpha() in /www/
> > resourcespace/include/general.php on line 1535

Odd error. ctype_alpha is definitely a function:

http://uk.php.net/ctype_alpha

What version of PHP are you running?

Dan

Kevin Moloney (cariocakev)

unread,
Aug 1, 2010, 10:39:56 PM8/1/10
to ResourceSpace
RS is build 2022 and php is:

PHP 5.3.3 with Suhosin-Patch (cli) (built: Jul 30 2010 23:22:49)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Kevin Moloney (cariocakev)

unread,
Aug 1, 2010, 10:41:59 PM8/1/10
to ResourceSpace
FYI I tried the RS update through subversion. Now the error line is
1571, but it's the same line of code.

Perhaps there a config option on php I missed?

On Aug 1, 12:07 pm, Dan Huby <d...@montala.com> wrote:

Kevin Moloney (cariocakev)

unread,
Aug 2, 2010, 2:42:46 PM8/2/10
to ResourceSpace
So I reinstalled PHP 5.3.3 from source, and upgraded RS to 2024.
Running FreeBSD 8.1. No change, other than the line of code makes the
error: if (ctype_alpha($c))

Pretty big frustration as now a potential user has no way to request
resources, accounts or anything that depends on e-mail.

Would love at least some sleuthing suggestions for possible causes!

Best,

Kevin

Tom Gleason

unread,
Aug 2, 2010, 2:55:36 PM8/2/10
to resour...@googlegroups.com
if you type php -m on the command line you will get a list of php extensions...I assume your list does not include 'ctype'

This should be a standard extension and if it's not included in your php package you should notify the maintainers of that package if possible. I don't see any reason it shouldn't be included other than by error.

I did find this:

http://drupal.org/node/141550

which shows that it should be fairly easy to circumvent the need for this extension with a simple regex within a function replacement.


--
You received this message because you are subscribed to the Google Groups "ResourceSpace" group.
To post to this group, send email to resour...@googlegroups.com.
To unsubscribe from this group, send email to resourcespac...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/resourcespace?hl=en.




--
Tom Gleason, PHP Developer
DBA Impressive Design

Exploring ResourceSpace at:
http://resourcespace.blogspot.com

Kevin Moloney (cariocakev)

unread,
Aug 2, 2010, 4:37:14 PM8/2/10
to ResourceSpace
Hooray! That's why I love you guys.

I had no idea I should be looking for a ctype extension (I'm just not
that php literate).

Apparently it was a compile option on earlier versions but is no
longer. It's an installable extension and solved the problem.

So perhaps a Wiki suggestion: In the installation requirements list
you might add the required php extensions as well -- such as php5-
exif, php5-gd and now php5-ctype and any others -- for those of us
with distros that may not automatically include them.

Thanks a million,

Kevin
> > resourcespac...@googlegroups.com<resourcespace%2Bunsu...@googlegroups.com>
> > .
Reply all
Reply to author
Forward
0 new messages