PDA

View Full Version : unexpected T_CONSTANT_ENCAPSED_STRING


adamlaher
11-17-2007, 06:10 PM
hey
i am getting this message.

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/adam07/public_html/forum/alice/src/admin/dbprefs.php on line 51

The code is

<?php

/*
Program E
Copyright 2002, Paul Rydell

This file is part of Program E.

Program E is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Program E is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Program E; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

//Disable Error Reporting Since this code needs alot of work to become completely clean and error free under stict php setups.
//error_reporting(0);

# Turn this off in case people have it on.
set_magic_quotes_runtime(0);

# Can't turn off magic quotes gpc so just redo what it did if it is on.
if (get_magic_quotes_gpc()) {
foreach($_GET as $k=>$v)
$_GET[$k] = stripslashes($v);
foreach($_POST as $k=>$v)
$_POST[$k] = stripslashes($v);
foreach($_COOKIE as $k=>$v)
$_COOKIE[$k] = stripslashes($v);
}


define("LOOPINGERRORMSG", "Oops. I wasn't paying attention. Tell me again what is going on.");
define("LOOPINGLIMIT",75); // -1 for no limit
define("RANDOMCHANCECLEAN",200); // -1 to never check
define("MINUTESTOKEEPDATA",300); // -1 to keep forever

# This is where all the AIML and startup.xml resides
$rootdir= "http://www.virtualchat.ej.am/forum/alice/aiml/";

require('http://www.virtualchat.ej.am/forum/includes/config.php');

$DB_HOST=$config['MasterServer']['servername'] "localhost";
$DB_UNAME=$config['MasterServer']['username'] "adam07_chat";
$DB_PWORD=$config['MasterServer']['password'] "liverpool21";
$DB_DB=$config['Database']['dbname'] "adam07_vitrual";

$boterrors="";
mysql_connect($DB_HOST,$DB_UNAME,$DB_PWORD) or $boterrors = $boterrors . "Could not connect to database.\n";
@mysql_select_db($DB_DB) or $boterrors = $boterrors . "Unable to select database\n";
?>

I cant figure out the problem so could someone help me,thanks

CFMaBiSmAd
11-17-2007, 06:21 PM
The syntax on the following four lines has no meaning -
$DB_HOST=$config['MasterServer']['servername'] "localhost";
$DB_UNAME=$config['MasterServer']['username'] "adam07_chat";
$DB_PWORD=$config['MasterServer']['password'] "liverpool21";
$DB_DB=$config['Database']['dbname'] "adam07_vitrual";My guess is that you started with the following -
$DB_HOST= "localhost";
$DB_UNAME= "adam07_chat";
$DB_PWORD= "liverpool21";
$DB_DB= "adam07_vitrual";and failed to remove the original quoted string values when you added the array references?

adamlaher
11-17-2007, 06:32 PM
now i am getting this error

Warning: require() [function.require]: URL file-access is disabled in the server configuration in /home/adam07/public_html/forum/alice/src/admin/dbprefs.php on line 49

Warning: require(http://www.virtualchat.ej.am/forum/includes/config.php) [function.require]: failed to open stream: no suitable wrapper could be found in /home/adam07/public_html/forum/alice/src/admin/dbprefs.php on line 49

Fatal error: require() [function.require]: Failed opening required 'http://www.virtualchat.ej.am/forum/includes/config.php' (include_path='.:/software/php/lib/php') in /home/adam07/public_html/forum/alice/src/admin/dbprefs.php on line 49

i did that so it looks like this

<?php

/*
Program E
Copyright 2002, Paul Rydell

This file is part of Program E.

Program E is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Program E is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Program E; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

//Disable Error Reporting Since this code needs alot of work to become completely clean and error free under stict php setups.
//error_reporting(0);

# Turn this off in case people have it on.
set_magic_quotes_runtime(0);

# Can't turn off magic quotes gpc so just redo what it did if it is on.
if (get_magic_quotes_gpc()) {
foreach($_GET as $k=>$v)
$_GET[$k] = stripslashes($v);
foreach($_POST as $k=>$v)
$_POST[$k] = stripslashes($v);
foreach($_COOKIE as $k=>$v)
$_COOKIE[$k] = stripslashes($v);
}


define("LOOPINGERRORMSG", "Oops. I wasn't paying attention. Tell me again what is going on.");
define("LOOPINGLIMIT",75); // -1 for no limit
define("RANDOMCHANCECLEAN",200); // -1 to never check
define("MINUTESTOKEEPDATA",300); // -1 to keep forever

# This is where all the AIML and startup.xml resides
$rootdir= "http://www.virtualchat.ej.am/forum/alice/aiml/";

require('http://www.virtualchat.ej.am/forum/includes/config.php');

$DB_HOST= "localhost";
$DB_UNAME= "adam07_chat";
$DB_PWORD= "liverpool21";
$DB_DB= "adam07_vitrual";

$boterrors="";
mysql_connect($DB_HOST,$DB_UNAME,$DB_PWORD) or $boterrors = $boterrors . "Could not connect to database.\n";
@mysql_select_db($DB_DB) or $boterrors = $boterrors . "Unable to select database\n";
?>

_Aerospace_Eng_
11-17-2007, 06:35 PM
Your server does have url_fopen_wrappers turned on so you can't use includes from another server though it looks like it might be a mistake. Change this
require('http://www.virtualchat.ej.am/forum/includes/config.php');
to this
require('forum/includes/config.php');

adamlaher
11-17-2007, 06:39 PM
error again

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/adam07/public_html/forum/alice/src/admin/dbprefs.php on line 51

i did this


<?php

/*
Program E
Copyright 2002, Paul Rydell

This file is part of Program E.

Program E is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Program E is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Program E; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

//Disable Error Reporting Since this code needs alot of work to become completely clean and error free under stict php setups.
//error_reporting(0);

# Turn this off in case people have it on.
set_magic_quotes_runtime(0);

# Can't turn off magic quotes gpc so just redo what it did if it is on.
if (get_magic_quotes_gpc()) {
foreach($_GET as $k=>$v)
$_GET[$k] = stripslashes($v);
foreach($_POST as $k=>$v)
$_POST[$k] = stripslashes($v);
foreach($_COOKIE as $k=>$v)
$_COOKIE[$k] = stripslashes($v);
}


define("LOOPINGERRORMSG", "Oops. I wasn't paying attention. Tell me again what is going on.");
define("LOOPINGLIMIT",75); // -1 for no limit
define("RANDOMCHANCECLEAN",200); // -1 to never check
define("MINUTESTOKEEPDATA",300); // -1 to keep forever

# This is where all the AIML and startup.xml resides
$rootdir= "http://www.virtualchat.ej.am/forum/alice/aiml/";

require('forum/includes/config.php');

$DB_HOST=$config['MasterServer']['servername'] "localhost";
$DB_UNAME=$config['MasterServer']['username'] "adam07_chat";
$DB_PWORD=$config['MasterServer']['password'] "liverpool21";
$DB_DB=$config['Database']['dbname'] "adam07_vitrual";

$boterrors="";
mysql_connect($DB_HOST,$DB_UNAME,$DB_PWORD) or $boterrors = $boterrors . "Could not connect to database.\n";
@mysql_select_db($DB_DB) or $boterrors = $boterrors . "Unable to select database\n";
?>

CFMaBiSmAd
11-17-2007, 06:59 PM
The last posted error is EXACTLY the same problem as in the first post, because the code on those lines is exactly back to what it was before.

PHP is a programming language. If you don't have the knowledge to read and understand what the code means or know what you are changing in the code, then you should not be attempting this.

Start by buying and reading a PHP book or two, find and read some basic php tutorials http://w3schools.com/php/default.asp , and the php programming language reference manual is invaluable - http://www.php.net/docs.php

adamlaher
11-17-2007, 07:14 PM
could you just tell me what i need to do
i have tried the above think but still getting


Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/adam07/public_html/forum/alice/src/admin/dbprefs.php on line 51

_Aerospace_Eng_
11-17-2007, 07:34 PM
Post your updated code. And if you aren't going to take the time to learn how to overcome your issues on your own then maybe you shouldn't be coding.

adamlaher
11-17-2007, 07:36 PM
<?php

/*
Program E
Copyright 2002, Paul Rydell

This file is part of Program E.

Program E is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Program E is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Program E; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

//Disable Error Reporting Since this code needs alot of work to become completely clean and error free under stict php setups.
//error_reporting(0);

# Turn this off in case people have it on.
set_magic_quotes_runtime(0);

# Can't turn off magic quotes gpc so just redo what it did if it is on.
if (get_magic_quotes_gpc()) {
foreach($_GET as $k=>$v)
$_GET[$k] = stripslashes($v);
foreach($_POST as $k=>$v)
$_POST[$k] = stripslashes($v);
foreach($_COOKIE as $k=>$v)
$_COOKIE[$k] = stripslashes($v);
}


define("LOOPINGERRORMSG", "Oops. I wasn't paying attention. Tell me again what is going on.");
define("LOOPINGLIMIT",75); // -1 for no limit
define("RANDOMCHANCECLEAN",200); // -1 to never check
define("MINUTESTOKEEPDATA",300); // -1 to keep forever

# This is where all the AIML and startup.xml resides
$rootdir= "http://www.virtualchat.ej.am/forum/alice/aiml/";

require('http://www.virtualchat.ej.am/forum/includes/config.php');

$DB_HOST=$config['MasterServer']['servername']'localhost';
$DB_UNAME=$config['MasterServer']['username']'adam07_chat';
$DB_PWORD=$config['MasterServer']['password']'liverpool21';
$DB_DB=$config['Database']['dbname']'adam07_vitrual';

$boterrors="";
mysql_connect($DB_HOST,$DB_UNAME,$DB_PWORD) or $boterrors = $boterrors . "Could not connect to database.\n";
@mysql_select_db($DB_DB) or $boterrors = $boterrors . "Unable to select database\n";
?>

_Aerospace_Eng_
11-17-2007, 07:42 PM
Sighs you have the same problem as stated already. DO NOT DO THIS
$DB_HOST=$config['MasterServer']['servername']'localhost';
$DB_UNAME=$config['MasterServer']['username']'username';
$DB_PWORD=$config['MasterServer']['password']'password';
$DB_DB=$config['Database']['dbname']'dbname';
Just do this
$DB_HOST=$config['MasterServer']['servername'];
$DB_UNAME=$config['MasterServer']['username'];
$DB_PWORD=$config['MasterServer']['password'];
$DB_DB=$config['Database']['dbname'];
If that doesn't work which I'm guessing it probably won't try this
$DB_HOST='localhost';
$DB_UNAME='dbusernamehere';
$DB_PWORD='dbuserpasswordhere';
$DB_DB='databasenamehere';
You shouldn't probably leave your mysql connect information in your posts for security reasons.

And you STILL didn't change what we told you to. Don't do this
require('http://www.virtualchat.ej.am/forum/includes/config.php');
Try this instead
require('forum/includes/config.php');
What is the point of helping you if you aren't going to listen to our advice?

adamlaher
11-17-2007, 07:51 PM
nw am getin this error
i have done many edit to differerent php file and they have all been successful but this one has been a problem for me


Warning: require(forum/includes/config.php) [function.require]: failed to open stream: No such file or directory in /home/adam07/public_html/forum/alice/src/admin/dbprefs.php on line 49

Warning: require(forum/includes/config.php) [function.require]: failed to open stream: No such file or directory in /home/adam07/public_html/forum/alice/src/admin/dbprefs.php on line 49

Fatal error: require() [function.require]: Failed opening required 'forum/includes/config.php' (include_path='.:/software/php/lib/php') in /home/adam07/public_html/forum/alice/src/admin/dbprefs.php on line 49

_Aerospace_Eng_
11-17-2007, 07:55 PM
Change this
require('forum/includes/config.php');
to this
require($_SERVER['DOCUMENT_ROOT'].'/forum/includes/config.php');
If that doesn't work then make sure you have a folder called config.php file that is in an includes folder in a folder called forum.

adamlaher
11-17-2007, 07:58 PM
THANKYOU SO MUCH
if u were here,i would have gave u a big head and a long kiss,u have just made my day
it works,thanks alot mate,i owe you for this one

_Aerospace_Eng_
11-17-2007, 08:03 PM
Probably not much you can offer me but you're welcome anyways.

adamlaher
11-17-2007, 08:14 PM
one more error

Warning: opendir(http://www.virtualchat.ej.am/forum/alice/aiml/) [function.opendir]: failed to open dir: not implemented in /home/adam07/public_html/forum/alice/src/admin/botloaderfuncs.php on line 531

Warning: readdir(): supplied argument is not a valid Directory resource in /home/adam07/public_html/forum/alice/src/admin/botloaderfuncs.php on line 532

Warning: closedir(): supplied argument is not a valid Directory resource in /home/adam07/public_html/forum/alice/src/admin/botloaderfuncs.php on line 540

<?

/*
Program E
Copyright 2002, Paul Rydell
Portions by Jay Myers

This file is part of Program E.

Program E is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Program E is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Program E; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

function deletebot(){
$q="delete from bot";
$e = mysql_query($q);
if ($e){
}
$q="delete from patterns";
$e = mysql_query($q);
if ($e){
}
$q="delete from templates";
$e = mysql_query($q);
if ($e){
}
}

function getmaxwordid(){

$query="select max(id) from patterns";

$selectcode = mysql_query($query);
if ($selectcode){
if(!mysql_numrows($selectcode)){
return 1;
}
else{
while ($q = mysql_fetch_array($selectcode)){
return $q[0]+1;
}
}
}

}

function lockdatabase(){
$qlock=mysql_query("lock tables patterns write, templates write, bot write");
if ($qlock){
}
}

function upperkeysarray($testa){
$newtesta=array();
$newkeys=array_keys($testa);
for ($x=0;$x<sizeof($newkeys);$x++){
$newtesta[strtoupper($newkeys[$x])]=$testa[$newkeys[$x]];
}
return $newtesta;
}

function addtosubs($string){

global $fp;

fwrite($fp,$string);

}

function createsubfile(){

global $fp;

$fp = fopen ("subs.inc", "w+");

}

function findwordid($word,$parent){

$word=addslashes($word);
$query="select id,isend from patterns where word='$word' and parent=$parent";

$selectcode = mysql_query($query);
if ($selectcode){
if(!mysql_numrows($selectcode)){
return 0;
}
else{
while ($q = mysql_fetch_array($selectcode)){

if ($q[1]==1){
setnotend($q[0]);
}

return $q[0];
}
}
}
}

function findwordidstar($word,$parent){

if ($word=="*"){
$val=3;
}
elseif ($word=="_"){
$val=1;
}
$query="select id,isend from patterns where parent=$parent and word is null and ordera=$val";

$selectcode = mysql_query($query);
if ($selectcode){
if(!mysql_numrows($selectcode)){
return 0;
}
else{
while ($q = mysql_fetch_array($selectcode)){

if ($q[1]==1){
setnotend($q[0]);
}

return $q[0];
}
}
}
}

function setnotend($wordid){

$query="update patterns set isend=0 where id=$wordid";
$q=mysql_query($query);
if ($q){

}

}

function insertmysentence($mybigsentence){

global $wordidcounter;

$sentencepart="";

$newstarted=0;
$parent=0;

#Parse into invidividual words
#Use split
$allwords=split(" ",$mybigsentence);
$qadd="";
for ($x=0;$x<sizeof($allwords)+1;$x++){

# Last word in context
$lwic=0;

if ($x==sizeof($allwords)){
$word="";
}
else {
$word=$allwords[$x];
}

if (strtoupper($word)=="<INPUT>"){
$sentencepart="INPUT";
} elseif (strtoupper($word)=="<THAT>"){
$sentencepart="THAT";
} elseif (strtoupper($word)=="<TOPIC>"){
$sentencepart="TOPIC";
}

# Find out if it is the last word in its context
if ($x==(sizeof($allwords)-1)){
$lwic=1;
}
elseif ((strtoupper($allwords[$x+1])=="<THAT>") || (strtoupper($allwords[$x+1])=="<TOPIC>")){
$lwic=1;
}

if (($word!="*")&&($word!="_")){

if ($newstarted!=1){
$wordid=findwordid($word,$parent);
}

if (($wordid!=0) && ($newstarted!=1)){
$parent=$wordid;
}
else {

$newstarted=1;

$sword=addslashes($word);
$qadd.="($wordidcounter,'$sword',2,$parent,$lwic),";
$parent=$wordidcounter;
$wordidcounter++;
}
}
elseif (($word=="*")||($word=="_")){

if ($newstarted!=1){
$wordid=findwordidstar($word,$parent);
}

if (($wordid!=0) && ($newstarted!=1)){
$parent=$wordid;
}
else {

$newstarted=1;

if ($word=="*"){
$val=3;
}
elseif ($word=="_"){
$val=1;
}

$qadd.="($wordidcounter,null,$val,$parent,$lwic),";
$parent=$wordidcounter;
$wordidcounter++;
}
}
}

$qadd=substr($qadd,0,(strlen($qadd)-1));
$query="insert into patterns(id,word,ordera,parent,isend) values $qadd";

$qcode=mysql_query($query);
if ($qcode){
}

return $parent;

}


function insertmytemplate($idused,$template){

global $templatesinserted;

if (!templateexists($idused)){
$templatesinserted++;

$template=addslashes($template);
$query="insert into templates (id,template) values ($idused,'$template')";

$qcode=mysql_query($query);
if ($qcode){
}
}

}

function templateexists($idused){

$query="select id from templates where id=$idused";
$qcode=mysql_query($query);

if ($qcode){
if(!mysql_numrows($qcode)){
return false;
}
}

return true;

}

function startS($parser,$name,$attrs){

global $whaton,$startupwhich,$splitterarray,$inputarray,$genderarray,$personarray,$person2array;

$attrs=upperkeysarray($attrs);

if (strtoupper($name)=='LEARN') {
$whaton = 'LEARN';
}
if (strtoupper($name)=="GENDER"){
$startupwhich="GENDER";
}
elseif (strtoupper($name)=="INPUT"){
$startupwhich="INPUT";
}
elseif (strtoupper($name)=="PERSON"){
$startupwhich="PERSON";
}
elseif (strtoupper($name)=="PERSON2"){
$startupwhich="PERSON2";
}

if (strtoupper($name)=="PROPERTY"){
$q="insert into bot (name,value) values ('" . addslashes($attrs["NAME"]) . "','" . addslashes($attrs["VALUE"]) . "')";
$qcode=mysql_query($q);
if ($qcode){
}
}
elseif (strtoupper($name)=="SPLITTER"){
$splitterarray[]=$attrs["VALUE"];
}
elseif (strtoupper($name)=="SUBSTITUTE"){
if (trim($attrs["FIND"])!=""){
if ($startupwhich=="INPUT"){
$inputarray[]=array($attrs["FIND"],$attrs["REPLACE"]);
}
elseif ($startupwhich=="GENDER"){
$genderarray[]=array($attrs["FIND"],$attrs["REPLACE"]);
}
elseif ($startupwhich=="PERSON"){
$personarray[]=array($attrs["FIND"],$attrs["REPLACE"]);
}
elseif ($startupwhich=="PERSON2"){
$person2array[]=array($attrs["FIND"],$attrs["REPLACE"]);
}
}
}
}

function endS($parser,$name){
global $whaton;
if (strtoupper($name)=='LEARN') {
$whaton = '';
}
}

function handlemeS($parser, $data){
global $whaton, $learnfiles;
if (strtoupper($whaton)=="LEARN"){
if (trim($data)=="*"){
learnallfiles();
}
else {
array_push($learnfiles,trim($data));
}

}
}

function getbotvalue($name){

$q="select value from bot where name=" . addslashes($name);

$selectcode = mysql_query($q);
if ($selectcode){
if(!mysql_numrows($selectcode)){
return "undefined";
}
else{
while ($q = mysql_fetch_array($selectcode)){
return $q["value"];
}
}
}
}


function startElement($parser, $name, $attrs) {
global $whaton,$template,$pattern,$recursive,$topic;

if (strtoupper($name)=="CATEGORY"){
$whaton="CATEGORY";
}
elseif (strtoupper($name)=="TEMPLATE"){
$whaton="TEMPLATE";
$template="";
$recursive=0;
}
elseif (strtoupper($name)=="PATTERN"){
$whaton="PATTERN";
}
elseif ((strtoupper($name)=="THAT")&&(strtoupper($whaton)!="TEMPLATE")){
$whaton="THAT";
}
elseif (strtoupper($name)=="TOPIC"){
$whaton="TOPIC";
}

if ((strtoupper($whaton)=="PATTERN")&&(strtoupper($name)!="PATTERN")){


if (strtoupper($name)=="BOT"){

$attrs = upperkeysarray($attrs);
$pattern .= getbotvalue($attrs["NAME"]);

}
else{
$pattern .="<$name";

while (list ($key, $val) = each ($attrs)) {
$pattern .= " $key=\"$val\" ";
}

$pattern .= ">";
}

}
elseif ((strtoupper($whaton)=="TEMPLATE")&&(strtoupper($name)!="TEMPLATE")){

$template .="<$name";

while (list ($key, $val) = each ($attrs)) {
$template .= " $key=\"$val\" ";
}

$template .=">";
}
elseif (strtoupper($whaton)=="TOPIC"){

$attrs = upperkeysarray($attrs);
$topic=$attrs["NAME"];

}
}

function endElement($parser, $name) {

global $whaton,$pattern,$template,$recursive,$topic,$that;

if (strtoupper($name)=="TOPIC"){
$topic="";
}

if (strtoupper($name)=="CATEGORY"){
$template=trim($template);
$topic=trim($topic);
$that=trim($that);
$pattern=trim($pattern);

if ($that==""){
$that="*";
}
if ($topic==""){
$topic="*";
}
if ($pattern==""){
$pattern="*";
}


$mybigsentence="<input> $pattern <that> $that <topic> $topic";

$idused=insertmysentence($mybigsentence);

insertmytemplate($idused,$template);

print " ";
flush();

$pattern="";
$template="";
$that="";

}
else {
if ((strtoupper($whaton)=="PATTERN")&&(strtoupper($name)!="PATTERN")){
if (strtoupper($name)!="BOT"){
$pattern .="</$name>";
}
}
elseif ((strtoupper($whaton)=="TEMPLATE")&&(strtoupper($name)!="TEMPLATE")){
$template .="</$name>";
}
}

}

function handleme($parser, $data){
global $whaton,$pattern,$template,$topic,$that;

if (strtoupper($whaton)=="PATTERN"){
$pattern .= $data;
}
elseif (strtoupper($whaton)=="TOPIC"){
$topic .= $data;
}
elseif (strtoupper($whaton)=="THAT"){
$that .= $data;
}
elseif (strtoupper($whaton)=="TEMPLATE"){
$template .= $data;
}
}

function loadstartup(){

global $rootdir,$learnfiles;

print "<font size='3'>Loading startup.xml<BR></font>\n";
$learnfiles = array(); # This array will hold the files to LEARN

$file = $rootdir . "startup.xml";
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
xml_set_element_handler($xml_parser, "startS", "endS");
xml_set_character_data_handler ($xml_parser, "handlemeS");
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);

$learnfiles = array_unique ($learnfiles);

foreach ($learnfiles as $file) {
learn($file);
}

}

function learnallfiles(){
global $rootdir,$learnfiles;

$dir=opendir ($rootdir);
while ($file = readdir($dir)) {

if (substr($file,strpos($file,"."))==".aiml"){

$learnfiles[]=$file;
}
}

closedir($dir);
}

function learnstring($xmlstring){

set_time_limit(600);
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler ($xml_parser, "handleme");

if (!xml_parse($xml_parser, $xmlstring)) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}

xml_parser_free($xml_parser);
}

function learn($file){

global $rootdir;
set_time_limit(600);
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler ($xml_parser, "handleme");
print "<font size='3'>Loading data aiml file: $file<BR></font>\n";
flush();

if (strtoupper(substr($file,0,7))=="HTTP://"){
$file=$file;
}
else {
$file=$rootdir . $file;
}

if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}

while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
fclose($fp);
xml_parser_free($xml_parser);
}

# Start a timer
function ss_timing_start ($name = 'default') {
global $ss_timing_start_times;
$ss_timing_start_times[$name] = explode(' ', microtime());
}

# Stop a timer
function ss_timing_stop ($name = 'default') {
global $ss_timing_stop_times;
$ss_timing_stop_times[$name] = explode(' ', microtime());
}

# Get the timer value
function ss_timing_current ($name = 'default') {
global $ss_timing_start_times, $ss_timing_stop_times;
if (!isset($ss_timing_start_times[$name])) {
return 0;
}
if (!isset($ss_timing_stop_times[$name])) {
$stop_time = explode(' ', microtime());
}
else {
$stop_time = $ss_timing_stop_times[$name];
}
// do the big numbers first so the small ones aren't lost
$current = $stop_time[1] - $ss_timing_start_times[$name][1];
$current += $stop_time[0] - $ss_timing_start_times[$name][0];
return $current;
}

function unlocktables(){
$qlock=mysql_query("unlock tables");
if ($qlock){
}
}

function makesrphp($inarray,$sname){

$myphp="\$" . $sname . "search=array(\n";

for ($x=0;$x<sizeof($inarray);$x++){

$searchvar=cleanforsearch($inarray[$x][0]);

$beginsearch="";
$endsearch="";

if (substr($searchvar,0,1)==" "){
$beginsearch="\\b";
}
if ((substr($searchvar,strlen($searchvar)-1,1))==" "){
$endsearch="\\b";
}
$myphp.="\"/$beginsearch" . trim($searchvar) . "$endsearch/ie\",\n";

}

$myphp.=");\n";

$myphp.="\$" . $sname . "replace=array(\n";

for ($x=0;$x<sizeof($inarray);$x++){
$myphp.="\"myfunc('" . cleanforreplace($inarray[$x][1]) . "')\",\n";
}

$myphp.=");\n";
return $myphp;

}

function makesplitterphp($splitterarray){
$splitterphp="\$likeperiodsearch=array(\n";
for ($x=0;$x<sizeof($splitterarray);$x++){

$splitterphp.="\"" . $splitterarray[$x] . "\",\n";

}
$splitterphp.=");\n";

$splitterphp.="\$likeperiodreplace=array(\n";
for ($x=0;$x<sizeof($splitterarray);$x++){

$splitterphp.="\"" . "." . "\",\n";

}
$splitterphp.=");\n";

return $splitterphp;
}

function cleanforreplace($input){
$input=str_replace("\\","\\\\",$input);
$input=str_replace("\"","\\\"",$input);
$input=str_replace("'","\'",$input);
return trim($input);
}

function cleanforsearch($input){
$input=str_replace("\\","\\\\\\\\",$input);
$input=str_replace("\"","\\\"",$input);
$input=str_replace("'","\'",$input);
$input=str_replace("/","\/",$input);
$input=str_replace("(","\(",$input);
$input=str_replace(")","\)",$input);
$input=str_replace(".","\.",$input);
return $input;
}

function makesubscode(){

global $genderarray,$personarray,$person2array,$inputarray,$splitterarray;

$genderphp=makesrphp($genderarray,"gender");
$personphp=makesrphp($personarray,"firstthird");
$person2php=makesrphp($person2array,"firstsecond");
$inputphp=makesrphp($inputarray,"contract");
$splitterphp=makesplitterphp($splitterarray);

createsubfile();
addtosubs("<?\n");
addtosubs($genderphp);
addtosubs($personphp);
addtosubs($person2php);
addtosubs($inputphp);
addtosubs($splitterphp);
addtosubs("\n?>");

}

?>

_Aerospace_Eng_
11-17-2007, 08:18 PM
Same issue.
$rootdir= $_SERVER['DOCUMENT_ROOT']."/forum/alice/aiml/";
You REALLY need to start reading the manual. These are ALL VERY simple questions that can be answered if you just do a little research on your own. You have the internet. Use it. Google can help wonders.

adamlaher
11-17-2007, 08:58 PM
thanks alot now its complete
am really sorry but this has only happened on this occasion as i used to be 100% successful with my other hacks