Skip to content

Commit a3a440e

Browse files
authored
Merge pull request #1 from TheTempusProject/dev
Updates
2 parents c313f5b + 3d329ac commit a3a440e

18 files changed

Lines changed: 645 additions & 358 deletions

App.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,18 @@ private function getController()
131131
$this->path = $this->controllerPath; // docroot
132132
return $this->controllerName;
133133
}
134-
if ($this->directed && file_exists($this->indexPath . $this->url[0] . '.php')) {
135-
Debug::log("Modifying the controller from $this->controllerName to " . $this->url[0]);
136-
$out = array_shift($this->url);
137-
$this->path = $this->indexPath; // docroot
138-
return strtolower($out);
134+
if ($this->directed) {
135+
if (file_exists($this->indexPath . $this->url[0] . '.php')) {
136+
Debug::log("Modifying the controller from $this->controllerName to " . $this->url[0]);
137+
$out = array_shift($this->url);
138+
$this->path = $this->indexPath; // docroot
139+
return strtolower($out);
140+
} elseif (file_exists($this->controllerPath . $this->url[0] . '.php')) {
141+
Debug::log("Modifying the controller from $this->controllerName to " . $this->url[0]);
142+
$out = array_shift($this->url);
143+
$this->path = $this->controllerPath; // docroot
144+
return strtolower($out);
145+
}
139146
}
140147
if (!$this->directed && file_exists($this->controllerPath . $this->url[0] . '.php')) {
141148
Debug::log("Modifying the controller from $this->controllerName to " . $this->url[0]);

Classes/Check.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public static function dataTitle($data)
278278
*
279279
* @return bool
280280
*/
281-
public static function path()
281+
public static function path($data)
282282
{
283283
if (!preg_match('#^[^/?*:;\\{}]+$#mi', $data)) {
284284
return true;

Classes/Code.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ public static function genConfirmation()
3131
return $code;
3232
}
3333

34+
/**
35+
* Generates a new install hash.
36+
*
37+
* @return string
38+
*/
39+
public static function genInstall()
40+
{
41+
$code = md5(uniqid());
42+
Debug::log("Code Generated: Token: $code");
43+
return $code;
44+
}
45+
3446
/**
3547
* Generates a new token code.
3648
*

Classes/Config.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,15 @@ public static function saveConfig($default = false)
135135
self::load();
136136
}
137137
if ($default) {
138-
file_put_contents(Docroot::getLocation('appConfigDefault')->fullPath, json_encode(self::$config));
138+
if (file_put_contents(Docroot::getLocation('appConfigDefault')->fullPath, json_encode(self::$config))) {
139+
return true;
140+
}
141+
return false;
142+
}
143+
if (file_put_contents(Docroot::getLocation('appConfig')->fullPath, json_encode(self::$config))) {
144+
return true;
139145
}
140-
file_put_contents(Docroot::getLocation('appConfig')->fullPath, json_encode(self::$config));
146+
return false;
141147
}
142148

143149
/**
@@ -232,7 +238,7 @@ public static function addConfig($parent, $name, $value)
232238
*
233239
* @return boolean
234240
*/
235-
public static function generateConfig()
241+
public static function generateConfig($mods = [])
236242
{
237243
$docLocation = Docroot::getLocation('appConfig');
238244
if (!$docLocation->error) {
@@ -249,19 +255,11 @@ public static function generateConfig()
249255
}
250256

251257
self::$config = json_decode(file_get_contents($docLocation->fullPath), true);
252-
self::updateConfig('main', 'name', Input::postNull('siteName'), true);
253-
self::updateConfig('main', 'loginLimit', 5, true);
254-
self::updateConfig('main', 'pageLimit', 50, true);
255-
self::updateConfig('uploads', 'files', true, true);
256-
self::updateConfig('uploads', 'images', true, true);
257-
self::updateConfig('uploads', 'maxFileSize', 5000000, true);
258-
self::updateConfig('uploads', 'maxImageSize', 500000, true);
259-
self::updateConfig('database', 'dbHost', Input::postNull('dbHost'), true);
260-
self::updateConfig('database', 'dbUsername', Input::postNull('dbUsername'), true);
261-
self::updateConfig('database', 'dbPassword', Input::postNull('dbPassword'), true);
262-
self::updateConfig('database', 'dbName', Input::postNull('dbName'), true);
263-
self::updateConfig('database', 'dbEnabled', true, true);
264-
self::updateConfig('database', 'dbMaxQuery', 100, true);
258+
if (!empty($mods)) {
259+
foreach ($mods as $mod) {
260+
self::updateConfig($mod['category'], $mod['name'], $mod['value'], true);
261+
}
262+
}
265263
self::saveConfig(true);
266264
Debug::info('config file generated successfully.');
267265

Classes/CustomException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public function __construct($type, $data = null)
7777
if (Debug::status()) {
7878
Issue::error('Missing View: ' . $data);
7979
}
80-
Redirect::to(404);
8180
break;
8281

8382
case 'defaultMethod':

Classes/DB.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public function newTable($name, $addID = true)
477477
* @todo - add more error reporting and checks
478478
* use switch/cases?
479479
*/
480-
public function addfield($name, $type, $length, $null = false, $default = null, $comment = '')
480+
public function addfield($name, $type, $length, $null = true, $default = null, $comment = '')
481481
{
482482
if (empty($this->tableBuff)) {
483483
Debug::info("No Table set.");

Classes/Debug.php

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818

1919
namespace TempusProjectCore\Classes;
2020

21-
use \FirePHP as FirePHP;
21+
use TempusProjectCore\Functions\Docroot;
22+
23+
require_once Docroot::getFull() . 'vendor/TheTempusProject/TempusDebugger/TempusDebugger.php';
24+
25+
use TempusDebugger\TempusDebugger;
2226

2327
class Debug
2428
{
@@ -27,21 +31,21 @@ class Debug
2731
*
2832
* @var bool
2933
*/
30-
private static $debugStatus = false;
34+
private static $debugStatus = true;
3135

3236
/**
33-
* Very Important, this will enable the firebug console output.
37+
* Very Important, this will enable the TempusTools console output.
3438
* It only applies when debugging is enabled, or the config cannot
3539
* be found as a safety net.
3640
*
3741
* @var bool
3842
*/
39-
private static $console = false;
43+
private static $console = true;
4044
private static $showLines = false;
4145
private static $redirect = false;
4246
private static $errorTrace = false;
4347
private static $group = 0;
44-
private static $fire = null;
48+
private static $tempusDebugger = null;
4549
private static $debugLog = null;
4650

4751
/**
@@ -51,8 +55,8 @@ private static function startDebug()
5155
{
5256
if (self::$console) {
5357
ob_start();
54-
self::$fire = FirePHP::getInstance(true);
55-
self::$fire->setOption('includeLineNumbers', self::$showLines);
58+
self::$tempusDebugger = TempusDebugger::getInstance(true);
59+
self::$tempusDebugger->setOption('includeLineNumbers', self::$showLines);
5660
}
5761
}
5862

@@ -96,50 +100,48 @@ private static function put($type, $data = null, $params = null)
96100
return;
97101
}
98102
if (strlen(self::$debugLog) > 50000) {
99-
self::$fire->log('Error log too large, possible loop.');
103+
self::$tempusDebugger->log('Error log too large, possible loop.');
100104
self::$debugStatus = false;
101105
return;
102106
}
103107
if (!is_object($data)) {
104-
self::$debugLog .= var_export($data, true);
105-
self::$debugLog .= '\n';
108+
self::$debugLog .= var_export($data, true) . PHP_EOL;
106109
} else {
107-
self::$debugLog .= 'cannot save objects';
108-
self::$debugLog .= '\n';
110+
self::$debugLog .= 'cannot save objects' . PHP_EOL;
109111
}
110112
if (!self::$console) {
111113
return;
112114
}
113-
if (!self::$fire) {
115+
if (!self::$tempusDebugger) {
114116
self::startDebug();
115117
}
116118
switch ($type) {
117119
case 'variable':
118-
self::$fire->info($data, $params);
120+
self::$tempusDebugger->info($data, $params);
119121
break;
120122

121123
case 'groupEnd':
122-
self::$fire->groupEnd();
124+
self::$tempusDebugger->groupEnd();
123125
break;
124126

125127
case 'trace':
126-
self::$fire->trace($data);
128+
self::$tempusDebugger->trace($data);
127129
break;
128130

129131
case 'group':
130132
if ($params) {
131-
self::$fire->group($data, $params);
133+
self::$tempusDebugger->group($data, $params);
132134
} else {
133-
self::$fire->group($data);
135+
self::$tempusDebugger->group($data);
134136
}
135137
break;
136138

137139
case 'info':
138-
self::$fire->$type('color: #1452ff', '%c' . $data);
140+
self::$tempusDebugger->$type('color: #1452ff', '%c' . $data);
139141
break;
140142

141143
default:
142-
self::$fire->$type($data);
144+
self::$tempusDebugger->$type($data);
143145
break;
144146
}
145147
}
@@ -272,6 +274,6 @@ public static function error($data, $params = null)
272274
*/
273275
public static function dump()
274276
{
275-
return var_dump(self::$debugLog);
277+
return self::$debugLog;
276278
}
277279
}

Classes/Email.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public static function send($email, $type, $params = null, $flags = null)
153153
if (self::$useTemplate) {
154154
$data = new \stdClass();
155155
if (self::$unsub) {
156-
$data->UNSUB = Template::standardView('mail.default.unsub');
156+
$data->UNSUB = Template::standardView('email.unsubscribe');
157157
} else {
158158
$data->UNSUB = '';
159159
}
@@ -167,21 +167,25 @@ public static function send($email, $type, $params = null, $flags = null)
167167
$data->$key = $value;
168168
}
169169
}
170-
$data->MAIL_FOOT = Template::standardView('mail.default.foot');
170+
$data->MAIL_FOOT = Template::standardView('email.foot');
171171
$data->MAIL_TITLE = self::$title;
172172
$data->MAIL_BODY = Template::parse(self::$message, $data);
173173
$subject = Template::parse(self::$subject, $data);
174-
$body = Template::standardView('mail.default.template', $data);
174+
$body = Template::standardView('email.template', $data);
175175
} else {
176176
$subject = self::$subject;
177177
$body = '<h1>' . self::$title . '</h1>' . self::$message;
178178
}
179179
if (is_object($email)) {
180180
foreach ($email as $data) {
181-
mail($data->email, $subject, $body, self::$header);
181+
if (!@mail($data->email, $subject, $body, self::$header)) {
182+
Debug::error('Failed to send email. Subject: ' . $subject . ' Email: ' . $data->email);
183+
}
182184
}
183185
} else {
184-
mail($email, $subject, $body, self::$header);
186+
if (!@mail($email, $subject, $body, self::$header)) {
187+
Debug::error('Failed to send email. Subject: ' . $subject . ' Email: ' . $email);
188+
}
185189
}
186190
Debug::info("Email sent: $type.");
187191

0 commit comments

Comments
 (0)