Jump to content

Gandalf64

Members
  • Content Count

    20
  • Joined

  • Last visited

  • Days Won

    1

Gandalf64 last won the day on July 15 2017

Gandalf64 had the most liked content!

Community Reputation

2 Neutral

About Gandalf64

  • Rank
    Member
  • Birthday August 28

Profile Information

  • Gender
    Male
  • Age
    56
  1. I developed my own calendar and if I am understanding you correctly then you could do something like the following: protected function checkForEntry($calDate, $page = 'index.php') { $this->username = isset($_SESSION['user']) ? $_SESSION['user']->username : \NULL; $this->query = 'SELECT 1 FROM cms WHERE page=:page AND DATE_FORMAT(date_added, "%Y-%m-%d")=:date_added'; $this->stmt = static::pdo()->prepare($this->query); $this->stmt->execute([':page' => $page, ':date_added' => $calDate]); $this->result =
  2. I found this http://phpenthusiast.com/blog/how-to-autoload-with-composer link explaining Namespace and PSR-4 Autoloader to be pretty informative.
  3. I have a repository (actually a couple of repositories) on creating a calendar in php at https://github.com/Strider64 I basically start of the premise of have 7 rows as the calendar I want to display for it will cover the previous month days (Starting with the first week of the selected month) and continuing to fill in the days as needed which more than likely will cover future month's days.
  4. Here's my version -> <?php function IsPrime($n) { for ($x = 2; $x < $n; $x++) { if ($n % $x == 0) { return 0; } } return 1; } function isStrob($num) { $myNumber = str_split($num); for ($i = 0; $i <= count($myNumber) / 2; $i++) { $c = $myNumber[$i]; $b = $myNumber[count($myNumber) - 1 - $i]; if (!isValid($c, $b)) { return FALSE; } } return TRUE; } function isValid ($c, $b) { switch ($c) { case '1': return $b == '1'; case '6': return $b
  5. Or you could use DateTime() -> <?php $variableDate = "October 8, 2017"; /* * DateTime & DateTimezone are classes built into PHP. */ $myDate = new DateTime($variableDate, new DateTimeZone("America/Detroit")); /* * N is a numeric representation -> 1 (for Monday) through 7 (for Sunday) */ if ( $myDate->format("N") < 6) { $myDate->modify("+3 days"); // modify is a method (function) that does what it says { similar to strtotime } } else { $myDate->modify("+5 days"); } echo $myDate->format("l, F j, Y") . "<br>"; // Display it in the format of your
  6. First simply turning on error reporting (without exemptions) should had help you out or pointing into you into the right direction. Second I would minimize at first what you are trying to insert into database. Here's an example of of a tutorial that I starting on php pdo function createLogin(array $data, $pdo) { /* Secure the Password by hashing the user's password. */ $data['password'] = password_hash($data['password'], PASSWORD_BCRYPT, array("cost" => 15)); try { /* Set the query variable */ $query = 'INSERT INTO myUsers (name, password, email, sec
  7. That for me was the hardest part in writing clean URLS and I don't know why? I would have this in my .htaccess file RewriteRule ^(index|about|blog|calendar|contact|edit|login|order)$ $1.php [NC,L] RewriteRule ^edit/(\d+)$ edit.php?id=$1 [NC,L] but forget I had to do this echo '<a class="edit" href="edit/' . $this->row->id . '">Edit</a>'; I would spend days trying to get it work and finally a light bulb turned on, but until I did figure it out it was like I was myself.
  8. It just so happens I developed a script that does just that, by that I mean takes images from a particular directory and made a very simple slideshow (actually it rotates). I recently took it down from my website, so I can't show it in action but here's a test script that I made. <style> /* essential styles: these make the slideshow work */ #slides { position: relative; height: 400px; padding: 0px; margin: 0px; list-style-type: none; } .slide { position: absolute; left: 0px; top: 0px; width: 1
  9. I personally would use an addEventListener instead of inline javascript like this example: selectBtn.addEventListener("change", function (event) { event.preventDefault(); selectCompany(); // Ajax or what have you function. }, false); // End of addEventListener Function: the Ajax would be something that you will have to figure out. However, doing it this way it would be easier to daisy chain or do whatever you are trying to do. For example I generate blog postings based on the person selected and the following is the ajax portion based on what the visitor of the website choose
  10. I have a repository at Github of my website that I think incorporates a nice secure login system -> https://github.com/Strider64/Slice-of-Technology You might be able to modify it to your liking? The only thing it won't really stop is a brute force attack, but from what I read about brute force attacks is that it takes a long time to crack a user who uses a strong password. That's is why it's important for users to have strong passwords and brute force attacks are almost impossible to defend against (at least I haven't found a real good solution).
  11. Someone awhile back told me that I should do something like the following (Just an example): <?php require_once '../private/initialize.php'; use Library\Display\Display; $status = FALSE; $display = new Display(); if (is_logged_in()) { $status = TRUE; } /* Makes it so we don't have to decode the json coming from Javascript */ header('Content-type: application/json'); /* Start of your php routine(s) */ $submit = filter_input(INPUT_POST, 'submit', FILTER_SANITIZE_FULL_SPECIAL_CHARS); if (isset($submit)) { $user_id = filter_input(INPUT_POST, 'user_id', FILTER_SANITIZE_FULL_SPEC
  12. It's bad practice to send a password over a url. Though I don't know what you're after, but why not have them login at the redirect?
  13. Another way to go about doing this is when you display the record(s). For example on my website I have a CMS for my web page(s) and I do this -> if (isset($_SESSION['user']) && ($_SESSION['user']->security_level === 'sysop' || $_SESSION['user']->id === $this->row->user_id)) { echo '<div class="system">' . "\n"; echo '<a class="edit" href="edit/' . urlencode($this->row->id) . '">Edit</a>' . "\n"; echo '<a class="delete" href="delete_page.php?id=' . urlencode($this->row->id) . '">Delete</a>' . "\n"; echo "</div>\n";
  14. A good way to practice HTML/CSS and Javascript is using jsfiddle -> https://jsfiddle.net/Strider64/o0tqd538/12/ A great way to test out small designs and javascript code.
  15. I personally like this website to generate the ModRewrite rule - http://www.generateit.net/mod-rewrite/index.php I find it easier to visualize what the php portion should be after I generate the rule.
×
×
  • 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.