Beispiel #1
0
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $config = new Model\Config();
     if ($this->request->isPost()) {
         $config->save($this->request->getPost());
         $this->sess->setRequestValue('saved', true);
         $this->redirect(BASE_PATH . APP_URI . '/config');
     }
     $this->prepareView('phire/config/index.phtml');
     $this->view->title = 'Configuration';
     $this->view->overview = $config->overview;
     $this->view->config = $config->config;
     $this->send();
 }
Beispiel #2
0
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $config = new Model\Config();
     if (!isset($this->sess->updates)) {
         $this->sess->updates = $config->getUpdates($this->application->config()['updates']);
     }
     $this->prepareView('phire/index.phtml');
     $this->view->title = 'Dashboard';
     $this->view->overview = $config->overview;
     $this->view->config = $config->config;
     $this->view->modules = $config->modules;
     $this->view->phire_update_version = $this->sess->updates->phirecms;
     $this->send();
 }
Beispiel #3
0
 /**
  * Static method to process uploaded media
  *
  * @param string       $fileName
  * @param \ArrayObject $config
  * @param string       $dir
  * @return void
  */
 public static function process($fileName, $config, $dir = null)
 {
     $cfg = $config->media_actions;
     $adapter = '\\Pop\\Image\\' . $config->media_image_adapter;
     $formats = $adapter::formats();
     $ext = strtolower(substr($fileName, strrpos($fileName, '.') + 1));
     if (null === $dir) {
         $dir = $_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . DIRECTORY_SEPARATOR . 'media';
     }
     if (in_array($ext, $formats)) {
         foreach ($cfg as $size => $action) {
             if (in_array($action['action'], Config::getMediaActions())) {
                 // If 'size' directory does not exist, create it
                 if (!file_exists($dir . DIRECTORY_SEPARATOR . $size)) {
                     mkdir($dir . DIRECTORY_SEPARATOR . $size);
                     chmod($dir . DIRECTORY_SEPARATOR . $size, 0777);
                     copy($dir . DIRECTORY_SEPARATOR . 'index.html', $dir . DIRECTORY_SEPARATOR . $size . DIRECTORY_SEPARATOR . 'index.html');
                     chmod($dir . DIRECTORY_SEPARATOR . $size . DIRECTORY_SEPARATOR . 'index.html', 0777);
                 }
                 if (!is_array($action['params'])) {
                     if (strpos(',', $action['params']) !== false) {
                         $pAry = explode(',', $action['params']);
                         $params = array();
                         foreach ($pAry as $p) {
                             $params[] = trim($p);
                         }
                     } else {
                         $params = array($action['params']);
                     }
                 } else {
                     $params = $action['params'];
                 }
                 $quality = isset($action['quality']) ? (int) $action['quality'] : 80;
                 // Save original image, and then save the resized image
                 $img = new $adapter($dir . DIRECTORY_SEPARATOR . $fileName);
                 $img->setQuality($quality);
                 $ext = strtolower($img->getExt());
                 if ($ext == 'ai' || $ext == 'eps' || $ext == 'pdf' || $ext == 'psd') {
                     $img->flatten()->convert('jpg');
                     $newFileName = $fileName . '.jpg';
                 } else {
                     $newFileName = $fileName;
                 }
                 $img = call_user_func_array(array($img, $action['action']), $params);
                 $img->save($dir . DIRECTORY_SEPARATOR . $size . DIRECTORY_SEPARATOR . $newFileName);
                 chmod($dir . DIRECTORY_SEPARATOR . $size . DIRECTORY_SEPARATOR . $newFileName, 0777);
             }
         }
     }
 }
 /**
  * Update index action method
  *
  * @return void
  */
 public function index()
 {
     $config = new Model\Config();
     $updates = $config->getUpdates();
     if (version_compare($updates->phirecms, \Phire\Module::VERSION) < 0) {
         $this->console->append($this->console->colorize($updates->phirecms . ' is available for update.', Console::BOLD_YELLOW));
         $this->console->append();
         $this->console->append($this->console->colorize('Please back up all of your files and your database before proceeding.', Console::BOLD_RED));
         $this->console->append();
         $this->console->send();
         $update = null;
         while (strtolower($update) != 'y' && strtolower($update) != 'n') {
             $update = $this->console->prompt($this->console->getIndent() . 'Update the system? (Y/N) ');
         }
         if (strtolower($update) == 'y') {
             if (is_writable(__DIR__ . '/../../../../../') && is_writable(__DIR__ . '/../../../../..' . APP_PATH)) {
                 $baseUpdater = new \Phire\BaseUpdater();
                 $baseUpdater->getUpdate();
                 clearstatcache();
                 $updater = new \Phire\Updater();
                 $updater->runPost();
                 $this->console->append();
                 $this->console->append($this->console->colorize('Update completed successfully!', Console::BOLD_CYAN));
                 $this->console->append($this->console->colorize('You have updated to Phire version ' . \Phire\Module::VERSION . '.', Console::BOLD_CYAN));
                 $this->console->send();
             } else {
                 $this->console->append();
                 $this->console->append($this->console->colorize('The system folders are not writable. They must be writable to update the system.', Console::BOLD_RED));
                 $this->console->send();
             }
         }
     } else {
         $this->console->append($this->console->colorize('System is up-to-date!', Console::BOLD_GREEN));
         $this->console->send();
     }
 }
Beispiel #5
0
 /**
  * Static method to get base configuration values
  *
  * @return \ArrayObject
  */
 public static function getSystemConfig()
 {
     $settings = array('system_title', 'system_email', 'reply_email', 'site_title', 'separator', 'default_language', 'datetime_format', 'media_allowed_types', 'media_max_filesize', 'media_actions', 'media_image_adapter', 'pagination_limit', 'pagination_range', 'force_ssl', 'live');
     $config = array();
     $cfg = static::findAll();
     foreach ($cfg->rows as $c) {
         if (in_array($c->setting, $settings)) {
             $config[$c->setting] = $c->setting == 'media_allowed_types' || $c->setting == 'media_actions' ? unserialize($c->value) : $c->value;
         }
     }
     $allowedTypes = Model\Config::getMediaTypes();
     foreach ($allowedTypes as $key => $value) {
         if (!in_array($key, $config['media_allowed_types'])) {
             unset($allowedTypes[$key]);
         }
     }
     if ($config['media_max_filesize'] > 999999) {
         $maxSize = round($config['media_max_filesize'] / 1000000) . ' MB';
     } else {
         if ($config['media_max_filesize'] > 999) {
             $maxSize = round($config['media_max_filesize'] / 1000) . ' KB';
         } else {
             $maxSize = $config['media_max_filesize'] . ' B';
         }
     }
     $config['media_max_filesize_formatted'] = $maxSize;
     $config['media_allowed_types'] = $allowedTypes;
     $site = Sites::findBy(array('document_root' => $_SERVER['DOCUMENT_ROOT']));
     if (isset($site->id)) {
         $config['site_title'] = $site->title;
         $config['base_path'] = $site->base_path;
         $config['force_ssl'] = $site->force_ssl;
         $config['live'] = $site->live;
     } else {
         $config['base_path'] = BASE_PATH;
     }
     return new \ArrayObject($config, \ArrayObject::ARRAY_AS_PROPS);
 }
 /**
  * Index method
  *
  * @return void
  */
 public function index()
 {
     $config = new Model\Config(array('acl' => $this->project->getService('acl')));
     $extensions = new Model\Extension();
     $this->prepareView('index.phtml', array('assets' => $this->project->getAssets(), 'acl' => $this->project->getService('acl'), 'phireNav' => $this->project->getService('phireNav')));
     $this->view->set('title', $this->view->i18n->__('Dashboard'));
     if (isset($this->sess->sessionError)) {
         $this->view->set('sessionError', $this->sess->sessionError);
         unset($this->sess->sessionError);
     }
     $overview = $config->getOverview();
     $this->view->set('modules', $extensions->getAllModules())->set('overview', $overview['system'])->set('sites', $overview['sites']);
     $this->send();
 }
 /**
  * Config update method
  *
  * @return void
  */
 public function update()
 {
     $this->prepareView('update.phtml', array('assets' => $this->project->getAssets(), 'acl' => $this->project->getService('acl'), 'phireNav' => $this->project->getService('phireNav')));
     if (null !== $this->request->getQuery('module')) {
         $type = 'module';
         $name = $this->request->getQuery('module');
         $version = null;
         $title = $this->view->i18n->__('Module Update') . ' ' . $this->view->separator . ' ' . $name;
         $linkParam = '&module=' . $name;
         $ext = Table\Extensions::findBy(array('name' => $name));
         if (isset($ext->id)) {
             $assets = unserialize($ext->assets);
             $version = $assets['info']['Version'];
         }
     } else {
         if (null !== $this->request->getQuery('theme')) {
             $type = 'theme';
             $name = $this->request->getQuery('theme');
             $version = null;
             $title = $this->view->i18n->__('Theme Update') . ' ' . $this->view->separator . ' ' . $name;
             $linkParam = '&theme=' . $name;
             $ext = Table\Extensions::findBy(array('name' => $name));
             if (isset($ext->id)) {
                 $assets = unserialize($ext->assets);
                 $version = $assets['info']['Version'];
             }
         } else {
             $type = 'system';
             $name = 'phire';
             $version = \Phire\Project::VERSION;
             $title = $this->view->i18n->__('System Update');
             $linkParam = null;
         }
     }
     $format = null;
     $formats = \Pop\Archive\Archive::formats();
     if (isset($formats['zip'])) {
         $format = 'zip';
     } else {
         if (isset($formats['tar']) && isset($formats['gz'])) {
             $format = 'tar.gz';
         }
     }
     $this->view->set('title', $this->view->i18n->__('Configuration') . ' ' . $this->view->separator . ' ' . $title);
     $config = new Model\Config();
     $writable = false;
     if ($type == 'system' && is_writable(__DIR__ . '/../../../../../../../')) {
         $writable = true;
     } else {
         if ($type == 'module' && is_writable(__DIR__ . '/../../../../../../../../' . CONTENT_PATH . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'modules')) {
             $writable = true;
         } else {
             if ($type == 'theme' && is_writable(__DIR__ . '/../../../../../../../../' . CONTENT_PATH . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR . 'themes')) {
                 $writable = true;
             }
         }
     }
     if ($writable) {
         if (null !== $this->request->getQuery('writable')) {
             $config->getUpdate(array('type' => $type, 'name' => $name, 'version' => $version, 'format' => $format));
             if (null !== $config->error) {
                 $this->view->set('msg', $config->error);
                 $this->send();
             } else {
                 $this->view->set('msg', $config->msg);
                 $this->send();
             }
         } else {
             $link = $this->request->getFullUri() . '?writable=1' . $linkParam;
             $form = '<div id="update-form">' . $this->view->i18n->__('The %1 folder has been detected as writable.', $type) . ' ' . $this->view->i18n->__('You can proceed with the %1 update by clicking the update button below.', $type) . '<br /><br /><a href="' . $link . '" class="save-btn" style="display: block; width: 220px; height: 20px; color: #fff; text-decoration: none;">' . $this->view->i18n->__('UPDATE') . '</a></div>';
             $this->view->set('form', $form);
             $this->send();
         }
     } else {
         $form = new Form\Update($this->request->getBasePath() . $this->request->getRequestUri(), 'post', $type, $name, $version, $format);
         if ($this->request->isPost()) {
             $form->setFieldValues($this->request->getPost(), array('htmlentities' => array(ENT_QUOTES, 'UTF-8')));
             if ($form->isValid()) {
                 $config->getUpdate($this->request->getPost());
                 if (null !== $config->error) {
                     $this->view->set('msg', $config->error);
                     $this->send();
                 } else {
                     $this->view->set('msg', $config->msg);
                     $this->send();
                 }
             } else {
                 $this->view->set('form', $form);
                 $this->send();
             }
         } else {
             $this->view->set('form', $form);
             $this->send();
         }
     }
 }
 /**
  * Update action method
  *
  * @return void
  */
 public function update()
 {
     $config = new Model\Config();
     $updates = $config->getUpdates();
     $moduleId = $this->getModuleId();
     $module = Table\Modules::findById($moduleId);
     if (isset($module->id)) {
         if (isset($updates->modules[$module->folder]) && version_compare($updates->modules[$module->folder], $module->version) < 0) {
             $this->console->append();
             $this->console->append($this->console->colorize('The \'' . $module->folder . '\' module is available for update.', Console::BOLD_YELLOW));
             $this->console->append();
             $this->console->append($this->console->colorize('Please back up all of your files and your database before proceeding.', Console::BOLD_RED));
             $this->console->append();
             $this->console->send();
             $update = null;
             while (strtolower($update) != 'y' && strtolower($update) != 'n') {
                 $update = $this->console->prompt($this->console->getIndent() . 'Update the \'' . $module->folder . '\' module? (Y/N) ');
             }
             if (strtolower($update) == 'y') {
                 if (is_writable(__DIR__ . '/../../../') && is_writable(__DIR__ . '/../../../' . $module->folder) && is_writable(__DIR__ . '/../../../' . $module->folder . '.zip')) {
                     $updater = new \Phire\Updater($module->folder);
                     $updater->getUpdate($module->folder);
                     clearstatcache();
                     $updaterClass = $module->prefix . 'Updater';
                     if (class_exists($updaterClass)) {
                         $updater = new $updaterClass($module->folder);
                         $updater->runPost();
                     } else {
                         if (file_exists(__DIR__ . '/../../../' . $module->folder . '/src/Updater.php')) {
                             include __DIR__ . '/../../../' . $module->folder . '/src/Updater.php';
                             if (class_exists($updaterClass)) {
                                 $updater = new $updaterClass($module->folder);
                                 $updater->runPost();
                             }
                         } else {
                             $module->updated_on = date('Y-m-d H:i:s');
                             $module->save();
                         }
                     }
                     $this->console->append();
                     $this->console->append($this->console->colorize('Update completed successfully!', Console::BOLD_CYAN));
                     $this->console->append($this->console->colorize('You have updated \'' . $module->folder . '\' to version ' . $updates->modules[$module->folder] . '.', Console::BOLD_CYAN));
                     $this->console->send();
                 } else {
                     $this->console->append();
                     $this->console->append($this->console->colorize('The module folders are not writable. They must be writable to update the module.', Console::BOLD_RED));
                     $this->console->send();
                 }
             }
         } else {
             $this->console->append();
             $this->console->append($this->console->colorize('The \'' . $module->folder . '\' module is up-to-date!', Console::BOLD_GREEN));
             $this->console->send();
         }
     }
 }