function checkAuth($redirectIfNeeded) { // is the user already logged in? if (isset($_SESSION["uid"]) && $_SESSION["uid"] != "") { // yes, already logged in return $_SESSION["uid"]; } else { if ($redirectIfNeeded) { // user is not logged in and needs to do so // send to the login page // pass the current URL so that we can come back here after login $currentUrl = currentUrl(); // rawurlencode converts the string so it's safe to pass as a URL GET parameter $urlOfLogin = "******" . rawurlencode($currentUrl) . "&cb=" . microtime(true); // use a JavaScript redirect; FYI, there's also an http header (Location:) that // can be used to redirect, but that MUST be sent before any HTML, and this // function (checkAuth) might be called after some HTML is sent echo "<script>location.replace('{$urlOfLogin}');</script>"; return ""; } else { // user is not logged in, but whoever called this function doesn't care return ""; } } }
public function indexAct() { $id = I('get.id'); $info = D('activity')->where(array('id' => $id))->find(); $this->assign('info', $info); $this->assign('inviteurl', currentUrl()); $this->display(); }
function currentPage() { $currentPage = end(explode('/', currentUrl())); $currentPage = str_replace('.php', '', $currentPage); $currentPage = preg_replace('/\\?.*/', '', $currentPage); if (empty($currentPage) || $currentPage === 'home') { $currentPage = 'home'; } return $currentPage; }
public function __construct() { parent::__construct(); $this->ogType = 'website'; $this->ogUrl = currentUrl(); $this->ogTitle = appName(); $this->ogDescription = appDescription(); $this->ogImage = appLogo(); $this->ogSiteName = appName(); $this->ogLocale = currentFullLocaleCode(); $this->ogLocaleAlternate = allSupportedFullLocaleCodes(); }
/** * Digunakan untuk pengalihan halaman (URL) * * @param string $url URL Tujuan * @return void */ function redirect($url = '', $delay = false) { if (PHP_SAPI != 'cli') { $url = strpos('?', $url) === 1 ? currentUrl($url) : siteUrl($url); if ($delay !== false) { header("refresh: {$delay}; url={$url}"); } else { header("Location: " . $url); } unset($_POST, $_GET, $_REQUEST); exit; } return; }
protected function _session_openid() { $wechatObj = wechatInstance(); if ($_GET['code']) { $result = $wechatObj->getOauthAccessToken(); $userInfo = $wechatObj->getUserInfo($result['openid']); $this->_saveUserInfo($userInfo); session('openid', $result['openid']); } else { //$callBackUrl = __BASE__.substr(UC(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME),1); $callBackUrl = currentUrl(); $url = $wechatObj->getOauthRedirect($callBackUrl, '', 'snsapi_base'); redirect($url); } }
function checkAuth($redirectIfNeeded) { if (isset($_SESSION["uid"]) && $_SESSION["uid"] != "") { return $_SESSION["uid"]; } else { if ($redirectIfNeeded) { $currentUrl = currentUrl(); $urlOfLogin = "******" . rawurlencode($currentUrl) . "&cb=" . microtime(true); echo "<script>location.replace('{$urlOfLogin}');</script>"; return ""; } else { return ""; } } }
/** * Setup Anchor tag * * @param mixed $url Path or Permalink * @param string $label Text label * @return string */ function anchor($url, $label = '', array $extras = []) { if (is_array($url) and $label == '') { $attrs = $url; $label = $attrs['label']; unset($attrs['label']); } else { $attrs = ['href' => $url]; } $attrs = array_merge($extras, $attrs); if ($attrs['href'] == '' || substr($attrs['href'], 0, 2) != '//') { $attrs['href'] = siteUrl($attrs['href']); } elseif (strpos('?', $attrs['href']) === 1) { $attrs['href'] = currentUrl($attrs['href'], true); } if (!isset($attrs['class']) or isset($attrs['class']) and strpos($attrs['class'], 'btn') === false) { $attrs['tabindex'] = '-1'; } return '<a ' . parseAttrs($attrs) . '>' . $label . '</a>'; }
public function current(string $fix = NULL) : string { return currentUrl($fix); }
//-------------------------------------------------------------------------------------------------- // SITE_URL //-------------------------------------------------------------------------------------------------- // // @return example.com/zeroneed.php // //-------------------------------------------------------------------------------------------------- define('SITE_URL', siteUrl()); //-------------------------------------------------------------------------------------------------- // CURRENT_URL //-------------------------------------------------------------------------------------------------- // // @return example.com/aktive // //-------------------------------------------------------------------------------------------------- define('CURRENT_URL', currentUrl()); //-------------------------------------------------------------------------------------------------- // PREV_URL //-------------------------------------------------------------------------------------------------- // // @return example.com/prev // //-------------------------------------------------------------------------------------------------- define('PREV_URL', prevUrl()); //-------------------------------------------------------------------------------------------------- // HOST_URL //-------------------------------------------------------------------------------------------------- // // @return hostname // //--------------------------------------------------------------------------------------------------
if (!isset($context)) { header('Location: ' . $link['kb'] . '?code=' . $errorCode['FORUM_INTEGRATION']); } //Load other classes and database login info require_once $link['root'] . 'classes/Format.php'; require_once $link['root'] . 'classes/Validation.php'; require_once $link['root'] . 'setting.php'; require_once $link['root'] . 'classes/Help.php'; //Gets website setting !DO NOT REMOVE IT! $setting = getSetting(); //Save current page url into session for login/logout redirect............ well it does not work anyway! could be a SMF Bug. if (!strpos(currentUrl(), 'login') && !strpos(currentUrl(), 'logout') && !strpos(currentUrl(), 'includes') && !strpos(currentUrl(), 'styles') && !strpos(currentUrl(), 'img') && !strpos(currentUrl(), 'kb')) { $_SESSION['login_url'] = currentUrl(); $_SESSION['logout_url'] = currentUrl(); $_SESSION['old_url'] = currentUrl(); $_SESSION['redirect'] = currentUrl(); } $_SESSION['previous_page'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $link['url']; // var_dump($_SESSION['redirect']); //Get user avatar or use the default avatar $user_avatar = $context['user']['avatar'] != null ? $context['user']['avatar']['href'] : $link['url'] . 'img/usersmall.jpg'; //Get the musicbee satble and beta release data $releaseData['stable'] = getVersionInfo(0, 'byCurrentVersion')[0]; $releaseData['beta'] = getVersionInfo(1, 'byCurrentVersion')[0]; //Contains EVERYTHING in single multidimensional array! DO NOT REMOVE IT! $mb = array('website' => array('ver' => '1.9.0', 'show_warning' => false, 'is_test' => false, 'github_link' => 'https://github.com/Avik-B/mb_web/'), 'charset' => 'UTF-8', 'user' => array('id' => $context['user']['id'], 'is_logged' => $context['user']['is_logged'], 'is_guest' => $context['user']['is_guest'], 'is_admin' => $context['user']['is_admin'], 'is_mod' => $context['user']['is_mod'], 'is_elite' => false, 'is_newbie' => false, 'rank_name' => null, 'need_approval' => true, 'can_mod' => $context['user']['can_mod'], 'username' => $context['user']['name'], 'email' => $context['user']['email'], 'name' => $context['user']['name'], 'messages' => $context['user']['messages'], 'unread_messages' => $context['user']['unread_messages'], 'avatar' => $user_avatar), 'session_var' => $context['session_var'], 'session_id' => $context['session_id'], 'current_time' => array('date' => date("F j, Y"), 'date_time' => date("F j, Y, g:i a")), 'main_menu' => array('dashboard' => array('title' => $lang['dashboard'], 'href' => $link['addon']['dashboard'], 'restriction' => 'login', 'sub_menu' => array()), 'member-panel' => array('title' => '<img src="' . $user_avatar . '" class="user_avatar">', 'href' => $link['forum'] . '?action=profile', 'restriction' => 'login', 'sub_menu' => array('user-profile' => array('title' => '' . sprintf($lang['hey_username'], $context['user']['name']) . '', 'href' => $link['forum'] . '?action=profile'), 'line1' => array('title' => $lang['line']), 'admin-panel' => array('title' => $lang['web_admin'], 'href' => $link['addon']['dashboard'] . '#admin_setting', 'icon' => $lang['20'], 'restriction' => 'admin'), 'forum-admin' => array('title' => $lang['forum_admin'], 'href' => $link['admin']['forum-panel'], 'icon' => $lang['21'], 'restriction' => 'admin'), 'line2' => array('title' => $lang['line']), 'sign-out' => array('title' => $lang['sign_out'], 'href' => $link['logout'], 'icon' => $lang['23']))), 'download' => array('title' => $lang['download'], 'href' => $link['download'], 'sub_menu' => array()), 'add-ons' => array('title' => $lang['addons'], 'href' => $link['addon']['home'], 'sub_menu' => array('1' => array('title' => $lang['skins'], 'href' => $link['addon']['home'] . "s/?type=1", 'icon' => $lang['24'], 'desc' => $lang['description_1'], 'id' => 1), '2' => array('title' => $lang['plugins'], 'href' => $link['addon']['home'] . "s/?type=2", 'icon' => $lang['25'], 'desc' => $lang['description_2'], 'id' => 2), '3' => array('title' => $lang['visualizer'], 'href' => $link['addon']['home'] . "s/?type=3", 'icon' => $lang['26'], 'desc' => $lang['description_3'], 'id' => 3), '4' => array('title' => $lang['theater_mode'], 'href' => $link['addon']['home'] . "s/?type=4", 'icon' => $lang['28'], 'desc' => $lang['description_5'], 'id' => 4), '5' => array('title' => $lang['misc'], 'href' => $link['addon']['home'] . "s/?type=5", 'icon' => $lang['29'], 'desc' => $lang['description_6'], 'id' => 5))), 'forum' => array('title' => $lang['forum'], 'href' => $link['forum'], 'sub_menu' => array()), 'help' => array('title' => $lang['help'], 'href' => $link['faq'], 'sub_menu' => array('faq' => array('title' => $lang['faq'], 'href' => $link['faq'], 'icon' => $lang['faq_icon']), 'api' => array('title' => $lang['dev_api'], 'href' => $link['api'], 'icon' => $lang['code_icon']), 'line2' => array('title' => $lang['line']), 'release-note' => array('title' => $lang['release-note'], 'href' => $link['release-note'], 'icon' => $lang['note_icon']), 'press' => array('title' => $lang['press'], 'href' => $link['press'], 'icon' => $lang['press_icon']), 'line3' => array('title' => $lang['line']), 'bug' => array('title' => $lang['report_bug'], 'href' => $link['bugreport'], 'icon' => $lang['bug_icon'], 'hide' => true), 'wiki' => array('title' => $lang['mb_wiki'], 'href' => $setting['wikiaLink'], 'icon' => $lang['wiki_icon'], 'target' => '_blank', 'hide' => true)))), 'musicbee_download' => array('stable' => array('appname' => isset($releaseData['stable']['appname']) ? $releaseData['stable']['appname'] : "NA", 'version' => isset($releaseData['stable']['version']) ? $releaseData['stable']['version'] : "NA", 'release_date' => isset($releaseData['stable']['release_date']) ? $releaseData['stable']['release_date'] : "NA", 'supported_os' => isset($releaseData['stable']['supported_os']) ? $releaseData['stable']['supported_os'] : "NA", 'download' => array('available' => isset($releaseData['stable']['available']) ? $releaseData['stable']['available'] : 0, 'installer' => array('link1' => isset($releaseData['stable']['DownloadLink']) ? $releaseData['stable']['DownloadLink'] : "NA", 'link2' => isset($releaseData['stable']['MirrorLink1']) ? $releaseData['stable']['MirrorLink1'] : null, 'link3' => isset($releaseData['stable']['MirrorLink2']) ? $releaseData['stable']['MirrorLink2'] : null), 'portable' => array('link1' => isset($releaseData['stable']['PortableLink']) ? $releaseData['stable']['PortableLink'] : "NA"))), 'beta' => array('appname' => isset($releaseData['beta']['appname']) ? $releaseData['beta']['appname'] : "NA", 'version' => isset($releaseData['beta']['version']) ? $releaseData['beta']['version'] : "NA", 'release_date' => isset($releaseData['beta']['release_date']) ? $releaseData['beta']['release_date'] : "NA", 'supported_os' => isset($releaseData['beta']['supported_os']) ? $releaseData['beta']['supported_os'] : "NA", 'download' => array('available' => isset($releaseData['beta']['available']) ? $releaseData['beta']['available'] : 0, 'link1' => isset($releaseData['beta']['DownloadLink']) ? $releaseData['beta']['DownloadLink'] : "NA"), 'message' => isset($releaseData['beta']['message']) ? $releaseData['beta']['message'] : null), 'patch' => getVersionInfo(2, 'byCurrentVersion')[0]), 'help' => Help::getHelp(), 'view_range' => array('addon_view_range' => 20, 'dashboard_all_view_range' => 20, 'release_all_view_range' => 20)); //var_dump($mb['musicbee_download']); /** * Maybe we don't wan't anyone except admin to see this, show error to anyone else. Or maybe * this is only available for logged in users. No guest is allowed kicked them to error page */
public static function createLink() { self::$totalPages = ceil(self::$numberOfRows / self::$resultPerPage); $halfPages = floor(self::$numberOfPages / 2); $range = ['Start' => 1, 'End' => self::$totalPages]; $isEven = self::$numberOfPages % 2 == 0; $atRangeEnd = self::$totalPages - $halfPages; $parseUrl = parse_url(currentUrl()); $url = $parseUrl['scheme'] . "://" . $parseUrl['host'] . $parseUrl['path']; unset($_GET['page']); if (count($_GET) > 0) { $url .= '?' . http_build_query($_GET); } $query = parse_url($url, PHP_URL_QUERY); if ($query) { $url = $url . '&page='; } else { $url = $url . '?page='; } if ($isEven) { $atRangeEnd++; } if (self::$totalPages > self::$numberOfPages) { if (self::$page <= $halfPages) { $range['End'] = self::$numberOfPages; } else { if (self::$page >= $atRangeEnd) { $range['Start'] = self::$totalPages - self::$numberOfPages + 1; } else { $range['Start'] = self::$page - $halfPages; $range['End'] = self::$page + $halfPages; if ($isEven) { $range['End']--; } } } } $result = self::$fullTagOpen . PHP_EOL; if (!empty(self::$firstLabel) && self::$page > 1) { $result .= self::$tagOpen . '<a href="' . $url . '1">' . self::$firstLabel . '</a>' . self::$tagClose . PHP_EOL; } if (!empty(self::$prevLabel) && self::$page > 1) { $result .= self::$tagOpen . '<a href="' . $url . (self::$page - 1) . '">' . self::$prevLabel . '</a>' . self::$tagClose . PHP_EOL; } if (self::$usePageNumber) { for ($i = $range['Start']; $i <= $range['End']; $i++) { if ($i == self::$page) { $result .= self::$tagOpen . self::$activeTagOpen . $i . self::$activeTagClose . self::$tagClose . PHP_EOL; } else { $result .= self::$tagOpen . '<a href="' . $url . $i . '">' . $i . '</a>' . self::$tagClose . PHP_EOL; } } } if (!empty(self::$nextLabel) && self::$page < self::$totalPages) { $result .= self::$tagOpen . '<a href="' . $url . (self::$page + 1) . '">' . self::$nextLabel . '</a>' . self::$tagClose . PHP_EOL; } if (!empty(self::$lastLabel) && self::$page < self::$totalPages) { $result .= self::$tagOpen . '<a href="' . $url . self::$totalPages . '">' . self::$lastLabel . '</a>' . self::$tagClose . PHP_EOL; } $result .= self::$fullTagClose; return $result; }
private function includeTargetUrl($targetUrl, $queueUrl) { $queueUrl = preg_replace("/(&?t=[^&]*&?)/i", "", $queueUrl); if ($targetUrl == null) { $targetUrl = $this->defaultIncludeTargetUrl; } if (is_bool($targetUrl) && $targetUrl == true) { $targetUrl = currentUrl(); } if (is_bool($targetUrl) && $targetUrl == false) { return $queueUrl; } if (!strpos($queueUrl, '?')) { return $queueUrl . '?t=' . urlencode($targetUrl); } return $queueUrl . '&t=' . urlencode($targetUrl); }
public function run($terminalType = 'php', $settings = array()) { if (!is_array($settings)) { return Error::set(lang('Error', 'arrayParameter', 'settings')); } $settings['width'] = isset($settings['width']) ? $settings['width'] : '800px'; $settings['height'] = isset($settings['height']) ? $settings['height'] : '350px'; $settings['bgColor'] = isset($settings['bgColor']) ? $settings['bgColor'] : '#000'; $settings['barBgColor'] = isset($settings['barBgColor']) ? $settings['barBgColor'] : '#222'; $settings['textColor'] = isset($settings['textColor']) ? $settings['textColor'] : '#ccc'; $settings['textType'] = isset($settings['textType']) ? $settings['textType'] : 'monospace'; $settings['textSize'] = isset($settings['textSize']) ? $settings['textSize'] : '12px'; if (isset($_POST['clear']) && $_POST['clear'] === 'clear') { $this->clearCommand(); } if (!isset($_SESSION['persistCommands']) || !isset($_SESSION['commands'])) { $_SESSION['persistCommands'] = array(); $_SESSION['commands'] = array(); $_SESSION['commandResponses'] = array(); } $togglingPersist = false; if (isset($_POST['persistCommandId']) && is_numeric($_POST['persistCommandId'])) { $togglingPersist = true; $persistCommandId = $_POST['persistCommandId']; if (count($_SESSION['persistCommands']) == $persistCommandId) { $togglingCurrentPersistCommand = true; } } $previousCommands = ''; $response = array(); if (!empty($_SESSION['persistCommands'])) { foreach ($_SESSION['persistCommands'] as $index => $persist) { if (!empty($persist)) { $currentCommand = $_SESSION['commands'][$index]; if (!empty($currentCommand)) { $previousCommands .= $currentCommand . '; '; } } } } if (isset($_POST['command'])) { $command = $_POST['command']; if (!empty($command) && empty($togglingPersist)) { if ($command === 'clear') { $this->clearCommand(); } else { if ($terminalType === 'php') { $cmd = $command; ob_start(); eval("{$command}"); $content = ob_get_contents(); ob_end_clean(); $command = $content; if ($getError = error_get_last()) { $command = $cmd; $response[] = $getError['message']; } } else { $terminalType = 'cmd'; exec($previousCommands . $command . ' 2>&1', $response); } } } if ($command !== 'clear') { if (!empty($togglingPersist)) { if ($togglingCurrentPersistCommand) { array_push($_SESSION['persistCommands'], true); array_push($_SESSION['commands'], $command); array_push($_SESSION['commandResponses'], $response); if (!empty($command)) { $previousCommands = $previousCommands . $command . '; '; } } } else { array_push($_SESSION['persistCommands'], false); array_push($_SESSION['commands'], $command); array_push($_SESSION['commandResponses'], $response); } } } ?> <style type="text/css"> * { margin: 0; padding: 0; } input { color: inherit; font-family: inherit; font-size: inherit; font-weight: inherit; background-color: inherit; border: inherit; } .content { width: <?php echo $settings['width']; ?> ; min-width: 400px; margin: 0px auto; text-align: left; overflow: auto; background-color: <?php echo $settings['bgColor']; ?> ; color: <?php echo $settings['textColor']; ?> ; font-family: <?php echo $settings['textType']; ?> ; font-weight: bold; font-size: <?php echo $settings['textSize']; ?> ; } .terminal { border: 1px solid #CCC; height: <?php echo $settings['height']; ?> ; position: relative; overflow: auto; padding-bottom: 20px; } .terminal .bar { background:<?php echo $settings['barBgColor']; ?> ;; height:23px; padding: 2px; white-space: nowrap; overflow: hidden; color:<?php echo $settings['textColor']; ?> ; text-align:center; padding-top:12px; } .terminal .commands { padding: 2px; padding-right: 0; } .terminal #command { width: 90%; outline:none; border:none; } </style> <div class="content"> <div class="terminal" onclick="document.getElementById('command').focus();" id="terminal"> <div class="bar"> <?php echo 'ZN Framework Terminal Application '; ?> </div> <form action="<?php echo currentUrl(); ?> " method="post" class="commands" id="commands"> <?php if (!empty($_SESSION['commands'])) { ?> <div> <?php foreach ($_SESSION['commands'] as $index => $command) { ?> <pre><?php echo $terminalType . ' > ', $command, "\n"; ?> </pre> <?php foreach ($_SESSION['commandResponses'][$index] as $value) { ?> <pre><?php echo htmlentities($value), "\n"; ?> </pre> <?php } ?> <?php } ?> </div> <?php } ?> <?php echo $terminalType . ' > '; ?> <input type="text" name="command" id="command" autocomplete="off" onkeydown="return commandKeyedDown(event);" /> </form> </div> </div> <script type="text/javascript"> <?php $singleQuoteCancelledCommands = array(); if (!empty($_SESSION['commands'])) { foreach ($_SESSION['commands'] as $command) { $cancelledCommand = str_replace('\\', '\\\\', $command); $cancelledCommand = str_replace('\'', '\\\'', $command); $singleQuoteCancelledCommands[] = $cancelledCommand; } } ?> var previousCommands = ['', '<?php echo implode('\', \'', $singleQuoteCancelledCommands); ?> ', '']; var currentCommandIndex = previousCommands.length - 1; document.getElementById('command').select(); document.getElementById('terminal').scrollTop = document.getElementById('terminal').scrollHeight; function togglePersistCommand(command_id) { document.getElementById('persistCommandId').value = command_id; document.getElementById('commands').submit(); } function commandKeyedDown(event) { var keyCode = getKeyCode(event); if( keyCode == 38 ) { fillInPreviousCommand(); } else if( keyCode == 40 ) { fillInNextCommand(); } else if( keyCode == 13 ) { if (event.shiftKey) { togglePersistCommand ( <?php if (isset($_SESSION['commands'])) { echo count($_SESSION['commands']); } else { echo 0; } ?> ); return false; } } return true; } function fillInPreviousCommand() { currentCommandIndex--; if( currentCommandIndex < 0 ) { currentCommandIndex = 0; return; } document.getElementById('command').value = previousCommands[currentCommandIndex]; } function fillInNextCommand() { currentCommandIndex++; if( currentCommandIndex >= previousCommands.length ) { currentCommandIndex = previousCommands.length - 1; return; } document.getElementById('command').value = previousCommands[currentCommandIndex]; } function getKeyCode(event) { var eventKeyCode = event.keyCode; return eventKeyCode; } </script> <?php }
function unsubscribe() { global $wpdb; if ($_GET['action'] == 'unsubscribe') { ?> <div id="unsubscribe"> <form action="<?php echo currentUrl(); ?> " method="get"> <p><?php _e('Enter your email bellow'); ?> </p> <p><input size="10" type="text" name="unsub_email" /></p> <p> <input type="submit" value="Unsubscribe" /> <input type="hidden" value="yes" name="unsub" /> </p> </form> </div> <?php } ?> <?php if (isset($_GET['unsub_email']) && $_GET['unsub'] == 'yes') { ?> <?php $queryResult = $wpdb->query($wpdb->prepare("UPDATE epicwin_feed SET opt_in=0 WHERE email='" . $_GET['unsub_email'] . "'")); if ($queryResult > 0) { ?> <div id="unsubscribe"> <p><?php _e('You have been removed form our mailing list. If you would like to join the mailing list in the future, just fill in the subscribe box again'); ?> .</p> <a href="#" class="close" onclick="document.getElementById('unsubscribe').style.visibility='hidden'">Close</a> </div> <?php } else { ?> <div id="unsubscribe"> <p><?php _e('You have either already unsubscribed or we could not find your email in our recrods'); ?> .</p> <a href="#" class="close" onclick="document.getElementById('unsubscribe').style.visibility='hidden'">Close</a> </div> <?php } } }
<?php defined('ROOT') or die('Not allowed!'); require ADMIN_SIDEBAR; ?> <div id="main-contents"> <form action="<?php echo currentUrl(); ?> " id="user-form" method="post" class="form"> <div class="control-group"> <label class="label" for="nama_lengkap">Nama lengkap</label> <div class="control-input"> <input type="text" required name="nama_lengkap" id="nama_lengkap" <?php echo $data ? 'value="' . $data->nama_lengkap . '"' : ''; ?> > </div> </div> <div class="control-group"> <label class="label" for="alamat">Alamat</label> <div class="control-input"> <textarea name="alamat" id="alamat"><?php echo $data ? $data->alamat : ''; ?> </textarea> </div> </div> <div class="control-group">
public function getUrl() { return currentUrl(); }
public function create(int $year = NULL, int $month = NULL) : string { $today = getdate(); if (!isset($this->url)) { $this->url = suffix(CURRENT_CFURL); } if ($month === NULL && $year === NULL) { if (!is_numeric(URI::segment(-1))) { $month = $today['mon']; } else { $month = URI::segment(-1); } if (!is_numeric(URI::segment(-2))) { $year = $today['year']; } else { $year = URI::segment(-2); } } else { if (!is_numeric($month)) { $month = $today['mon']; } if (!is_numeric($year)) { $year = $today['year']; } } if (isset($_SERVER['HTTP_REFERER'])) { $arrays = array_diff(explode('/', prevUrl()), explode('/', currentUrl())); $prevMonth = end($arrays); } else { $prevMonth = $month; } $monthNamesConfig = VIEWOBJECTS_CALENDAR_CONFIG['monthNames'][getLang()]; if ($this->monthNames === 'long') { $monthNames = array_keys($monthNamesConfig); } else { $monthNames = array_values($monthNamesConfig); } $dayNamesConfig = VIEWOBJECTS_CALENDAR_CONFIG['dayNames'][getLang()]; $monthName = $monthNames[$month - 1]; $dayNames = $this->dayNames === 'long' ? array_keys($dayNamesConfig) : array_values($dayNamesConfig); $firstDay = getdate(mktime(0, 0, 0, $month, 1, $year)); $lastDay = getdate(mktime(0, 0, 0, $month + 1, 0, $year)); $tableClass = !empty($this->css['table']) ? ' class="' . $this->css['table'] . '"' : ''; $tableStyle = !empty($this->style['table']) ? ' style="' . $this->style['table'] . '"' : ''; $monthRowClass = !empty($this->css['monthName']) ? ' class="' . $this->css['monthName'] . '"' : ''; $monthRowStyle = !empty($this->style['monthName']) ? ' style="' . $this->style['monthName'] . '"' : ''; $dayRowClass = !empty($this->css['dayName']) ? ' class="' . $this->css['dayName'] . '"' : ''; $dayRowStyle = !empty($this->style['dayName']) ? ' style="' . $this->style['dayName'] . '"' : ''; $rowsClass = !empty($this->css['days']) ? ' class="' . $this->css['days'] . '"' : ''; $rowsStyle = !empty($this->style['days']) ? ' style="' . $this->style['days'] . '"' : ''; $buttonClass = !empty($this->css['links']) ? ' class="' . $this->css['links'] . '"' : ''; $buttonStyle = !empty($this->style['links']) ? ' style="' . $this->style['links'] . '"' : ''; $eol = EOL; $url = suffix($this->url); $pcyear = $month == 1 ? $year - 1 : $year; $pcmonth = $month - 1 == 0 ? 12 : $month - 1; $ncyear = $month == 12 ? $year + 1 : $year; $ncmonth = $month + 1 == 13 ? 1 : $month + 1; $prevDate = $pcyear . "/" . $pcmonth; $nextDate = $ncyear . "/" . $ncmonth; if ($this->type === 'ajax') { $prevUrl = '#cdate=' . $prevDate; $nextUrl = '#cdate=' . $nextDate; $prevAttr = ' ctype="ajax" cyear="' . $pcyear . '" cmonth="' . $pcmonth . '"'; $nextAttr = ' ctype="ajax" cyear="' . $ncyear . '" cmonth="' . $ncmonth . '"'; } else { $prevUrl = $url . $prevDate; $nextUrl = $url . $nextDate; $prevAttr = ''; $nextAttr = ''; } $prev = "<a href='" . $prevUrl . "' {$buttonClass}{$buttonStyle}{$prevAttr}>{$this->prev}</a>"; $next = "<a href='" . $nextUrl . "' {$buttonClass}{$buttonStyle}{$nextAttr}>{$this->next}</a>"; $str = "<table{$tableClass}{$tableStyle}>" . $eol; $str .= "\t<tr>" . $eol . "\t\t<th{$monthRowClass}{$monthRowStyle} colspan=\"7\">{$prev} {$monthName} - {$year} {$next}</th></tr>" . $eol; $str .= "\t<tr>" . $eol; foreach ($dayNames as $day) { $str .= "\t\t<td{$dayRowClass}{$dayRowStyle}>{$day}</td>" . $eol; } $str .= "\t<tr>" . $eol; if ($firstDay['wday'] == 0) { $firstDay['wday'] = 7; } for ($i = 1; $i < $firstDay['wday']; $i++) { $str .= "\t\t<td{$rowsClass}{$rowsStyle}> </td>" . $eol; } $activeDay = 0; for ($i = $firstDay['wday']; $i <= 7; $i++) { $activeDay++; if ($activeDay == $today['mday'] && $year == $today['year'] && $month == $today['mon']) { $class = !empty($this->css['current']) ? ' class="' . $this->css['current'] . '"' : ''; $style = !empty($this->style['current']) ? ' style="' . $this->style['current'] . '"' : ''; } else { $class = !empty($this->css['days']) ? ' class="' . $this->css['days'] . '"' : ''; $style = !empty($this->style['days']) ? ' style="' . $this->style['days'] . '"' : ''; } $str .= "\t\t<td{$class}{$style}>{$activeDay}</td>" . $eol; } $str .= "\t</tr>" . $eol; $weekCount = floor(($lastDay['mday'] - $activeDay) / 7); for ($i = 0; $i < $weekCount; $i++) { $str .= "\t<tr>"; for ($j = 0; $j < 7; $j++) { $activeDay++; if ($activeDay == $today['mday'] && $year == $today['year'] && $month == $today['mon']) { $class = !empty($this->css['current']) ? ' class="' . $this->css['current'] . '"' : ''; $style = !empty($this->style['current']) ? ' style="' . $this->style['current'] . '"' : ''; } else { $class = !empty($this->css['days']) ? ' class="' . $this->css['days'] . '"' : ''; $style = !empty($this->style['days']) ? ' style="' . $this->style['days'] . '"' : ''; } $str .= "\t\t<td{$class}{$style}>{$activeDay}</td>" . $eol; } $str .= "\t</tr>" . $eol; } if ($activeDay < $lastDay['mday']) { $str .= "\t<tr>" . $eol; for ($i = 0; $i < 7; $i++) { $activeDay++; if ($activeDay == $today['mday']) { $class = !empty($this->css['current']) ? ' class="' . $this->css['current'] . '"' : ''; $style = !empty($this->style['current']) ? ' style="' . $this->style['current'] . '"' : ''; } else { $class = !empty($this->css['days']) ? ' class="' . $this->css['days'] . '"' : ''; $style = !empty($this->style['days']) ? ' style="' . $this->style['days'] . '"' : ''; } if ($activeDay <= $lastDay['mday']) { $str .= "\t\t<td{$class}{$style}>{$activeDay}</td>" . $eol; } else { $str .= "\t\t<td{$class}{$style}> </td>" . $eol; } } $str .= "\t</tr>" . $eol; } $str .= "</table>"; $this->_defaultVariables(); return $str; }
function currentPath() { $path = parse_url(currentUrl())['path']; return empty($path) ? '/' : $path; }