From 153f07a1201765d059f5cdbec1222214cd3fa23a Mon Sep 17 00:00:00 2001 From: Josh North Date: Thu, 11 May 2017 17:22:44 +0000 Subject: [PATCH] minor fixes to work with php 7 - finally --- config.inc.php.example | 10 ++++------ includes/functions.inc.php | 16 ++++++++-------- includes/menu.inc.php | 2 +- index.php | 9 +++++++-- manualpunch.php | 12 ++++++------ mysql.sql | 14 +++++++------- profile.php | 12 ++++++------ reports.php | 2 +- users.php | 8 ++++---- 9 files changed, 44 insertions(+), 41 deletions(-) diff --git a/config.inc.php.example b/config.inc.php.example index 787ad5b..7633760 100755 --- a/config.inc.php.example +++ b/config.inc.php.example @@ -1,16 +1,16 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Advanced PDO handling $yaptc_db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); // Advanced PDO handling -$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Advanced PDO handling -$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); // Advanced PDO handling $_SESSION['yaptc_dir'] = $yaptc_dirpath; // Put absolute directory path in session $_SESSION['yaptc_url'] = $yaptc_webpath; // Put absolute url path in session $yaptc_inc = $yaptc_dirpath . 'includes/'; // Concatenate an includes directory path diff --git a/includes/functions.inc.php b/includes/functions.inc.php index d1e15b3..4856097 100755 --- a/includes/functions.inc.php +++ b/includes/functions.inc.php @@ -76,10 +76,10 @@ function lang($phrase){ $timenow = date('Y-m-d H:i:s'); // This Version -$yaptc_version = 'yaptc 0.8-beta'; +$yaptc_version = 'yaptc 0.9-beta'; // Timezone from config -date_default_timezone_set("$timezone"); +date_default_timezone_set("$yaptc_timezone"); // Get user list for users management page function listUsers($yaptc_db) { @@ -171,8 +171,8 @@ function getPunchStatus($yaptc_db, $userid) } // List punches sorted by intime. Pass uid or % for all. Pass limit to restrict row results. Default is set to tons of 9's because no wildcard exists for limit in mysql or pgsql. Limit can also include offset for pagination, i.e. "20,10" for a result of 10 records starting 20 records in -function listPunches($db, $uid, $limit = "999999999999999", $offset = "0") { - $stmt = $db->prepare(' +function listPunches($yaptc_db, $uid, $limit = "999999999999999", $offset = "0") { + $stmt = $yaptc_db->prepare(' SELECT ROUND(TIME_TO_SEC(TIMEDIFF(punches.outtime, punches.intime))/3600,2) AS punchhours, punches.id as punchid, @@ -198,8 +198,8 @@ function listPunches($db, $uid, $limit = "999999999999999", $offset = "0") { } // Get user info from user id. Pass uid or % for all. -function getUserInfo($db, $uid, $limit = "999999999999999", $offset = "0") { - $stmt = $db->prepare(' +function getUserInfo($yaptc_db, $uid, $limit = "999999999999999", $offset = "0") { + $stmt = $yaptc_db->prepare(' SELECT users.id AS userid, users.username AS username, @@ -238,8 +238,8 @@ $stmt->execute(array( // Set user info from user id -function setUserInfo($db, $uid, $firstname, $lastname, $email, $usertypeid, $password) { - $stmt = $db->prepare(' +function setUserInfo($yaptc_db, $uid, $firstname, $lastname, $email, $usertypeid, $password) { + $stmt = $yaptc_db->prepare(' UPDATE yaptc.users SET diff --git a/includes/menu.inc.php b/includes/menu.inc.php index 2d65623..4ff2ee4 100755 --- a/includes/menu.inc.php +++ b/includes/menu.inc.php @@ -1,5 +1,5 @@ diff --git a/index.php b/index.php index 5cd249e..7de8104 100755 --- a/index.php +++ b/index.php @@ -1,6 +1,11 @@ '; @@ -12,7 +17,7 @@ else: ?> $page_count): $page_num = 1; endif; endif; +if (0 === $row_count): else: $page_count = (int)ceil($row_count / $yaptc_rowsperpage); if($page_num > $page_count): $page_num = 1; endif; endif; ?> @@ -79,7 +79,7 @@ if (0 === $row_count): else: $page_count = (int)ceil($row_count / $rowsperpage); - + diff --git a/mysql.sql b/mysql.sql index 33fa612..85f8fbb 100755 --- a/mysql.sql +++ b/mysql.sql @@ -25,8 +25,8 @@ DROP TABLE IF EXISTS `punches`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `punches` ( - `id` int(11) unsigned zerofill NOT NULL AUTO_INCREMENT, - `userid` int(11) unsigned zerofill NOT NULL, + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `userid` int(11) unsigned NOT NULL, `notes` varchar(255) DEFAULT NULL, `modified` tinyint(4) DEFAULT NULL, `intime` datetime NOT NULL, @@ -54,14 +54,14 @@ DROP TABLE IF EXISTS `users`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `users` ( - `id` int(11) unsigned zerofill NOT NULL AUTO_INCREMENT, + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `password` varchar(60) NOT NULL, `email` varchar(100) DEFAULT NULL, `created` datetime NOT NULL, `firstname` varchar(50) DEFAULT NULL, `lastname` varchar(50) DEFAULT NULL, - `usertype` int(11) unsigned zerofill NOT NULL, + `usertype` int(11) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `users_ibfk_1` (`usertype`), CONSTRAINT `users_ibfk_1` FOREIGN KEY (`usertype`) REFERENCES `usertypes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -74,7 +74,7 @@ CREATE TABLE `users` ( LOCK TABLES `users` WRITE; /*!40000 ALTER TABLE `users` DISABLE KEYS */; -INSERT INTO `users` VALUES (00000000001,'admin','$2a$08$6WUE0S4UEYJO5.GMoCzjAO.W8y4Gage/tC7.SWEppWxwQO2ccjMgy','admin@example.com','2015-02-18 19:50:31','System','Administrator',00000000001); +INSERT INTO `users` VALUES (1,'admin','$2a$08$6WUE0S4UEYJO5.GMoCzjAO.W8y4Gage/tC7.SWEppWxwQO2ccjMgy','admin@example.com','2015-02-18 19:50:31','System','Administrator',1); /*!40000 ALTER TABLE `users` ENABLE KEYS */; UNLOCK TABLES; @@ -86,7 +86,7 @@ DROP TABLE IF EXISTS `usertypes`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `usertypes` ( - `id` int(11) unsigned zerofill NOT NULL AUTO_INCREMENT, + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `typename` varchar(50) CHARACTER SET latin1 NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; @@ -98,7 +98,7 @@ CREATE TABLE `usertypes` ( LOCK TABLES `usertypes` WRITE; /*!40000 ALTER TABLE `usertypes` DISABLE KEYS */; -INSERT INTO `usertypes` VALUES (00000000001,'Administrator'),(00000000002,'User'); +INSERT INTO `usertypes` VALUES (1,'Administrator'),(2,'User'); /*!40000 ALTER TABLE `usertypes` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; diff --git a/profile.php b/profile.php index 4c45708..e7b52a4 100755 --- a/profile.php +++ b/profile.php @@ -13,7 +13,7 @@ else: ?> HashPassword($_POST['password']); -setUserInfo($db, $session_user["0"]["userid"], $_POST['firstname'], $_POST['lastname'], $_POST['email'], $session_user["0"]["usertypeid"], $password); +setUserInfo($yaptc_db, $session_user["0"]["userid"], $_POST['firstname'], $_POST['lastname'], $_POST['email'], $session_user["0"]["usertypeid"], $password); header('Location: ' . $_SERVER['PHP_SELF']); endif; endif; @@ -39,10 +39,10 @@ if(!empty($_GET['pnum'])): $page_num = 1; endif; endif; -$offset = ($page_num - 1) * $rowsperpage; -$row_count = count(listPunches($db, $session_user["0"]["userid"])); +$offset = ($page_num - 1) * $yaptc_rowsperpage; +$row_count = count(listPunches($yaptc_db, $session_user["0"]["userid"])); $page_count = 0; -if (0 === $row_count): else: $page_count = (int)ceil($row_count / $rowsperpage); if($page_num > $page_count): $page_num = 1; endif; endif; +if (0 === $row_count): else: $page_count = (int)ceil($row_count / $yaptc_rowsperpage); if($page_num > $page_count): $page_num = 1; endif; endif; ?>

@@ -89,7 +89,7 @@ if (0 === $row_count): else: $page_count = (int)ceil($row_count / $rowsperpage); - + diff --git a/reports.php b/reports.php index a77ac32..bd3a867 100755 --- a/reports.php +++ b/reports.php @@ -55,7 +55,7 @@ else: ?> - +
InOutNameHoursFlaggedNotes
diff --git a/users.php b/users.php index 0ded193..553e901 100755 --- a/users.php +++ b/users.php @@ -138,10 +138,10 @@ if(!empty($_GET['pnum'])): $page_num = 1; endif; endif; -$offset = ($page_num - 1) * $rowsperpage; -$row_count = count(getUserInfo($db, "%")); +$offset = ($page_num - 1) * $yaptc_rowsperpage; +$row_count = count(getUserInfo($yaptc_db, "%")); $page_count = 0; -if (0 === $row_count): else: $page_count = (int)ceil($row_count / $rowsperpage); if($page_num > $page_count): $page_num = 1; endif; endif; +if (0 === $row_count): else: $page_count = (int)ceil($row_count / $yaptc_rowsperpage); if($page_num > $page_count): $page_num = 1; endif; endif; ?>

@@ -152,7 +152,7 @@ if (0 === $row_count): else: $page_count = (int)ceil($row_count / $rowsperpage); - +