Skip to content
Open
Show file tree
Hide file tree
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
48 changes: 26 additions & 22 deletions framework/ZincModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ abstract class ZincModule
private $depends = array(), $includes = array(), $classes = array();
protected $hasConfig = false;
public $path;

final function __construct($path, $lib)
{
// assign in the paramamters
$this->path = $path;
$this->lib = $lib;
$this->name = strtolower(str_replace('Module', '', get_class($this)));

// second stage (module specific) construction
$this->init();

$classname = get_class($this);
// load any dependant modules
if($this->getDepends())
foreach($this->getDepends() as $thisDepends)
$this->lib->loadMod($thisDepends);

// include any normal files that need to be included
if($this->getIncludes())
{
Expand All @@ -33,22 +33,22 @@ final function __construct($path, $lib)
require($this->path . '/' . $thisInclude);
}
}

// register any class files
if($classes = $this->getClasses())
foreach($classes as $thisClass)
ZoopLoader::addClass($thisClass, $this->path . '/' . $thisClass . '.php');
foreach($classes as $className => $classPath)
ZoopLoader::addClass($className, $classPath);

if($this->hasConfig)
$this->loadConfig();

// handle configuration
$this->configure();
$this->configure();
}

protected function init() {}
protected function configure() {}

/**
* Figures out the name of the module by removing the word "Module" from
* the class name and returning the result
Expand All @@ -59,17 +59,17 @@ function createName()
{
return strtolower(str_replace('Module', '', get_class($this)));
}

function getConfigPath()
{
return $this->name;
}

private function loadConfig()
{
Config::suggest($this->path . '/' . 'config.yaml', 'zinc.' . $this->getConfigPath());
}

/**
* Returns the configuration options using the Config class.
* Returns config options from "zinc.<modulename>.<path>"
Expand All @@ -83,37 +83,41 @@ function getConfig($path = '')
$config = Config::get('zinc.' . $this->getConfigPath() . $path);
return $config;
}

/**
* stuff about this function
*
* @return array(list of files to include) or false;
*/
protected function addClass($className)
protected function addClass($className, $classPath = null)
{
$this->classes[] = $className;
if (!$classPath) {
$classPath = $this->path . "/" . $className . ".php";
}
$this->classes[$className] = $classPath;
}

protected function getClasses()
{
return $this->classes;
}

protected function addInclude($include)
{
$this->includes[] = $include;
}

protected function getIncludes()
{
return $this->includes;
}

protected function depend($module)
{
$this->depends[] = $module;
}

private function getDepends()
{
return $this->depends;
Expand Down
4 changes: 3 additions & 1 deletion framework/core/app/Globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
{
if( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' )
$protocol = 'https://';
elseif ( isset($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
$protocol = 'https://';
else
$protocol = 'http://';
$sslProtocol = 'https://';
Expand All @@ -34,7 +36,7 @@
// what other situations besides mod_rewrite set this to 200?
if(isset($_SERVER['REDIRECT_STATUS']) && $_SERVER['REDIRECT_STATUS'] == 200)
{
$uri = $_SERVER['REQUEST_URI'];
$uri = urldecode($_SERVER['REQUEST_URI']);
if($pos = strpos($uri, '?'))
$uri = substr($uri, 0, $pos);

Expand Down
69 changes: 48 additions & 21 deletions framework/core/utils/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,40 @@ function RequestIsPost()
return $_SERVER['REQUEST_METHOD'] == 'POST' ? 1 : 0;
}

/**
* Returns true if the current page was requested with the POST method
*
* @return boolean
*/
function RequestIsPut()
{
return $_SERVER['REQUEST_METHOD'] == 'PUT' ? 1 : 0;
}

/**
* Returns true if the current page was requested with the POST method
*
* @return boolean
*/
function RequestIsDelete()
{
return $_SERVER['REQUEST_METHOD'] == 'DELETE' ? 1 : 0;
}

function GetJsonData()
{
$input = file_get_contents("php://input", 1000000);
$value = json_decode($input, true);
return $value;
}

/**
* Evaluates the POST variables and creates a standard "year-month-day Hour24:minute:second -7:00" date from a POSTed form
* The fields in the form should be as follows:
* <name>Month, <name>Day, <name>Year
* <name>Hour, <name>Minute, <name>Second
* <name>Meridian (<-- "am" or "pm")
*
*
* @param $name Prefix of the POST variables to evaluate
* @return string Date string
*/
Expand All @@ -34,7 +61,7 @@ function GetFormDate($name, $src = null)
{
if(!$src)
$src = $_POST;

if(is_array($src[$name]))
{
$year = $src[$name]['Date_Year'];
Expand All @@ -48,7 +75,7 @@ function GetFormDate($name, $src = null)
$day = $src[$name . 'Day'];
$year = $src[$name . 'Year'];
}

return "$year-$month-$day";
}

Expand All @@ -65,9 +92,9 @@ function GetPostDate($name)
$minute = $_POST[$name . 'Minute'];
$second = $_POST[$name . 'Second'];
$meridian = $_POST[$name . 'Meridian'];

$hour = $meridian == 'pm' ? ($hour + 12) : $hour;

return "$year-$month-$day $hour:$minute:$second -7:00";
}
*/
Expand All @@ -83,10 +110,10 @@ function echo_r($var, $showBacktrace = NULL)
{
if(is_null($showBacktrace))
$showBacktrace = Config::get('zinc.debug.echorShowBacktrace');

if($showBacktrace)
EchoBacktrace();

echo '<pre>';
print_r($var);
echo '</pre>';
Expand Down Expand Up @@ -142,7 +169,7 @@ function FormatBacktraceHtml($backtraceInfo)
<tr>
<th>File</th><th>Line</th><th>Function</th>
</tr>
<?php foreach($backtraceInfo as $thisRow):
<?php foreach($backtraceInfo as $thisRow):
$lineInfo = FormateBacktraceLineHtml($thisRow);
?><tr>
<td><?php echo $lineInfo['file']; ?></td>
Expand Down Expand Up @@ -173,7 +200,7 @@ function FormatBacktraceFunctionCellHtml($lineInfo)
$call .= isset($lineInfo['class']) ? ($lineInfo['class'] . $lineInfo['type']) : '';
$call .= $lineInfo['function'] . '(';
$argStrings = array();

if(isset($lineInfo['args']))
foreach($lineInfo['args'] as $thisArg)
{
Expand Down Expand Up @@ -207,14 +234,14 @@ function FormatBacktraceFunctionCellHtml($lineInfo)
die('unhandled type ' . gettype($thisArg));
break;
}

// echo '<strong>call = ' . $call . '</strong><br>';
}

$call .= implode(', ', $argStrings);

$call .= ')';

return $call;
}

Expand All @@ -228,11 +255,11 @@ function FormatBacktraceFunctionCellHtml($lineInfo)
function EchoStaticFile($filename)
{
$fp = fopen($filename, 'rb');

// send the headers
//header("Content-Type: image/png"); // figure out what should really be done here
header("Content-Length: " . filesize($filename)); // also we want to be able to properly set the cache headers here

fpassthru($fp);
}

Expand All @@ -255,17 +282,17 @@ function ListDir($path, $params)
{
$keep = 0;
$extention = GetFileExtention($entry);

if(in_array($extention, $params['extentions']))
//echo $extention . "\n";
$keep = 1;
}

if($keep)
$entries[] = $entry;
}
$d->close();

return $entries;
}

Expand All @@ -277,7 +304,7 @@ function WalkDir($dir, $action)
{
if($entry == '.' || $entry == '..')
continue;

echo $entry."\n";
$action($entry);
}
Expand Down Expand Up @@ -358,7 +385,7 @@ function GetRandomBytes($count, $allowFallback = false)
{
if(!$allowFallback)
trigger_error('system could not generate enough random data');

$output = '';
for ($i = 0; $i < $count; $i += 16) {
$this->random_state =
Expand All @@ -382,7 +409,7 @@ function GetNonEmptyLines($text)
if($line)
$lines[] = $line;
}

return $lines;
}

Expand Down
Loading