Example #1
0
 /**
  * Testing that the ConfigProvider reloadConfig method reloads the config from storage
  *
  * @since 2.0.1
  */
 public function testReloadConfig()
 {
     $this->configCopy->set('app.title', 'Testing');
     $this->assertEquals('Testing', $this->configCopy->get('app.title'), 'testing that the ConfigProvider reloadConfig method reloads the config from storage');
     $this->configCopy->reloadConfig();
     $this->assertEquals('Alpha Unit Tests', $this->configCopy->get('app.title'), 'testing that the ConfigProvider reloadConfig method reloads the config from storage');
 }
 /**
  * Testing the createApplicationDirs method.
  */
 public function testCreateApplicationDirs()
 {
     $controller = new InstallController();
     $testInstallDir = '/tmp/alphainstalltestdir';
     $config = ConfigProvider::getInstance();
     $config->set('app.root', $testInstallDir . '/');
     $config->set('app.file.store.dir', $testInstallDir . '/store/');
     if (!file_exists($testInstallDir)) {
         mkdir($testInstallDir);
     }
     if (!file_exists($testInstallDir . '/store')) {
         mkdir($testInstallDir . '/store');
     }
     $controller->createApplicationDirs();
     $this->assertTrue(file_exists($testInstallDir . '/src'));
     $this->assertTrue(file_exists($testInstallDir . '/src/Model'));
     $this->assertTrue(file_exists($testInstallDir . '/src/View'));
     $this->assertTrue(file_exists($testInstallDir . '/store/logs'));
     $this->assertTrue(file_exists($testInstallDir . '/store/attachments'));
     $this->assertTrue(file_exists($testInstallDir . '/store/cache'));
     $this->assertTrue(file_exists($testInstallDir . '/store/cache/html'));
     $this->assertTrue(file_exists($testInstallDir . '/store/cache/images'));
     $this->assertTrue(file_exists($testInstallDir . '/store/cache/pdf'));
     $this->assertTrue(file_exists($testInstallDir . '/store/cache/xls'));
 }
Example #3
0
 /**
  * Testing the doTask() method.
  *
  * @since 2.0
  */
 public function testDoTask()
 {
     $config = ConfigProvider::getInstance();
     $task = new BackupTask();
     $task->doTask();
     $this->assertTrue(file_exists($config->get('backup.dir') . '/' . date('Y-m-d') . '.zip'), 'Testing the doTask() method');
 }
Example #4
0
 /**
  * Called before the test functions will be executed
  * this function is defined in PHPUnit_TestCase and overwritten
  * here.
  *
  * @since 1.0
  */
 protected function setUp()
 {
     $config = ConfigProvider::getInstance();
     // override setting to ensure dates default to now
     $config->set('app.default.datetime', 'now');
     $this->date1 = new Date();
 }
Example #5
0
 /**
  * Testing the checkAdminPasswordIsDefault() method.
  *
  * @since 2.0.2
  */
 public function testCheckAdminPasswordIsDefault()
 {
     $config = ConfigProvider::getInstance();
     $config->set('app.install.password', 'test');
     $this->assertTrue(SecurityUtils::checkAdminPasswordIsDefault(password_hash('test', PASSWORD_DEFAULT, ['cost' => 12])), 'Testing when the default password is compared');
     $this->assertFalse(SecurityUtils::checkAdminPasswordIsDefault(password_hash('different', PASSWORD_DEFAULT, ['cost' => 12])), 'Testing when a non-default password is compared');
 }
Example #6
0
 /**
  * Drop the test database between tests.
  *
  * @since 2.0
  */
 protected function tearDown()
 {
     $config = ConfigProvider::getInstance();
     foreach ($this->getActiveRecordProviders() as $provider) {
         $config->set('db.provider.name', $provider[0]);
         ActiveRecord::dropDatabase();
         ActiveRecord::disconnect();
     }
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function init()
 {
     if (session_id() == '' && !headers_sent()) {
         $config = ConfigProvider::getInstance();
         $url = parse_url($config->get('app.url'));
         $hostname = $url['host'];
         session_set_cookie_params(0, '/', $hostname, false, true);
         session_start();
     }
 }
Example #8
0
 /**
  * {@inheritdoc}
  *
  * @since 1.0
  */
 protected function setUp()
 {
     $config = ConfigProvider::getInstance();
     $config->set('session.provider.name', 'Alpha\\Util\\Http\\Session\\SessionProviderArray');
     $denum = new DEnum();
     $denum->rebuildTable();
     $item = new DEnumItem();
     $item->rebuildTable();
     $this->view = View::getInstance(new Article());
 }
Example #9
0
 /**
  * Set up tests.
  *
  * @since 2.0
  */
 protected function setUp()
 {
     parent::setUp();
     $config = ConfigProvider::getInstance();
     $config->set('session.provider.name', 'Alpha\\Util\\Http\\Session\\SessionProviderArray');
     $tag = new Tag();
     $tag->rebuildTable();
     $article = new Article();
     $article->rebuildTable();
 }
Example #10
0
 /**
  * {@inheritdoc}
  *
  * @since 2.0
  */
 protected function setUp()
 {
     $config = ConfigProvider::getInstance();
     $config->set('session.provider.name', 'Alpha\\Util\\Http\\Session\\SessionProviderArray');
     $sequence = new Sequence();
     $sequence->rebuildTable();
     $sequence->set('prefix', 'TEST');
     $sequence->set('sequence', 1);
     $sequence->save();
 }
Example #11
0
 /**
  * constructor to set up the object.
  *
  * @since 2.0.3
  */
 public function __construct()
 {
     self::$logger = new Logger('PhpinfoController');
     self::$logger->debug('>>__construct()');
     $config = ConfigProvider::getInstance();
     // ensure that the super class constructor is called, indicating the rights group
     parent::__construct('Admin');
     // set up the title and meta details
     $this->setTitle('Information about the PHP installation');
     self::$logger->debug('<<__construct');
 }
Example #12
0
 /**
  * Constructor.
  *
  * @since 1.1
  */
 public function __construct()
 {
     self::$logger = new Logger('CacheProviderMemcache');
     $config = ConfigProvider::getInstance();
     try {
         $this->connection = new Memcache();
         $this->connection->connect($config->get('cache.memcached.host'), $config->get('cache.memcached.port'));
     } catch (\Exception $e) {
         self::$logger->error('Error while attempting to load connect to Memcache cache: [' . $e->getMessage() . ']');
     }
 }
Example #13
0
 /**
  * Testing the doGET method.
  */
 public function testDoGET()
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $front = new FrontController();
     $request = new Request(array('method' => 'GET', 'URI' => '/metric', 'params' => array('dir' => 'Alpha')));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method');
     $this->assertEquals('text/html', $response->getHeader('Content-Type'), 'Testing the doGET method');
 }
Example #14
0
 /**
  * Testing the doGET method.
  */
 public function testDoGET()
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $front = new FrontController();
     $request = new Request(array('method' => 'GET', 'URI' => '/log/' . urlencode($config->get('app.file.store.dir') . 'logs/alpha.log')));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method');
     $this->assertEquals('text/html', $response->getHeader('Content-Type'), 'Testing the doGET method');
 }
Example #15
0
 /**
  * Constructor.
  *
  * @since 1.2.4
  */
 public function __construct()
 {
     self::$logger = new Logger('CacheProviderRedis');
     $config = ConfigProvider::getInstance();
     try {
         $this->connection = new Redis();
         $this->connection->connect($config->get('cache.redis.host'), $config->get('cache.redis.port'));
         $this->connection->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
         $this->connection->select($config->get('cache.redis.db'));
     } catch (\Exception $e) {
         self::$logger->error('Error while attempting to connect to Redis cache: [' . $e->getMessage() . ']');
     }
 }
 /**
  * Testing the doPOST method.
  */
 public function testDoPOST()
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $front = new FrontController();
     $controller = new GenSecureQueryStringController();
     $securityParams = $controller->generateSecurityFields();
     $params = array('QS' => 'act=ViewArticle&oid=00000000001', 'var1' => $securityParams[0], 'var2' => $securityParams[1]);
     $request = new Request(array('method' => 'POST', 'URI' => '/gensecure', 'params' => $params));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doPOST method');
     $this->assertEquals('text/html', $response->getHeader('Content-Type'), 'Testing the doPOST method');
 }
Example #17
0
 /**
  * A static method that attempts to return a LogProviderInterface instance
  * based on the name of the provider class supplied.
  *
  * @param $providerName The class name of the provider class (fully qualified).
  *
  * @throws Alpha\Exception\IllegalArguementException
  *
  * @return Alpha\Util\Logging\LogProviderInterface
  *
  * @since 2.0
  */
 public static function getInstance($providerName)
 {
     $config = ConfigProvider::getInstance();
     if (class_exists($providerName)) {
         $instance = new $providerName();
         if (!$instance instanceof LogProviderInterface) {
             throw new IllegalArguementException('The class [' . $providerName . '] does not implement the expected LogProviderInterface intwerface!');
         }
         $instance->setMaxSize($config->get('app.log.file.max.size'));
         return $instance;
     } else {
         throw new IllegalArguementException('The class [' . $providerName . '] is not defined anywhere!');
     }
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public function send($to, $from, $subject, $body, $isHTML = false)
 {
     self::$logger->debug('>>send(to=[' . $to . '], from=[' . $from . '], subject=[' . $subject . '], body=[' . $body . '], isHTML=[' . $isHTML . '])');
     $config = ConfigProvider::getInstance();
     $headers = 'MIME-Version: 1.0' . "\n";
     if ($isHTML) {
         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
     }
     $headers .= 'From: ' . $from . "\n";
     if ($config->getEnvironment() != 'dev') {
         try {
             mb_send_mail($to, $subject, $body, $headers);
         } catch (PHPException $e) {
             throw new MailNotSentException('Error sending a mail to [' . $to . ']');
         }
     } else {
         self::$logger->info("Sending email:\n" . $headers . "\n" . $body);
     }
     self::$logger->debug('<<send');
 }
Example #19
0
 /**
  * Testing the doGET method.
  */
 public function testDoGET()
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $front = new FrontController();
     $request = new Request(array('method' => 'GET', 'URI' => '/image/' . urlencode($config->get('app.root') . 'public/images/icons/accept.png') . '/16/16/png/0.75/false/false'));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method');
     $this->assertEquals('image/jpeg', $response->getHeader('Content-Type'), 'Testing the doGET method');
     $request = new Request(array('method' => 'GET', 'URI' => '/image/' . urlencode($config->get('app.root') . 'public/images/icons/accept.png') . '/16/16/png/0.75/false/true'));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method');
     $this->assertEquals('image/jpeg', $response->getHeader('Content-Type'), 'Testing the doGET method with secure image and no tokens');
     $tokens = Controller::generateSecurityFields();
     $request = new Request(array('method' => 'GET', 'URI' => '/image/' . urlencode($config->get('app.root') . 'public/images/icons/accept.png') . '/16/16/png/0.75/false/true/' . urlencode($tokens[0]) . '/' . urlencode($tokens[1])));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method');
     $this->assertEquals('image/jpeg', $response->getHeader('Content-Type'), 'Testing the doGET method with secure image and valid tokens');
 }
 /**
  * {@inheritdoc}
  */
 public function process($request)
 {
     $config = ConfigProvider::getInstance();
     $client = $request->getUserAgent();
     $IP = $request->getIP();
     // if no user agent string or IP are provided, we can't filter by these anyway to might as well skip
     if ($client == null || $IP == null) {
         return;
     }
     if (!empty($client) && !empty($IP)) {
         $badRequest = new BadRequest();
         $badRequest->set('client', $client);
         $badRequest->set('IP', $IP);
         $badRequestCount = $badRequest->getBadRequestCount();
         if ($badRequestCount >= $config->get('security.client.temp.blacklist.filter.limit')) {
             // if we got this far then the client is bad
             self::$logger->warn('The client [' . $client . '] was blocked from accessing the resource [' . $request->getURI() . '] on a temporary basis');
             throw new ResourceNotAllowedException('Not allowed!');
         }
     }
 }
 /**
  * Set up tests.
  *
  * @since 1.2.3
  */
 protected function setUp()
 {
     $config = ConfigProvider::getInstance();
     $config->set('session.provider.name', 'Alpha\\Util\\Http\\Session\\SessionProviderArray');
     $config->set('db.provider.name', 'Alpha\\Model\\ActiveRecordProviderSQLite');
     ActiveRecord::createDatabase();
     $tag = new Tag();
     $tag->makeTable();
     $denum = new DEnum();
     $denum->makeTable();
     $item = new DEnumItem();
     $item->makeTable();
     $article = new Article();
     $article->makeTable();
     $denum = new DEnum('Alpha\\Model\\Article::section');
     $item->set('DEnumID', $denum->getOID());
     $item->set('value', 'Test');
     $item->save();
     $this->DEnumID = $denum->getOID();
     $this->article = $this->createArticle('unitTestArticle');
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 public function doTask()
 {
     $config = ConfigProvider::getInstance();
     self::$logger = new Logger('BackupTask');
     self::$logger->setLogProviderFile($config->get('app.file.store.dir') . 'logs/tasks.log');
     if (!file_exists($config->get('backup.dir'))) {
         mkdir($config->get('backup.dir'));
     }
     $targetDir = $config->get('backup.dir') . date('Y-m-d') . '/';
     if (file_exists($targetDir)) {
         FileUtils::deleteDirectoryContents($targetDir);
     }
     if (!file_exists($targetDir)) {
         mkdir($targetDir);
     }
     $back = new BackupUtils();
     $back->backUpAttachmentsAndLogs($targetDir);
     $back->backUpDatabase($targetDir);
     $additionalDirectories = explode(',', $config->get('backup.include.dirs'));
     if (count($additionalDirectories) > 0) {
         foreach ($additionalDirectories as $additionalDirectory) {
             FileUtils::copy($additionalDirectory, $targetDir . basename($additionalDirectory));
         }
     }
     if ($config->get('backup.compress')) {
         FileUtils::zip($targetDir, $config->get('backup.dir') . date('Y-m-d') . '.zip');
         // we can safely remove the uncompressed files now to save space...
         FileUtils::deleteDirectoryContents($targetDir . 'logs');
         rmdir($targetDir . 'logs');
         FileUtils::deleteDirectoryContents($targetDir . 'attachments');
         rmdir($targetDir . 'attachments');
         unlink($targetDir . $config->get('db.name') . '_' . date('Y-m-d') . '.sql');
         if (count($additionalDirectories) > 0) {
             foreach ($additionalDirectories as $additionalDirectory) {
                 FileUtils::deleteDirectoryContents($targetDir . basename($additionalDirectory));
                 rmdir($targetDir . basename($additionalDirectory));
             }
         }
     }
 }
 /**
  * A static method that attempts to return a ActiveRecordProviderInterface instance
  * based on the name of the provider class supplied.
  *
  * @param $providerName The fully-qualified class name of the provider class.
  * @param $BO The (optional) active record instance to pass to the persistance provider for mapping.
  *
  * @throws Alpha\Exception\IllegalArguementException
  *
  * @return Alpha\Model\ActiveRecordProviderInterface
  *
  * @since 1.1
  */
 public static function getInstance($providerName, $BO = null)
 {
     if (self::$logger == null) {
         self::$logger = new Logger('ActiveRecordProviderFactory');
     }
     self::$logger->debug('>>getInstance(providerName=[' . $providerName . '], BO=[' . print_r($BO, true) . '])');
     $config = ConfigProvider::getInstance();
     if (class_exists($providerName)) {
         $instance = new $providerName();
         if (!$instance instanceof ActiveRecordProviderInterface) {
             throw new IllegalArguementException('The class [' . $providerName . '] does not implement the expected ActiveRecordProviderInterface interface!');
         }
         if ($BO instanceof ActiveRecord) {
             $instance->setBO($BO);
         }
         self::$logger->debug('<<getInstance: [Object ' . $providerName . ']');
         return $instance;
     } else {
         throw new IllegalArguementException('The class [' . $providerName . '] is not defined anywhere!');
     }
     self::$logger->debug('<<getInstance');
 }
Example #24
0
 /**
  * Testing the convertImageURLToPath method.
  *
  * @since 1.0
  */
 public function testConvertImageURLToPath()
 {
     $config = ConfigProvider::getInstance();
     $this->assertEquals('images/testimage.png', Image::convertImageURLToPath($config->get('app.url') . '/images/testimage.png'), 'testing the convertImageURLToPath method');
 }
Example #25
0
 /**
  * Renders the HTML for the file upload section.
  *
  * @return string
  *
  * @since 1.0
  */
 protected function renderFileUploadSection()
 {
     $config = ConfigProvider::getInstance();
     $html = '<div class="form-group">';
     $html .= '  <h3>File Attachments:</h3>';
     if (is_dir($this->BO->getAttachmentsLocation())) {
         $handle = opendir($this->BO->getAttachmentsLocation());
         $fileCount = 0;
         $html .= '<table class="table table-bordered">';
         // loop over the attachments directory
         while (false !== ($file = readdir($handle))) {
             if ($file != '.' && $file != '..') {
                 ++$fileCount;
                 $html .= '<tr>';
                 $html .= '<td>' . $file . ' <em>(' . number_format(filesize($this->BO->getAttachmentsLocation() . '/' . $file) / 1024) . ' KB)</em></td>';
                 $js = "if(window.jQuery) {\n                            BootstrapDialog.show({\n                                title: 'Confirmation',\n                                message: 'Are you sure you wish to delete this item?',\n                                buttons: [\n                                    {\n                                        icon: 'glyphicon glyphicon-remove',\n                                        label: 'Cancel',\n                                        cssClass: 'btn btn-default btn-xs',\n                                        action: function(dialogItself){\n                                            dialogItself.close();\n                                        }\n                                    },\n                                    {\n                                        icon: 'glyphicon glyphicon-ok',\n                                        label: 'Okay',\n                                        cssClass: 'btn btn-default btn-xs',\n                                        action: function(dialogItself) {\n                                            \$('[id=\"" . ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('deletefile')) : 'deletefile') . "\"]').attr('value', '" . $file . "');\n                                            \$('[id=\"" . stripslashes(get_class($this->BO)) . '_' . $this->BO->getID() . "\"]').submit();\n                                            dialogItself.close();\n                                        }\n                                    }\n                                ]\n                            });\n                        }";
                 $button = new Button($js, 'Delete', 'delete' . $fileCount . 'But');
                 $html .= '<td>' . $button->render() . '</td>';
                 $html .= '</tr>';
             }
         }
         $html .= '</table>';
     } else {
         // we will take this opportunity to create the attachments folder is it does
         // not already exist.
         $this->BO->createAttachmentsFolder();
     }
     $html .= '<span class="btn btn-default btn-file">';
     $html .= '<input name="userfile" type="file" value="Browse..."/>';
     $html .= '</span>';
     $temp = new Button('submit', 'Upload', 'uploadBut');
     $html .= $temp->render();
     $fieldname = $config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('deletefile')) : 'deletefile';
     $html .= '<input type="hidden" name="' . $fieldname . '" id="' . $fieldname . '" value=""/>';
     $html .= '</div>';
     return $html;
 }
Example #26
0
 /**
  * Drop the user tables and session between tests.
  *
  * @since 2.0
  */
 protected function tearDown()
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $session->set('currentUser', null);
     $person = new Person();
     $person->dropTable();
     $rights = new Rights();
     $rights->dropTable();
     $rights->dropTable('Person2Rights');
 }
 /**
  * Testing the doGET method.
  */
 public function testDoGET()
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $front = new FrontController();
     $uri = '/recordselector/m2m/1/hiddenformfield/' . urlencode('Alpha\\Model\\Person') . '/email/' . urlencode('Alpha\\Model\\Rights') . '/name/' . urlencode('Alpha\\Model\\Person') . '/1';
     $request = new Request(array('method' => 'GET', 'URI' => $uri));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method for MANY-TO-MANY relation');
     $this->assertEquals('text/html', $response->getHeader('Content-Type'), 'Testing the doGET method');
     $uri = '/recordselector/12m/1/hiddenformfield/' . urlencode('Alpha\\Model\\ArticleComment') . '/articleOID/content';
     $request = new Request(array('method' => 'GET', 'URI' => $uri));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method for ONE-TO-MANY relation');
     $this->assertEquals('text/html', $response->getHeader('Content-Type'), 'Testing the doGET method');
 }
 /**
  * Handle POST requests.
  *
  * @param alpha\Util\Http\Request $request
  *
  * @return alpha\Util\Http\Response
  *
  * @since 1.0
  */
 public function doPOST($request)
 {
     self::$logger->debug('>>doPOST($request=[' . var_export($request, true) . '])');
     $params = $request->getParams();
     $config = ConfigProvider::getInstance();
     $body = View::displayPageHead($this);
     try {
         // check the hidden security fields before accepting the form POST data
         if (!$this->checkSecurityFields()) {
             throw new SecurityException('This page cannot accept post data from remote servers!');
         }
         if (isset($params['createTableBut'])) {
             try {
                 $classname = $params['createTableClass'];
                 $BO = new $classname();
                 $BO->makeTable();
                 self::$logger->action('Created the table for class ' . $classname);
                 $body .= View::displayUpdateMessage('The table for the class ' . $classname . ' has been successfully created.');
             } catch (AlphaException $e) {
                 self::$logger->error($e->getMessage());
                 $body .= View::displayErrorMessage('Error creating the table for the class ' . $classname . ', check the log!');
             }
         }
         if (isset($params['createHistoryTableBut'])) {
             try {
                 $classname = $params['createTableClass'];
                 $BO = new $classname();
                 $BO->makeHistoryTable();
                 self::$logger->action('Created the history table for class ' . $classname);
                 $body .= View::displayUpdateMessage('The history table for the class ' . $classname . ' has been successfully created.');
             } catch (AlphaException $e) {
                 self::$logger->error($e->getMessage());
                 $body .= View::displayErrorMessage('Error creating the history table for the class ' . $classname . ', check the log!');
             }
         }
         if (isset($params['recreateTableClass']) && $params['admin_' . stripslashes($params['recreateTableClass']) . '_button_pressed'] == 'recreateTableBut') {
             try {
                 $classname = $params['recreateTableClass'];
                 $BO = new $classname();
                 $BO->rebuildTable();
                 self::$logger->action('Recreated the table for class ' . $classname);
                 $body .= View::displayUpdateMessage('The table for the class ' . $classname . ' has been successfully recreated.');
             } catch (AlphaException $e) {
                 self::$logger->error($e->getMessage());
                 $body .= View::displayErrorMessage('Error recreating the table for the class ' . $classname . ', check the log!');
             }
         }
         if (isset($params['updateTableClass']) && $params['admin_' . stripslashes($params['updateTableClass']) . '_button_pressed'] == 'updateTableBut') {
             try {
                 $classname = $params['updateTableClass'];
                 $BO = new $classname();
                 $missingFields = $BO->findMissingFields();
                 $count = count($missingFields);
                 for ($i = 0; $i < $count; ++$i) {
                     $BO->addProperty($missingFields[$i]);
                 }
                 self::$logger->action('Updated the table for class ' . $classname);
                 $body .= View::displayUpdateMessage('The table for the class ' . $classname . ' has been successfully updated.');
             } catch (AlphaException $e) {
                 self::$logger->error($e->getMessage());
                 $body .= View::displayErrorMessage('Error updating the table for the class ' . $classname . ', check the log!');
             }
         }
     } catch (SecurityException $e) {
         $body .= View::displayErrorMessage($e->getMessage());
         self::$logger->warn($e->getMessage());
     }
     $body .= $this->displayBodyContent();
     $body .= View::displayPageFoot($this);
     self::$logger->debug('<<doPOST');
     return new Response(200, $body, array('Content-Type' => 'text/html'));
 }
Example #29
0
 /**
  * Handle GET requests.
  *
  * @param Alpha\Util\Http\Request $request
  *
  * @return Alpha\Util\Http\Response
  *
  * @since 1.0
  */
 public function doGET($request)
 {
     self::$logger->debug('>>doGET(request=[' . var_export($request, true) . '])');
     $config = ConfigProvider::getInstance();
     if ($config->get('app.check.installed') && !ActiveRecord::isInstalled()) {
         $response = new Response(301);
         $response->redirect($config->get('app.url') . '/install');
         self::$logger->warn('App not installed so re-directing to the install controller');
         self::$logger->debug('<<doGET');
         return $response;
     }
     $params = $request->getParams();
     $body = View::loadTemplateFragment('html', 'head.phtml', array('title' => $config->get('app.title'), 'description' => 'Welcome to our site', 'allowCSSOverrides' => true));
     $body .= View::loadTemplateFragment('html', 'index.phtml');
     $body .= View::loadTemplateFragment('html', 'footer.phtml');
     self::$logger->debug('<<doGET');
     return new Response(200, $body, array('Content-Type' => 'text/html'));
 }
Example #30
0
 /**
  * Overrides the TCPDF::Image method to decrypt encrypted $file paths from the Image widget, then pass
  * them to the normal TCPDF::Image along with all of the other (unmodified) parameters.
  *
  * @param string $file    Name of the file containing the image.
  * @param float  $x       Abscissa of the upper-left corner.
  * @param float  $y       Ordinate of the upper-left corner.
  * @param float  $w       Width of the image in the page. If not specified or equal to zero, it is automatically calculated.
  * @param float  $h       Height of the image in the page. If not specified or equal to zero, it is automatically calculated.
  * @param string $type    Image format. Possible values are (case insensitive): JPEG and PNG (whitout GD library) and all images supported by GD: GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM;. If not specified, the type is inferred from the file extension.
  * @param mixed  $link    URL or identifier returned by AddLink().
  * @param string $align   Indicates the alignment of the pointer next to image insertion relative to image height. The value can be:<ul><li>T: top-right for LTR or top-left for RTL</li><li>M: middle-right for LTR or middle-left for RTL</li><li>B: bottom-right for LTR or bottom-left for RTL</li><li>N: next line</li></ul>
  * @param bool   $resize  If true resize (reduce) the image to fit $w and $h (requires GD library).
  * @param int    $dpi     dot-per-inch resolution used on resize
  * @param string $palign  Allows to center or align the image on the current line. Possible values are:<ul><li>L : left align</li><li>C : center</li><li>R : right align</li><li>'' : empty string : left for LTR or right for RTL</li></ul>
  * @param bool   $ismask  true if this image is a mask, false otherwise
  * @param mixed  $imgmask image object returned by this function or false
  * @param mixed  $border  Indicates if borders must be drawn around the image. The value can be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
  *
  * @since 1.0
  */
 public function Image($file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0)
 {
     if (self::$logger == null) {
         self::$logger = new Logger('TCPDF');
     }
     $config = ConfigProvider::getInstance();
     self::$logger->debug('Processing image file URL [' . $file . ']');
     try {
         if (mb_strpos($file, '/tk/') !== false) {
             $start = mb_strpos($file, '/tk/') + 3;
             $end = mb_strlen($file);
             $tk = mb_substr($file, $start + 1, $end - ($start + 1));
             $decoded = FrontController::getDecodeQueryParams($tk);
             parent::Image($decoded['source'], $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border);
         } else {
             // it has no query string, so threat as a regular image URL
             if (Validator::isURL($file)) {
                 parent::Image($config->get('app.root') . '/' . Image::convertImageURLToPath($file), $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border);
             } else {
                 parent::Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border);
             }
         }
     } catch (\Exception $e) {
         self::$logger->error('Error processing image file URL [' . $file . '], error [' . $e->getMessage() . ']');
         throw $e;
     }
 }