Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


imgrooot last won the day on May 16 2018

imgrooot had the most liked content!

Community Reputation

1 Neutral

About imgrooot

  • Rank
    Advanced Member
  1. imgrooot

    subtract a month from a date()

    Here's how I would do it. // GET THE DATE FROM YOUR DATABASE TABLE $db_date = '12-08-2018'; // SUBTRACT DAYS FROM IT $get_date = DateTime::createFromFormat('Y-m-d H:i:s',$db_date); $get_date->modify('-30 days'); $new_date = $get_date->format('Y-m-d H:i:s'); // NEW DATE WILL BE YOUR ORIGINAL DATE MINUS 30 DAYS echo $new_date;
  2. imgrooot

    Is there a proper way to set this up?

    Well one of the things the person mentioned was that SERVER['DOCUMENT_ROOT'] doesn't work on all servers and that DIR is better for PHP >= 5.3.
  3. imgrooot

    Is there a proper way to set this up?

    Got it. And I actually read that on Stackoverflow.
  4. imgrooot

    Is there a proper way to set this up?

    Could you please explain how using "$_SERVER['PHP_SELF']" makes it XSS vulnerable? What do I use it in it's place instead?
  5. imgrooot

    Is there a proper way to set this up?

    I've read that not to use $_SERVER['DOCUMENT_ROOT'] Instead use define('PROJECT_ROOT', dirname(dirname(__FILE__))); $project_root = PROJECT_ROOT; So using that, it would look like this. require_once $project_root . '/core/init.php'; require_once $project_root . '/members/dashboard.php'; It seems to work fine now.
  6. imgrooot

    Is there a proper way to set this up?

    Ah yes that's exactly what I was looking for. I have a couple questions. 1. <?=APP_PREFIX?>. Is this the same as "<?php =APP_PREFIX ?>" ? 2. What is the reason for the = sign in =APP_PREFIX? 3. I want to include it in the include/require files like this. require_once '../core/init.php'; require_once '/members/dashboard.php'; How do I properly add the APP_PREFIX to the require_once above? I've tried different ways and i still get an error like this. define('APP_PREFIX', '/mysite'); $root_dir = APP_PREFIX; require_once "$root_dir/core/init.php"; Warning: require_once(/mysite/core/init.php): failed to open stream: No such file or directory Fatal error: require_once(): Failed opening required '/mysite/core/init.php' (include_path='C:\xampp\php\PEAR')
  7. imgrooot

    Is there a proper way to set this up?

    I get what you're saying but your method of leading slash doesn't work. For e.g. // CURRENT PAGE LOCATION: mysite/members/dashboard.php // YOUR METHOD <a href="/index">LINK</a> // RESULT localhost/index // WHAT I WANT IS localhost/mysite/index // I CAN ONLY GET THAT IF THE URL IS LIKE THIS <a href="../index">LINK</a> Maybe I'm just not getting your leading slash. Please do explain what I am doing wrong.
  8. imgrooot

    Is there a proper way to set this up?

    Here is my setup for the absolute URL. The normal a links seem to work fine and so are the includes/requires. But the scripts in the HEAD section of the site don't seem to load, even though the path is correct. define('PROJECT_ROOT', dirname(dirname(__FILE__))); $root_dir = PROJECT_ROOT; // THIS WOULD GET ME THE ROOT DIRECTORY OF MY SITE C:\xampp\htdocs\mysite // IF I INCLUDE IT IN THESE FILES <link href="<?php echo $root_dir; ?>/css/screen.css" media="screen" rel="stylesheet" /> <script src="<?php echo $root_dir; ?>/javascripts/jquery.js"></script> // I GET THIS ERROR IN THE INSPECT ELEMENTS WINDOW Not allowed to load local resource: file:///C:/xampp/htdocs/mysite/css/screen.css Not allowed to load local resource: file:///C:/xampp/htdocs/mysite/javascripts/jquery.js // IF USE RIGHT CLICK AND SEE THE PAGE SOURCE, THE PROJECT ROOT SLASHES ARE BACKWARDS LIKE THIS <link href="C:\xampp\htdocs\mysite/css/screen.css" media="screen" rel="stylesheet" /> <script src="C:\xampp\htdocs\mysite/javascripts/jquery.js"></script> So what do you think is going on?
  9. imgrooot

    Is there a proper way to set this up?

    I'm sorry but your post does not show how to get an absolute URL. I did some digging and found one of the posts here. https://stackoverflow.com/questions/6511496/how-to-generate-absolute-url-path-to-a-script-file I will try the absolute URLs based on their examples.
  10. Say I have two areas of a website. 1 - root directory (index, sign up, sign in) 2 - folders (this would contain folders such as snippets, members, assets) Due to the nature of the folders, the links cannot be the same as they are on the pages in the root directory. Index page for example. So if I'm on members/dashboard.php, any a links linking to index.php, will have to have "../" in front of them. To solve the issue, my current set up is like this. But I understand it's not the most efficient way to do this. I was wondering if you can share your expertise for a better method. $currentPage = basename($_SERVER['PHP_SELF'], ".php"); <?php if($currentPage == 'index' || $currentPage == 'members') { ?> <!DOCTYPE HTML> <head> <meta charset="UTF-8"> <title></title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="description" content=""> <link rel="shortcut icon" href="images/favicon.ico.png"> <link href="css/screen.css" media="screen" rel="stylesheet" /> </head> <body> <a href="index"> <img src="images/logo.PNG" alt="logo" /> </a> </body> <?php } else { ?> <!DOCTYPE HTML> <head> <meta charset="UTF-8"> <title></title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="description" content=""> <link rel="shortcut icon" href="../images/favicon.ico.png"> <link href="../css/screen.css" media="screen" rel="stylesheet" /> </head> <body> <a href="../index"> <img src="../images/logo.PNG" alt="logo" /> </a> </body> <?php } else { ?>
  11. So in your opinion, which method is better to use? The $_COOKIE method I used above or a $_SESSION one?
  12. Because if I'm not mistaken, the SESSION only lasts until you close the browser. I want to use the COOKIES so that the referral name is saved for up to a year, unless someone deletes their browser cookies or uses a different referral link.
  13. Of course it was that simple. I should have thought of that. It works like a charm now. Thanks again.
  14. Not sure if I understand you correctly. But I have found a fix around. Instead of having the referral link go directly to the sign up page, I instead link it to the home page. Like this "www.mysite.com/?ref=johnsmith". This way when the user goes to the sign up page, the cookie will already be set. I tried it and it seems to work fine.

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.