public function processLogin() { require_once dirname(__FILE__) . '../../../../modules/designer/designer.php'; $themeName = trim(Tools::getValue('theme_name')); $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); $domain = getSessionDomain($themeName); $version = function_exists('theme_get_manifest_version') ? '&ver=' . theme_get_manifest_version($themeName) : ''; $desktop = function_exists('getDesktopParams') ? getDesktopParams() : ''; if (empty($email)) { $this->errors[] = Tools::displayError('E-mail is empty'); } elseif (!Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid e-mail address'); } if (empty($passwd)) { $this->errors[] = Tools::displayError('Password is blank'); } elseif (!Validate::isPasswd($passwd)) { $this->errors[] = Tools::displayError('Invalid password'); } if (!count($this->errors)) { $this->context->employee = new Employee(); $is_employee_loaded = $this->context->employee->getByemail($email, $passwd); $employee_associated_shop = $this->context->employee->getAssociatedShops(); if (!$is_employee_loaded) { $this->errors[] = Tools::displayError('Employee does not exist or password is incorrect.'); $this->context->employee->logout(); } elseif (empty($employee_associated_shop) && !$this->context->employee->isSuperAdmin()) { $this->errors[] = Tools::displayError('Employee does not manage any shop anymore (shop has been deleted or permissions have been removed).'); $this->context->employee->logout(); } else { $this->context->employee->remote_addr = ip2long(Tools::getRemoteAddr()); $cookie = Context::getContext()->cookie; $cookie->id_employee = $this->context->employee->id; $cookie->email = $this->context->employee->email; $cookie->profile = $this->context->employee->id_profile; $cookie->passwd = $this->context->employee->passwd; $cookie->remote_addr = $this->context->employee->remote_addr; $cookie->write(); if (Tools::getIsset('theme_name')) { $url = $this->context->link->getAdminLink('AdminAjax') . '&ajax=1' . $domain . $version . $desktop; } else { $tab = new Tab((int) $this->context->employee->default_tab); $url = $this->context->link->getAdminLink($tab->class_name); } if (Tools::isSubmit('ajax')) { die(Tools::jsonEncode(array('hasErrors' => false, 'redirect' => $url))); } else { $this->redirect_after = $url; } } } if (Tools::isSubmit('ajax')) { die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors))); } }
private function _buildPage($themeName) { $version = theme_get_manifest_version($themeName); theme_copy_manifest($themeName, $version); $manifestVersion = '&ver=' . $version; $token = $this->token; $adminUrl = $this->_adminUrl; $moduleUrl = $this->_baseUrl . 'modules/designer'; $manifestPath = FilesHelper::normalizePath(getThemeDir($themeName)) . '/export/themler.manifest'; $manifest = file_exists($manifestPath) ? sprintf('manifest="%s/Export/Manifest.php"', $moduleUrl) : ''; $version = time(); $output = <<<EOT <!DOCTYPE html> <html manifest="{$adminUrl}?ajax=1&action=getManifest&controller=AdminAjax&token={$token}{$manifestVersion}"> <head> <title>Themler</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <script type="text/javascript" src="{$adminUrl}?ajax=1&action=initProject&controller=AdminAjax&token={$token}&themeName={$themeName}"></script> <script type="text/javascript" src="{$moduleUrl}/DataProvider.js?version={$version}"></script> <script type="text/javascript" src="{$moduleUrl}/loader.js?version={$version}"></script> </head> <body> </body> </html> EOT; return $output; }
function theme_save_manifest($themeName, $manifest) { $themeDir = FilesHelper::normalizePath(getThemeDir($themeName)); $version = theme_get_manifest_version($themeName, $manifest); FilesHelper::writeFile($themeDir . '/export/' . $version, $manifest); FilesHelper::writeFile($themeDir . '/export/manifest.version', $version); }
public static function buildThemesData($currentIndex = '', $adminDir = '') { $token = Designer::getToken(); $baseUrl = Designer::getBaseUrlWithLastSlash(); $themesUrl = $baseUrl . 'themes'; $adminUrl = $baseUrl . $adminDir . '/' . ($currentIndex ? $currentIndex : 'index.php?controller=AdminAjax') . '&token=' . $token; $shop = Designer::getShop(); $themes = array(); foreach (Theme::getAvailable(false) as $themeName) { if (strpos($themeName, _PREVIEW_SUFFIX_) !== FALSE || !file_exists(getProjectPath($themeName))) { continue; } $id = Designer::getThemeId($themeName); $themeUrl = $themesUrl . '/' . $themeName; $url = $adminUrl . '&theme_name=' . $themeName; $themes['themes'][$themeName] = array('themeName' => $themeName, 'thumbnailUrl' => $themeUrl . '/preview.jpg', 'openUrl' => $url . '&ajax=1&ver=' . theme_get_manifest_version($themeName) . getDesktopParams(), 'settingsUrl' => $url . '&edit=1', 'isActive' => $id && $shop->id_theme == $id); } return $themes; }