/** * @example * $content = array( * 'foo' => 'bar', * 'file' => array( * 'content' => 'file content is simple text', // or path, mantatory * 'name' => 'filename.txt', // optional * 'type' => 'text/plain' // optional * )); * * @param string $url * @param array $content * @return CUrl - call ->exec() */ static function postUploadFile($url, array $content) { $eol = "\r\n"; $boundary = md5(microtime(TRUE)); $curl = new CUrl($url); $curl->setOptions(array(CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 0, CURLOPT_POST => 1, CURLOPT_VERBOSE => 1, CURLOPT_HTTPHEADER => array('Content-Type: multipart/form-data; charset=utf-8; boundary="' . $boundary . '"'))); $body = ''; foreach ($content as $name => $value) { $body .= '--' . $boundary . $eol; $body .= 'Content-Disposition: form-data;name="' . $name . '"'; if (is_array($value)) { if (file_exists($value['content'])) { $type = MimeTypeDetector::fromFile($value['content']); $content = file_get_contents($value['content']); } else { $type = MimeTypeDetector::fromString($content = $value['content']); } // is file $body .= '; filename="' . (isset($value['name']) ? $value['name'] : date('YmdHis')) . '"' . $eol; $body .= 'Content-Type: ' . (isset($value['type']) ? $value['type'] : $type) . $eol; if (preg_match('~base64~i', $content)) { $body .= 'Content-Transfer-Encoding: base64' . $eol; $content = preg_replace('~^base64~i', '', $content); } $body .= $eol; // $body .= chunk_split(base64_encode($content)); // RFC 2045 $body .= trim($content) . $eol; } else { $body .= $eol . $eol . $value . $eol; } } $body .= "--{$boundary}--" . $eol . $eol; $curl->setopt(CURLOPT_POSTFIELDS, $body); return $curl; }
public function setVars($value = null) { $url = '?cancel=1'; if (!empty($value)) { $url .= $value; } $uri = new CUrl($url); $url = $uri->getUrl(); return $this->setAttribute('onclick', "javascript: return redirect('" . $url . "');"); }
public function setAction($value = null) { if (!is_null($value)) { return parent::setAttribute('onclick', $value); } global $page; $confirmation = "Confirm('" . $this->msg . "')"; if (isset($this->vars)) { $link = $page['file'] . '?' . $this->name . '=1' . $this->vars; $url = new CUrl($link); $action = "redirect('" . $url->getUrl() . "')"; } else { $action = 'true'; } return parent::setAttribute('onclick', 'if (' . $confirmation . ') { return ' . $action . '; } else { return false; }'); }
/** * Creates new CUrl object based on giver URL (or $_REQUEST if null is given), * and adds/removes parameters based on current page context. * * @param string $sourceUrl * * @return CUrl */ public static function getContextUrl($sourceUrl = null) { $config = self::resolveConfig(); $url = new CUrl($sourceUrl); if (isset($config['remove'])) { foreach ($config['remove'] as $key) { $url->removeArgument($key); } } if (isset($config['add'])) { foreach ($config['add'] as $key) { $url->setArgument($key, getRequest($key)); } } return $url; }
function GetRSS() { $this->checkValues(); $rssValue = "<?xml version=\"1.0\"?>\r\n"; $rssValue .= "<rss version=\"2.0\">\r\n"; $rssValue .= "<channel>\r\n"; $rssValue .= "<title>" . $this->channelTitle . "</title>\r\n"; $rssValue .= "<link>" . $this->channelLink . "</link>\r\n"; $rssValue .= "<description>" . $this->channelDesc . "</description>\r\n"; $rssValue .= "<image>\r\n"; $rssValue .= "<title>" . $this->imageTitle . "</title>\r\n"; $rssValue .= "<url>" . $this->imageURL . "</url>\r\n"; $rssValue .= "<link>" . $this->imageLink . "</link>\r\n"; $rssValue .= "</image>\r\n"; $sql = "SELECT * FROM page WHERE etat = 1 ORDER BY date DESC"; $res = CBdd::select($sql); while($page = mysql_fetch_array($res)) { $rssValue .= "<item>\r\n"; $rssValue .= "<title>" . $page['nom'] . "</title>\r\n"; $rssValue .= "<description>" . $page['description'] . "</description>\r\n"; $rssValue .= "<link>" .htmlentities(CUrl::get_href('page', $page['id'], $page['nom'])). "</link>\r\n"; $rssValue .= "</item>\r\n"; } $rssValue .= "</channel>\r\n"; $rssValue .= "</rss>\r\n"; return $rssValue; }
function create($sitemap_name = '') { if(!$sitemap_name) $sitemap_name = SS_ADMIN_TO_USERFILE . "/sitemap.xml"; if(empty($sitemap_name)) $sitemap_name = "sitemap_" . $rep_name . ".xml"; $changefreq = array('daily', 'weekly', 'monthly'); $priority = array('0.1', '0.5', '1.0'); $tab_archive = array(); rsort($tab_archive); $xml = simplexml_load_file(SS_ADMIN_TO_USERFILE . '/google/sitemap_base.xml'); //scan bdd $sql = "SELECT * FROM page WHERE etat = 1"; $res = CBdd::select($sql); while($page = mysql_fetch_array($res)) { $url = $xml->addChild('url'); $url->addChild('loc', CUrl::get_urlsite() . "/" . CFunction::formate_chaine(utf8_decode($page['nom']), '-') . "_p" . $page['id']. ".html"); $url->addChild('lastmod', CDate::formate_date($page['date'])); $url->addChild('changefreq', $changefreq[rand(0, 2)]); $url->addChild('priority', $priority[rand(0, 2)]); } $html = $xml->asXML(); file_put_contents($sitemap_name, $html); }
function resetGetParams($params, $newURL = null) { zbx_value2array($params); $redirect = false; $url = new CUrl($newURL); foreach ($params as $num => $param) { if (!isset($_GET[$param])) { continue; } $redirect = true; $url->setArgument($param, null); } if ($redirect) { jsRedirect($url->getUrl()); include_once 'include/page_footer.php'; } }
/** * @param array $options['objectOptions'] an array of parameters to be added to the request URL * * @see jQuery.multiSelect() */ public function __construct(array $options = []) { parent::__construct('div', true); $this->addClass('multiselect'); $this->setId(zbx_formatDomId($options['name'])); // url $url = new CUrl('jsrpc.php'); $url->setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON); $url->setArgument('method', 'multiselect.get'); $url->setArgument('objectName', $options['objectName']); if (!empty($options['objectOptions'])) { foreach ($options['objectOptions'] as $optionName => $optionvalue) { $url->setArgument($optionName, $optionvalue); } } $params = ['url' => $url->getUrl(), 'name' => $options['name'], 'labels' => ['No matches found' => _('No matches found'), 'More matches found...' => _('More matches found...'), 'type here to search' => _('type here to search'), 'new' => _('new'), 'Select' => _('Select')]]; if (array_key_exists('data', $options)) { $params['data'] = zbx_cleanHashes($options['data']); } foreach (['ignored', 'defaultValue', 'disabled', 'selectedLimit', 'addNew'] as $option) { if (array_key_exists($option, $options)) { $params[$option] = $options[$option]; } } if (array_key_exists('popup', $options)) { foreach (['parameters', 'width', 'height'] as $option) { if (array_key_exists($option, $options['popup'])) { $params['popup'][$option] = $options['popup'][$option]; } } } zbx_add_post_js('jQuery("#' . $this->getAttribute('id') . '").multiSelect(' . CJs::encodeJson($params) . ');'); }
/** * @param array $options['objectOptions'] an array of parameters to be added to the request URL * * @see jQuery.multiSelect() */ public function __construct(array $options = array()) { parent::__construct('div', 'yes'); $this->addClass('multiselect'); $this->attr('id', zbx_formatDomId($options['name'])); // url $url = new CUrl('jsrpc.php'); $url->setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON); $url->setArgument('method', 'multiselect.get'); $url->setArgument('objectName', $options['objectName']); if (!empty($options['objectOptions'])) { foreach ($options['objectOptions'] as $optionName => $optionvalue) { $url->setArgument($optionName, $optionvalue); } } $params = array('url' => $url->getUrl(), 'name' => $options['name'], 'labels' => array('No matches found' => _('No matches found'), 'More matches found...' => _('More matches found...'), 'type here to search' => _('type here to search'), 'new' => _('new'), 'Select' => _('Select')), 'data' => empty($options['data']) ? array() : zbx_cleanHashes($options['data']), 'ignored' => isset($options['ignored']) ? $options['ignored'] : null, 'defaultValue' => isset($options['defaultValue']) ? $options['defaultValue'] : null, 'disabled' => isset($options['disabled']) ? $options['disabled'] : false, 'selectedLimit' => isset($options['selectedLimit']) ? $options['selectedLimit'] : null, 'addNew' => isset($options['addNew']) ? $options['addNew'] : false, 'popup' => array('parameters' => isset($options['popup']['parameters']) ? $options['popup']['parameters'] : null, 'width' => isset($options['popup']['width']) ? $options['popup']['width'] : null, 'height' => isset($options['popup']['height']) ? $options['popup']['height'] : null, 'buttonClass' => isset($options['popup']['buttonClass']) ? $options['popup']['buttonClass'] : null)); zbx_add_post_js('jQuery("#' . $this->getAttribute('id') . '").multiSelect(' . CJs::encodeJson($params) . ');'); }
} $req = new CUrl(); $req->setArgument('print', null); $link = new CLink(bold('«' . S_BACK_BIG), $req->getUrl(), 'small_font', null, 'nosid'); $link->setAttribute('style', 'padding-left: 10px;'); $printview = new CDiv($link, 'printless'); $printview->setAttribute('style', 'border: 1px #333 dotted;'); $printview->Show(); } if (!defined('ZBX_PAGE_NO_MENU')) { COpt::compare_files_with_menu($ZBX_MENU); $help = new CLink(S_HELP, 'http://www.zabbix.com/documentation/', 'small_font', null, 'nosid'); $help->setTarget('_blank'); $support = new CLink(S_GET_SUPPORT, 'http://www.zabbix.com/support.php', 'small_font', null, 'nosid'); $support->setTarget('_blank'); $req = new CUrl($_SERVER['REQUEST_URI']); $req->setArgument('print', 1); $printview = new CLink(S_PRINT, $req->getUrl(), 'small_font', null, 'nosid'); $page_header_r_col = array($help, '|', $support, '|', $printview); if ($USER_DETAILS['alias'] != ZBX_GUEST_USER) { $page_header_r_col[] = array('|'); array_push($page_header_r_col, new CLink(S_PROFILE, 'profile.php', 'small_font', null, 'nosid'), '|'); if ($USER_DETAILS['debug_mode'] == GROUP_DEBUG_MODE_ENABLED) { $debug = new CLink(S_DEBUG, '#debug', 'small_font', null, 'nosid'); $d_script = " if(!isset('state', this)) this.state = 'none'; " . " if(this.state == 'none') this.state = 'block'; " . " else this.state = 'none'; " . " showHideByName('zbx_gebug_info', this.state);"; $debug->setAttribute('onclick', 'javascript: ' . $d_script); array_push($page_header_r_col, $debug, '|'); } array_push($page_header_r_col, new CLink(S_LOGOUT, 'index.php?reconnect=1', 'small_font', null, 'nosid')); } else { $page_header_r_col[] = array('|', new CLink(S_LOGIN, 'index.php?reconnect=1', 'small_font', null, 'nosid'));
/** * Composes a URL path into a string ready to be used as a part of a URL and returns it. * * Any characters that cannot be represented literally in a valid path part of a URL come out percent-encoded. The * resulting path always starts with "/". * * Because the characters in path components are stored in their literal representations, the resulting path string * is always normalized, with only those characters appearing percent-encoded that really require it for the path * string to be valid and with the hexadecimal letters in percent-encoded characters appearing uppercased. * * @return CUStringObject A string containing the URL path. */ public function pathString() { $components = CArray::makeCopy($this->m_components); $len = CArray::length($components); for ($i = 0; $i < $len; $i++) { $components[$i] = CUrl::enterTdNew($components[$i]); } return "/" . CArray::join($components, "/"); }
public function deleteLink($controller, $method, $id) { $deleteLink = '<a class="remove" onClick="if(!confirm(\'' . JText::_('COM_COMMUNITY_CONFIRM_DELETE_FRIEND') . '\'))return false;" href="' . CUrl::build($controller, $method) . '&fid=' . $id . '"> </a>'; return $deleteLink; }
----------------------------------------------------------------------*/ $headscript = CHeadscript::get_headscript($id_page_courant); ?> <title><?php echo $meta->title ?></title> <meta name="description" content="<?php echo $meta->description ?>" /> <meta name="keywords" content="<?php echo $meta->keywords ?>" /> <?php CUrl::inclure('reset.css'); ?> <?php CUrl::inclure('default.css'); ?> <?php CUrl::inclure('css/diaporama.css'); ?> <?php CUrl::inclure('css/video.css'); ?> <?php echo $headscript ?> </head> <body> <div id="mainwrap"> <div id="header"><?php include(CUrl::formate('header.php'))?></div> <div id="contentarea"> <div id="left"><?php include(CUrl::formate('left.php')) ?></div> <div id="center"><?php include(CUrl::formate('center.php')) ?></div> <div class="clearfloat"></div> </div> <div id="footer"><?php include(CUrl::formate('footer.php')) ?></div> <script type="text/javascript" src="/plug/panther/accordion.js"></script> <script type="text/javascript" src="/plug/panther/jquery.li-scroller.1.0.js"></script> <script type="text/javascript" src="../plug/prototype/prototype.js"></script> <script type="text/javascript" src="/plug/send_mail_queue/script.js"></script> <script type="text/javascript" src="/plug/popup/popup.js"></script> <script type="text/javascript" src="/userfiles/file/module/contact/inc/sendmail.js"></script></div> </body> </html>
/** * Return the URL for the graph. * * @param array $itemIds * * @return string */ protected function getGraphUrl(array $itemIds) { $url = new CUrl('chart.php'); $url->setArgument('period', $this->timeline['period']); $url->setArgument('stime', $this->timeline['stime']); $url->setArgument('itemids', $itemIds); $url->setArgument('type', $this->graphType); if ($this->action == HISTORY_BATCH_GRAPH) { $url->setArgument('batch', 1); } return $url->getUrl() . $this->getProfileUrlParams(); }
/** * Creates a parsed URL from a URL string. * * The URL string is expected to be by all means valid, with characters being percent-encoded where it is required * by the URL standard and without any leading or trailing whitespace. It is only when the URL string does not * indicate any protocol that the URL may still be considered valid and the default protocol is assigned to the * URL, which is "http". * * @param string $url The URL string. */ public function __construct($url) { assert('is_cstring($url)', vs(isset($this), get_defined_vars())); assert('self::isValid($url, true)', vs(isset($this), get_defined_vars())); $this->m_url = $url; $parsedUrl = parse_url($url); assert('is_cmap($parsedUrl)', vs(isset($this), get_defined_vars())); // should not rise for a valid URL // Protocol (scheme). if (CMap::hasKey($parsedUrl, "scheme")) { $this->m_hasProtocol = true; $this->m_protocol = $parsedUrl["scheme"]; // Normalize by converting to lowercase. $this->m_normProtocol = CString::toLowerCase($this->m_protocol); } else { $this->m_hasProtocol = false; $this->m_normProtocol = self::DEFAULT_PROTOCOL; if (!CMap::hasKey($parsedUrl, "host")) { // Most likely, `parse_url` function has not parsed the host because the protocol (scheme) is absent // and there are no "//" in the front, so try parsing the host with the default protocol in the URL. $parsedUrl = parse_url(self::ensureProtocol($url)); assert('is_cmap($parsedUrl)', vs(isset($this), get_defined_vars())); CMap::remove($parsedUrl, "scheme"); } } // Host (domain). $this->m_hostIsInBrackets = false; if (CMap::hasKey($parsedUrl, "host")) { $this->m_host = $parsedUrl["host"]; if (CRegex::find($this->m_host, "/^\\[.*\\]\\z/")) { // Most likely, an IPv6 enclosed in "[]". $this->m_hostIsInBrackets = true; $this->m_host = CString::substr($this->m_host, 1, CString::length($this->m_host) - 2); } // Normalize by converting to lowercase. $this->m_normHost = CString::toLowerCase($this->m_host); } else { // Same as invalid. assert('false', vs(isset($this), get_defined_vars())); } // Port. if (CMap::hasKey($parsedUrl, "port")) { $this->m_hasPort = true; $this->m_port = $parsedUrl["port"]; // Should be `int`, but look into the type just in case. if (is_cstring($this->m_port)) { $this->m_port = CString::toInt($this->m_port); } } else { $this->m_hasPort = false; } // Path. if (CMap::hasKey($parsedUrl, "path")) { $this->m_hasPath = true; $this->m_path = $parsedUrl["path"]; // Normalize by replacing percent-encoded bytes of unreserved characters with their literal equivalents and // ensuring that all percent-encoded parts are in uppercase. $pathDelimitersReEsc = CRegex::enterTd(self::$ms_delimiters); $this->m_normPath = CRegex::replaceWithCallback($this->m_path, "/[^{$pathDelimitersReEsc}]+/", function ($matches) { return CUrl::enterTdNew(CUrl::leaveTdNew($matches[0])); }); } else { $this->m_hasPath = false; $this->m_normPath = "/"; } $this->m_urlPath = new CUrlPath($this->m_normPath); // Query string. $this->m_hasQuery = false; if (CMap::hasKey($parsedUrl, "query")) { $this->m_hasQuery = true; $this->m_queryString = $parsedUrl["query"]; $parsingWasFruitful; $this->m_urlQuery = new CUrlQuery($this->m_queryString, $parsingWasFruitful); if ($parsingWasFruitful) { $this->m_hasQuery = true; $this->m_normQueryString = $this->m_urlQuery->queryString(true); } } // Fragment ID. if (CMap::hasKey($parsedUrl, "fragment")) { $this->m_hasFragmentId = true; $this->m_fragmentId = $parsedUrl["fragment"]; // Normalize by replacing percent-encoded bytes of unreserved characters with their literal equivalents and // ensuring that all percent-encoded parts are in uppercase. $fiDelimitersReEsc = CRegex::enterTd(self::$ms_delimiters); $this->m_normFragmentId = CRegex::replaceWithCallback($this->m_fragmentId, "/[^{$fiDelimitersReEsc}]+/", function ($matches) { // Use the newer flavor of percent-encoding. return CUrl::enterTdNew(CUrl::leaveTdNew($matches[0])); }); } else { $this->m_hasFragmentId = false; } // User. if (CMap::hasKey($parsedUrl, "user")) { $this->m_hasUser = true; $this->m_user = $parsedUrl["user"]; } else { $this->m_hasUser = false; } // Password. if (CMap::hasKey($parsedUrl, "pass")) { $this->m_hasPassword = true; $this->m_password = $parsedUrl["pass"]; } else { $this->m_hasPassword = false; } // Compose the normalized URL string. $this->m_normUrl = ""; $this->m_normUrl .= $this->m_normProtocol . "://"; if ($this->m_hasUser) { $this->m_normUrl .= $this->m_user; } if ($this->m_hasPassword) { $this->m_normUrl .= ":" . $this->m_password; } if ($this->m_hasUser || $this->m_hasPassword) { $this->m_normUrl .= "@"; } if (!$this->m_hostIsInBrackets) { $this->m_normUrl .= $this->m_normHost; } else { $this->m_normUrl .= "[" . $this->m_normHost . "]"; } if ($this->m_hasPort) { // Normalize by skipping port indication if the port is the default one for the protocol. if (!(CMap::hasKey(self::$ms_knownProtocolToDefaultPort, $this->m_normProtocol) && self::$ms_knownProtocolToDefaultPort[$this->m_normProtocol] == $this->m_port)) { $this->m_normUrl .= ":" . $this->m_port; } } $this->m_normUrl .= $this->m_normPath; if ($this->m_hasQuery) { $this->m_normUrl .= "?" . $this->m_normQueryString; } $this->m_normUrlWithoutFragmentId = $this->m_normUrl; if ($this->m_hasFragmentId) { $this->m_normUrl .= "#" . $this->m_normFragmentId; } }
$createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); $createForm->addItem(new CSubmit('form', _('Create host prototype'))); $itemsWidget->addPageHeader(_('CONFIGURATION OF HOST PROTOTYPES'), $createForm); // header $itemsWidget->addHeader(array(_('Host prototypes of') . SPACE, new CSpan($this->data['discovery_rule']['name'], 'parent-discovery'))); $itemsWidget->addHeaderRowNumber(); $itemsWidget->addItem(get_header_host_table('hosts', $discoveryRule['hostid'], $this->data['parent_discoveryid'])); // create form $itemForm = new CForm(); $itemForm->setName('hosts'); $itemForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); // create table $hostTable = new CTableInfo(_('No host prototypes found.')); $sortLink = new CUrl(); $sortLink->setArgument('parent_discoveryid', $this->data['parent_discoveryid']); $sortLink = $sortLink->getUrl(); $hostTable->setHeader(array(new CCheckBox('all_hosts', null, "checkAll('" . $itemForm->getName() . "', 'all_hosts', 'group_hostid');"), make_sorting_header(_('Name'), 'name', $sortLink), _('Templates'), make_sorting_header(_('Status'), 'status', $sortLink))); foreach ($this->data['hostPrototypes'] as $hostPrototype) { // name $name = array(); if ($hostPrototype['templateid']) { $sourceTemplate = $hostPrototype['sourceTemplate']; $name[] = new CLink($sourceTemplate['name'], '?parent_discoveryid=' . $hostPrototype['sourceDiscoveryRuleId'], 'unknown'); $name[] = NAME_DELIMITER; } $name[] = new CLink($hostPrototype['name'], '?form=update&parent_discoveryid=' . $discoveryRule['itemid'] . '&hostid=' . $hostPrototype['hostid']); // template list if (empty($hostPrototype['templates'])) { $hostTemplates = '-';
private static function __ModeCurl($url) { if (function_exists('curl_init')) { /*$ini = curl_init(); @curl_setopt($ch, CURLOPT_HEADER, TRUE); @curl_setopt($ch, CURLOPT_NOBODY, TRUE); @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ini, CURLOPT_URL, $url); curl_setopt($ini, CURLOPT_HEADER, 0); ob_start(); curl_exec($ini); curl_close($ini); $var = ob_get_contents(); ob_end_clean(); return $var;*/ //$f = fopen($url, 'r'); //return file_get_contents($url); return CUrl::fetchContent($url); } else { return false; } }
$msginfo = "<span class='msginfo'>Félicitation : Istallation réussie. Vous pouvez maintenant aller au <a href='" . $URL_RACINE . "'>site</a> ou à l'<a href='" . $URL_RACINE . "/adminpanther'>administration</a>.</span>"; /*-------------------------------------------------------------------- TRAITEMENTS ----------------------------------------------------------------------*/ $config = file_get_contents('../install/CONFIG.txt'); $config = ereg_replace("DB_HOSTNAME_VALUE", $DB_HOSTNAME, $config); $config = ereg_replace('DB_USERNAME_VALUE', $DB_USERNAME, $config); $config = ereg_replace('DB_PASSWORD_VALUE', $DB_PASSWORD, $config); $config = ereg_replace('DB_DATABASE_VALUE', $DB_DATABASE, $config); $config = ereg_replace('PATH_RACINE_VALUE', $PATH_RACINE, $config); $config = ereg_replace('URL_RACINE_VALUE' , $URL_RACINE , $config); include_once("../obj/CUrl.php"); file_put_contents(CUrl::get_pathsite() . '/inc/constante.php', $config); include_once("init.php"); $bdd_object = new CInstall(); if(!$bdd_object->sql_array()) { $msginfo = $msgerror; echo $msginfo; exit; } $msginfo = ($bdd_object->db_ok()) ? $msginfo : $msginfo; /*--------------------------------------------------------------------- CONFIRMATION
/** * This function will prep user info so that it can display user mini header in privacy warning template. * Do not call this function outside this view.php */ function _prepUser($user) { if (!empty($user)) { $obj = new stdClass(); $my = CFactory::getUser(); $user = CFactory::getUser($user->id); $obj->friendsCount = $user->getFriendCount(); $obj->user = $user; $obj->profileLink = CUrl::build('profile', '', array('userid' => $user->id)); $isFriend = CFriendsHelper::isConnected($user->id, $my->id); $obj->addFriend = !$isFriend && $my->id != 0 && $my->id != $user->id ? true : false; return array($obj); } return false; }
/** * Renders an "access denied" message and stops the execution of the script. * * The $mode parameters controls the layout of the message: * - ACCESS_DENY_OBJECT - render the message when denying access to a specific object * - ACCESS_DENY_PAGE - render a complete access denied page * * @param int $mode */ function access_deny($mode = ACCESS_DENY_OBJECT) { // deny access to an object if ($mode == ACCESS_DENY_OBJECT) { require_once dirname(__FILE__) . '/page_header.php'; show_error_message(_('No permissions to referred object or it does not exist!')); require_once dirname(__FILE__) . '/page_footer.php'; } else { // url to redirect the user to after he loggs in $url = new CUrl(!empty($_REQUEST['request']) ? $_REQUEST['request'] : ''); $url->setArgument('sid', null); $url = urlencode($url->toString()); // if the user is logged in - render the access denied message if (CWebUser::isLoggedIn()) { $header = _('Access denied.'); $message = array(_('Your are logged in as'), ' ', bold(CWebUser::$data['alias']), '. ', _('You have no permissions to access this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.')); $buttons = array(); // display the login button only for guest users if (CWebUser::isGuest()) { $buttons[] = new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist'); } $buttons[] = new CButton('back', _('Go to dashboard'), 'javascript: document.location = "dashboard.php"', 'formlist'); } else { $header = _('You are not logged in.'); $message = array(_('You must login to view this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.')); $buttons = array(new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist')); } $warning = new CWarning($header, $message); $warning->setButtons($buttons); $warningView = new CView('general.warning', array('warning' => $warning)); $warningView->render(); exit; } }
/** * Return groups html block */ function _getGroupsHTML() { $tmpl = new CTemplate(); $model = CFactory::getModel('groups'); $my = CFactory::getUser(); $userid = JRequest::getVar('userid', $my->id); $user = CFactory::getUser($userid); $groups = $model->getGroups($user->id); $total = count($groups); // Randomize groups if ($groups) { shuffle($groups); } CFactory::load('helpers', 'url'); // Load the groups as proper CTableGroup object foreach ($groups as &$gr) { $groupTable = JTable::getInstance('Group', 'CTable'); $groupTable->load($gr->id); $gr = $groupTable; } for ($i = 0; $i < count($groups); $i++) { $row =& $groups[$i]; $row->avatar = $row->getThumbAvatar(); $row->link = CUrl::build('groups', 'viewgroup', array('groupid' => $row->id), true); } $tmpl->set('user', $user); $tmpl->set('total', $total); $tmpl->set('groups', $groups); return $tmpl->fetch('profile.groups'); }
function access_deny() { require_once dirname(__FILE__) . '/page_header.php'; if (CWebUser::$data['alias'] != ZBX_GUEST_USER) { show_error_message(_('No permissions to referred object or it does not exist!')); } else { $url = new CUrl(!empty($_REQUEST['request']) ? $_REQUEST['request'] : ''); $url->setArgument('sid', null); $url = urlencode($url->toString()); $warning = new CWarning(_('You are not logged in.'), array(_('You cannot view this URL as a'), SPACE, bold(ZBX_GUEST_USER), '. ', _('You must login to view this page.'), BR(), _('If you think this message is wrong, please consult your administrators about getting the necessary permissions.'))); $warning->setButtons(array(new CButton('login', _('Login'), 'javascript: document.location = "index.php?request=' . $url . '";', 'formlist'), new CButton('back', _('Cancel'), 'javascript: window.history.back();', 'formlist'))); $warning->show(); } require_once dirname(__FILE__) . '/page_footer.php'; }
<script type="text/javascript" src="../plug/popup/popup.js"></script> <link href="../plug/jscalendar/calendar-win2k-1.css" rel="stylesheet" type="text/css"/> <link href="../plug/jquery/css/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../plug/popup/popup.js"></script> <script type="text/javascript" src="../plug/jquery/js/jquery-1.3.2.js"></script> <script type="text/javascript" src="../plug/jquery/js/jquery-ui-1.7.2.custom.min.js"></script> <script type="text/javascript" src="../plug/jquery/js/ui/i18n/ui.datepicker-fr.js"></script> <script type="text/javascript" src="../plug/jquery/js/jquery.form.js"></script> <script type="text/javascript" src="../plug/panther/campagne.js"></script> <script type="text/javascript" src="../plug/tinymce/jscripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ mode : "exact", elements : "expediteur_publipostage, objet_publipostage, message_publipostage", theme : "advanced", document_base_url : "<?php echo CUrl::get_urlsite() ?>", relative_urls : false, remove_script_host : false, plugins :"safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager,fullpage", theme_advanced_buttons1 : "bold,italic,underline,pastetext,separator,strikethroughjustifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink,styleselect,formatselect,code", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_align : "left", theme_advanced_toolbar_location : "external" }); </script> <style type="text/css"> .margin-left { margin-left:40px; } input[type='text'] {
/** * Ajax function to approve a specific member when event admin or site admin tries to approve an invitation. * * @params string id The member's id that needs to be approved. * @params string groupid The group id that the user is in. **/ public function ajaxApproveInvite($memberId, $eventId) { $response = new JAXResponse(); $filter = JFilterInput::getInstance(); $memberId = $filter->clean($memberId, 'int'); $eventId = $filter->clean($eventId, 'int'); $my = CFactory::getUser(); $model = $this->getModel('events'); $event =& JTable::getInstance('Event', 'CTable'); $event->load($eventId); CFactory::load('helpers', 'event'); $handler = CEventHelper::getHandler($event); if (!$handler->manageable()) { $response->addScriptCall(JText::_('COM_COMMUNITY_NOT_ALLOWED_TO_ACCESS_SECTION')); } else { // Load required tables $member =& JTable::getInstance('EventMembers', 'CTable'); $member->load($memberId, $eventId); $member->attend(); $member->store(); // Build the URL. $url = CUrl::build('events', 'viewevent', array('eventid' => $event->id), true); $user = CFactory::getUser($memberId); $tmplData = array(); $tmplData['url'] = CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false); $tmplData['event'] = $event->title; $tmplData['user'] = $user->getDisplayName(); $tmplData['approval'] = 1; // Send email to evnt member once their invitation is approved CFactory::load('libraries', 'notification'); $params = new CParameter(''); $params->set('url', CRoute::getExternalURL('index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id, false)); $params->set('eventTitle', $event->title); CNotificationLibrary::add('etype_events_invitation_approved', $event->creator, $user->id, JText::sprintf('COM_COMMUNITY_EVENTS_EMAIL_SUBJECT', $event->title), '', 'events.invitation.approved', $params); $response->addScriptCall('joms.jQuery("#member_' . $memberId . '").css("border","3px solid blue");'); $response->addScriptCall('joms.jQuery("#notice").html("' . JText::_('COM_COMMUNITY_EVENTS_REQUEST_APPROVED') . '");'); $response->addScriptCall('joms.jQuery("#notice").attr("class","info");'); $response->addScriptCall('joms.jQuery("#events-approve-' . $memberId . '").remove();'); } $this->cacheClean(array(COMMUNITY_CACHE_TAG_EVENTS)); return $response->sendResponse(); }
public function browse($data = null) { //require_once (JPATH_COMPONENT . '/libraries/template.php'); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $document = JFactory::getDocument(); $this->addPathway(JText::_('COM_COMMUNITY_GROUPS_MEMBERS'), ''); /** * Opengraph */ CHeadHelper::setType('website', JText::_('COM_COMMUNITY_GROUPS_MEMBERS')); $my = CFactory::getUser(); $view = CFactory::getView('search'); $searchModel = CFactory::getModel('search'); $userModel = CFactory::getModel('user'); $avatar = CFactory::getModel('avatar'); $friends = CFactory::getModel('friends'); $tmpl = new CTemplate(); $sorted = $jinput->get->get('sort', 'latest', 'STRING'); //JRequest::getVar( 'sort' , 'latest' , 'GET' ); $filter = JRequest::getWord('filter', 'all', 'GET'); $profiletype = $jinput->get('profiletype', 0, 'INT'); $rows = $searchModel->getPeople($sorted, $filter, $profiletype); $sortItems = array('online' => JText::_('COM_COMMUNITY_SORT_ONLINE'), 'latest' => JText::_('COM_COMMUNITY_SORT_LATEST'), 'alphabetical' => JText::_('COM_COMMUNITY_SORT_ALPHABETICAL')); $filterItems = array(); $config = CFactory::getConfig(); if ($config->get('alphabetfiltering')) { $filterItems = array('all' => JText::_('COM_COMMUNITY_JUMP_ALL'), 'abc' => JText::_('COM_COMMUNITY_JUMP_ABC'), 'def' => JText::_('COM_COMMUNITY_JUMP_DEF'), 'ghi' => JText::_('COM_COMMUNITY_JUMP_GHI'), 'jkl' => JText::_('COM_COMMUNITY_JUMP_JKL'), 'mno' => JText::_('COM_COMMUNITY_JUMP_MNO'), 'pqr' => JText::_('COM_COMMUNITY_JUMP_PQR'), 'stu' => JText::_('COM_COMMUNITY_JUMP_STU'), 'vwx' => JText::_('COM_COMMUNITY_JUMP_VWX'), 'yz' => JText::_('COM_COMMUNITY_JUMP_YZ'), 'others' => JText::_('COM_COMMUNITY_JUMP_OTHERS')); } $html = ''; $totalUser = $userModel->getMembersCount(); $resultRows = array(); $alreadyfriend = array(); // No need to pre-load multiple users at once since $searchModel->getPeople // already did for ($i = 0; $i < count($rows); $i++) { $row = $rows[$i]; $obj = clone $row; $user = CFactory::getUser($row->id); $obj->friendsCount = $user->getFriendCount(); $obj->user = $user; $obj->profileLink = CUrl::build('profile', '', array('userid' => $row->id)); $isFriend = CFriendsHelper::isConnected($row->id, $my->id); $connection = $friends->getFriendConnection($my->id, $row->id); $obj->isMyFriend = false; if (!empty($connection)) { if ($connection[0]->connect_from == $my->id) { $obj->isMyFriend = true; } } $obj->addFriend = !$isFriend && $my->id != $row->id ? true : false; if ($obj->addFriend) { $alreadyfriend[$row->id] = $row->id; } $resultRows[] = $obj; } $featuredList = $this->_cachedCall('getFeaturedMember', array(), '', array(COMMUNITY_CACHE_TAG_FEATURED)); $config = CFactory::getConfig(); if ($config->get('alphabetfiltering')) { $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'); $alphabetHTML = CFilterBar::getHTML(CRoute::getURI(), '', '', $filterItems, 'all'); } else { $sortingsHTML = CFilterBar::getHTML(CRoute::getURI(), $sortItems, 'latest'); } $multiprofileArr = array(); $hasMultiprofile = false; //let see if we have any multiprofile enabled if ($config->get('profile_multiprofile')) { $hasMultiprofile = true; //lets get the available profile $profileModel = CFactory::getModel('Profile'); $profiles = $profileModel->getProfileTypes(); if ($profiles) { $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=browse&filter=' . $filter . '&sort=' . $sorted), 'name' => JText::_('COM_COMMUNITY_ALL_PROFILE'), 'selected' => !$profiletype ? 1 : 0); foreach ($profiles as $profile) { $multiprofileArr[] = array('url' => CRoute::_('index.php?option=com_community&view=search&task=browse&filter=' . $filter . '&sort=' . $sorted . '&profiletype=' . $profile->id), 'name' => $profile->name, 'selected' => $profile->id == $profiletype ? 1 : 0); } } } echo $tmpl->set('featuredList', $featuredList)->set('hasMultiprofile', $hasMultiprofile)->set('multiprofileArr', $multiprofileArr)->set('alreadyfriend', $alreadyfriend)->set('isCommunityAdmin', COwnerHelper::isCommunityAdmin())->set('data', $resultRows)->set('sortings', $sortingsHTML)->set('alphabet', $alphabetHTML)->set('my', $my)->set('submenu', $this->showSubmenu(false))->set('totalUser', $totalUser)->set('showFeaturedList', $config->get('show_featured'))->set('pagination', $searchModel->getPagination())->fetch('people.browse'); }
/** * Returns paging line. * * @param array $items list of items * @param string $sortorder the order in which items are sorted ASC or DESC * @param CUrl $url URL object containing arguments and query * * @return CDiv */ function getPagingLine(&$items, $sortorder, CUrl $url) { global $page; $rowsPerPage = CWebUser::$data['rows_per_page']; $itemsCount = count($items); $pagesCount = $itemsCount > 0 ? ceil($itemsCount / $rowsPerPage) : 1; $currentPage = getPageNumber(); if ($currentPage < 1) { $currentPage = 1; } elseif ($currentPage > $pagesCount) { $currentPage = $pagesCount; } $start = ($currentPage - 1) * $rowsPerPage; $tags = []; if ($pagesCount > 1) { // For MVC pages $page is not set if (isset($page['file'])) { CProfile::update('web.paging.lastpage', $page['file'], PROFILE_TYPE_STR); CProfile::update('web.paging.page', $currentPage, PROFILE_TYPE_INT); } elseif (isset($_REQUEST['action'])) { CProfile::update('web.paging.lastpage', $_REQUEST['action'], PROFILE_TYPE_STR); CProfile::update('web.paging.page', $currentPage, PROFILE_TYPE_INT); } // viewed pages (better to use not odd) $pagingNavRange = 11; $endPage = $currentPage + floor($pagingNavRange / 2); if ($endPage < $pagingNavRange) { $endPage = $pagingNavRange; } if ($endPage > $pagesCount) { $endPage = $pagesCount; } $startPage = $endPage > $pagingNavRange ? $endPage - $pagingNavRange + 1 : 1; if ($startPage > 1) { $url->setArgument('page', 1); $tags[] = new CLink(_('First'), $url->getUrl()); } if ($currentPage > 1) { $url->setArgument('page', $currentPage - 1); $tags[] = new CLink((new CSpan())->addClass(ZBX_STYLE_ARROW_LEFT), $url->getUrl()); } for ($p = $startPage; $p <= $endPage; $p++) { $url->setArgument('page', $p); $link = new CLink($p, $url->getUrl()); if ($p == $currentPage) { $link->addClass(ZBX_STYLE_PAGING_SELECTED); } $tags[] = $link; } if ($currentPage < $pagesCount) { $url->setArgument('page', $currentPage + 1); $tags[] = new CLink((new CSpan())->addClass(ZBX_STYLE_ARROW_RIGHT), $url->getUrl()); } if ($p < $pagesCount) { $url->setArgument('page', $pagesCount); $tags[] = new CLink(_('Last'), $url->getUrl()); } } if ($pagesCount == 1) { $table_stats = _s('Displaying %1$s of %2$s found', $itemsCount, $itemsCount); } else { $config = select_config(); $end = $start + $rowsPerPage; if ($end > $itemsCount) { $end = $itemsCount; } $total = $itemsCount; if ($config['search_limit'] < $itemsCount) { if ($sortorder == ZBX_SORT_UP) { array_pop($items); } else { array_shift($items); } $total .= '+'; } $table_stats = _s('Displaying %1$s to %2$s of %3$s found', $start + 1, $end, $total); } // trim array with items to contain items for current page $items = array_slice($items, $start, $rowsPerPage, true); return (new CDiv())->addClass(ZBX_STYLE_TABLE_PAGING)->addItem((new CDiv())->addClass(ZBX_STYLE_PAGING_BTN_CONTAINER)->addItem($tags)->addItem((new CDiv())->addClass(ZBX_STYLE_TABLE_STATS)->addItem($table_stats))); }
$_REQUEST['show_triggers'] = TRIGGERS_OPTION_ONLYTRUE; } $_REQUEST['show_events'] = get_request('show_events', CProfile::get('web.tr_status.filter.show_events', EVENTS_OPTION_NOEVENT)); $_REQUEST['ack_status'] = get_request('ack_status', CProfile::get('web.tr_status.filter.ack_status', ZBX_ACK_STS_ANY)); $_REQUEST['show_severity'] = get_request('show_severity', CProfile::get('web.tr_status.filter.show_severity', -1)); $_REQUEST['status_change_days'] = get_request('status_change_days', CProfile::get('web.tr_status.filter.status_change_days', 14)); $_REQUEST['txt_select'] = get_request('txt_select', CProfile::get('web.tr_status.filter.txt_select', '')); if (EVENT_ACK_DISABLED == $config['event_ack_enable']) { if (!str_in_array($_REQUEST['show_events'], array(EVENTS_OPTION_NOEVENT, EVENTS_OPTION_ALL))) { $_REQUEST['show_events'] = EVENTS_OPTION_NOEVENT; } $_REQUEST['ack_status'] = ZBX_ACK_STS_ANY; } } if (get_request('show_events') != CProfile::get('web.tr_status.filter.show_events')) { $url = new CUrl(); $path = $url->getPath(); insert_js('cookie.eraseArray("' . $path . '")'); } //-- if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) { CProfile::update('web.tr_status.filter.show_details', $_REQUEST['show_details'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.show_events', $_REQUEST['show_events'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.ack_status', $_REQUEST['ack_status'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.show_severity', $_REQUEST['show_severity'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.txt_select', $_REQUEST['txt_select'], PROFILE_TYPE_STR); CProfile::update('web.tr_status.filter.status_change', $_REQUEST['status_change'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.status_change_days', $_REQUEST['status_change_days'], PROFILE_TYPE_INT); } $show_triggers = $_REQUEST['show_triggers']; $show_events = $_REQUEST['show_events'];
$createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addVar('hostid', $this->data['hostid']); $createForm->addItem(new CSubmit('form', _('Create discovery rule'))); $discoveryWidget->addPageHeader(_('CONFIGURATION OF DISCOVERY RULES'), $createForm); // header $discoveryWidget->addHeader(_('Discovery rules')); $discoveryWidget->addHeaderRowNumber(); $discoveryWidget->addItem(get_header_host_table('discoveries', $this->data['hostid'])); // create form $discoveryForm = new CForm(); $discoveryForm->setName('discovery'); $discoveryForm->addVar('hostid', $this->data['hostid']); // create table $discoveryTable = new CTableInfo(_('No discovery rules found.')); $sortLink = new CUrl(); $sortLink->setArgument('hostid', $this->data['hostid']); $sortLink = $sortLink->getUrl(); $discoveryTable->setHeader(array(new CCheckBox('all_items', null, "checkAll('" . $discoveryForm->getName() . "', 'all_items', 'g_hostdruleid');"), make_sorting_header(_('Name'), 'name', $sortLink), _('Items'), _('Triggers'), _('Graphs'), $data['host']['flags'] == ZBX_FLAG_DISCOVERY_NORMAL ? _('Hosts') : null, make_sorting_header(_('Key'), 'key_', $sortLink), make_sorting_header(_('Interval'), 'delay', $sortLink), make_sorting_header(_('Type'), 'type', $sortLink), make_sorting_header(_('Status'), 'status', $sortLink), $data['showErrorColumn'] ? _('Error') : null)); foreach ($data['discoveries'] as $discovery) { $description = array(); if ($discovery['templateid']) { $template_host = get_realhost_by_itemid($discovery['templateid']); $description[] = new CLink($template_host['name'], '?hostid=' . $template_host['hostid'], 'unknown'); $description[] = NAME_DELIMITER; } $discovery['name_expanded'] = itemName($discovery); $description[] = new CLink($discovery['name_expanded'], '?form=update&itemid=' . $discovery['itemid']); $status = new CLink(itemIndicator($discovery['status'], $discovery['state']), '?hostid=' . $_REQUEST['hostid'] . '&g_hostdruleid=' . $discovery['itemid'] . '&go=' . ($discovery['status'] ? 'activate' : 'disable'), itemIndicatorStyle($discovery['status'], $discovery['state'])); if ($data['showErrorColumn']) { $error = '';
} elseif ($_REQUEST['favaction'] == 'remove') { $result = CFavorite::remove('web.favorite.graphids', $_REQUEST['favid'], $_REQUEST['favobj']); if ($result) { echo '$("addrm_fav").title = "' . _('Add to favourites') . '";' . "\n"; echo '$("addrm_fav").onclick = function() { add2favorites("graphid", "' . $_REQUEST['favid'] . '"); }' . "\n"; } } $result = DBend($result); if ($page['type'] == PAGE_TYPE_JS && $result) { echo 'switchElementClass("addrm_fav", "iconminus", "iconplus");'; } } } if (!empty($_REQUEST['period']) || !empty($_REQUEST['stime'])) { CScreenBase::calculateTime(array('profileIdx' => 'web.screens', 'profileIdx2' => $pageFilter->graphid, 'updateProfile' => true, 'period' => getRequest('period'), 'stime' => getRequest('stime'))); $curl = new CUrl(); $curl->removeArgument('period'); $curl->removeArgument('stime'); ob_end_clean(); DBstart(); CProfile::flush(); DBend(); redirect($curl->getUrl()); } ob_end_flush(); if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /* * Display
<span></span> <input type="submit" value="<?php echo JText::_('COM_COMMUNITY_SAVE_CHANGES_BUTTON'); ?> " class="joms-button--primary joms-button--full-small"> </div> </div> <div class="joms-js--tab-content joms-js--tab-content-ignorelist" style="display:none"> <div class="joms-gap"></div> <ul class="joms-list--friend"> <?php foreach ($blockedUsers as $row) { $user = CFactory::getUser($row->blocked_userid); $user->profileLink = CUrl::build('profile', '', array('userid' => $user->id)); ?> <li class="joms-list__item"> <div class="joms-list__avatar"> <a href="<?php echo $user->profileLink; ?> " class="joms-avatar"> <img src="<?php echo $user->getThumbAvatar(); ?> " alt="<?php echo $user->getDisplayName(); ?> " > </a>