protected function is_even($number) { if (defined('STRICT_TYPES') && CAMEL_CASE == '1') { return (bool) self::parameters(['number' => DT::NUMBER])->call(__FUNCTION__)->with($number)->returning(DT::BOOL); } else { return (bool) is_even($number); } }
function eoargs($array) { if (is_even(count($array))) { $i = 0; do { $a = $i; $b = $i + 1; $x[crunch($array[$a])] = $array[$b]; $i = $i + 2; } while ($i <= count($array)); return $x; } else { exLog('eoargs(): requires an even number array.'); } }
function pro_encode_string($inputstr) { //CS8vdGhlIGRpY3Rpb25hcnkgaXMgY29uZmlybWVkLg0KCS8vIHRoZSBhbGdvcml0aG0gaXMgYmVzdCBndWVzcy4NCi8qCQkkZGljdGlvbmFyeT1hcnJheSgNCgkJJ2EnPT4nYCcsLy8weDYxLT4weDYwDQoJCSdiJz0+J2MnLC8vMHg2Mi0+MHg2Mw0KCQknYyc9PidiJywvLzB4NjMtPjB4NjINCgkJJ2QnPT4nZScsLy8weDY0LT4weDY1DQoJCSdlJz0+J2QnLC8vMHg2NA0KCQknZic9PidnJywvLzB4NjcNCgkJJ2cnPT4nZicsLy8weDY2DQoJCSdoJz0+J2knLC8vMHg2OQ0KCQkpOyovDQo= $ret = ""; $i = 0; for ($i = 0; $i < strlen($inputstr); ++$i) { $num = ord($inputstr[$i]); if (is_even($num)) { ++$num; } else { --$num; } $ret .= chr($num); } return $ret; }
function nc_browse_messages($cc_env, $range, $user_template = false) { if ($user_template) { $browse_msg = $user_template; } else { global $browse_msg; } global $classPreview, $admin_mode, $inside_admin; $nc_core = nc_Core::get_object(); if (isset($classPreview)) { $classPreview += 0; } if ($cc_env['cur_cc'] == $nc_core->input->fetch_get("cur_cc")) { $curPos = $cc_env['curPos'] + 0; } else { $curPos = 0; } $maxRows = $cc_env['maxRows']; $totRows = $cc_env['totRows']; if (!$maxRows || !$totRows) { return ''; } if ($cc_env['cur_cc']) { $cur_cc = $cc_env['cur_cc']; } $page_count = ceil($totRows / $maxRows); $half_range = ceil($range / 2); $cur_page = ceil($curPos / $maxRows) + 1; if ($page_count < 2) { return ''; } $maybe_from = $cur_page - $half_range; $maybe_to = $cur_page + $half_range - (is_even($range) ? 0 : 1); if ($maybe_from < 0) { $maybe_to = $maybe_to - $maybe_from; $maybe_from = 0; if ($maybe_to > $page_count) { $maybe_to = $page_count; } } if ($maybe_to > $page_count) { $maybe_from = $page_count - $range; $maybe_to = $page_count; if ($maybe_from < 0) { $maybe_from = 0; } } // формируем ссылку // const_url не меняется для каждой страницы $const_url = $cc_env['LocalQuery']; if ($const_url == '?') { $const_url = ''; } //$const_url = rawurlencode ($const_url); // добавим get-парметры $_get_arr = $nc_core->input->fetch_get(); $get_params = array(); // добавим в ссылку cur_cc if (isset($cur_cc)) { $get_params['cur_cc'] = $cur_cc; } if (!empty($_get_arr)) { $ignore_arr = array('sid', 'ced', 'inside_admin', 'catalogue', 'sub', 'cc', 'curPos', 'cur_cc', 'REQUEST_URI', 'srchPat'); if ($inside_admin || $admin_mode) { $ignore_arr[] = 'isNaked'; } foreach ($_get_arr as $k => $v) { if (!in_array($k, $ignore_arr)) { $get_params[$k] = $nc_core->input->recursive_striptags_escape($v); } } } $const_url .= count($get_params) ? (strstr($const_url, "?") ? "&" : "?") . $nc_core->url->build_url($get_params) : ""; if (!$admin_mode && nc_module_check_by_keyword('routing')) { $use_routing_module = true; $routing_parameters = nc_resolve_url($nc_core->url); $routing_parameters['variables'] = array_merge(nc_array_value($routing_parameters, 'variables', array()), $get_params, array('curPos' => null, 'nc_page' => null)); $routing_parameters['page'] = null; $routing_resource_type = $routing_parameters['resource_type']; if ($routing_resource_type == 'folder' && $routing_parameters['infoblock_id']) { $routing_resource_type = 'infoblock'; } } else { $use_routing_module = $routing_parameters = $routing_resource_type = false; } $array_result = array(); for ($i = $maybe_from; $i < $maybe_to; $i++) { $page_number = $i + 1; $page_from = $i * $maxRows; $page_to = $page_from + $maxRows; if ($use_routing_module) { $routing_parameters['variables']['curPos'] = $page_from ? $page_from : null; $routing_parameters['page'] = $page_number > 1 ? $page_number : null; $url = nc_routing::get_resource_path($routing_resource_type, $routing_parameters); } elseif ($page_from && !$admin_mode) { // ссылка не на первую страницу $url = $nc_core->url->get_parsed_url('path') . $const_url . (strpos($const_url, "?") !== false ? "&" : "?") . "curPos=" . $page_from; $url = $nc_core->SUB_FOLDER . $url; } elseif ($page_from && $admin_mode) { $url = $const_url . (strpos($const_url, "?") !== false ? "&" : "?") . "curPos=" . $page_from; } else { // ссылка на первую страницу, curPos не нужен $url = $const_url ? $const_url : $nc_core->url->get_parsed_url('path'); } // replace existing & with & then replace all & to & $url = nc_preg_replace(array("/&/", "/&/"), array("&", "&"), $url); if ($curPos == $page_from) { $array_result[$i] = $browse_msg['active']; } else { $array_result[$i] = $browse_msg['unactive']; } $array_result[$i] = str_replace("%URL", $url, $array_result[$i]); $array_result[$i] = str_replace("%PAGE", $page_number, $array_result[$i]); $array_result[$i] = str_replace("%FROM", $page_from + 1, $array_result[$i]); $array_result[$i] = str_replace("%TO", $page_to, $array_result[$i]); } $result = $browse_msg['prefix']; $result .= join($browse_msg['divider'], $array_result); $result .= $browse_msg['suffix']; return $result; }
} else { $rs = safe_rows_start('*, unix_timestamp(log_time) as stamp', 'pixie_log', "log_type = 'system' order by log_time desc limit 30"); } if ($rs) { $counter = 0; while ($a = nextRow($rs)) { $counter++; extract($a); $logunix = returnUnixtimestamp($log_time); $time = safe_strftime($date_format, $logunix); if ($log_important == 'yes') { $trclass = 'logimportant'; } else { $trclass = 'normal'; } if (is_even($counter)) { $trclass .= ' even'; } else { $trclass .= ' odd'; } if ($counter >= 20) { $trclass .= ' fade' . (30 - $counter); } if (isset($do) && $do == 'referral') { $log_url = htmlentities($log_message); $from = "<a href=\"{$log_url}\" title=\"Visit: {$log_url}\">" . chopme(str_replace('http://', "", $log_url), 70) . "</a>"; echo "\n\t\t\t\t\t\t\t\t<tr class=\"{$trclass}\">\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"icon\"><img src=\"admin/theme/images/icons/{$log_icon}.png\" alt=\"{$log_icon} icon\" /></td>\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"when\">{$time}</td>\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"who\"><a href=\"http://network-tools.com/default.asp?prog=lookup&host={$user_ip}\" title=\"Lookup IP: {$user_ip}\" target=\"_blank\">{$user_ip}</a> </td>\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"from\">{$from}</a></td>\n\t\t\t\t\t\t\t\t</tr>"; } else { echo "\n\t\t\t\t\t\t\t\t<tr class=\"{$trclass}\">\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"icon\"><img src=\"admin/theme/images/icons/{$log_icon}.png\" alt=\"{$log_icon} icon\" /></td>\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"when\">{$time}</td>\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"who\"><a href=\"http://network-tools.com/default.asp?prog=lookup&host={$user_ip}\" title=\"Lookup IP: {$user_ip}\" target=\"_blank\">{$user_id}</a> </td>\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"what\">{$log_message}</td>\n\t\t\t\t\t\t\t\t</tr>"; } }
private function _set_get_params($_array = []) { global $_GET; if (array_count($_array) > 0 && is_even(count($_array))) { $_array_count = floor(count($_array) / 2); for ($i = 0; $i / 2 < $_array_count; $i += 2) { $_GET[$_array[$i]] = !empty($_array[$i + 1]) ? $_array[$i + 1] : ''; } } }
function show_single() { global $s, $m, $x, $mtitle, $site_url, $comments, $page_display_name, $site_name, $comment_ok, $date_format, $lang, $error, $scream, $sname, $semail, $scomment, $sweb, $timezone; $rs = safe_row('*', 'pixie_dynamic_posts', "post_slug = '{$x}' and public = 'yes' limit 0,1"); if ($rs) { extract($rs); safe_update('pixie_dynamic_posts', "post_views = {$post_views} + 1", "post_id = '{$post_id}'"); $logunix = returnUnixtimestamp($posted); $date = safe_strftime($date_format, $logunix); $timeunix = returnUnixtimestamp($last_modified); $xdate = safe_strftime($date_format, $timeunix); $microformat = safe_strftime('%Y-%m-%dT%T%z', $logunix); $slug = $post_slug; $fullname = safe_field('realname', 'pixie_users', "user_name='{$author}'"); if (public_page_exists('profiles')) { $mauthor = "<a href=\"" . createURL("profiles", $author) . "\" class=\"url fn\" title=\"" . $lang['view'] . " {$fullname}'s " . $lang['profile'] . "\">{$fullname}</a>"; } else { $mauthor = "<a href=\"{$site_url}\" class=\"url fn\" title=\"{$site_url}\">{$fullname}</a>"; } if (isset($tags) && $tags) { $all_tags = strip_tags($tags); $all_tags = str_replace('"', "", $tags); $tags_array_temp = explode(" ", $all_tags); for ($count = 0; $count < count($tags_array_temp); $count++) { $current = $tags_array_temp[$count]; $first = $current[strlen($current) - strlen($current)]; if ($first == " ") { $current = substr($current, 1, strlen($current) - 1); } $ncurrent = make_slug($current); if (isset($s) && isset($ncurrent)) { if (isset($tag_list)) { } else { $tag_list = NULL; } $tag_list .= "<a href=\"" . createURL($s, 'tag', $ncurrent) . "\" title=\"" . $lang['view'] . " " . $lang['all_posts_tagged'] . ": " . $current . "\" rel=\"tag\" >" . $current . "</a>, "; } if ($ncurrent != "") { if (isset($class_list)) { } else { $class_list = NULL; } $class_list .= "tag_{$ncurrent} "; } } $tag_list = substr($tag_list, 0, strlen($tag_list) - 2) . ""; } if (isset($s)) { $permalink = createURL($s, 'permalink', $slug); } $authorclass = strtolower($author); $timeclass = safe_strftime('y%Y m%m d%d h%H', $logunix); echo "\n\t\t\t\t\t<div class=\"section hentry author_{$authorclass} {$class_list}{$timeclass} single\" id=\"post_{$post_id}\">\n\t\t\t\t\t\t<h4 class=\"entry-title\"><a href=\"{$permalink}\" rel=\"bookmark\">{$title}</a></h4>\n\t\t\t\t\t\t<ul class=\"post_links\">\n\t\t\t\t\t\t\t<li class=\"post_date\"><abbr class=\"published\" title=\"{$microformat}\">{$date}</abbr></li>"; if (isset($_COOKIE['pixie_login'])) { list($username, $cookie_hash) = explode(',', $_COOKIE['pixie_login']); $nonce = safe_field('nonce', 'pixie_users', "user_name='{$username}'"); if (md5($username . $nonce) == $cookie_hash) { $privs = safe_field('privs', 'pixie_users', "user_name='{$username}'"); if ($privs >= 1) { echo "\n\t\t\t\t\t\t\t<li class=\"post_edit\"><a href=\"" . $site_url . "admin/?s=publish&m=dynamic"; if (isset($s)) { echo '&x=' . $s; } echo "&edit={$post_id}\" title=\"" . $lang['edit_post'] . "\">" . $lang['edit_post'] . "</a></li>"; } } } echo "\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t<div class=\"post entry-content\">\n"; //<!--more--> $post = get_extended($content); echo "\t\t\t\t\t\t\t" . $post['main']; if ($post['extended']) { echo $post['extended']; } echo "\n\t\t\t\t\t\t</div>\t\t\n\t\t\t\t\t\t<div class=\"post_credits\">\n\t\t\t\t\t\t \t<span class=\"vcard author\">" . $lang['by'] . " {$mauthor}</span>\n\t\t\t\t\t\t \t<span class=\"post_tags\">" . $lang['tagged'] . ": {$tag_list}</span>\n\t\t\t\t\t\t \t<span class=\"post_updated\">" . $lang['last_updated'] . ": {$xdate} </span>\n\t\t\t\t\t\t</div>\t\t\t\n\t\t\t\t\t</div>\n\t\t\t\t\t\n\t\t\t\t\t<div id=\"nav_posts\" class=\"dynamic_bottom_nav\">\n"; // previous and next posts if (isset($s)) { $thisid = get_page_id($s); } // what post is next? $searchnext = safe_field('post_id', 'pixie_dynamic_posts', "page_id = '{$thisid}' and public = 'yes' and posted > '{$posted}' limit 0,1"); if ($searchnext) { $ntitle = safe_field('title', 'pixie_dynamic_posts', "post_id ='{$searchnext}'"); $nslug = safe_field('post_slug', 'pixie_dynamic_posts', "post_id ='{$searchnext}'"); echo "\t\t\t\t\t\t<div id=\"post_next\" class=\"link_next\"><a class=\"link_next_a\" href=\""; if (isset($s)) { echo createURL($s, 'permalink', $nslug); } echo "\" title=\"" . $lang['next_post'] . ": {$ntitle}\">" . $lang['next_post'] . " »</a></div>\n"; } // what post is previous? $searchprev = safe_field('post_id', 'pixie_dynamic_posts', "page_id = '{$thisid}' and public = 'yes' and posted < '{$posted}' order by posted desc limit 0,1"); if ($searchprev) { $ptitle = safe_field('title', 'pixie_dynamic_posts', "post_id ='{$searchprev}'"); $pslug = safe_field('post_slug', 'pixie_dynamic_posts', "post_id ='{$searchprev}'"); echo "\t\t\t\t\t\t<div id=\"post_previous\" class=\"link_previous\"><a class=\"link_prev_a\" href=\""; if (isset($s)) { echo createURL($s, 'permalink', $pslug); } echo "\" title=\"" . $lang['previous_post'] . ": "; if (isset($ptitle)) { echo $ptitle; } echo "\">« " . $lang['previous_post'] . "</a></div>\n"; } echo "\t\t\t\t\t</div>\n"; $comms = safe_rows('*', 'pixie_module_comments', "post_id = '{$post_id}'"); $no_comms = count($comms); // fix to remove commenting when plug in is removed if (public_page_exists('comments')) { if ($comments == 'yes' or $comms) { echo "\n\t\t\t\t\t<div id=\"comments\">\n\t\t\t\t\t\t<h4 id=\"comments_title\">" . $lang['comments'] . "</h4>"; if (isset($_COOKIE['pixie_login'])) { list($username, $cookie_hash) = explode(',', $_COOKIE['pixie_login']); $nonce = safe_field('nonce', 'pixie_users', "user_name='{$username}'"); if (md5($username . $nonce) == $cookie_hash) { $realname = safe_field('realname', 'pixie_users', "user_name='{$username}'"); $umail = safe_field('email', 'pixie_users', "user_name='{$username}'"); } } $r2 = safe_rows('*', 'pixie_module_comments', "post_id = '{$post_id}' order by posted asc"); if ($r2) { $i = 0; while ($i < $no_comms) { extract($r2[$i]); $default = "{$site_url}files/images/no_grav.jpg"; if (isset($email)) { $grav_url = 'http://www.gravatar.com/avatar.php?gravatar_id=' . md5($email) . '&default=' . urlencode($default) . '&size=40'; } $hash = $i + 1; if ($url) { $namepr = "<span class=\"message_name author\"><a href=\"{$permalink}#comment_{$hash}\" rel=\"bookmark\" class=\"comment_permalink\">#{$hash}</a> <a href=\"" . htmlentities($url) . "\" rel=\"external nofollow\" class=\"url fn\">{$name}</a></span>"; } else { $namepr = "<span class=\"message_name author\"><a href=\"{$permalink}#comment_{$hash}\" rel=\"bookmark\" class=\"comment_permalink\">#{$hash}</a> <span class=\"fn\">{$name}</span></span>"; } if (is_even($i + 1)) { $type = 'comment_even'; } else { $type = 'comment_odd'; } if ($admin_user == 'yes') { $atype = ' comment_admin'; } else { $atype = ""; } $logunix = returnUnixtimestamp($posted); $days_ago = safe_strftime('since', $logunix); $microformatcomment = safe_strftime('%Y-%m-%dT%T%z', $logunix); $commenttimeclass = safe_strftime('c_y%Y c_m%m c_d%d c_h%H', $logunix); echo "\n\t\t\t\t\t\t<div class=\"{$type} hentry comment comment_author_" . str_replace('-', '_', make_slug($name)) . " {$commenttimeclass}" . $atype . "\" id=\"comment_{$hash}\">\n\t\t\t\t\t\t\t<div class=\"comment_message\">\n\t\t\t\t\t\t\t\t<div class=\"message_details vcard\">\n\t\t\t\t\t\t\t\t\t<img src=\"{$grav_url}\" alt=\"Gravatar Image\" class=\"gr photo\" />\n\t\t\t\t\t\t\t\t\t{$namepr}\n\t\t\t\t\t\t\t\t\t<span class=\"message_time\"><abbr class=\"published\" title=\"{$microformatcomment}\">{$days_ago}</abbr></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"message_body entry-title entry-content\"><p>{$comment}</p></div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>"; $i++; } } else { echo "\n\t\t\t\t\t\t<span class=\"comments_none\">" . $lang['no_comments'] . "</span>"; } echo "\n\t\t\t\t\t</div>\n"; echo "\n\t\t\t\t\t<div class=\"comment_form\" id=\"commentform\">"; if ($comment_ok) { echo "\n\t\t\t\t\t\t\t<p class=\"success\">" . $lang['comment_thanks'] . '</p>'; } else { if ($comments == 'yes') { if (isset($s)) { $posty = createURL($s, $m, $x); } echo "\n\t\t\t\t\t\t<form accept-charset=\"UTF-8\" action=\"{$posty}#commentform\" method=\"post\" class=\"form\">\n\t\t\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\t\t var blogTool = \"pixie\";\n\t\t\t\t\t\t var blogURL = \"{$site_url}\";\n\t\t\t\t\t\t var blogTitle = \"{$site_name} - {$page_display_name}\";\n\t\t\t\t\t\t var postURL = \"{$posty}\";\n\t\t\t\t\t\t var postTitle = \"{$title}\";\n\t\t\t\t\t\t var commentTextFieldName = \"comment\";\n\t\t\t\t\t\t var commentButtonName = \"comment_submit\";"; if (isset($realname) && $realname) { echo "\n\t\t\t\t\t\t var commentAuthorLoggedIn = true;"; } else { echo "\n\t\t\t\t\t\t var commentAuthorLoggedIn = false;"; } echo "\n\t\t\t\t\t\t var commentAuthorFieldName = \"name\";\n\t\t\t\t\t\t var commentFormID = \"commentform\";\n\t\t\t\t\t\t</script>\n\t\t\t\t\t\t\t<fieldset>\n\t\t\t\t\t\t\t\t<legend>" . $lang['comment_leave'] . "</legend>"; if (isset($error)) { echo "\n\t\t\t\t\t\t\t\t<p class=\"error\">{$error}</p>"; if (in_array('name', $scream)) { $name_style = 'form_highlight'; } if (in_array('comment', $scream)) { $comment_style = 'form_highlight'; } if (in_array('email', $scream)) { $email_style = 'form_highlight'; } if (in_array('web', $scream)) { $web_style = 'form_highlight'; } } else { echo "<p class=\"notice\">" . $lang['comment_form_info'] . "</p>"; } echo "\n\t\t\t\t\t\t\t\t<div class=\"form_row "; if (isset($name_style)) { echo $name_style; } echo "\">\n\t\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"comment_name\">" . $lang['comment_name'] . " <span class=\"form_required\">" . $lang['form_required'] . "</span></label></div>"; if (isset($realname) && $realname) { echo "\n\t\t\t\t\t\t\t\t\t<div class=\"form_item\"><input type=\"text\" disabled=\"disabled\" tabindex=\"1\" name=\"name\" class=\"form_text\" id=\"comment_name\""; if (isset($realname)) { echo " value=\"{$realname}\""; } echo " /></div>"; } else { echo "\n\t\t\t\t\t\t\t\t<div class=\"form_item\"><input type=\"text\" tabindex=\"1\" name=\"name\" class=\"form_text\" id=\"comment_name\" value=\"{$sname}\"/></div>"; } if ($sweb == "") { $sweb = 'http://'; } if (isset($realname) && $realname) { $sweb = $site_url; $semail = $umail; } echo "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"form_row "; if (isset($email_style)) { echo $email_style; } echo "\">\n\t\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"comment_email\">" . $lang['comment_email'] . " <span class=\"form_required\">" . $lang['form_required'] . "</span></label></div>\n\t\t\t\t\t\t\t\t\t<div class=\"form_item\"><input type=\"text\" tabindex=\"2\" name=\"email\" class=\"form_text\" id=\"comment_email\" value=\"{$semail}\" /></div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"form_row "; if (isset($web_style)) { echo $web_style; } echo "\">\n\t\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"comment_web\">" . $lang['comment_web'] . " <span class=\"form_optional\">" . $lang['form_optional'] . "</span></label></div>\n\t\t\t\t\t\t\t\t\t<div class=\"form_item\"><input type=\"text\" tabindex=\"2\" name=\"web\" class=\"form_text\" id=\"comment_web\" value=\"{$sweb}\" /></div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"form_row "; if (isset($comment_style)) { echo $comment_style; } echo "\">\n\t\t\t\t\t\t\t\t\t<div class=\"form_label\"><label for=\"comment\">" . $lang['comment'] . " <span class=\"form_required\">" . $lang['form_required'] . "</span></label></div>\n\t\t\t\t\t\t\t\t\t<div class=\"form_item\"><textarea name=\"comment\" tabindex=\"3\" id=\"comment\" class=\"form_text_area\" cols=\"25\" rows=\"5\">{$scomment}</textarea></div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class=\"form_row_submit\">\n\t\t\t\t\t\t\t\t\t<input type=\"submit\" name=\"comment_submit\" tabindex=\"4\" value=\"" . $lang['comment_button_leave'] . "\" class=\"form_submit\" />\n\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"post\" value=\"{$post_id}\" />"; if (isset($realname) && $realname) { echo "\n\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"admin_user\" value=\"" . md5($nonce) . "\" />\n\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"name\""; if (isset($realname)) { echo " value=\"{$realname}\""; } echo " />"; } echo "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</fieldset>\n\t\t\t\t\t\t</form>"; } else { echo "\n\t\t\t\t\t\t<span class=\"comments_closed\">" . $lang['comment_closed'] . "</span>"; } } echo "\n\t\t\t\t\t</div>"; } // end if comments plugin enabled } } else { extract(safe_row('*', 'pixie_core', "page_name='404'")); extract(safe_row('*', 'pixie_static_posts', "page_id='{$page_id}'")); if (isset($s)) { echo "<div id=\"{$s}\">\n\t\t\t\t\t\t<h3>{$page_display_name}</h3>\n"; eval('?>' . $page_content . '<?php '); echo "\n\t\t\t\t\t</div>\n"; } } }
{ } function is_even($x) { if ($x == 0) throw new MyException("0是一个特别的数,它是偶数和奇数的分水岭", 1);//会优先寻找对应的异常类的catch捕捉,寻找基础异常类的捕捉或finally if ($x % 2 == 0) { return true; } else { return true; } } try { echo is_even(0), '<br/>';//这里已经抛出异常了 echo inverse(0), '<br/>'; } catch (MyException $e) { echo 'into MyException', '<br/>'; echo $e->getMessage(), '<br/>'; } catch (Exception $e) { echo 'into Exception', '<br/>'; echo $e->getMessage(), '<br/>'; }
do { if (is_even($fibn)) { $sum += $fibn; } $n++; $fibn = fibonacci_rec($n); } while ($fibn < $below); end_method(); result("recursive fibonaccy function", "sum of fibonaccy even terms", $sum, "1", $stime); //Method 2 - Calc n fibonacci start_method(); $n = 1; $sum = 0; $fibn = fibonacci_calc($n); do { if (is_even($fibn)) { $sum += $fibn; } $n++; $fibn = fibonacci_calc($n); } while ($fibn < $below); end_method(); result("calculated fibonaccy function", "sum of fibonaccy even terms", $sum, "2", $stime); //Method 3 - Calc n fibonaccy start_method(); $n = 3; $sum = 0; $fibn = fibonacci_calc($n); do { $sum += $fibn; $n += 3;
/** * CLI模式解析URL */ private function _parse3() { //适用于 php index.php //及适用于 php index.php index index 和 php index.php index index a 1 b 2 的情况 $count = count($_SERVER['argv']); if ($count == 1) { $this->group_name = C('default_group'); $this->module_name = 'Index'; $this->action_name = 'index'; } else { foreach ($_SERVER['argv'] as $k => $v) { if ($k > 0) { $path_array[] = $v; } } $param_count = count($path_array); //根据参数个数来判断是否定义了分组 if (is_even($param_count)) { $this->group_name = C('default_group'); //参数为偶数则为默认分组 } else { $this->group_name = $path_array[0]; //参数为奇数则第一个参数为分组 array_shift($path_array); //弹出第一个数组元素 } $this->module_name = isset($path_array[0]) ? $path_array[0] : 'Index'; $this->action_name = isset($path_array[1]) ? $path_array[1] : 'index'; if ($param_count >= 4) { // 从 key = 2 开始获取参数 for ($i = 2; $i <= floor($param_count / 2); $i++) { $_GET[$path_array[($i - 1) * 2]] = $path_array[($i - 1) * 2 + 1]; } } } }
function DrawBody() { global $date_format, $lang, $page_display_name; echo "\t<table class=\"tbl {$this->table}\" summary=\"" . $lang['results_from'] . " {$this->table}.\">\n\t\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t\t<tr>"; for ($j = 0; $j < mysql_num_fields($this->Res); $j++) { if (!in_array(mysql_field_name($this->Res, $j), $this->exclude)) { if (isset($arlen) && isset($sum)) { $arlen[$j] = mysql_field_len($this->Res, $j); $sum += $arlen[$j]; } } } for ($j = 0; $j < mysql_num_fields($this->Res); $j++) { if (!in_array(mysql_field_name($this->Res, $j), $this->exclude)) { $st3 = "class=\"tbl_heading\""; $fieldname = simplify(mysql_field_name($this->Res, $j)); if (isset($lang['form_' . mysql_field_name($this->Res, $j)]) && $lang['form_' . mysql_field_name($this->Res, $j)]) { $fieldname = $lang['form_' . mysql_field_name($this->Res, $j)]; } echo "<th {$st3} id=\"" . mysql_field_name($this->Res, $j) . "\">{$fieldname}</th>"; } } echo "\n\t\t\t\t\t\t\t\t\t<th class=\"tbl_heading\" id=\"page_edit\"></th>\n\t\t\t\t\t\t\t\t\t<th class=\"tbl_heading\" id=\"page_delete\"></th>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</thead>"; if ($this->finalmax) { $this->limit = $this->finalmax; } echo "\n\t\t\t\t\t\t\t<tbody>"; $counter = NULL; while ($counter < $this->limit) { $F = mysql_fetch_array($this->Res); if (is_even($counter)) { $trclass = 'odd'; } else { $trclass = 'even'; } echo "\n\t\t\t\t\t\t\t\t<tr class=\"{$trclass}\">\n"; for ($j = 0; $j < mysql_num_fields($this->Res); $j++) { if (!in_array(mysql_field_name($this->Res, $j), $this->exclude)) { if (mysql_field_type($this->Res, $j) == 'timestamp') { $logunix = returnUnixtimestamp($F[$j]); $date = safe_strftime($date_format, $logunix); echo "\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"" . mysql_field_name($this->Res, $j) . "\">" . $date . "</td>"; } else { if (mysql_field_name($this->Res, $j) == 'url') { echo "\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"" . mysql_field_name($this->Res, $j) . "\"><a href=\"" . $F[$j] . "\">" . $F[$j] . "</a></td>"; } else { if (mysql_field_name($this->Res, $j) == 'email') { echo "\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"" . mysql_field_name($this->Res, $j) . "\"><a href=\"mailto:" . $F[$j] . "\">" . $F[$j] . "</a></td>"; } else { if ($F[$j] == "") { echo "\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"" . mysql_field_name($this->Res, $j) . "\">No Content</td>"; } else { echo "\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row\" headers=\"" . mysql_field_name($this->Res, $j) . "\">" . strip_tags($F[$j]) . "</td>"; } } } } } } echo "\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row tbl_edit\" headers=\"page_edit\"><a href=\"{$this->whereami}&edit={$F['0']}\" title=\"" . $lang['edit'] . "\">" . $lang['edit'] . "</a></td>\n\t\t\t\t\t\t\t\t\t<td class=\"tbl_row tbl_delete\" headers=\"page_delete\"><a href=\"{$this->whereami}&delete={$F['0']}\" onclick=\"return confirm('" . $lang['sure_delete_entry'] . " (#{$F['0']}) " . $lang['from_the'] . " {$page_display_name} " . $lang['settings_page'] . "?')\" title=\"" . $lang['delete'] . "\">" . $lang['delete'] . "</a></td>\n\t\t\t\t\t\t\t\t</tr>"; $counter++; } echo "\n\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t</table>\n"; }
function order_by($order_list, $text, $starting_value, $included_vars) { $order_list = explode(",", $order_list); $order_list_text = explode(",", $text); $included_vars_list = explode(",", $included_vars); $starting_value = explode(",", $starting_value); $starting_value_string = DEFINED_SCRIPT_FILENAME . "?" . $starting_value['0'] . "=" . $starting_value['1']; $included_vars_chain = $starting_value_string; foreach ($included_vars_list as $key => $val) { if (req($val)) { $included_vars_chain .= "&" . $val . "=" . urlencode(req($val)); } } $return_string = "\n<select name=\"quick_nav\" onchange=\"go(this)\" title=\"set_order\">"; $return_string .= "\n<option value=\"\">" . translate("order_by") . ":</option>"; for ($counter = 0; $counter < count($order_list); $counter++) { if (is_even($counter)) { $style = " style=\"background-color:#EEEBDD;\" "; } else { $style = ""; } //DESC $return_string .= "\n \n<option {$style} value=\"" . $included_vars_chain . "&order_by=" . $order_list[$counter] . "-DESC"; $return_string .= "\""; $return_string .= is_selected_option($order_list[$counter] . "-DESC", req("order_by")); $return_string .= ">" . translate($order_list_text[$counter]) . " Desc [+ -]</option>"; //ASC $return_string .= "\n \n<option {$style} value=\"" . $included_vars_chain . "&order_by=" . $order_list[$counter] . "-ASC"; $return_string .= "\""; $return_string .= is_selected_option($order_list[$counter] . "-ASC", req("order_by")); $return_string .= ">" . translate($order_list_text[$counter]) . " Asc [- +]</option>"; } $return_string .= "\n<option style=\"background-color:#FFCC00;font-weight: bold;\" value=\"" . $starting_value_string . "\">RESET</option>\n </select>"; return $return_string; }