Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make slack-birthdays.php #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions slack-birthdays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

date_default_timezone_set('America/New_York');

function getBirthdays($connection, $date)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why make this a function if it's only used in one place and is only three lines long?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force of habit. I'll fix that. :)

{
$statement = $connection->query("SELECT slackId FROM members WHERE dob = '$date'");
$statement->execute();
return $statement->fetchAll(PDO::FETCH_ASSOC);
}

require_once ".db_config.php";

if (!isset($_GET["token"]) || $_GET["token"] != $slacktoken) {
die("nope.");
}

try {

$connection = new PDO("mysql:host=$dhost;dbname=$dname", $duser, $dpassword);
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

if (!isset($dname)) {
$dname = 'ambulanc_web';
}

$connection->exec("USE `$dname`");

$date = isset($_GET["date"]) ? $_GET["date"] : date("Y-m-d");
$birthdayPeople = getBirthdays($connection, $_GET["date"]);
echo $birthdayPeople;

} catch (Exception $e) {
echo $e;
}

?>