function Unauthorize() { global $HTTP_HOST, $EDIT_DOMAIN, $AUTHORIZATION_TYPE; global $PHP_AUTH_USER, $PHP_AUTH_PW, $_SERVER, $PHP_AUTH_LANG, $PHP_AUTH_SID; global $PHPSESSID, $MODULE_VARS; global $db; if ($sname = session_name()) { global ${$sname}; } switch (true) { // cookie case $AUTHORIZATION_TYPE == 'cookie': $EditDomainHost = substr($EDIT_DOMAIN, 0, nc_strlen($EDIT_DOMAIN) - nc_strlen(strchr($EDIT_DOMAIN, "/"))); $db->query("DELETE FROM `Session` WHERE `Session_ID` = '" . $PHP_AUTH_SID . "' OR `SessionTime` < '" . time() . "'"); // unset back-end and front-end cookies $cookie_domain = ""; if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\\-]{1,63}\\.[a-z\\.]{2,6})$/i', $HTTP_HOST, $regs)) { $cookie_domain .= '.' . $regs['domain']; } else { $cookie_domain .= '.' . $HTTP_HOST; } setcookie("PHP_AUTH_SID", NULL, NULL, "/", $cookie_domain); setcookie("PHP_AUTH_LANG", NULL, NULL, "/", $cookie_domain); break; // http // http case $AUTHORIZATION_TYPE == 'http': unset($_SERVER['PHP_AUTH_USER']); unset($_SERVER['PHP_AUTH_PW']); unset($_SERVER['HTTP_AUTHORIZATION']); break; // session // session case $AUTHORIZATION_TYPE == 'session': if (${$sname} != "") { $db->query("DELETE FROM Session WHERE Session_ID = '" . ${$sname} . "' OR SessionTime < " . time()); ${$sname} = $_POST['$sname']; ${$sname} = $_GET['$sname']; } unset($_SESSION['User']); session_destroy(); break; } }
/** * Make request and process it * * @access private * @param array * Assoc array * - name * - url * - params (array) * - pattern * - method * @return array */ function request_and_process($source) { global $nc_core; if (!is_array($source)) { return array("ok" => false); } foreach (array("name", "url", "pattern") as $param) { if (!$source[$param]) { user_error($source['name'] . ": " . $param . " not set", E_USER_WARNING); return array("ok" => false); } } if (!$source["method"]) { $source["method"] = "get"; } $ret = array("ok" => false); $this->user_agent->{$source["method"]}($source["url"], $source["params"]); $response = $this->user_agent->currentResponse(); if ($response["code"] == "200") { // START --- Encode content in preg expressions --- $source_encoding = MAIN_ENCODING ? MAIN_ENCODING : "windows-1251"; // вся обработка идет в utf-8, конвертация в кодировке пользователя - при выдаче результата, // в файле get_data.php $source_encoding = 'utf-8'; if ($response['headers']['content-type']) { preg_match('/charset=([\\w\\d-]+)/is', $response['headers']['content-type'], $matches); $source_charset = $matches[1] ? $matches[1] : $source_encoding; } if ($source_encoding && $source_charset && strtolower($source_encoding) != strtolower($source_charset)) { $response["body"] = $nc_core->utf8->conv($source_charset, 'utf-8', $response["body"]); //$source["pattern"] = $source["pattern"] ? iconv($source_encoding, $source_charset, $source["pattern"]) : $source["pattern"]; //$source["replace"][0] = $source["pattern"] ? iconv($source_encoding, $source_charset, $source["replace"][0]) : $source["pattern"]; } // END --- Encode content in preg expressions --- // extract data if (!$source["pattern"]) { user_error("NO DATA PATTERN", E_USER_WARNING); } else { nc_preg_match($source["pattern"], $response["body"], $regs); if (nc_strlen($regs[1])) { array_shift($regs); if (sizeof($regs) > 1) { if ($source["reverse"]) { $regs = array_reverse($regs); } } $ret["value"] = join(" / ", $regs); $ret["ok"] = true; if (is_array($source["replace"]) && nc_strlen($source["replace"][0])) { $ret["value"] = nc_preg_replace($source["replace"][0], $source["replace"][1], $ret["value"]); } } } } $ret["name"] = $source["name"]; $ret["href"] = $source["href"]; if (!$ret["value"] && $source["negative"]) { $ret["value"] = $source["negative"]; } $ret = array_merge($response, $ret); return $ret; }
#} } elseif ($admin_modal) { eval($nc_core->template->get_current("Settings")); } // openstat if (NC_OPENSTAT_COUNTER) { if (!$admin_mode && !$inside_admin) { $pos = nc_strpos($template_header, NC_OPENSTAT_COUNTER); if ($pos !== FALSE) { $template_header = nc_substr($template_header, 0, $pos) . nc_openstat_get_code() . nc_substr($template_header, $pos + nc_strlen(NC_OPENSTAT_COUNTER)); $template_header = str_replace(NC_OPENSTAT_COUNTER, "", $template_header); $template_footer = str_replace(NC_OPENSTAT_COUNTER, "", $template_footer); } else { $pos = nc_strpos($template_footer, NC_OPENSTAT_COUNTER); if ($pos !== FALSE) { $template_footer = nc_substr($template_footer, 0, $pos) . nc_openstat_get_code() . nc_substr($template_footer, $pos + nc_strlen(NC_OPENSTAT_COUNTER)); $template_footer = str_replace(NC_OPENSTAT_COUNTER, "", $template_footer); } } } } if (!$check_auth && NC_AUTH_IN_PROGRESS !== 1) { eval("echo \"" . $template_header . "\";"); if ($AUTH_USER_ID || !$AUTH_USER_ID && !$nc_core->modules->get_vars('auth')) { if ($nc_core->inside_admin) { nc_print_status(NETCAT_MODERATION_ERROR_NORIGHTS, 'error'); } else { print NETCAT_MODERATION_ERROR_NORIGHTS; } } elseif (!$AUTH_USER_ID && $nc_core->modules->get_vars('auth')) { $nc_auth->login_form();
function nc_admin_textarea_template($name, $value = '', $attr = null, $prefix = '', $suffix = '') { if (is_array($value)) { $value = $value[$name]; } $ret = $prefix . "<textarea name='{$name}'"; if (isset($attr["simple"])) { $ret .= " " . $attr["simple"]; unset($attr["simple"]); } foreach ($attr as $key => $val) { if (!empty($val)) { $ret .= " {$key}='{$val}'"; } } $ret .= '>' . (nc_strlen($value) ? htmlentities($value, ENT_QUOTES, MAIN_ENCODING) : '') . '</textarea>' . $suffix; return $ret; }
function drawLegend($img, $report, $caption_color, $color1, $color2, $color3, $caption1, $caption2, $caption3) { global $ttf_font_file, $nc_core; $y_step = 40; $base_x = DIAGRAM_WIDTH + DIAGRAM_X + 25; //imagettftext($img, 12, 0, $base_x, DIAGRAM_Y, $caption_color, $ttf_font_file, $report['title']); $y = DIAGRAM_Y + 25; $x = $base_x + 12 + nc_strlen($caption1) * 7; if (!$nc_core->NC_UNICODE) { $caption1 = $nc_core->utf8->win2utf($caption1); } imagettftext($img, 10, 0, $base_x, $y, $caption_color, $ttf_font_file, $caption1); imageBoldLine($img, $x, $y - 5, $x + 15, $y - 5, $color3, 3); //imagettftext($img, 14, 0, $base_x, $y+19, $caption_color, $ttf_font_file, $report['sum'][2]); $y = $y + $y_step; $x = $base_x + 12 + nc_strlen($caption2) * 7; if (!$nc_core->NC_UNICODE) { $caption2 = $nc_core->utf8->win2utf($caption2); } imagettftext($img, 10, 0, $base_x, $y, $caption_color, $ttf_font_file, $caption2); imageBoldLine($img, $x, $y - 5, $x + 15, $y - 5, $color2, 3); //imagettftext($img, 14, 0, $base_x, $y+19, $caption_color, $ttf_font_file, $report['sum'][1]); $y = $y + $y_step; $x = $base_x + 12 + nc_strlen($caption3) * 7; if (!$nc_core->NC_UNICODE) { $caption3 = $nc_core->utf8->win2utf($caption3); } imagettftext($img, 10, 0, $base_x, $y, $caption_color, $ttf_font_file, $caption3); imageBoldLine($img, $x, $y - 5, $x + 15, $y - 5, $color1, 3); //imagettftext($img, 14, 0, $base_x, $y+19, $caption_color, $ttf_font_file, $report['sum'][0]); }
} // пользовательское соглашение if (!$nc_agreed && $nc_core->get_settings('agreed', 'auth')) { $posting = 0; $warnText = NETCAT_MODERATION_MSG_NEED_AGREED . "<br/>"; } } if ($user_table_mode && $posting && ($action == 'add' || isset($Password1) && $action == 'change')) { // совпадение паролей if ($Password1 != $Password2 || !$Password1) { $warnText = NETCAT_MODERATION_MSG_RETRYPASS . "<br/>"; $posting = 0; } // минимальная длина пароля $pass_min = $nc_core->get_settings('pass_min', 'auth'); if ($pass_min && nc_strlen($Password1) < $pass_min) { $warnText = sprintf(NETCAT_MODERATION_MSG_PASSMIN, $pass_min) . "<br/>"; $posting = 0; } $Password = $Password1; } if ($posting) { $multiple_changes = +$_POST['multiple_changes']; $nc_multiple_changes = (array) $_POST['nc_multiple_changes']; do { if ($multiple_changes) { if (list($msg_id, $multiple_changes_fields) = each($nc_multiple_changes)) { foreach ($multiple_changes_fields as $multiple_changes_key => $multiple_changes_value) { $fldValue[array_search($multiple_changes_key, $fld)] = $multiple_changes_value; } } else {
function ShowMenu($CatalogueID, $phase1, $action1, $phase2, $action2) { global $db, $perm; global $EDIT_DOMAIN, $HTTP_ROOT_PATH, $DOMAIN_NAME, $ADMIN_PATH, $SUB_FOLDER; global $UI_CONFIG; $CatalogueID = intval($CatalogueID); $is_admin = $perm->isCatalogueAdmin($CatalogueID); $Array = $db->get_row("SELECT * FROM `Catalogue` WHERE `Catalogue_ID`='" . $CatalogueID . "'"); if (!$Array) { nc_print_status(CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWCATALOGUELIST_DBERROR, 'error'); EndHtml(); exit; } $countChild = HighLevelChildrenNumber($CatalogueID); $ModerationType = $Array->Moderation_ID == 2 ? CLASSIFICATOR_TYPEOFMODERATION_MODERATION : CLASSIFICATOR_TYPEOFMODERATION_RIGHTAWAY; $UserGroupName = array(1 => CLASSIFICATOR_USERGROUP_ALL, 2 => CLASSIFICATOR_USERGROUP_REGISTERED, 3 => CLASSIFICATOR_USERGROUP_AUTHORIZED); // In MySQL 4.1, TIMESTAMP display format changes to be the same as DATETIME. if (nc_strpos($Array->LastUpdated[4], '-')) { $Array->LastUpdated = nc_substr($Array->LastUpdated, 0, 4) . "-" . nc_substr($Array->LastUpdated, 4, 2) . "-" . nc_substr($Array->LastUpdated, 6, 2) . " " . nc_substr($Array->LastUpdated, 8, 2) . ":" . nc_substr($Array->LastUpdated, 10, 2) . ":" . nc_substr($Array->LastUpdated, 12, 2); } echo "<br />\n\t<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td>\n\t<table border='0' cellpadding='0' cellspacing='1' width='100%'><tr><td>\n \t<table border='0' cellpadding='0' cellspacing='0' width='100%' class='border-bottom'>\n \t<tr><td width='50%'>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_CREATED . ":</td><td>" . $Array->Created . "</td></tr>\n \t<tr><td>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_UPDATED . ":</td><td>" . $Array->LastUpdated . "</td></tr>\n \t</table>\n\t</td></tr><tr><td>\n \t<table border='0' cellpadding='0' cellspacing='0' width='100%' class='border-bottom'>\n <tr><td width='50%'>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_SECTIONSCOUNT . ":</td>"; echo "<td>" . $countChild; if ($countChild) { echo " ( <a href='" . $ADMIN_PATH . "subdivision/index.php?CatalogueID=" . $CatalogueID . "&ParentSubID=0'>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWCATALOGUELIST_LIST . "</a>\n " . ($is_admin ? ", <a href='" . $ADMIN_PATH . "subdivision/index.php?phase=2&ParentSubID=0&CatalogueID=" . $CatalogueID . "'>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_ADD . "\n </a> )" : ")") . ""; } echo "</td></tr>\n \t<tr><td>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_SITESTATUS . ":</td><td>" . ($Array->Checked ? CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_ON : CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_OFF) . "</td></tr>\n \t</table>\n\t</td></tr><tr><td>\n \t<table border='0' cellpadding='0' cellspacing='0' width='100%' class='border-bottom'>\n \t<tr><td width=50%>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_READACCESS . ":</td><td>" . $UserGroupName[$Array->Read_Access_ID] . " " . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_USERS . "</td></tr>\n <tr><td>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_ADDACCESS . ":</td><td>" . $UserGroupName[$Array->Write_Access_ID] . " " . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_USERS . "</td></tr>\n \t<tr><td>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_EDITACCESS . ":</td><td>" . $UserGroupName[$Array->Edit_Access_ID] . " " . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_USERS . "</td></tr>\n \t<tr><td>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_SUBSCRIBEACCESS . ":</td><td>" . $UserGroupName[$Array->Subscribe_Access_ID] . " " . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_USERS . "</td></tr>\n \t<tr><td>" . CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_PUBLISHACCESS . ":</td><td>" . $ModerationType . "</td></tr>\n \t</table>\n\t</td></tr></table></td></tr></table>"; $UI_CONFIG->actionButtons[] = array("id" => "delete", "caption" => CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_DELETE, "location" => "site.delete(" . $CatalogueID . ")", "red_border" => true); $UI_CONFIG->actionButtons[] = array("id" => "preview", "caption" => CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWMENU_VIEW, "action" => "urlDispatcher.load('http://" . ($Array->Domain ? strstr($Array->Domain, ".") ? $Array->Domain : $Array->Domain . "." . $DOMAIN_NAME : $DOMAIN_NAME) . $SUB_FOLDER . (nc_strlen(session_id()) > 0 ? "?" . session_name() . "=" . session_id() . "" : "") . "', '1')"); }
/** * Пропарсить формат поля * Для поля типа "Файл" возвращаемое значение - хэш-массив с ключами: * size - размер; * type - массив с mimetype. Каждый элемент - массив, 0 - то, что стоит до /, 1 - то, что стоит после * fs - тип файловой системы * disposition - content-disposition, 0 - inline, 1 - attachment * download - считать скачивания? * * Для поле "Текстовы блок": * html - разрешить тэги * br - перенос строки - <br> * fck - встроить редактор в поле * rows, cols - высота и шириина * bbcode - доступены bb-коды * * @param string format * @param int field type * @return array */ function nc_field_parse_format($format, $fieldtype) { $ret = array(); //возвращаемое значение $format = str_replace(' ', '', $format); // уберем пробелы switch ($fieldtype) { case NC_FIELDTYPE_FILE: // значения по умолчанию $ret['size'] = 0; $ret['type'] = ''; $ret['fs'] = NC_FS_PROTECTED; $ret['download'] = 0; $ret['disposition'] = 0; // если формат пустой - вернуть значения по умолчанию if (!$format) { break; } // формат в общем случае: size:type1/type,type2/type:fs1|fs2|fs3:inline|attachment:download //уберем из формата лишнее $format = array_shift(explode(';', $format)); // определение фс if (preg_match('/(:?)(fs)(\\d+)/', $format, $match)) { $ret['fs'] = $match[3]; // уберем из формата тип фс $format = nc_preg_replace('/(:?)(fs)(\\d+)/', '', $format); } if (!$format) { break; } // определение download if (strstr($format, 'download') !== false) { $ret['download'] = 1; } $format = nc_preg_replace('/(:?)(download)/', '', $format); // уберем download // определение content-disposition if (strstr($format, 'attachment') !== false) { $ret['disposition'] = 1; } $format = nc_preg_replace('/(:?)((attachment)|(inline))/', '', $format); // уберем attachment $format_array = explode(':', $format); if (empty($format_array)) { break; } if ($format_array[0]) { $ret['size'] = $format_array[0]; } // размер //определение mimetype if ($format_array[1]) { $fileformat = explode(",", $format_array[1]); // определим каждый тип foreach ($fileformat as $k => $v) { $ret['type'][$k] = explode('/', $v); } } break; case NC_FIELDTYPE_TEXT: // значения по умолчанию $ret['rows'] = 5; // количество строк $ret['cols'] = 60; // и столбцов $ret['html'] = 0; // разрешить тэги $ret['br'] = 0; // перенос строки - br $ret['fck'] = 0; // редактор встроен в поле $ret['panel'] = 0; $ret['typo'] = 0; $ret['bbcode'] = 0; if (!$format) { return $ret; } $params = array('html', 'br', 'fck', 'panel', 'typo', 'bbcode'); // пробуем найти каждый параметр foreach ($params as $param) { if (($start = nc_strpos($format, $param)) !== false) { $ret[$param] = intval(nc_substr($format, $start + nc_strlen($param) + 1, 1)); } } // высоту и ширину ищем отдельно if ($format[0] > 0) { $format = strtok($format, ';'); $ret['rows'] = strtok($format, ':'); $ret['cols'] = strtok(':'); } break; case NC_FIELDTYPE_DATETIME: $ret['type'] = ''; $ret['calendar'] = 0; if (nc_strpos($format, 'calendar') !== false) { $ret['calendar'] = 1; $format = str_replace(array(';', 'calendar'), '', $format); } if ($format) { $ret['type'] = $format; } break; case NC_FIELDTYPE_STRING: $format = explode(':', $format); $ret['format'] = $format[0]; $ret['protect_email'] = isset($format[1]) && $format[1] == 'protect'; $ret['use_transliteration'] = $format[2]; $ret['transliteration_field'] = $format[3]; $ret['use_url_rules'] = $format[4]; break; } return $ret; }
if ($action_type == 1) { BeginHtml($Title8, $Title8, "http://" . $DOC_DOMAIN . "/management/class/groupofclass/"); } else { BeginHtml($Title2, $Title2, "http://" . $DOC_DOMAIN . "/management/class/"); } $perm->ExitIfNotAccess(NC_PERM_CLASS, 0, 0, 0, 1); if (!$Class_Name) { nc_print_status(CONTROL_CONTENT_CLASS_ERROR_NAME, 'error'); $AJAX_SAVER = true; ClassForm(0, "index.php", 3, 1, $BaseClassID); EndHtml(); exit; } if ($Class_Group_New) { nc_preg_match('/[0-9]+/', $Class_Group_New, $matches); if (nc_strlen($Class_Group_New) == nc_strlen($matches[0])) { nc_print_status(CONTROL_CONTENT_CLASS_GROUP_ERROR_NAME, 'error'); ClassForm(0, "index.php", 3, 1, $BaseClassID); exit; } } $OldClass = $db->get_row("SELECT Class_Name, Class_Group FROM Class WHERE Class_ID = '" . $ClassID . "'", ARRAY_A); if ($Class_Group_New) { $isNewGroup = $db->get_var("SELECT COUNT(Class_Group) FROM Class WHERE Class_Group = '" . $Class_Group_New . "'"); } if (ActionClassComleted($type) === false) { nc_print_status(CONTROL_CONTENT_CLASS_ERROR_EDIT, 'error'); $AJAX_SAVER = true; ClassForm($ClassID, "index.php", 5, 2, 0); EndHtml(); exit;
/** * Аналог strpos * * @param $haystack * @param $needle * @param null|int $offset * @return int or false */ function nc_strrpos($haystack, $needle, $offset = null) { $nc_core = nc_Core::get_object(); if (!$nc_core->NC_UNICODE) { return strrpos($haystack, $needle, $offset); } if ($nc_core->utf8->mbstring_ext()) { return mb_strrpos($haystack, $needle, $offset); } $pos = strrpos($haystack, $needle, $offset); if ($pos === false) { return false; } return nc_strlen(substr($haystack, 0, $pos)); }
function strord($string) { for ($i = 0; $i < nc_strlen($string); $i++) { $result[$i] = ord($string[$i]); } return $result; }
} // sic (remove header) if ($use_gzip_compression) { header("Content-Encoding: "); } // get filetime $file_time = filemtime($full_file_path); // format timestamp as GMT date $last_modified = nc_timestamp_to_gmt($file_time); // check If-Modified-Since and REDIRECT 304, if needed nc_attempt_last_modified_redirect($file_time); $file_data = $db->get_row("SELECT f.`ID`, f.`Real_Name`, f.`File_Type`, f.`Content_Disposition`, fl.`Format`\n \t\t FROM `Filetable` as f, `Field` as `fl`\n \t\t WHERE `Virt_Name` = '" . $matches[3] . "'\n AND `File_Path` = '/" . $file_path . "'\n AND fl.`Field_ID` = f.`Field_ID`\n LIMIT 1", ARRAY_N); if (!empty($file_data)) { list($file_id, $real_name, $file_type, $attachment, $format) = $file_data; $file_size = @filesize($full_file_path); if (!nc_strlen($file_type)) { $file_type = "application/octet-stream"; } header($_SERVER['SERVER_PROTOCOL'] . " 200 OK"); if ($nc_core->PHP_TYPE == "cgi") { header("Status: 200 OK"); } header("Last-Modified: " . $last_modified); header("Content-type: " . $file_type); header("Content-Disposition: " . ($attachment ? 'attachment' : 'inline') . "; filename=\"" . urldecode($real_name) . "\""); header('Content-Transfer-Encoding: binary'); if ($file_size) { header("Content-Length: " . $file_size); header("Connection: close"); } if (strstr($format, 'download') !== false) {