0.9.0 - the ZapV version updated to current php standards. Brave search used, while Bing and Google search api are deprecated
This commit is contained in:
parent
3d4298fe8b
commit
4ddaddda3d
31 changed files with 1778 additions and 1 deletions
91
lib/ZAPDisplay.class.php
Executable file
91
lib/ZAPDisplay.class.php
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
/**
|
||||
* Class is responsible for starting up ZAP machine
|
||||
*/
|
||||
class ZAPDisplay {
|
||||
/**
|
||||
* Template file
|
||||
*/
|
||||
private $template = 'display';
|
||||
|
||||
/**
|
||||
* Folder string
|
||||
*/
|
||||
private $folder = '';
|
||||
|
||||
/**
|
||||
* Words array
|
||||
*/
|
||||
private $words = array();
|
||||
|
||||
/**
|
||||
* Content string
|
||||
*/
|
||||
private $tpl = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
ob_start();
|
||||
$this->folder = $this->createFolder();
|
||||
$this->words = $this->handleWords();
|
||||
|
||||
$_SESSION['words'] = $this->words;
|
||||
$_SESSION['folder'] = $this->folder;
|
||||
$_SESSION['collages'] = (int) $_POST['collages']; //number of zaps
|
||||
$_SESSION['width'] = (int) $_POST['width'];
|
||||
$_SESSION['height'] = (int) $_POST['height'];
|
||||
$_SESSION['date'] = ZAP_MOMENT;
|
||||
|
||||
$ver = ZAP_VERSION;
|
||||
include getZAPTemplate($this->template);
|
||||
$this->tpl .= ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create folder and return path
|
||||
* @return string $folder path or throws exception
|
||||
*/
|
||||
private function createFolder() {
|
||||
try {
|
||||
$folder = ZAP_APP_BASE_DIR . DIRECTORY_SEPARATOR
|
||||
. ZAP_SESSIONS_DIR . DIRECTORY_SEPARATOR . 'zap_' . ZAP_MOMENT;
|
||||
if (!@mkdir($folder, 0777)) {
|
||||
throw new Exception('<p>' . ERROR_PREFIX . 'Unable to create base dir: ' . $folder . '</p>');
|
||||
}
|
||||
return $folder;
|
||||
} catch (Exception $e) {
|
||||
$this->tpl .= $e->getMessage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an array based on post data
|
||||
* @return array $words
|
||||
*/
|
||||
private function handleWords() {
|
||||
$words = array();
|
||||
$ix = 1;
|
||||
$postix = sprintf("%02d", $ix);
|
||||
$wd = 'word' . $postix;
|
||||
|
||||
while(!empty($_POST[$wd])) {
|
||||
array_push($words, $_POST[$wd]);
|
||||
$ix++;
|
||||
$postfix = sprintf("%02d", $ix);
|
||||
$wd = 'word' . $postfix;
|
||||
}
|
||||
return $words;
|
||||
}
|
||||
|
||||
/**
|
||||
* return rendered content
|
||||
*/
|
||||
public function getContent() {
|
||||
return $this->tpl;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue