Jump to content

MrGary

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MrGary's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, is there any way to check if the cookies are enabled by the user's browser rather than storing a cookie and hoping the user is gonna refresh the page so we can test if something is set in the $_COOKIE variable?? I've tried on my localhost, it seems that there are two default cookies (when cookies are enabled) __utma and __utmz, and when the cookies are disabled, the $_COOKIE variable is empty, is that by default in PHP?? Can I rely on that? Enable cookies and test the result of <?php print_r(var_dump($_COOKIE)); ?> Disable cookies and test the same page, do you get the same results as me? Thanks
  2. Hello, I can't find those or mr. Google, can anyone please help me to find them? the tags that can be included in HTML and deciphered by PHP as a PHP code <if> <else> <elseif> etc.. Thanks
  3. Nevermind, but eval() isn't used for debugging only... Many big softwares use it in their code and it's in many cases the only possible way to do things... Thanks anyway
  4. Oh it worked I did this : <?php $code = 0; $return = get_function_code("Plugin_Name", "Method_Name"); /* "Plugin_Name" is the class of my plugin, "Method_Name" is the name of my method.. get_function_code() returns the code of the method "Method_Name" of the class "Plugin_Name" */ eval("$return;"); echo $code; //echo'd 1 ?> Tadaaaa
  5. I did that I feel so proud of me, actually I'm building a new way of implementing plugins into a script... that consists of methods and hooks... You program your method EXACTLY AS IF you were programming in the core (no need to get parameters or anything), and then you just add your function to the hook you want it to be implemented in for example : If my core code is : <?php $code = 0; run_hooks("hook_here"); echo $code; ?> And now let's say that I want to create a plugin that increments the $code variable before the output, I will just and put in the plugin : <?php function install() //this is the function called while the install { add_hook("hook_here", "function_1"); //adding the function_1() to the "hook_here"... } /* The problem is, I need to do something like $code = function_1() to increment it... because calling function_1() only won't increment the $code variable, or I need to pass it by reference which is deprecated and complex */ /* So I will do : */ function function_1() { //exactly as if I were programming directly in the core $code++; } ?> run_hooks() gets the code of the functions added, and eval() it directly in the core... So you don't edit any core files, and you don't create complex HOOKS Anyway, thank you everyone
  6. Hello, I just wanted to know if it was possible to get the code of a function created inside a PHP file, for example : <?php function test() { $var = 0; echo $var++; } ?> I want to get the code inside the function, means : <?php $string = function_get_content("test"); /* $string = "$var = 0; echo $var++;" */ ?> Is that possible in any way? I believe that I'd have to analyze the page's code :s Thanks in advance..
  7. It's still all messy, I'm still building the code so you can say that the current code is going to change many times before I release it.. Can I send it to you by PM please? I don't want to make it public in here
  8. The Class "Comment" creates an object, than checks that all what the user has typed is SQL injection free / Javascript injection free etc (needs the variable $database to "escape" SQL injection"... Checks that it respects the maximum number of characters defined by the administrator (needs the variable $settings that contains all the admin settings that have been extracted from the database to avoid multiple calls to the db)... And gets the author's IP address's ID (ID in the database to avoid storing IP Addresses everywhere), so it needs the object $ip... It also verifies that the page we're willing to add a comment on accepts new comments (need the object $page to check that) The same class (Comment) has a method to display the comment (display_comment()) that needs the $template variable to do that... All this avoids multiple callings to database... Well for arguments we need all what contributes to building a comment, "subject" "message" "author's website" "author's email" "author's username" "date of creation" etc... Am I doing anything wrong?
  9. BASE_URL isn't a PHP constant, I don't know how it has been defined in your code but I think that it refers to the "URL" to your script which is : "localhost/ICU" So I guess that it may work if you do : $url = "http://".BASE_URL."/index.php";
  10. If your "index.php" file is in the same folder, why don't you use $url = "./index.php";
  11. There's never a need to use 'global'. Argument lists exist for a reason. It's especially egregious to use 'global' in an OOP setting, as it creates a hidden link to an outside context, thereby coupling the object to its environment. Simply put, if you're using 'global', you're doing it wrong. I'm sorry to bring this topic back again but, do you really mean that "global" shouldn't be used in OOP methods? Sometimes I need a lot of global variables, if I pass them as arguments it would make my class look ugly, (20+ arguments for one method)... Usually I need the $database, $template, $language, $settings variables which are elementary for many classes... "global" makes it a lot easier, can you please tell me why it's not a good thing to use "global" in OOP methods? Because even in PHP documentation, they use that : http://php.net/manual/en/language.variables.scope.php Thank you
  12. Thank you very much for your answer Where should I place the hooks that should be ran? for example run_hook("hook_here); that will run all the hooks that are placed in "hook_here"
  13. I still can't understand how I implement "hooks" in my script.. Any advices?
  14. Hello, Thank you very much for replying, I've read a little bit about hooks and I want you please to correct me if I'm wrong : - there should be a function "add_hook()" that allows plugin developers to add another function to a placement in the script - there should be multiple hook placements in the script to allow plugin developers add their code where they need. Can I know where exactly I am supposed to add those "hook placements" in the code? (for example, before every HTML output, before SQL calls etc..?) or it's something I can decide based on how & where I want the plugins to work ? Thanks
  15. Hello everyone, I'm in the process of creating a PHP script (will be open-source), I just need to know how to make it easy for people to add plugins? Like I don't really know much about the concept of plugins (how they should work), all I know is that there should be a function to activate / deactivate the plugin, but how can I make it possible for people to run their "code" wherever they want? I've heard about "hooks" but I don't really understand how this should work, anyone can explain please? Thank you very much in advance
×
×
  • 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.