Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Frank_b last won the day on October 14 2014

Frank_b had the most liked content!

Community Reputation

7 Neutral

About Frank_b

  • Rank
    Advanced Member
  1. Sorry i did not read al of your code but it seems to be more complex then needed. First about IP-banning. If you use ip banning instead of user banning please do realise that you could ban a complete officebuilding of hospital ! Otherwise mobile devices are switching ip's many times. I always say: forget this whole IP-shit! that said, Did you ever try to use the DateTime and DateInterval standard PHP objects? <?php $last = new DateTime('2015-1-26 11:53:12'); $now = new DateTime(); $diff = $now->diff($last); echo 'Difference is:<br>'; if($diff->y) echo $diff->y . ' years<br>'; if($diff->m) echo $diff->m . ' months<br>'; if($diff->d) echo $diff->d . ' days<br>'; if($diff->h) echo $diff->h . ' hours<br>'; if($diff->i) echo $diff->i . ' minutes<br>'; if($diff->s) echo $diff->s . ' seconds<br>'; ?>
  2. Most simple is an include() Or use Twig or Blade template engines.
  3. AJAX means that the javascript makes a request to the webserver. (javascript runs in the browser of the client). after the call it waits on an answer. This answer comes as a variable (which can be an object) in javascript. There will be no new page loaded. But you can overwrite some content of the page (for example a <div>) with javascript using the data that comes back from the webserver. The request to the webserver can be handled by a php script. For the transportation of data (think about more than one variabele) programmers often use JSON these days. I recommand that you look for some examples on the internet with JSON and AJAX to understand this methods
  4. if you use the POST method there will never be a GET generated unless you change the action tag to something like action="send.php?s=1". You could do this with javascript but it is unlogic. I should do something like this: <form action="" method="POST "> the empty action tag will hold the user on one and the same page. you can use $_SERVER['REQUEST_METHOD'] to test if the form has been posted. after it is you can validate the form. if there is something wrong (like no email) then you just let the page load again (with an error message). if everything is alright then you send your email and after that you can redirect the page to another page like 'thankyou.php' with this snippet <?php header('Location: thankyou.php'); exit; ?> aware that there may not be any output before you send headers
  5. You are in the right direction. i think you have to debug a bit. For example echo your queries to see if they are allright. Are you sure that you can read the temporarily file? Or do you need to move it first?
  6. 1. store the images outside your documentroot. 2. Use sessions to remember who may download and who doesn't 3. Use a PHP script to download the images: get_image.php: <?php if(!isset($_GET['filename'])) { header("HTTP/1.0 404 Not Found"); echo 'no filename received!'; exit; } session_start(); if(!isset($_SESSION['may_download']) || (isset($_SESSION['may_download']) && $_SESSION['may_download'] === FALSE)) { header('HTTP/1.0 401 Unauthorized'); echo 'This content is not available for you.'; exit; } $path = '/var/www/private/images/' . $_GET['filename']; if(!file_exists($path)) { header("HTTP/1.0 404 Not Found"); echo 'filename does not exist!'; exit; } // output the image header("Content-Type: image/jpg"); header("Content-Length: ". filesize($path)); header("Content-Disposition: attachment; filename=". $_GET['filename']); echo file_get_contents($path); ?> To download an image: http://yourdomain.com/get_image.php?filename=picture1.jpg To show the image in a HTML page: <!DOCTYPE html> <html> <head> <title>something</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div><img src="get_image.php?filename=picture1.jpg" alt="picture1" /></div> </body> </html>
  7. you wrote option instead of options
  8. fourth: if u still dont get your email (check your spam also) then you might try to send a very simple email like this: mail('myself@myhost.com','Test mail', 'Just a test...'); If then there is still no email then you have to contact your provider. Maybe they blocked the email() function of maybe you have to send your email through a SMTP server. In that case you could use a library like PHPMailer or Swiftmailer.
  9. first of all: place a echo 'test'; just above the mail() function so that you are sure that your code reaches this part of code. second: remove that @ before the mail function. Don't you want to be informed if an error occurs?? third: give an error if the mail function returns a FALSE. if(mail(...) === FALSE) echo 'Sorry your email could not be sent.';
  10. The icons are not a problem. $items = array( '<i class="fa fa-dashboard fa-3x"></i> Dashboard' => 'dashboard', ); The submenus do make it more complex. You could use this example: http://www.phpf1.com/download.html?dl=21
  11. use a array and a loop to echo your <ul>: $items = array( 'Login' => 'login', 'Dashboard' => 'dashboard', 'Page two' => 'page-two', 'Page three' => 'page-three', ); echo '<ul>'; foreach($items as $title => $basename) { $class = ''; if($p == $basename) $class = ' class="active"'; echo '<li><a'.$class.' href="index.php?p='.$basename.'">'.$title.'</a></li>'; } echo '</ul>';
  12. Exactly, it does not make any sense. Do not think too difficult! Even if you store the mysql username and password in a normal accessible .php file then normal http users will not be able to read the code in the .php file. So the options mentioned above is allready a little extra security. And as ginerjm mentioned above it is much more important to use strong password protection for other protocols like SSH and FTP because that are main entrances! (Think about locking all the windows from the house but forget to close your frontdoor )
  13. I do not understand what an emailing class has to do with the creation of a new contract.. What i do know is that users do not think about relations and jointables. They want a userfriendly application and press buttons and write forms as less as possible. With that reason in mind i would give the people/{person-id} page a button 'Add contract' what would bring the user to the people/{person-id}/create-new-contract page. There you will need to show a form just to add a new contract. On the background you do allready know for who this new contract will be. And of course as for any form you will need to accept a GET and a POST method. The GET method will just show a new empty form and the POST method will validate input and if validated insert a new record into the table(s). In this case it would insert a record to the contracts table AND insert a record to the JOIN table both. A full working system has four actions per table: CREATE, READ, UPDATE and DELETE. (CRUD). You did not add any actions for READ and DELETE until now. Besides this four actions you could give a fifth action for many-to-many relations: change the relation. Think about this scenario: One College stops working into your company because he or she accepted another job. Now the contracts need to be moved to another college... You will need to make an administration tool for that too.
  14. I prefer to store it outside the documentroot of your website. So in case your documentroot is /var/www/html then i should maybe store it in /var/www/config/config.php. Another possibility is to store it in a subdirectory of the documentroot and protect it by an .htaccess file with the content Deny from All If you are using apache 2.4 then it should be Require all denied
  15. and your problem is? do you get any errors? if you dont see errors: enter this at the beginning of your code: error_reporting(E_ALL); ini_set('display_errors', '1');
  • 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.