Skip to content

Commit

Permalink
Merge pull request #16 from funktechno/f/updates
Browse files Browse the repository at this point in the history
F/updates
  • Loading branch information
lastlink authored Mar 5, 2021
2 parents fa32116 + fa604aa commit c9651b0
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 142 deletions.
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Fixes # .

Changes proposed in this pull request:
-
-
-
26 changes: 26 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
This issue is:

- [ ] Bug report
- [ ] Feature request
- [ ] Improvement

### Actual behaviour


### Expected behaviour


### Steps to reproduce


### Screenshots


### Logs
* attach export from options screen. Can replace urls and repo names used.

### Configuration

- OS:
- Browser:
- Browser version:
75 changes: 8 additions & 67 deletions accounts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,7 @@
require_once '../model/configuration-model.php';


// Get the array of categories
// $categories = getCategories();
// var_dump($categories);
// exit;

// Build a navigation bar using the $categories array
$directoryURI = $_SERVER['REQUEST_URI'];
// $navList = getNavList($categories, $directoryURI);

// echo $navList;
// exit;

// if ($action == NULL) {
// include 'view/home.php';
// exit;
// }
// echo $action;
// exit();

switch ($action) {
case 'registration':
Expand All @@ -48,12 +31,10 @@
// destroy session
session_destroy();
session_start();
// include '../view/login.php';
header('location: /');
break;
case 'register_user':
// echo 'You are in the register case statement.';
// $clientFirstname = filter_input(INPUT_POST, 'clientFirstname', FILTER_SANITIZE_STRING);
$clientDisplayName = filter_input(INPUT_POST, 'clientDisplayName', FILTER_SANITIZE_STRING);
$clientEmail = filter_input(INPUT_POST, 'clientEmail', FILTER_SANITIZE_EMAIL);
$clientPassword = filter_input(INPUT_POST, 'clientPassword', FILTER_SANITIZE_STRING);
Expand All @@ -70,11 +51,6 @@
include '../view/login.php';
exit;
}
// else {
// //return 1;
// echo 'Match found';
// exit;
// }
if (empty($clientDisplayName) || empty($clientEmail) || empty($checkPassword)) {
$_SESSION['message'] = '<p class="error">Please provide information for all empty form fields.</p>';
include '../view/registration.php';
Expand Down Expand Up @@ -158,33 +134,18 @@
$_SESSION['clientData'] = $clientData;
// Send them to the admin view
include '../view/admin.php';
exit;

break;
// case 'home':
// include 'view/home.php';
// break;
// case 'template':
// include 'template/template.php';

// break;
case 'modClient':
// $clientId = filter_input(INPUT_GET, 'clientId', FILTER_VALIDATE_INT);
$clientId = $_SESSION['clientData']['id'];

// $prodInfo = getProductInfo($invId);
// if (count($prodInfo) < 1) {
// $_SESSION['message'] = '<p class="error">Sorry, no product information could be found.</p>';
// header('location: /acme/products/');
// exit;
// }
include '../view/client-update.php';
break;
case 'updateClient':
if (!IsLoggedInAndHasAccess()) {
include '../view/client-update.php';
exit();
}
// only allow display name update
$clientDisplayName = filter_input(INPUT_POST, 'clientDisplayName', FILTER_SANITIZE_STRING);
// $clientLastname = filter_input(INPUT_POST, 'clientLastname', FILTER_SANITIZE_STRING);
// $clientEmail = filter_input(INPUT_POST, 'clientEmail', FILTER_SANITIZE_EMAIL);
Expand Down Expand Up @@ -232,12 +193,7 @@
include '../view/admin.php';
exit();
}
// echo 'test1';
// echo 'test55';
$formEmails = getContactFormEmails();
// echo json_encode($formEmails);
// echo 'test2';
// exit;
$sentEmail = sentTestEmail($formEmails);
echo $sentEmail;
// send email
Expand Down Expand Up @@ -353,10 +309,7 @@
$configInput = [];
$configInput['name'] = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$configInput['data'] = filter_input(INPUT_POST, 'data', FILTER_SANITIZE_STRING);
// $configInput['userId'] = $_SESSION['clientData']['id'];
$configInput['id'] = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
// echo json_encode($configInput);
// exit();
try {
$updateResult = updateConfig(
$configInput
Expand All @@ -375,12 +328,10 @@

if ($updateResult) {
$message = "<p class='notice'>Config " . $configInput['id'] . " was updated successfuly.</p>";
$_SESSION['message'] = $message;
// header('location: /acme/accounts/');
// exit;
} else {
$message = "<p class='notice'>Error. Updating config " . $configInput['id'] . ".</p>";
}
$_SESSION['message'] = $message;

include '../view/updateConfig.php';
break;
Expand Down Expand Up @@ -411,13 +362,11 @@

if ($updateResult) {
$message = "<p class='notice'>Config " . $configInput['slug'] . " was added successfuly.</p>";
$_SESSION['message'] = $message;
// header('location: /acme/accounts/');
// exit;
} else {
$message = "<p class='notice'>Error. Adding page " . $configInput['slug'] . ".</p>";
$_SESSION['message'] = $message;
}
$_SESSION['message'] = $message;

include '../view/managePages.php';
break;
case 'addConfigData':
Expand All @@ -435,24 +384,23 @@
} catch (\Throwable $th) {
if (isset($th->errorInfo)) {
$message = "<p class='notice'>Error. Adding config " . $configInput['name'] . ".<br/>" . json_encode($th->errorInfo) . "</p>";
$_SESSION['message'] = $message;
} else {
$message = "<p class='notice'>Error. Adding config " . $configInput['name'] . ".</p>";
$_SESSION['message'] = $message;
}
$_SESSION['message'] = $message;

include '../view/updateConfig.php';
exit();
}

if ($updateResult) {
$message = "<p class='notice'>Config " . $configInput['name'] . " was added successfuly.</p>";
$_SESSION['message'] = $message;
// header('location: /acme/accounts/');
// exit;
} else {
$message = "<p class='notice'>Error. Adding config " . $configInput['name'] . ".</p>";
$_SESSION['message'] = $message;
}
$_SESSION['message'] = $message;

include '../view/updateConfig.php';
break;
case 'contactForms':
Expand All @@ -466,17 +414,10 @@
include '../view/client-update.php';
exit();
}
// $clientFirstname = filter_input(INPUT_POST, 'clientFirstname', FILTER_SANITIZE_STRING);
// $clientLastname = filter_input(INPUT_POST, 'clientLastname', FILTER_SANITIZE_STRING);
// $clientEmail = filter_input(INPUT_POST, 'clientEmail', FILTER_SANITIZE_EMAIL);
$clientPassword = filter_input(INPUT_POST, 'clientPassword', FILTER_SANITIZE_STRING);

// validate
// $clientEmail = checkEmail($clientEmail);
$checkPassword = checkPassword($clientPassword);

// $existingEmail = checkExistingEmail($clientEmail);
// $clientId = filter_input(INPUT_POST, 'clientId', FILTER_SANITIZE_STRING);
$clientId = $_SESSION['clientData']['id'];
if (empty($checkPassword)) {
$_SESSION['message'] = '<p class="error">Please provide information for all empty form fields.</p>';
Expand Down
25 changes: 0 additions & 25 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,21 @@
// Get the database connection file
require_once 'library/connections.php';
require_once 'library/functions.php';
// Get the acme model for use as needed

// Get the array of categories
// $categories = getCategories();

// var_dump($categories);
// exit;

// Build a navigation bar using the $categories array
$directoryURI = $_SERVER['REQUEST_URI'];
// $navList = getNavList($categories, $directoryURI);

// echo $navList;
// exit;

if ($action == NULL) {
include 'view/home.php';
exit;
}

switch ($action) {
// case 'registration':
// include 'view/registration.php';

// break;
// case 'login':
// include 'view/login.php';

// break;
case 'home':
include 'view/home.php';
break;

case 'bootstrap':
include 'view/bootstrap.php';
break;
// case 'contact':
// include 'template/template.php';

// break;
default:
include 'view/404.php';
}
13 changes: 5 additions & 8 deletions library/connections-backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@
$GLOBALS['documentRoot'] = '/';
require_once 'Core.php';

// run composer require phpmailer/phpmailer
// use PHPMailer\PHPMailer\SMTP;
// use PHPMailer\PHPMailer\Exception;
// use PHPMailer\PHPMailer\PHPMailer;
// require '../vendor/autoload.php';
define('Allowed_Origins','*');
define('Allowed_Methods','GET,POST');
// jwt secret
define('SECRET','CHANGEME!');
define('DEBUG',false);

// http://localhost/acme/library/connections.php
function acmeConnect()
{
// same config from docker
$server = 'localhost';
$dbname = 'acme';
$password = 'acme';
$username = 'acme';
$dbname = 'testcomments';
$password = 'my-secret-pw';
$username = 'root';
$dsn = 'mysql:host=' . $server . ';dbname=' . $dbname;
$options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
// Create the actual connection object and assign it to a variable
Expand All @@ -37,6 +33,7 @@ function acmeConnect()
$error = $e;
// echo 'Sorry, the connection failed';
// header('location: /view/500.php');
// this will cause issue w/ rest api returns, maybe fine if db connection never fails
include $GLOBALS['root'] . 'view/500.php';
exit;
}
Expand Down
18 changes: 0 additions & 18 deletions mail/mailConfig-backup.php

This file was deleted.

5 changes: 3 additions & 2 deletions mail/testMail.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

require_once './mailConfig.php';
// use server built in mail function
require_once './library/connectios.php';
$mailConfig = getMailConfig();
// standard mail from server

// use wordwrap() if lines are longer than 70 characters
Expand Down
4 changes: 3 additions & 1 deletion mail/testPHPMailer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
// will require composer to pull then upload the vendor contents
use PHPMailer\PHPMailer\PHPMailer;
require_once './mailConfig.php';
require_once './library/connectios.php';
$mailConfig = getMailConfig();
require '../vendor/autoload.php';

$mail = new PHPMailer();
Expand Down
7 changes: 6 additions & 1 deletion mail/testSendGrid.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php
// uses sendgrid api directly using curl method
// no external library
// will need an api key from sendgrid
// also need to verify from email address for the send to work
$curl = curl_init();
require_once './mailConfig.php';
require_once './library/connectios.php';
$mailConfig = getMailConfig();
$postfields = "{\"personalizations\": [{\"to\": [{\"email\": \"" . $mailConfig['To'] . "\"}]}],\"from\": {\"email\": \"" . $mailConfig['From'] . "\"},\"subject\": \"" . $mailConfig['Subject'] . 'send grid' . "\",\"content\": [{\"type\": \"text/plain\",\"value\": \"" . $mailConfig['Msg'] . "\"}]}";
// echo json_encode($postfields);

Expand Down
Loading

0 comments on commit c9651b0

Please sign in to comment.