Jump to content

AbstractFire

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

AbstractFire's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok. Let me try this again since I wasn't thinking straight before. I want to use Heredoc Syntax in my application. The problem is using it in multiple classes and trying to add to it. I have a main class that I use for database connection and other things and that is where I want to keep my variable that holds the HTML until I print it. One example is that I am in a different class editing a user and want to add to the current code using heredoc. $this->mainclass->html .= <<<EOF Blah blah. EOF; Problem is when I tried this, it didn't work. What do I need to do?
  2. So I discovered heredoc syntax recently (<<<EOF blah blah EOF;) and I want to be able to use it. Problem is that I have multiple classes (a member management class, group management, skin templates, etc.) and I want to know I can make this work across classes and such. $this->afscore->html = <<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Language" content="en-us" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Admin CP</title> <link rel="stylesheet" type="text/css" href="{$SOURCEPATH}stylesheet_global.css" /> <link rel="stylesheet" type="text/css" href="{$SOURCEPATH}stylesheet_menubar.css" /> <script type="text/javascript" src="sources/admin_source/menubar.js"></script> </head> <body> <!--End of Header--> EOF; The code above is part of my template class. afscore is the main class. But, if I'm in another class, It doesn't work right.... I hope I made enough sense here for someone to help me ><
  3. I recently rewrote my a login script so that the possibility of an SQL injection is diminished. However, I now have a new issue that I have come across. Since I now compare the username in php rather than in a query, how can I make it so that it compares 2 strings regardless of case and returns true if they match?
  4. fixed... I was missing $this when calling the functions in the classes.
  5. ok scrap my last post I just need to know how to make other classes aware of the other classes so that I can use them with on top of each other. I have them all included and instantiated in the main wrapper, but if I call another classes function from within another function, I have a fatal error.
  6. Alright, well I guess I better post a little bit more to see if you guys can help me pin point the problem further. admin.php <?php /* + -------------------------------------------------- | AFS: Personal Blog - Version 1.0 Alpha | (c) AbstractFire - 2007 | Admin CP Main Wrapper Script + -------------------------------------------------- | Wrapper Revision 14$ | Last Edited on: 2007-05-06 | Edited by : + -------------------------------------------------- */ // =============================================== // Path to all files needed // =============================================== $sourcepath = "sources/admin_source/"; // =============================================== // Fetch the Main Function Class and the Admin // Function Class - Define them too... // =============================================== require("sources/class_main.php"); $mainfunct = new class_main(); require($sourcepath . "class_afunct.php"); $acpfunc = new class_afunct(); // =============================================== // Important Concept - Connect to the DB Now // =============================================== $mainfunct->DatabaseConnect(); // =============================================== // Now to fetch and include the required ACP items // =============================================== require($sourcepath . "session.php"); require($sourcepath . "session_open.php"); // =============================================== // Page Array // =============================================== $page_array = array(NULL, 'idx', 'useraction', 'useradd', 'userform', 'userinsert', 'usermanage'); // =============================================== // Wrapper - Header // =============================================== require($sourcepath. "header.php"); // =============================================== // Wrapper - Page Includes // =============================================== if ($_GET['acpsection'] != "") { $page = htmlentities($_GET['acpsection'], ENT_QUOTES); $page_search = array_search($page, $page_array); if($page_search == FALSE) { $mainfunct->acpError("This page is not part of the ACP."); } $page = $sourcepath . $page . ".php"; if (file_exists($page)) { include($page); } else { $mainfunct->acpError("This page which you are trying to access does not exist."); } } else { include $sourcepath . "idx.php"; } // =============================================== // Wrapper - Footer // =============================================== require($sourcepath. "footer.php"); ?> $mainfunct is the general class that does the DB connecting and SQL Injection Escape. small section of class_afunct I'm trying to use. section of $class_afunct: <?php /* + -------------------------------------------------- | AFS: Personal Blog - Version 1.00 Alpha | (c)AbstractFire - 2007 | Admin CP Function File + -------------------------------------------------- | Revision Status: 12$ | Last Edited on: | Edited by : + -------------------------------------------------- */ class class_afunct { // =============================================== // Constructor // =============================================== function class_afunct() { } // =============================================== // General Message // =============================================== function acpMessage($txt) { require("session.php"); ?> <table border="0"> <tr> <td><img src="images/message.gif" alt="" /></td> <td><h1>Personal Blog Message</h1></td> </tr> <tr> <td></td> <td><?php echo $txt; ?></td> </tr> </table><br /> <?php require("footer.php"); exit(); } } ?> And here is a small section of class_user. <?php /* + ------------------------------------------------- | AFS: Personal Blog - Version 1.00 Alpha | (c)AbstractFire - 2007 | Add/Edit Member Check Functions + ------------------------------------------------- | Created on 16 Feb, 2007 2250 GMT -6 | Last Revised by: AF$ | Date of Revision: 2007-05-09 + ------------------------------------------------- */ class class_user { var $acpfunc; // =============================================== // Constructor // =============================================== function class_user() { include_once("class_afunct.php"); // Says cannot instantiate if using include_once and cannot redeclare if using include $this->$acpfunc = new acpfunc(); } // =============================================== // Check the username for the requirements // =============================================== function checkUsername($input) { $usrtest = mysql_query("SELECT username FROM mcp_logindata WHERE username = '$input'"); // =============================================== // Length of the username // =============================================== if(strlen($input)<4) { $acpfunc->acpMessage("Usernames need to have at least 4 characters."); } // =============================================== // In use yet? // =============================================== elseif($account=mysql_fetch_assoc($usrtest)) { $acpfunc->acpMessage("An account with this username already exists. Please select another one."); } } } ?> Hopefully this is a bit better to pin point the problem.
  7. Fatal error: Cannot redeclare class class_afunct in /home/*****/public_html/sources/admin_source/class_afunct.php on line 0 include_once did not get me anywhere and gave me the same message. Changed it to include I get this now in the constructor....
  8. Nothing. You can name the script whatever you like. Did you try include_once() to get rid of your last error? Yes. Still the same.
  9. What would that exactly do for the script?
  10. the name of the file is class_user.php Sorry if that wasn't clarified.
  11. Fatal error: Cannot instantiate non-existent class: acpfunc in /home/*****/public_html/sources/admin_source/class_user.php on line 23 acpfunc is included in admin.php which is in public_html. However, when I try to include it: Fatal error: Cannot redeclare class class_afunct in /home/*****/public_html/sources/admin_source/class_afunct.php on line 0
  12. Would I put both in the class to make work on php4 and 5?
  13. how would I use _construct() exactly? And I kinda wish for this script to work on php4 or php5, not be php5 exclusive. frost110: I made a mistake, its line 28. Which is $acpfunc->acpMessage("Usernames need to have at least 4 characters.");
  14. Hi all... I could use some help with this error I am getting. This is the error I am getting: Fatal error: Call to a member function on a non-object in /home/*****/public_html/sources/admin_source/class_user.php on line 35 This is class_user.php: <?php /* +------------------------------------------------- | AFS: Personal Blog Alpha | (c)AbstractFire - 2007 | Add/Edit Member Check Functions +------------------------------------------------- | Created on 2007-05-01 2250 GMT -6 | Last Revised by: AF$ | Date of Revision: 2007-05-07 +------------------------------------------------- */ class class_user { // =============================================== // Check the username for the requirements // =============================================== function checkUsername($input) { $usrtest = mysql_query("SELECT username FROM mcp_logindata WHERE username = '$input'"); // =============================================== // Length of the username // =============================================== if(strlen($input)<4) { $acpfunc->acpMessage("Usernames need to have at least 4 characters."); } // =============================================== // In use yet? // =============================================== elseif($account=mysql_fetch_assoc($usrtest)) { $acpfunc->acpMessage("An account with this username already exists. Please select another one."); } } // =============================================== // Check passwords for requirements // =============================================== function checkPasswords($password1, $password2) { // =============================================== // Check the passwords to see if they are equal // =============================================== if ($password1 != $password2) { $acpfunc->acpMessage("A problem was detected with the passwords you provided. Your passwords do not match."); } // =============================================== // Check the length of it now // =============================================== elseif (strlen($password1) < 6) { $acpfunc->acpMessage("A problem was detected with the password you provided. Passwords must be 6 characters in length."); } } // =============================================== // Check the email address now // =============================================== function checkEmail($input) { if (!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+([a-zA-Z0-9\._-] +)+$/" , $input)) { $acpfunc->acpMessage("You provided an invalid email address"); } } } ?> $acpfunc is declared in admin.php, which is located in the public_html folder. $acpfunc is another class I created that has functions specific for the ACP. IN admin.php: require("sources/admin_source/class_afunct.php"); $acpfunc = new class_afunct(); A little further down in admin.php, I have a little section that includes; the page that has the form that submits to userinsert.php. userinsert.php has class_user included and setup. I know this may not make much sense right now. Sorry. Thank you for any help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.