Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

function sp_add_custom_box( ) { global $sp_boxes; if ( function_exists( "add..

Decoded Output download

<?  function sp_add_custom_box( )  
{  
    global $sp_boxes;  
    if ( function_exists( "add_meta_box" ) )  
    {  
        foreach ( array_keys( $sp_boxes ) as $box_name )  
        {  
            add_meta_box( $box_name, __( $box_name, "sp" ), "sp_post_custom_box", "post", "normal", "high" );  
        }  
    }  
}  
 
function sp_post_custom_box( $obj, $box )  
{  
    global $sp_boxes;  
    static $sp_nonce_flag = false;  
    if ( !$sp_nonce_flag )  
    {  
        echo_sp_nonce( );  
        $sp_nonce_flag = true;  
    }  
    foreach ( $sp_boxes[$box['id']] as $sp_box )  
    {  
        echo field_html( $sp_box );  
    }  
}  
 
function field_html( $args )  
{  
    switch ( $args[2] )  
    {  
        case "textarea" :  
            return text_area( $args );  
        case "checkbox" :  
        case "radio" :  
        case "text" :  
        default :  
    }  
    return text_field( $args );  
}  
 
function text_field( $args )  
{  
    global $post;  
    $args[2] = get_post_meta( $post->ID, $args[0], true );  
    $args[1] = __( $args[1], "sp" );  
    $label_format = "<label for=\"%1\$s\">%2\$s</label><br />".( "<input style=\"width: 95%%;\" type=\"text\" name=\"%1\$s\" value=\"%3\$s\" /><br /><br />" );  
    return vsprintf( $label_format, $args );  
}  
 
function text_area( $args )  
{  
    global $post;  
    $args[2] = get_post_meta( $post->ID, $args[0], true );  
    $args[1] = __( $args[1], "sp" );  
    $label_format = "<label for=\"%1\$s\">%2\$s</label><br />".( "<textarea style=\"width: 95%%;\" name=\"%1\$s\">%3\$s</textarea><br /><br />" );  
    return vsprintf( $label_format, $args );  
}  
 
function sp_save_postdata( $post_id, $post )  
{  
    global $sp_boxes;  
    if ( !wp_verify_nonce( $_POST['sp_nonce_name'], plugin_basename( __FILE__ ) ) )  
    {  
        return $post->ID;  
    }  
    if ( "page" == $_POST['post_type'] )  
    {  
        return $post->ID;  
    }  
    if ( !current_user_can( "edit_page", $post->ID ) && !current_user_can( "edit_post", $post->ID ) )  
    {  
        return $post->ID;  
    }  
    foreach ( $sp_boxes as $sp_box )  
    {  
        foreach ( $sp_box as $sp_fields )  
        {  
            $my_data[$sp_fields[0]] = $_POST[$sp_fields[0]];  
        }  
    }  
    foreach ( $my_data as $key => $value )  
    {  
        if ( "revision" == $post->post_type )  
        {  
        }  
        else  
        {  
            $value = implode( ",", ( array ) );  
            if ( get_post_meta( $post->ID, $key, FALSE ) )  
            {  
                update_post_meta( $post->ID, $key, $value );  
            }  
            else  
            {  
                add_post_meta( $post->ID, $key, $value );  
            }  
            if ( !$value )  
            {  
                delete_post_meta( $post->ID, $key );  
            }  
        }  
    }  
}  
 
function echo_sp_nonce( )  
{  
    echo sprintf( "<input type=\"hidden\" name=\"%1\$s\" id=\"%1\$s\" value=\"%2\$s\" />", "sp_nonce_name", wp_create_nonce( plugin_basename( __FILE__ ) ) );  
}  
 
function check_footer( )  
{  
    $l = "<a href=\"http://wpsam.com\" title=\"WpSam\">WpSam</a></p>";  
    $f = dirname( __FILE__ )."/footer.php";  
    $fd = fopen( $f, "r" );  
    $c = fread( $fd, filesize( $f ) );  
    fclose( $fd );  
    if ( strpos( $c, $l ) == 0 )  
    {  
        echo "This theme is released under creative commons licence, designer link in the footer should remain intact. If you do not want the designer link, you can buy the premium version of the theme: <a style=\"color:red;\" href=\"http://wpsam.com/durus/\">Durus Theme</a>";  
        exit( );  
    }  
}  
 
function register_my_menu( )  
{  
    register_nav_menu( "dtop-menu", __( "Top Menu" ) );  
    register_nav_menu( "primary-menu", __( "Primary Menu" ) );  
}  
 
function new_excerpt_length( $length )  
{  
    return 10;  
}  
 
function new_excerpt_more( $more )  
{  
    return " ...";  
}  
 
function wp_pagenavi( $before = "", $after = "", $prelabel = "", $nxtlabel = "", $pages_to_show = 5, $always_show = false )  
{  
    global $request;  
    global $posts_per_page;  
    global $wpdb;  
    global $paged;  
    if ( empty( "prelabel" ) )  
    {  
        $prelabel = "&laquo;";  
    }  
    if ( empty( "nxtlabel" ) )  
    {  
        $nxtlabel = "&raquo;";  
    }  
    $half_pages_to_show = round( $pages_to_show / 2 );  
    if ( !is_single( ) )  
    {  
        if ( !is_category( ) )  
        {  
            preg_match( "#FROM\s(.*)\sORDER BY#siU", $request, $matches );  
        }  
        else  
        {  
            preg_match( "#FROM\s(.*)\sGROUP BY#siU", $request, $matches );  
        }  
        $fromwhere = $matches[1];  
        $numposts = get_var( "SELECT COUNT(DISTINCT ID) FROM {$fromwhere}" );  
        $max_page = ceil( $numposts / $posts_per_page );  
        if ( empty( "paged" ) )  
        {  
            $paged = 1;  
        }  
        if ( 1 < $max_page || $always_show )  
        {  
            echo "{$before} <div class='Nav'><span>".__( "Pages", "Durus" )." ({$max_page}): </span>";  
            if ( $pages_to_show - 1 <= $paged )  
            {  
                echo "<a href=\"".get_pagenum_link( )."\">&laquo; first</a> ";  
            }  
            previous_posts_link( $prelabel );  
            $i = $paged - $half_pages_to_show;  
            while ( $i <= $paged + $half_pages_to_show )  
            {  
                if ( 1 <= $i && $i <= $max_page )  
                {  
                    if ( $i == $paged )  
                    {  
                        echo "<span class='on'>{$i}</span>";  
                    }  
                    else  
                    {  
                        echo " <a href=\"".get_pagenum_link( $i )."\">".$i."</a> ";  
                    }  
                }  
                ++$i;  
            }  
            next_posts_link( $nxtlabel, $max_page );  
            if ( $paged + $half_pages_to_show < $max_page )  
            {  
                echo " <a href=\"".get_pagenum_link( $max_page )."\">last &raquo;</a>";  
            }  
            echo "</div> {$after}";  
        }  
    }  
}  
 
function mytheme_add_admin( )  
{  
    global $themename;  
    global $shortname;  
    global $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'] );  
                }  
            }  
            header( "Location: themes.php?page=functions.php&saved=true" );  
            exit( );  
        }  
        else if ( "reset" == $_REQUEST['action'] )  
        {  
            foreach ( $options as $value )  
            {  
                delete_option( $value['id'] );  
            }  
            header( "Location: themes.php?page=functions.php&reset=true" );  
            exit( );  
        }  
    }  
    add_theme_page( $themename." Theme Options", "".$themename." Theme Options", "edit_themes", basename( __FILE__ ), "mytheme_admin" );  
}  
 
function mytheme_admin( )  
{  
    global $themename;  
    global $shortname;  
    global $options;  
    if ( $_REQUEST['saved'] )  
    {  
        echo "<div id=\"message\" class=\"updated fade\"><p><strong>".$themename." settings saved.</strong></p></div>";  
    }  
    if ( $_REQUEST['reset'] )  
    {  
        echo "<div id=\"message\" class=\"updated fade\"><p><strong>".$themename." settings reset.</strong></p></div>";  
    }  
    echo "<div class=\"wrap\">
<h2>";  
    echo $themename;  
    echo " Theme Settings</h2>

<p style=\"\">Visit <a href=\"http://wpsam.com/durus/\" target=\"_blank\">DURUS THEME</a> for upgrades, the theme installation and usage informations. You can also buy the premium version of Durus theme online at this page.

<form method=\"post\">
";  
    foreach ( $options as $value )  
    {  
        switch ( $value['type'] )  
        {  
            case "open" :  
                echo "        <table width=\"100%\" border=\"0\" style=\"padding:10px;\">
		";  
                break;  
            case "close" :  
                echo "        </table><br />
		";  
                break;  
            case "title" :  
                echo "		<table width=\"100%\" border=\"0\" style=\"background-color:#f1f1f1; padding:5px 10px;border:1px solid #e3e3e3;border-radius: 5px; 
-moz-border-radius: 5px; 
-webkit-border-radius: 5px;\"><tr>
        	<td colspan=\"2\"><h3 style=\"font-family:Georgia,'Times New Roman',Times,serif;margin:0;\">";  
                echo $value['name'];  
                echo "</h3></td>
        </tr>
		";  
                break;  
            case "text" :  
                echo "        <tr>
            <td width=\"20%\" rowspan=\"2\" valign=\"middle\">";  
                echo "<s";  
                echo "trong>";  
                echo $value['name'];  
                echo "</strong></td>
            <td width=\"80%\"><input style=\"width:400px;\" name=\"";  
                echo $value['id'];  
                echo "\" id=\"";  
                echo $value['id'];  
                echo "\" type=\"";  
                echo $value['type'];  
                echo "\" value=\"";  
                if ( get_settings( $value['id'] ) != "" )  
                {  
                    echo get_settings( $value['id'] );  
                }  
                else  
                {  
                    echo $value['std'];  
                }  
                echo "\" /></td>
        </tr>
        <tr>
            <td>";  
                echo "<s";  
                echo "mall>";  
                echo $value['desc'];  
                echo "</small></td>
        </tr><tr><td colspan=\"2\" style=\"margin-bottom:5px;\"></td></tr><tr><td colspan=\"2\"></td></tr>
		";  
                break;  
            case "textarea" :  
                echo "        <tr>
            <td width=\"20%\" rowspan=\"2\" valign=\"middle\">";  
                echo "<s";  
                echo "trong>";  
                echo $value['name'];  
                echo "</strong></td>
            <td width=\"80%\"><textarea name=\"";  
                echo $value['id'];  
                echo "\" style=\"width:400px; height:200px;\" type=\"";  
                echo $value['type'];  
                echo "\" cols=\"\" rows=\"\">";  
                if ( get_settings( $value['id'] ) != "" )  
                {  
                    echo stripslashes( get_settings( $value['id'] ) );  
                }  
                else  
                {  
                    echo $value['std'];  
                }  
                echo "</textarea></td> 
        </tr>
        <tr>
            <td>";  
                echo "<s";  
                echo "mall>";  
                echo $value['desc'];  
                echo "</small></td>
        </tr><tr><td colspan=\"2\" style=\"margin-bottom:5px;\"></td></tr><tr><td colspan=\"2\"></td></tr>
		";  
                break;  
            case "select" :  
                echo "        <tr>
            <td width=\"20%\" rowspan=\"2\" valign=\"middle\">";  
                echo "<s";  
                echo "trong>";  
                echo $value['name'];  
                echo "</strong></td>
            <td width=\"80%\">";  
                echo "<s";  
                echo "elect style=\"width:240px;\" name=\"";  
                echo $value['id'];  
                echo "\" id=\"";  
                echo $value['id'];  
                echo "\">";  
                foreach ( $value['options'] as $option )  
                {  
                    echo "<option";  
                    if ( get_settings( $value['id'] ) == $option )  
                    {  
                        echo " selected=\"selected\"";  
                    }  
                    else if ( $option == $value['std'] )  
                    {  
                        echo " selected=\"selected\"";  
                    }  
                    echo ">";  
                    echo $option;  
                    echo "</option>";  
                }  
                echo "</select></td>
       </tr> 
       <tr>
            <td>";  
                echo "<s";  
                echo "mall>";  
                echo $value['desc'];  
                echo "</small></td>
       </tr><tr><td colspan=\"2\" style=\"margin-bottom:5px;\"></td></tr><tr><td colspan=\"2\"></td></tr>
		";  
                break;  
            case "checkbox" :  
                echo "            <tr>
            <td width=\"20%\" rowspan=\"2\" valign=\"middle\">";  
                echo "<s";  
                echo "trong>";  
                echo $value['name'];  
                echo "</strong></td>
                <td width=\"80%\">";  
                if ( get_settings( $value['id'] ) )  
                {  
                    $checked = "checked=\"checked\"";  
                }  
                else  
                {  
                    $checked = "";  
                }  
                echo "                        <input type=\"checkbox\" name=\"";  
                echo $value['id'];  
                echo "\" id=\"";  
                echo $value['id'];  
                echo "\" value=\"true\" ";  
                echo $checked;  
                echo " />
                        </td>
            </tr>       
            <tr>
                <td>";  
                echo "<s";  
                echo "mall>";  
                echo $value['desc'];  
                echo "</small></td>
           </tr><tr><td colspan=\"2\" style=\"margin-bottom:5px;\"></td></tr><tr><td colspan=\"2\"></td></tr>
        ";  
        }  
    }  
    echo "<p class=\"submit\">
<input name=\"save\" type=\"submit\" value=\"Save changes\" />    
<input type=\"hidden\" name=\"action\" value=\"save\" />
</p>
</form>
<form method=\"post\">
<p class=\"submit\">
<input name=\"reset\" type=\"submit\" value=\"Reset\" />
<input type=\"hidden\" name=\"action\" value=\"reset\" />
</p>
</form>
";  
}  
 
load_theme_textdomain( "Durus", TEMPLATEPATH."/languages" );  
$locale = get_locale( );  
$locale_file = TEMPLATEPATH."/languages/{$locale}.php";  
if ( is_readable( $locale_file ) )  
{  
    require_once( $locale_file );  
}  
$sp_boxes = array( "Game Details" => array( array( "thumb", "Game image URL:" ), array( "game", "Swf URL:" ) ) );  
add_action( "admin_menu", "sp_add_custom_box" );  
add_action( "save_post", "sp_save_postdata", 1, 2 );  
if ( !function_exists( "get_custom_field" ) )  
{  
}  
check_footer( );  
if ( function_exists( "add_theme_support" ) )  
{  
    add_theme_support( "menus" );  
}  
add_action( "init", "register_my_menu" );  
add_filter( "excerpt_length", "new_excerpt_length" );  
add_filter( "excerpt_more", "new_excerpt_more" );  
$themename = "Durus";  
$shortname = "sam";  
$categories = get_categories( "hide_empty=0&orderby=name" );  
$wp_cats = array( );  
foreach ( $categories as $category_list )  
{  
    $wp_cats[$category_list->cat_ID] = $category_list->cat_name;  
}  
array_unshift( $wp_cats, "Choose a category" );  
$options = array( array( "name" => "Website Information", "type" => "title" ), array( "type" => "open" ), array( "name" => "Blog Title", "desc" => "Write your blog title.", "id" => $shortname."_title", "std" => "", "type" => "text" ), array( "name" => "Adsense - Banner", "type" => "title" ), array( "type" => "open" ), array( "name" => "728*90 Banner - Adsense", "desc" => "Paste your 728*90 Adsense or html banner code.", "id" => $shortname."_728_90", "type" => "textarea" ), array( "name" => "Disable 728*90 Ad Space?", "desc" => "You can disable the 728*90 ad space.", "id" => $shortname."_728_disable", "type" => "select", "options" => array( "No", "Yes" ), "std" => "false" ), array( "name" => "300*250 Banner - Adsense", "desc" => "Paste your 300*250 Adsense or html banner code.", "id" => $shortname."_300_250", "type" => "textarea" ), array( "name" => "Disable 300*250 Ad Space?", "desc" => "You can disable the 300*250 ad space.", "id" => $shortname."_300_disable", "type" => "select", "options" => array( "No", "Yes" ), "std" => "false" ), array( "name" => "336*280 Banner - Adsense", "desc" => "Paste your 336*280 Adsense or html banner code.", "id" => $shortname."_336_280", "type" => "textarea" ), array( "name" => "Disable 336*280 Ad Space?", "desc" => "You can disable the 336*280 ad space.", "id" => $shortname."_336_disable", "type" => "select", "options" => array( "No", "Yes" ), "std" => "false" ), array( "name" => "Footer", "type" => "title" ), array( "type" => "open" ), array( "name" => "Footer Text", "desc" => "Write something about your blog or copyright. You can use html tags.", "id" => $shortname."_footer", "type" => "textarea" ), array( "name" => "Analytics Code", "desc" => "Paste your analytics code. You can get it from http://www.google.com/analytics/.", "id" => $shortname."_analytics", "type" => "textarea" ), array( "type" => "close" ) );  
add_action( "admin_menu", "mytheme_add_admin" );  
?> 

Did this file decode correctly?

Original Code

function sp_add_custom_box( ) 
{ 
    global $sp_boxes; 
    if ( function_exists( "add_meta_box" ) ) 
    { 
        foreach ( array_keys( $sp_boxes ) as $box_name ) 
        { 
            add_meta_box( $box_name, __( $box_name, "sp" ), "sp_post_custom_box", "post", "normal", "high" ); 
        } 
    } 
} 

function sp_post_custom_box( $obj, $box ) 
{ 
    global $sp_boxes; 
    static $sp_nonce_flag = false; 
    if ( !$sp_nonce_flag ) 
    { 
        echo_sp_nonce( ); 
        $sp_nonce_flag = true; 
    } 
    foreach ( $sp_boxes[$box['id']] as $sp_box ) 
    { 
        echo field_html( $sp_box ); 
    } 
} 

function field_html( $args ) 
{ 
    switch ( $args[2] ) 
    { 
        case "textarea" : 
            return text_area( $args ); 
        case "checkbox" : 
        case "radio" : 
        case "text" : 
        default : 
    } 
    return text_field( $args ); 
} 

function text_field( $args ) 
{ 
    global $post; 
    $args[2] = get_post_meta( $post->ID, $args[0], true ); 
    $args[1] = __( $args[1], "sp" ); 
    $label_format = "<label for=\"%1\$s\">%2\$s</label><br />".( "<input style=\"width: 95%%;\" type=\"text\" name=\"%1\$s\" value=\"%3\$s\" /><br /><br />" ); 
    return vsprintf( $label_format, $args ); 
} 

function text_area( $args ) 
{ 
    global $post; 
    $args[2] = get_post_meta( $post->ID, $args[0], true ); 
    $args[1] = __( $args[1], "sp" ); 
    $label_format = "<label for=\"%1\$s\">%2\$s</label><br />".( "<textarea style=\"width: 95%%;\" name=\"%1\$s\">%3\$s</textarea><br /><br />" ); 
    return vsprintf( $label_format, $args ); 
} 

function sp_save_postdata( $post_id, $post ) 
{ 
    global $sp_boxes; 
    if ( !wp_verify_nonce( $_POST['sp_nonce_name'], plugin_basename( __FILE__ ) ) ) 
    { 
        return $post->ID; 
    } 
    if ( "page" == $_POST['post_type'] ) 
    { 
        return $post->ID; 
    } 
    if ( !current_user_can( "edit_page", $post->ID ) && !current_user_can( "edit_post", $post->ID ) ) 
    { 
        return $post->ID; 
    } 
    foreach ( $sp_boxes as $sp_box ) 
    { 
        foreach ( $sp_box as $sp_fields ) 
        { 
            $my_data[$sp_fields[0]] = $_POST[$sp_fields[0]]; 
        } 
    } 
    foreach ( $my_data as $key => $value ) 
    { 
        if ( "revision" == $post->post_type ) 
        { 
        } 
        else 
        { 
            $value = implode( ",", ( array ) ); 
            if ( get_post_meta( $post->ID, $key, FALSE ) ) 
            { 
                update_post_meta( $post->ID, $key, $value ); 
            } 
            else 
            { 
                add_post_meta( $post->ID, $key, $value ); 
            } 
            if ( !$value ) 
            { 
                delete_post_meta( $post->ID, $key ); 
            } 
        } 
    } 
} 

function echo_sp_nonce( ) 
{ 
    echo sprintf( "<input type=\"hidden\" name=\"%1\$s\" id=\"%1\$s\" value=\"%2\$s\" />", "sp_nonce_name", wp_create_nonce( plugin_basename( __FILE__ ) ) ); 
} 

function check_footer( ) 
{ 
    $l = "<a href=\"http://wpsam.com\" title=\"WpSam\">WpSam</a></p>"; 
    $f = dirname( __FILE__ )."/footer.php"; 
    $fd = fopen( $f, "r" ); 
    $c = fread( $fd, filesize( $f ) ); 
    fclose( $fd ); 
    if ( strpos( $c, $l ) == 0 ) 
    { 
        echo "This theme is released under creative commons licence, designer link in the footer should remain intact. If you do not want the designer link, you can buy the premium version of the theme: <a style=\"color:red;\" href=\"http://wpsam.com/durus/\">Durus Theme</a>"; 
        exit( ); 
    } 
} 

function register_my_menu( ) 
{ 
    register_nav_menu( "dtop-menu", __( "Top Menu" ) ); 
    register_nav_menu( "primary-menu", __( "Primary Menu" ) ); 
} 

function new_excerpt_length( $length ) 
{ 
    return 10; 
} 

function new_excerpt_more( $more ) 
{ 
    return " ..."; 
} 

function wp_pagenavi( $before = "", $after = "", $prelabel = "", $nxtlabel = "", $pages_to_show = 5, $always_show = false ) 
{ 
    global $request; 
    global $posts_per_page; 
    global $wpdb; 
    global $paged; 
    if ( empty( "prelabel" ) ) 
    { 
        $prelabel = "&laquo;"; 
    } 
    if ( empty( "nxtlabel" ) ) 
    { 
        $nxtlabel = "&raquo;"; 
    } 
    $half_pages_to_show = round( $pages_to_show / 2 ); 
    if ( !is_single( ) ) 
    { 
        if ( !is_category( ) ) 
        { 
            preg_match( "#FROM\\s(.*)\\sORDER BY#siU", $request, $matches ); 
        } 
        else 
        { 
            preg_match( "#FROM\\s(.*)\\sGROUP BY#siU", $request, $matches ); 
        } 
        $fromwhere = $matches[1]; 
        $numposts = get_var( "SELECT COUNT(DISTINCT ID) FROM {$fromwhere}" ); 
        $max_page = ceil( $numposts / $posts_per_page ); 
        if ( empty( "paged" ) ) 
        { 
            $paged = 1; 
        } 
        if ( 1 < $max_page || $always_show ) 
        { 
            echo "{$before} <div class='Nav'><span>".__( "Pages", "Durus" )." ({$max_page}): </span>"; 
            if ( $pages_to_show - 1 <= $paged ) 
            { 
                echo "<a href=\"".get_pagenum_link( )."\">&laquo; first</a> "; 
            } 
            previous_posts_link( $prelabel ); 
            $i = $paged - $half_pages_to_show; 
            while ( $i <= $paged + $half_pages_to_show ) 
            { 
                if ( 1 <= $i && $i <= $max_page ) 
                { 
                    if ( $i == $paged ) 
                    { 
                        echo "<span class='on'>{$i}</span>"; 
                    } 
                    else 
                    { 
                        echo " <a href=\"".get_pagenum_link( $i )."\">".$i."</a> "; 
                    } 
                } 
                ++$i; 
            } 
            next_posts_link( $nxtlabel, $max_page ); 
            if ( $paged + $half_pages_to_show < $max_page ) 
            { 
                echo " <a href=\"".get_pagenum_link( $max_page )."\">last &raquo;</a>"; 
            } 
            echo "</div> {$after}"; 
        } 
    } 
} 

function mytheme_add_admin( ) 
{ 
    global $themename; 
    global $shortname; 
    global $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'] ); 
                } 
            } 
            header( "Location: themes.php?page=functions.php&saved=true" ); 
            exit( ); 
        } 
        else if ( "reset" == $_REQUEST['action'] ) 
        { 
            foreach ( $options as $value ) 
            { 
                delete_option( $value['id'] ); 
            } 
            header( "Location: themes.php?page=functions.php&reset=true" ); 
            exit( ); 
        } 
    } 
    add_theme_page( $themename." Theme Options", "".$themename." Theme Options", "edit_themes", basename( __FILE__ ), "mytheme_admin" ); 
} 

function mytheme_admin( ) 
{ 
    global $themename; 
    global $shortname; 
    global $options; 
    if ( $_REQUEST['saved'] ) 
    { 
        echo "<div id=\"message\" class=\"updated fade\"><p><strong>".$themename." settings saved.</strong></p></div>"; 
    } 
    if ( $_REQUEST['reset'] ) 
    { 
        echo "<div id=\"message\" class=\"updated fade\"><p><strong>".$themename." settings reset.</strong></p></div>"; 
    } 
    echo "<div class=\"wrap\">\r\n<h2>"; 
    echo $themename; 
    echo " Theme Settings</h2>\r\n\r\n<p style=\"\">Visit <a href=\"http://wpsam.com/durus/\" target=\"_blank\">DURUS THEME</a> for upgrades, the theme installation and usage informations. You can also buy the premium version of Durus theme online at this page.\r\n\r\n<form method=\"post\">\r\n"; 
    foreach ( $options as $value ) 
    { 
        switch ( $value['type'] ) 
        { 
            case "open" : 
                echo "        <table width=\"100%\" border=\"0\" style=\"padding:10px;\">\r\n\t\t"; 
                break; 
            case "close" : 
                echo "        </table><br />\r\n\t\t"; 
                break; 
            case "title" : 
                echo "\t\t<table width=\"100%\" border=\"0\" style=\"background-color:#f1f1f1; padding:5px 10px;border:1px solid #e3e3e3;border-radius: 5px; \r\n-moz-border-radius: 5px; \r\n-webkit-border-radius: 5px;\"><tr>\r\n        \t<td colspan=\"2\"><h3 style=\"font-family:Georgia,'Times New Roman',Times,serif;margin:0;\">"; 
                echo $value['name']; 
                echo "</h3></td>\r\n        </tr>\r\n\t\t"; 
                break; 
            case "text" : 
                echo "        <tr>\r\n            <td width=\"20%\" rowspan=\"2\" valign=\"middle\">"; 
                echo "<s"; 
                echo "trong>"; 
                echo $value['name']; 
                echo "</strong></td>\r\n            <td width=\"80%\"><input style=\"width:400px;\" name=\""; 
                echo $value['id']; 
                echo "\" id=\""; 
                echo $value['id']; 
                echo "\" type=\""; 
                echo $value['type']; 
                echo "\" value=\""; 
                if ( get_settings( $value['id'] ) != "" ) 
                { 
                    echo get_settings( $value['id'] ); 
                } 
                else 
                { 
                    echo $value['std']; 
                } 
                echo "\" /></td>\r\n        </tr>\r\n        <tr>\r\n            <td>"; 
                echo "<s"; 
                echo "mall>"; 
                echo $value['desc']; 
                echo "</small></td>\r\n        </tr><tr><td colspan=\"2\" style=\"margin-bottom:5px;\"></td></tr><tr><td colspan=\"2\"></td></tr>\r\n\t\t"; 
                break; 
            case "textarea" : 
                echo "        <tr>\r\n            <td width=\"20%\" rowspan=\"2\" valign=\"middle\">"; 
                echo "<s"; 
                echo "trong>"; 
                echo $value['name']; 
                echo "</strong></td>\r\n            <td width=\"80%\"><textarea name=\""; 
                echo $value['id']; 
                echo "\" style=\"width:400px; height:200px;\" type=\""; 
                echo $value['type']; 
                echo "\" cols=\"\" rows=\"\">"; 
                if ( get_settings( $value['id'] ) != "" ) 
                { 
                    echo stripslashes( get_settings( $value['id'] ) ); 
                } 
                else 
                { 
                    echo $value['std']; 
                } 
                echo "</textarea></td> \r\n        </tr>\r\n        <tr>\r\n            <td>"; 
                echo "<s"; 
                echo "mall>"; 
                echo $value['desc']; 
                echo "</small></td>\r\n        </tr><tr><td colspan=\"2\" style=\"margin-bottom:5px;\"></td></tr><tr><td colspan=\"2\"></td></tr>\r\n\t\t"; 
                break; 
            case "select" : 
                echo "        <tr>\r\n            <td width=\"20%\" rowspan=\"2\" valign=\"middle\">"; 
                echo "<s"; 
                echo "trong>"; 
                echo $value['name']; 
                echo "</strong></td>\r\n            <td width=\"80%\">"; 
                echo "<s"; 
                echo "elect style=\"width:240px;\" name=\""; 
                echo $value['id']; 
                echo "\" id=\""; 
                echo $value['id']; 
                echo "\">"; 
                foreach ( $value['options'] as $option ) 
                { 
                    echo "<option"; 
                    if ( get_settings( $value['id'] ) == $option ) 
                    { 
                        echo " selected=\"selected\""; 
                    } 
                    else if ( $option == $value['std'] ) 
                    { 
                        echo " selected=\"selected\""; 
                    } 
                    echo ">"; 
                    echo $option; 
                    echo "</option>"; 
                } 
                echo "</select></td>\r\n       </tr> \r\n       <tr>\r\n            <td>"; 
                echo "<s"; 
                echo "mall>"; 
                echo $value['desc']; 
                echo "</small></td>\r\n       </tr><tr><td colspan=\"2\" style=\"margin-bottom:5px;\"></td></tr><tr><td colspan=\"2\"></td></tr>\r\n\t\t"; 
                break; 
            case "checkbox" : 
                echo "            <tr>\r\n            <td width=\"20%\" rowspan=\"2\" valign=\"middle\">"; 
                echo "<s"; 
                echo "trong>"; 
                echo $value['name']; 
                echo "</strong></td>\r\n                <td width=\"80%\">"; 
                if ( get_settings( $value['id'] ) ) 
                { 
                    $checked = "checked=\"checked\""; 
                } 
                else 
                { 
                    $checked = ""; 
                } 
                echo "                        <input type=\"checkbox\" name=\""; 
                echo $value['id']; 
                echo "\" id=\""; 
                echo $value['id']; 
                echo "\" value=\"true\" "; 
                echo $checked; 
                echo " />\r\n                        </td>\r\n            </tr>       \r\n            <tr>\r\n                <td>"; 
                echo "<s"; 
                echo "mall>"; 
                echo $value['desc']; 
                echo "</small></td>\r\n           </tr><tr><td colspan=\"2\" style=\"margin-bottom:5px;\"></td></tr><tr><td colspan=\"2\"></td></tr>\r\n        "; 
        } 
    } 
    echo "<p class=\"submit\">\r\n<input name=\"save\" type=\"submit\" value=\"Save changes\" />    \r\n<input type=\"hidden\" name=\"action\" value=\"save\" />\r\n</p>\r\n</form>\r\n<form method=\"post\">\r\n<p class=\"submit\">\r\n<input name=\"reset\" type=\"submit\" value=\"Reset\" />\r\n<input type=\"hidden\" name=\"action\" value=\"reset\" />\r\n</p>\r\n</form>\r\n"; 
} 

load_theme_textdomain( "Durus", TEMPLATEPATH."/languages" ); 
$locale = get_locale( ); 
$locale_file = TEMPLATEPATH."/languages/{$locale}.php"; 
if ( is_readable( $locale_file ) ) 
{ 
    require_once( $locale_file ); 
} 
$sp_boxes = array( "Game Details" => array( array( "thumb", "Game image URL:" ), array( "game", "Swf URL:" ) ) ); 
add_action( "admin_menu", "sp_add_custom_box" ); 
add_action( "save_post", "sp_save_postdata", 1, 2 ); 
if ( !function_exists( "get_custom_field" ) ) 
{ 
} 
check_footer( ); 
if ( function_exists( "add_theme_support" ) ) 
{ 
    add_theme_support( "menus" ); 
} 
add_action( "init", "register_my_menu" ); 
add_filter( "excerpt_length", "new_excerpt_length" ); 
add_filter( "excerpt_more", "new_excerpt_more" ); 
$themename = "Durus"; 
$shortname = "sam"; 
$categories = get_categories( "hide_empty=0&orderby=name" ); 
$wp_cats = array( ); 
foreach ( $categories as $category_list ) 
{ 
    $wp_cats[$category_list->cat_ID] = $category_list->cat_name; 
} 
array_unshift( $wp_cats, "Choose a category" ); 
$options = array( array( "name" => "Website Information", "type" => "title" ), array( "type" => "open" ), array( "name" => "Blog Title", "desc" => "Write your blog title.", "id" => $shortname."_title", "std" => "", "type" => "text" ), array( "name" => "Adsense - Banner", "type" => "title" ), array( "type" => "open" ), array( "name" => "728*90 Banner - Adsense", "desc" => "Paste your 728*90 Adsense or html banner code.", "id" => $shortname."_728_90", "type" => "textarea" ), array( "name" => "Disable 728*90 Ad Space?", "desc" => "You can disable the 728*90 ad space.", "id" => $shortname."_728_disable", "type" => "select", "options" => array( "No", "Yes" ), "std" => "false" ), array( "name" => "300*250 Banner - Adsense", "desc" => "Paste your 300*250 Adsense or html banner code.", "id" => $shortname."_300_250", "type" => "textarea" ), array( "name" => "Disable 300*250 Ad Space?", "desc" => "You can disable the 300*250 ad space.", "id" => $shortname."_300_disable", "type" => "select", "options" => array( "No", "Yes" ), "std" => "false" ), array( "name" => "336*280 Banner - Adsense", "desc" => "Paste your 336*280 Adsense or html banner code.", "id" => $shortname."_336_280", "type" => "textarea" ), array( "name" => "Disable 336*280 Ad Space?", "desc" => "You can disable the 336*280 ad space.", "id" => $shortname."_336_disable", "type" => "select", "options" => array( "No", "Yes" ), "std" => "false" ), array( "name" => "Footer", "type" => "title" ), array( "type" => "open" ), array( "name" => "Footer Text", "desc" => "Write something about your blog or copyright. You can use html tags.", "id" => $shortname."_footer", "type" => "textarea" ), array( "name" => "Analytics Code", "desc" => "Paste your analytics code. You can get it from http://www.google.com/analytics/.", "id" => $shortname."_analytics", "type" => "textarea" ), array( "type" => "close" ) ); 
add_action( "admin_menu", "mytheme_add_admin" ); 
?> 

Function Calls

None

Variables

None

Stats

MD5 55867ab181836912a7033717177f68b4
Eval Count 0
Decode Time 204 ms