public function writeResponse(DevblocksHttpResponse $response) { $umsession = UmPortalHelper::getSession(); $stack = $response->path; $tpl = DevblocksPlatform::getTemplateService(); $tpl_path = dirname(dirname(__FILE__)) . '/templates/'; $tpl->assign('portal_code', UmPortalHelper::getCode()); $page_title = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_PAGE_TITLE, 'Support Center'); $tpl->assign('page_title', $page_title); $login_handler = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_LOGIN_HANDLER, ''); $tpl->assign('login_handler', $login_handler); $login_extension = DevblocksPlatform::getExtension($login_handler, true); $tpl->assign('login_extension', $login_extension); @($visible_modules = unserialize(DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_VISIBLE_MODULES, ''))); $tpl->assign('visible_modules', $visible_modules); @($active_user = $umsession->getProperty('sc_login', null)); $tpl->assign('active_user', $active_user); // Usermeet Session if (null == ($fingerprint = UmPortalHelper::getFingerprint())) { die("A problem occurred."); } $tpl->assign('fingerprint', $fingerprint); $module_uri = array_shift($stack); switch ($module_uri) { case 'ajax': $controller = new UmScAjaxController(null); $controller->handleRequest(new DevblocksHttpRequest($stack)); break; case 'rss': $controller = new UmScRssController(null); $controller->handleRequest(new DevblocksHttpRequest($stack)); break; case 'captcha': @($color = DevblocksPlatform::parseCsvString(DevblocksPlatform::importGPC($_REQUEST['color'], 'string', '40,40,40'))); @($bgcolor = DevblocksPlatform::parseCsvString(DevblocksPlatform::importGPC($_REQUEST['bgcolor'], 'string', '240,240,240'))); // Sanitize colors // [TODO] Sanitize numeric range for elements 0-2 if (3 != count($color)) { $color = array(40, 40, 40); } if (3 != count($bgcolor)) { $color = array(240, 240, 240); } header('Cache-control: max-age=0', true); // 1 wk // , must-revalidate header('Expires: ' . gmdate('D, d M Y H:i:s', time() - 604800) . ' GMT'); // 1 wk header('Content-type: image/jpeg'); // Get CAPTCHA secret passphrase $phrase = CerberusApplication::generatePassword(4); $umsession->setProperty(UmScApp::SESSION_CAPTCHA, $phrase); $im = @imagecreate(150, 70) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, $bgcolor[0], $bgcolor[1], $bgcolor[2]); $text_color = imagecolorallocate($im, $color[0], $color[1], $color[2]); $font = DEVBLOCKS_PATH . 'resources/font/ryanlerch_-_Tuffy_Bold(2).ttf'; imagettftext($im, 24, mt_rand(0, 20), 5, 60 + 6, $text_color, $font, $phrase); imagejpeg($im, null, 85); imagedestroy($im); exit; break; case 'captcha.check': $entered = DevblocksPlatform::importGPC($_REQUEST['captcha'], 'string', ''); $captcha = $umsession->getProperty(UmScApp::SESSION_CAPTCHA, ''); if (!empty($entered) && !empty($captcha) && 0 == strcasecmp($entered, $captcha)) { echo 'true'; exit; } echo 'false'; exit; break; default: // Build the menu $modules = $this->_getModules(); $menu_modules = array(); if (is_array($modules)) { foreach ($modules as $uri => $module) { // Must be menu renderable if (!empty($module->manifest->params['menu_title']) && !empty($uri)) { $menu_modules[$uri] = $module; } } } $tpl->assign('menu', $menu_modules); // Modules if (isset($modules[$module_uri])) { $controller = $modules[$module_uri]; } else { // First menu item $controller = reset($menu_modules); } array_unshift($stack, $module_uri); $tpl->assign('module', $controller); $tpl->assign('module_response', new DevblocksHttpResponse($stack)); $tpl->display('devblocks:usermeet.core:support_center/index.tpl:portal_' . UmPortalHelper::getCode()); break; } }
public function writeResponse(DevblocksHttpResponse $response) { $umsession = UmPortalHelper::getSession(); $stack = $response->path; $tpl = DevblocksPlatform::getTemplateService(); $tpl->cache_lifetime = "0"; $tpl_path = dirname(dirname(__FILE__)) . '/templates/'; $tpl->assign('tpl_path', $tpl_path); $logo_url = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_LOGO_URL, ''); $tpl->assign('logo_url', $logo_url); $page_title = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_PAGE_TITLE, 'Support Center'); $tpl->assign('page_title', $page_title); $style_css = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_STYLE_CSS, ''); $tpl->assign('style_css', $style_css); $footer_html = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_FOOTER_HTML, ''); $tpl->assign('footer_html', $footer_html); $allow_logins = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_ALLOW_LOGINS, 0); $tpl->assign('allow_logins', $allow_logins); $enabled_modules = DevblocksPlatform::parseCsvString(DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_ENABLED_MODULES, '')); $tpl->assign('enabled_modules', $enabled_modules); @($active_user = $umsession->getProperty('sc_login', null)); $tpl->assign('active_user', $active_user); // Usermeet Session if (null == ($fingerprint = UmPortalHelper::getFingerprint())) { die("A problem occurred."); } $tpl->assign('fingerprint', $fingerprint); $module_uri = array_shift($stack); switch ($module_uri) { case 'ajax': $controller = new UmScAjaxController(null); $controller->handleRequest(new DevblocksHttpRequest($stack)); break; case 'rss': $controller = new UmScRssController(null); $controller->handleRequest(new DevblocksHttpRequest($stack)); break; case 'captcha': header('Cache-control: max-age=0', true); // 1 wk // , must-revalidate header('Expires: ' . gmdate('D, d M Y H:i:s', time() - 604800) . ' GMT'); // 1 wk header('Content-type: image/jpeg'); // Get CAPTCHA secret passphrase $phrase = CerberusApplication::generatePassword(4); $umsession->setProperty(UmScApp::SESSION_CAPTCHA, $phrase); $im = @imagecreate(150, 70) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 240, 240, 240); $text_color = imagecolorallocate($im, 40, 40, 40); //233, 14, 91 $font = DEVBLOCKS_PATH . 'resources/font/ryanlerch_-_Tuffy_Bold(2).ttf'; imagettftext($im, 24, mt_rand(0, 20), 5, 60 + 6, $text_color, $font, $phrase); imagejpeg($im, null, 85); imagedestroy($im); exit; break; default: // Build the menu $modules = $this->_getModules(); $menu_modules = array(); if (is_array($modules)) { foreach ($modules as $uri => $module) { // Must be menu renderable if (!empty($module->manifest->params['menu_title']) && !empty($uri)) { $menu_modules[$uri] = $module; } } } $tpl->assign('menu', $menu_modules); if (isset($modules[$module_uri])) { $controller = $modules[$module_uri]; } else { // First menu item $controller = reset($menu_modules); } array_unshift($stack, $module_uri); $tpl->assign('module', $controller); $tpl->assign('module_response', new DevblocksHttpResponse($stack)); $tpl->display('file:' . $tpl_path . 'portal/sc/module/index.tpl'); break; } }