public static function slugRedirect($slug, $menuClasses = null) { foreach (self::getMenuItems($menuClasses) as $menuList) { foreach ($menuList as $row) { if (isset($row['slug']) && $row['slug'] == $slug) { header('Location: ' . Cfg::siteUrl() . '/' . $row['url']); exit; } } } // Default header('Location: ' . Cfg::siteUrl()); exit; }
protected function zoom() { $siteUrl = Cfg::siteUrl(); $html = ''; $html .= JS::library(JS::JQUERY); // Get the current Pin $url = Request::get('url'); $jQuery = <<<JS var currentXPos = 0; var currentYPos = 0; var IE = document.all?true:false if (!IE) document.captureEvents(Event.MOUSEMOVE); document.onmousemove = getMouseXY; function getMouseXY(e) { if (IE) { // grab the x-y pos.s if browser is IE currentXPos = event.clientX + document.body.scrollLeft; currentYPos = event.clientY + document.body.scrollTop; } else { // grab the x-y pos.s if browser is NS currentXPos = e.pageX; currentYPos = e.pageY; } if (currentXPos < 0) currentXPos = 0; if (currentYPos < 0) currentYPos = 0; return true; } function movePinToCursor () { var offs = \$('#baseImage').offset(); \$('#PinTop').attr ( 'value', '' + parseInt ( currentYPos - offs.top ) ); \$('#PinLeft').attr ( 'value', '' + parseInt ( currentXPos - offs.left ) ); } JS; $html .= JS::javaScript($jQuery); $html .= Tag::img($siteUrl . $url, ['title' => 'Click on this image to move the Pin', 'id' => 'baseImage', 'onClick' => 'movePinToCursor();', 'name' => 'voodoo_image']); $html .= '<br>X' . Tag::text('PinLeft', '', ['size' => 4, 'id' => 'PinLeft']); $html .= '<br>Y' . Tag::text('PinTop', '', ['size' => 4, 'id' => 'PinTop']); return $html; }
public function imageUrl() { $resp = new Response(); $url = Cfg::siteUrl() . '/ajax.php?' . Response::factory()->action(__CLASS__ . '::img()')->set('_CP1', $this->value)->set('_CP4', $this->hatch)->toUrl(Response::UNIQUE_CSRF); return $url; }
public static function doRedirect() { $redirectTime = 0; if (($index = Cfg::get('index')) == '') { $index = Cfg::siteUrl() . '/index.php'; } $url = Request::get(WebPage::SAVE_URL, $index); echo sprintf('<meta HTTP-EQUIV="REFRESH" content="%s; url=%s">', $redirectTime, $url); exit; }
private static function ensureNoForgery() { if (!Cfg::get('jb_forgery_check', true)) { return; } // Check if the current script is exempt from forgery check $fileName = ''; if (isset($_SERVER['SCRIPT_FILENAME'])) { $fileName = $_SERVER['SCRIPT_FILENAME']; } else { if (isset($_SERVER['argv'][0])) { $fileName = $_SERVER['argv'][0]; } } if (in_array(basename($fileName), Cfg::get('exempt', []))) { return; } // Add the known request variables to TamperGuard foreach (Cfg::get('known', []) as $val) { TamperGuard::known($val); } $message = null; if (($tg = TimeGuard::check()) !== TimeGuard::NOGUARD) { if ($tg !== true) { $message = <<<HTML Invalid AJAX Request ({$tg})<br/> %s has detected changes in the URL.<br/> Please do not manually edit URL or reuse URL (support %s).<br/> You will be <a href="%s">redirected</a> in %s seconds <meta HTTP-EQUIV="REFRESH" content="%s; url=%s"> HTML; } } else { if (($reqChk = Request::check()) !== true) { $reqChk = str_replace('%', '%%', $reqChk); $message = <<<HTML Invalid or expired request (URL Error - {$reqChk})<br/> %s has detected changes in the URL.<br/> Please do not manually edit URL (support %s).<br/> You will be <a href="%s">redirected</a> in %s seconds <meta HTTP-EQUIV="REFRESH" content="%s; url=%s"> HTML; } else { if (!CSRFGuard::check()) { $message = <<<HTML Invalid Request (CSRF error)<br/> %s has detected re-submission or form tampering.<br/> please contact support %s<br/> You will be <a href="%s">redirected</a> in %s seconds <meta HTTP-EQUIV="REFRESH" content="%s; url=%s"> HTML; } } } if ($message != null) { $seconds = '5'; if (($location = Cfg::get('index')) == '') { $location = Cfg::siteUrl() . '/index.php'; } echo sprintf($message, Cfg::get('version'), Cfg::get('boss'), $location, $seconds, $seconds, $location); exit; } }