Exemple #1
0
 public static function ipCronExecute($info)
 {
     if ($info['firstTimeThisDay'] || $info['test']) {
         self::cleanDirRecursive(ipFile('file/tmp/'));
         self::cleanDirRecursive(ipFile('file/secure/tmp/'));
     }
 }
Exemple #2
0
 public function downloadTheme($name, $url, $signature)
 {
     $model = Model::instance();
     //download theme
     $net = new \Ip\Internal\NetHelper();
     $themeTempFilename = $net->downloadFile($url, ipFile('file/secure/tmp/'), $name . '.zip');
     if (!$themeTempFilename) {
         throw new \Ip\Exception('Theme file download failed.');
     }
     $archivePath = ipFile('file/secure/tmp/' . $themeTempFilename);
     //check signature
     $fileMd5 = md5_file($archivePath);
     $rsa = new \Crypt_RSA();
     $rsa->loadKey($this->publicKey);
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $verified = $rsa->verify($fileMd5, base64_decode($signature));
     if (!$verified) {
         throw new \Ip\Exception('Theme signature verification failed.');
     }
     //extract
     $helper = Helper::instance();
     $secureTmpDir = ipFile('file/secure/tmp/');
     $tmpExtractedDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $secureTmpDir);
     \Ip\Internal\Helper\Zip::extract($secureTmpDir . $themeTempFilename, $secureTmpDir . $tmpExtractedDir);
     unlink($archivePath);
     //install
     $extractedDir = $helper->getFirstDir($secureTmpDir . $tmpExtractedDir);
     $installDir = $model->getThemeInstallDir();
     $newThemeDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $installDir);
     rename($secureTmpDir . $tmpExtractedDir . '/' . $extractedDir, $installDir . $newThemeDir);
 }
Exemple #3
0
 /**
  * @param array|string $data
  * @param null $defaultImage
  */
 public function __construct($data, $defaultImage = null)
 {
     if (is_string($data)) {
         $data = $this->parseStr($data);
     }
     if (!empty($data['imageOrig']) && file_exists(ipFile('file/repository/' . $data['imageOrig']))) {
         $this->imageOrig = $data['imageOrig'];
         if (isset($data['x1']) && isset($data['y1']) && isset($data['x2']) && isset($data['y2'])) {
             $this->x1 = $data['x1'];
             $this->y1 = $data['y1'];
             $this->x2 = $data['x2'];
             $this->y2 = $data['y2'];
             if (empty($data['requiredWidth'])) {
                 $data['requiredWidth'] = $this->x2 - $this->x1;
             }
             if (empty($data['requiredHeight'])) {
                 $data['requiredHeight'] = $this->y2 - $this->y1;
             }
             $this->requiredWidth = $data['requiredWidth'];
             $this->requiredHeight = $data['requiredHeight'];
             $transform = array('type' => 'crop', 'x1' => $this->getX1(), 'y1' => $this->getY1(), 'x2' => $this->getX2(), 'y2' => $this->getY2(), 'width' => $this->getRequiredWidth(), 'height' => $this->getRequiredHeight());
             $this->image = ipFileUrl(ipReflection($this->getImageOrig(), $transform, null));
         }
     } else {
         $this->image = $defaultImage;
     }
     if (!empty($data['id'])) {
         $this->id = $data['id'];
     } else {
         $this->id = mt_rand(2, 2147483647);
         //1 used for inline logo
     }
 }
Exemple #4
0
 protected static function concatenate($urls, $ext)
 {
     $key = md5(json_encode($urls));
     $path = 'file/concatenate/' . $key . '.' . $ext;
     if (!is_file(ipFile($path))) {
         $concatenated = '';
         foreach ($urls as $url) {
             $urlContent = self::fetchContent($url);
             if ($urlContent === false) {
                 //break if at least one of the assets can't be downloaded
                 return false;
             }
             if ($ext == 'css') {
                 $urlContent = self::replaceUrls($url, $urlContent);
                 $concatenated .= "\n" . '/*' . $url . "*/\n" . $urlContent;
             }
             if ($ext == 'js') {
                 $urlContent .= ';';
                 $concatenated .= "\n" . '//' . $url . "\n" . $urlContent;
             }
         }
         if (!is_dir(ipFile('file/concatenate'))) {
             mkdir(ipFile('file/concatenate'));
         }
         file_put_contents(ipFile($path), $concatenated);
     }
     return ipFileUrl($path);
 }
 public function downloadPlugin($name, $url, $signature)
 {
     if (is_dir(ipFile("Plugin/{$name}/"))) {
         Service::deactivatePlugin($name);
         Helper::removeDir(ipFile("Plugin/{$name}/"));
     }
     //download plugin
     $net = new \Ip\Internal\NetHelper();
     $pluginTempFilename = $net->downloadFile($url, ipFile('file/secure/tmp/'), $name . '.zip');
     if (!$pluginTempFilename) {
         throw new \Ip\Exception('Plugin file download failed.');
     }
     $archivePath = ipFile('file/secure/tmp/' . $pluginTempFilename);
     //check signature
     $fileMd5 = md5_file($archivePath);
     $rsa = new \Crypt_RSA();
     $rsa->loadKey($this->publicKey);
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $verified = $rsa->verify($fileMd5, base64_decode($signature));
     if (!$verified) {
         throw new \Ip\Exception('Plugin signature verification failed.');
     }
     //extract
     $secureTmpDir = ipFile('file/secure/tmp/');
     $tmpExtractedDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $secureTmpDir);
     \Ip\Internal\Helper\Zip::extract($secureTmpDir . $pluginTempFilename, $secureTmpDir . $tmpExtractedDir);
     unlink($archivePath);
     //install
     $extractedDir = $this->getFirstDir($secureTmpDir . $tmpExtractedDir);
     $installDir = Model::pluginInstallDir();
     $newPluginDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $installDir);
     rename($secureTmpDir . $tmpExtractedDir . '/' . $extractedDir, $installDir . $newPluginDir);
     Service::activatePlugin($name);
 }
Exemple #6
0
 /**
  * @param $info
  * @return array|null
  * @throws \Ip\Exception
  */
 public static function ipRouteAction_150($info)
 {
     $requestFile = ipFile('') . $info['relativeUri'];
     $fileDir = ipFile('file/');
     if (ipRequest()->getRelativePath() != $info['relativeUri']) {
         return null;
         //language specific url.
     }
     if (mb_strpos($requestFile, $fileDir) !== 0) {
         return null;
     }
     $reflection = mb_substr($requestFile, mb_strlen($fileDir));
     $reflection = urldecode($reflection);
     $reflectionModel = ReflectionModel::instance();
     $reflectionRecord = $reflectionModel->getReflectionByReflection($reflection);
     if ($reflectionRecord) {
         $reflectionModel->createReflection($reflectionRecord['original'], $reflectionRecord['reflection'], json_decode($reflectionRecord['options'], true));
         if (is_file(ipFile('file/' . $reflection))) {
             //supply file route
             $result['page'] = null;
             $result['plugin'] = 'Repository';
             $result['controller'] = 'PublicController';
             $result['action'] = 'download';
             return $result;
         }
     }
 }
Exemple #7
0
 /**
  * Execute response and return html response
  *
  * @return \Ip\Response
  */
 public function execute()
 {
     ipContent()->setBlockContent('main', $this->content);
     $layout = $this->getLayout();
     if ($layout[0] == '/' || $layout[1] == ':') {
         // Check if absolute path: '/' for unix, 'C:' for windows
         $viewFile = $layout;
         if (!is_file($viewFile)) {
             $viewFile = ipThemeFile('main.php');
         }
     } elseif (strpos($layout, '/') !== false) {
         //impresspages path. Eg. Ip/Internal/xxx.php
         $viewFile = $layout;
         if (!is_file(ipFile($viewFile))) {
             $viewFile = ipThemeFile('main.php');
         }
     } else {
         //layout file. Like main.php
         $viewFile = ipThemeFile($layout);
         if (!is_file($viewFile)) {
             $viewFile = ipThemeFile('main.php');
         }
     }
     $content = ipView($viewFile, $this->getLayoutVariables())->render();
     $response = new \Ip\Response($content, $this->getHeaders(), $this->getStatusCode());
     return $response;
 }
Exemple #8
0
 public function index()
 {
     ipAddJs('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.js');
     ipAddCss('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.css');
     ipAddJs('Ip/Internal/Core/assets/js/easyXDM/easyXDM.min.js');
     ipAddJs('Ip/Internal/Design/assets/options.js');
     ipAddJs('Ip/Internal/Design/assets/market.js');
     ipAddJs('Ip/Internal/Design/assets/design.js');
     ipAddJs('Ip/Internal/Design/assets/pluginInstall.js');
     ipAddJs('Ip/Internal/System/assets/market.js');
     $model = Model::instance();
     $themes = $model->getAvailableThemes();
     $model = Model::instance();
     $theme = $model->getTheme(ipConfig()->theme());
     $options = $theme->getOptionsAsArray();
     $themePlugins = $model->getThemePlugins();
     $installedPlugins = \Ip\Internal\Plugins\Service::getActivePluginNames();
     $notInstalledPlugins = array();
     //filter plugins that are already installed
     foreach ($themePlugins as $plugin) {
         if (!empty($plugin['name']) && (!in_array($plugin['name'], $installedPlugins) || !is_dir(ipFile('Plugin/' . $plugin['name'])))) {
             $notInstalledPlugins[] = $plugin;
         }
     }
     if (isset($_SESSION['module']['design']['pluginNote'])) {
         $pluginNote = $_SESSION['module']['design']['pluginNote'];
         unset($_SESSION['module']['design']['pluginNote']);
     } else {
         $pluginNote = '';
     }
     $data = array('pluginNote' => $pluginNote, 'theme' => $model->getTheme(ipConfig()->theme()), 'plugins' => $notInstalledPlugins, 'availableThemes' => $themes, 'marketUrl' => $model->getMarketUrl(), 'showConfiguration' => !empty($options), 'contentManagementUrl' => ipConfig()->baseUrl() . '?aa=Content.index', 'contentManagementText' => __('Manage content', 'Ip-admin', false));
     $contentView = ipView('view/layout.php', $data);
     ipResponse()->setLayoutVariable('removeAdminContentWrapper', true);
     return $contentView->render();
 }
Exemple #9
0
 public static function ipFile($path)
 {
     $path = str_replace('Plugin/', 'install/Plugin/', $path);
     if (self::$installationDir) {
         return self::$installationDir . $path;
     } else {
         return ipFile($path);
     }
 }
Exemple #10
0
 /**
  * @param array|string $data
  * @param string $defaultLogo
  */
 public function __construct($data, $defaultLogo = null)
 {
     if (is_string($data)) {
         $data = $this->parseStr($data);
     }
     if (!isset($data['type'])) {
         if ($defaultLogo) {
             $data['type'] = self::TYPE_IMAGE;
         } else {
             $data['type'] = self::TYPE_TEXT;
         }
     }
     switch ($data['type']) {
         case self::TYPE_TEXT:
             $this->type = self::TYPE_TEXT;
             break;
         case self::TYPE_IMAGE:
             $this->type = self::TYPE_IMAGE;
             break;
         default:
             $this->type = self::TYPE_TEXT;
             break;
     }
     if (!empty($data['imageOrig']) && file_exists(ipFile('file/repository/' . $data['imageOrig']))) {
         $this->imageOrig = $data['imageOrig'];
         if (isset($data['x1']) && isset($data['y1']) && isset($data['x2']) && isset($data['y2'])) {
             $this->x1 = $data['x1'];
             $this->y1 = $data['y1'];
             $this->x2 = $data['x2'];
             $this->y2 = $data['y2'];
             if (empty($data['requiredWidth'])) {
                 $data['requiredWidth'] = $this->x2 - $this->x1;
             }
             if (empty($data['requiredHeight'])) {
                 $data['requiredHeight'] = $this->y2 - $this->y1;
             }
             $this->requiredWidth = $data['requiredWidth'];
             $this->requiredHeight = $data['requiredHeight'];
             $transform = array('type' => 'crop', 'x1' => $this->getX1(), 'y1' => $this->getY1(), 'x2' => $this->getX2(), 'y2' => $this->getY2(), 'width' => $this->getRequiredWidth(), 'height' => $this->getRequiredHeight(), 'quality' => 100);
             $requestedName = \Ip\Internal\Text\Specialchars::url(ipGetOptionLang('Config.websiteTitle'));
             $this->image = ipReflection($this->getImageOrig(), $transform, $requestedName);
         }
     } else {
         $this->image = $defaultLogo;
     }
     if (!empty($data['text'])) {
         $this->setText($data['text']);
     } else {
         $this->setText(ipGetOptionLang('Config.websiteTitle'));
     }
     if (isset($data['color'])) {
         $this->setColor($data['color']);
     }
     if (isset($data['font'])) {
         $this->setFont($data['font']);
     }
 }
Exemple #11
0
 protected function pluginIcon($pluginName)
 {
     if (file_exists(ipFile('Plugin/' . $pluginName . '/assets/icon.svg'))) {
         return ipFileUrl('Plugin/' . $pluginName . '/assets/icon.svg');
     }
     if (file_exists(ipFile('Plugin/' . $pluginName . '/assets/icon.png'))) {
         return ipFileUrl('Plugin/' . $pluginName . '/assets/icon.png');
     }
 }
Exemple #12
0
 public static function setupTestDatabase($database, $tablePrefix)
 {
     Model::setInstallationDir(ipFile(''));
     Model::createDatabaseStructure($database, $tablePrefix);
     Model::importData($tablePrefix);
     OptionHelper::import(__DIR__ . '/options.json');
     Model::insertAdmin('test', '*****@*****.**', 'test');
     ipSetOptionLang('Config.websiteTitle', 'TestSite', 'en');
     ipSetOptionLang('Config.websiteEmail', '*****@*****.**', 'en');
 }
Exemple #13
0
 public function getTheme($name = null, $dir = null, $url = null)
 {
     if ($name == null) {
         $name = ipConfig()->theme();
     }
     if ($dir == null) {
         $dir = ipFile('Theme/');
     }
     $model = Model::instance();
     $theme = $model->getTheme($name, $dir, $url);
     return $theme;
 }
Exemple #14
0
 private function extractArchive($archivePath, $extractedPath)
 {
     $fs = new Helper\FileSystem();
     $fs->createWritableDir($extractedPath);
     $fs->clean($extractedPath);
     require_once ipFile('Ip/Internal/PclZip.php');
     $zip = new \PclZip($archivePath);
     $status = $zip->extract(PCLZIP_OPT_PATH, $extractedPath, PCLZIP_OPT_REMOVE_PATH, 'ImpressPages');
     if (!$status) {
         throw new UpdateException("Archive extraction failed");
     }
 }
 /**
  * Get list of all available permissions on the system
  */
 public static function availablePermissions()
 {
     $permissions = array('Super admin', 'Content', 'Pages', 'Design', 'Plugins', 'Config', 'Config advanced', 'Languages', 'System', 'Administrators', 'Log', 'Email', 'Repository', 'Repository upload');
     $plugins = \Ip\Internal\Plugins\Model::getActivePluginNames();
     foreach ($plugins as $plugin) {
         if (is_file(ipFile('Plugin/' . $plugin . '/AdminController.php'))) {
             array_push($permissions, $plugin);
         }
     }
     $permissions = ipFilter('ipAvailablePermissions', $permissions);
     return $permissions;
 }
Exemple #16
0
 public static function ipCacheClear()
 {
     $dir = ipFile('file/concatenate');
     $cacheFiles = scandir($dir);
     foreach ($cacheFiles as $file) {
         if (in_array($file, array('.', '..'))) {
             continue;
         }
         if (is_writable($dir . '/' . $file)) {
             unlink($dir . '/' . $file);
         }
     }
 }
Exemple #17
0
 public function render($view = null)
 {
     if ($this->totalPages < 1 && $this->currentPage == 1) {
         return null;
     }
     if (!$view) {
         $view = ipFile('Ip/Pagination/view/pagination.php');
     }
     $data = $this->options;
     $data['currentPage'] = $this->currentPage;
     $data['totalPages'] = $this->totalPages;
     $data['pages'] = $this->pages();
     return ipView($view, $data)->render();
 }
 public function load($name)
 {
     $fileName = str_replace('\\', '/', $name) . '.php';
     if ($fileName[0] == '/') {
         //in some environments required class starts with slash. In that case remove the slash.
         $fileName = substr($fileName, 1);
     }
     $possibleFilename = ipFile($fileName);
     if (file_exists($possibleFilename)) {
         require_once $possibleFilename;
         return true;
     }
     return false;
 }
Exemple #19
0
 public function generateJavascript()
 {
     $cacheVersion = $this->getCacheVersion();
     $javascriptFiles = $this->getJavascript();
     $javascriptFilesSorted = array();
     foreach ($javascriptFiles as $level) {
         foreach ($level as &$file) {
             if ($file['type'] == 'file' && $file['cacheFix']) {
                 $file['value'] .= (strpos($file['value'], '?') !== false ? '&' : '?') . $cacheVersion;
             }
         }
         $javascriptFilesSorted = array_merge($javascriptFilesSorted, $level);
     }
     $data = array('ip' => array('baseUrl' => ipConfig()->baseUrl(), 'languageId' => null, 'languageUrl' => '', 'theme' => ipConfig()->get('theme'), 'pageId' => null, 'securityToken' => \Ip\ServiceLocator::application()->getSecurityToken(), 'developmentEnvironment' => ipConfig()->isDevelopmentEnvironment(), 'debugMode' => ipconfig()->isDebugMode(), 'isManagementState' => false, 'isAdminState' => false, 'isAdminNavbarDisabled' => false), 'javascriptVariables' => $this->getJavascriptVariables(), 'javascript' => $javascriptFilesSorted);
     return ipView(ipFile('Ip/Internal/Config/view/javascript.php'), $data)->render();
 }
Exemple #20
0
 public static function download()
 {
     $requestFile = ipFile('') . ipRequest()->getRelativePath();
     $fileDir = ipFile('file/');
     if (mb_strpos($requestFile, $fileDir) !== 0) {
         return null;
     }
     $file = mb_substr($requestFile, mb_strlen($fileDir));
     $file = urldecode($file);
     if (empty($file)) {
         throw new \Ip\Exception('Required parameter is missing');
     }
     $absoluteSource = realpath(ipFile('file/' . $file));
     if (!$absoluteSource || !is_file($absoluteSource)) {
         throw new \Ip\Exception\Repository\Transform("File doesn't exist", array('filename' => $absoluteSource));
     }
     if (strpos($absoluteSource, realpath(ipFile('file/'))) !== 0 || strpos($absoluteSource, realpath(ipFile('file/secure'))) === 0) {
         throw new \Exception("Requested file (" . $file . ") is outside of public dir");
     }
     $mime = \Ip\Internal\File\Functions::getMimeType($absoluteSource);
     $fsize = filesize($absoluteSource);
     // set headers
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Cache-Control: public");
     header('Content-type: ' . $mime);
     header("Content-Transfer-Encoding: binary");
     header("Content-Length: " . $fsize);
     // download
     // @readfile($file_path);
     $file = @fopen($absoluteSource, "rb");
     if ($file) {
         while (!feof($file)) {
             print fread($file, 1024 * 8);
             flush();
             if (connection_status() != 0) {
                 @fclose($file);
                 die;
             }
         }
         @fclose($file);
     }
     //TODO provide method to stop any output by ImpressPages
     ipDb()->disconnect();
     exit;
 }
 /**
  * @param string $file relative path from file/repository
  * @param array $options - image cropping options
  * @param string $desiredName - desired file name. If reflection is missing, service will try to create new one with name as possible similar to desired
  * @param bool $onDemand transformation will be create on the fly when image accessed for the first time
  * @return string - file name from BASE_DIR
  * @throws \Ip\Exception\Repository\Transform
  */
 public function getReflection($file, $options, $desiredName = null, $onDemand = true)
 {
     $reflectionModel = ReflectionModel::instance();
     try {
         $reflection = $reflectionModel->getReflection($file, $options, $desiredName, $onDemand);
         if (ipConfig()->get('rewritesDisabled') && !is_file(ipFile('file/' . $reflection)) || !ipConfig()->get('realTimeReflections', true)) {
             //create reflections immediately if mod_rewrite is disabled
             $reflectionRecord = $reflectionModel->getReflectionByReflection($reflection);
             $reflectionModel->createReflection($reflectionRecord['original'], $reflectionRecord['reflection'], json_decode($reflectionRecord['options'], true));
         }
     } catch (\Exception $e) {
         ipLog()->error($e->getMessage(), array('errorTrace' => $e->getTraceAsString()));
         $this->lastException = $e;
         return false;
     }
     return 'file/' . $reflection;
 }
Exemple #22
0
 public function generateHtml($revisionId, $widgetId, $data, $skin)
 {
     if (empty($data['files']) || !is_array($data['files'])) {
         $data['files'] = array();
     }
     $newData = array();
     foreach ($data['files'] as $file) {
         if (!isset($file['fileName'])) {
             continue;
         }
         $newFile = array();
         $newFile['url'] = ipFileUrl('file/repository/' . $file['fileName']);
         $newFile['path'] = ipFile('file/repository/' . $file['fileName']);
         $newFile['title'] = isset($file['title']) ? $file['title'] : $file['fileName'];
         $newData['files'][] = $newFile;
     }
     return parent::generateHtml($revisionId, $widgetId, $newData, $skin);
 }
Exemple #23
0
 public static function extract($archivePath, $destinationDir)
 {
     if (class_exists('\\ZipArchive')) {
         $zip = new \ZipArchive();
         if ($zip->open($archivePath) === true) {
             $zip->extractTo($destinationDir);
             $zip->close();
         } else {
             throw new \Ip\Exception('Zip extraction failed.');
         }
     } else {
         require_once ipFile('Ip/Internal/PclZip.php');
         $zip = new \PclZip($archivePath);
         if (!$zip->extract(PCLZIP_OPT_PATH, $destinationDir)) {
             throw new \Ip\Exception('Zip extraction failed.');
         }
     }
 }
Exemple #24
0
 /**
  * Adds email to the queue
  *
  * Even if there is a big amount of emails, there is always reserved 20% of traffic for immediate emails.
  * Such emails are: registration cofirmation, contact form data and other.
  * Newsletters, greetings always can wait a litle. So they are not immediate and will not be send if is less than 20% of traffic left.
  *
  * @param string $from email address from whish an email should be send
  * @param $fromName
  * @param string $to email address where an email should be send
  * @param $toName
  * @param $subject
  * @param string $email email html text
  * @param bool $immediate indicate hurry of an email.
  * @param bool $html true if email message should be send as html
  * @param array $files files that should be attached to the email. Files should be accessible for php at this moment. They will be cached until send time.
  * @internal param $string @fromName
  * @internal param $string @toName
  */
 function addEmail($from, $fromName, $to, $toName, $subject, $email, $immediate, $html, $files = null)
 {
     $cached_files = array();
     $cached_fileNames = array();
     $cached_fileMimeTypes = array();
     if ($files) {
         if (is_string($files)) {
             $files = array($files);
         }
         foreach ($files as $fileSetting) {
             $file = array();
             if (is_array($fileSetting)) {
                 $file['real_name'] = $fileSetting[0];
                 $file['required_name'] = basename($fileSetting[1]);
             } else {
                 $file['real_name'] = $fileSetting;
                 $file['required_name'] = $fileSetting;
             }
             $new_name = 'contact_form_' . rand();
             $new_name = \Ip\Internal\File\Functions::genUnoccupiedName($new_name, ipFile('file/tmp/'));
             if (copy($file['real_name'], ipFile('file/tmp/' . $new_name))) {
                 $cached_files[] = ipFile('file/tmp/' . $new_name);
                 $cached_fileNames[] = $file['required_name'];
                 $tmpMimeType = \Ip\Internal\File\Functions::getMimeType($file['real_name']);
                 if ($tmpMimeType == null) {
                     $tmpMimeType = 'Application/octet-stream';
                 }
                 $cached_fileMimeTypes[] = $tmpMimeType;
             } else {
                 trigger_error('File caching failed');
             }
         }
     }
     $cachedFilesStr = implode("\n", $cached_files);
     $cachedFileNamesStr = implode("\n", $cached_fileNames);
     $cachedFileMimeTypesStr = implode("\n", $cached_fileMimeTypes);
     $email = str_replace('src="' . ipConfig()->baseUrl(), 'src="', $email);
     Db::addEmail($from, $fromName, $to, $toName, $subject, $email, $immediate, $html, $cachedFilesStr, $cachedFileNamesStr, $cachedFileMimeTypesStr);
 }
Exemple #25
0
 protected static function getAvailableLocales()
 {
     $locales = array();
     $translationDirectories = array(ipFile('Ip/Internal/Translations/translations'), ipFile('file/translations/original'), ipFile('file/translations/override'));
     $files = array();
     foreach ($translationDirectories as $dir) {
         if (!is_dir($dir)) {
             continue;
         }
         $files = array_merge($files, scandir($dir));
     }
     $files = array_unique($files, SORT_STRING);
     sort($files);
     foreach ($files as $file) {
         if (preg_match('/^Ip-admin-([a-z\\_A-Z]+)\\.json$/', $file, $matches)) {
             $locales[] = array($matches[1], strtoupper($matches[1]));
         }
     }
     if (empty($locales)) {
         $locales = array(array('en', 'EN'));
     }
     return $locales;
 }
Exemple #26
0
 /**
  * Used when management is needed in controller routed using routes.
  * @param $info
  * @return null
  */
 public static function ipBeforeController_70($info)
 {
     if (empty($info['page']) || empty($info['management']) || !ipIsManagementState()) {
         return null;
     }
     //find current page
     $page = $info['page'];
     // change layout if safe mode
     if (\Ip\Internal\Admin\Service::isSafeMode()) {
         ipSetLayout(ipFile('Ip/Internal/Admin/view/safeModeLayout.php'));
     } else {
         ipSetLayout($page->getLayout());
     }
     // initialize management
     if (!ipRequest()->getQuery('ipDesignPreview') && !ipRequest()->getQuery('disableManagement')) {
         Helper::initManagement();
     }
     //show page content
     $response = ipResponse();
     $response->setDescription(\Ip\ServiceLocator::content()->getDescription());
     $response->setKeywords(ipContent()->getKeywords());
     $response->setTitle(ipContent()->getTitle());
 }
Exemple #27
0
 private static function findPluginWidgets($moduleName)
 {
     $widgetDir = ipFile('Plugin/' . $moduleName . '/' . Model::WIDGET_DIR . '/');
     if (!is_dir($widgetDir)) {
         return array();
     }
     $widgetFolders = scandir($widgetDir);
     if ($widgetFolders === false) {
         return array();
     }
     $answer = array();
     //foreach all widget folders
     foreach ($widgetFolders as $widgetFolder) {
         //each directory is a widget
         if (!is_dir($widgetDir . $widgetFolder) || $widgetFolder == '.' || $widgetFolder == '..') {
             continue;
         }
         if (isset($answer[(string) $widgetFolder])) {
             ipLog()->warning('Content.duplicateWidget: {widget}', array('plugin' => 'Content', 'widget' => $widgetFolder));
         }
         $answer[] = array('module' => $moduleName, 'dir' => $widgetDir . $widgetFolder . '/', 'widgetKey' => $widgetFolder);
     }
     return $answer;
 }
Exemple #28
0
 /**
  * @ignore
  */
 public function modulesInit()
 {
     $translator = \Ip\ServiceLocator::translator();
     $overrideDir = ipFile("file/translations/override/");
     $plugins = \Ip\Internal\Plugins\Service::getActivePluginNames();
     foreach ($plugins as $plugin) {
         $translationsDir = ipFile("Plugin/{$plugin}/translations/");
         $translator->addTranslationFilePattern('json', $translationsDir, "{$plugin}-%s.json", $plugin);
         $translator->addTranslationFilePattern('json', $overrideDir, "{$plugin}-%s.json", $plugin);
         $translator->addTranslationFilePattern('json', $translationsDir, "{$plugin}-admin-%s.json", $plugin . '-admin');
         $translator->addTranslationFilePattern('json', $overrideDir, "{$plugin}-admin-%s.json", $plugin . '-admin');
     }
     foreach ($plugins as $plugin) {
         $routesFile = ipFile("Plugin/{$plugin}/routes.php");
         $this->addFileRoutes($routesFile, $plugin);
     }
     $this->addFileRoutes(ipFile('Ip/Internal/Ecommerce/routes.php'), 'Ecommerce');
 }
Exemple #29
0
$application = new \Ip\Application(__DIR__ . '/config.php');
$application->init();
$options = array('skipErrorHandler' => true);
$application->prepareEnvironment($options);
$options = array('skipInitEvents' => true, 'skipModuleInit' => true, 'translationsLanguageCode' => \Plugin\Install\Helper::$defaultLanguageCode);
if (!empty($_REQUEST['lang']) && strlen($_REQUEST['lang']) == 2 && ctype_alpha($_REQUEST['lang'])) {
    $_SESSION['installationLanguage'] = $_REQUEST['lang'];
}
if (isset($_SESSION['installationLanguage'])) {
    $options['translationsLanguageCode'] = $_SESSION['installationLanguage'];
}
// Because module init is skipped, we have to initialize translations manually
$translator = \Ip\ServiceLocator::translator();
$translator->setLocale($options['translationsLanguageCode']);
$trPluginDir = ipFile('Plugin/Install/translations/');
$trOverrideDir = ipFile('file/translations/override/');
$translator->addTranslationFilePattern('json', $trPluginDir, 'Install-%s.json', 'Install');
$translator->addTranslationFilePattern('json', $trOverrideDir, 'Install-%s.json', 'Install');
$request = new \Plugin\Install\Request();
$request->setQuery($_GET);
$request->setPost($_POST);
$request->setServer($_SERVER);
$request->setRequest($_REQUEST);
\Ip\ServiceLocator::addRequest($request);
$language = new \Ip\Language(null, $options['translationsLanguageCode'], null, null, null, 0, 'ltr');
ipContent()->_setCurrentLanguage($language);
\Ip\ServiceLocator::dispatcher()->_bindInstallEvents();
if ($request->isGet()) {
    $controller = new \Plugin\Install\PublicController();
    if (!empty($_GET['pa']) && $_GET['pa'] == 'Install.testSessions') {
        $response = $controller->testSessions();
Exemple #30
0
 /**
  * Rebuilds compiled css files.
  *
  * @param string $themeName
  */
 public function rebuild($themeName)
 {
     $lessFiles = $this->getLessFiles($themeName);
     foreach ($lessFiles as $file) {
         $lessFile = basename($file);
         $css = $this->compileFile($themeName, basename($lessFile));
         file_put_contents(ipFile('Theme/' . $themeName . '/' . \Ip\Application::ASSETS_DIR . '/' . substr($lessFile, 0, -4) . 'css'), $css);
     }
 }