Plugin Directory

Changeset 641779


Ignore:
Timestamp:
12/19/2012 03:15:27 PM (13 years ago)
Author:
dottoro
Message:

new option added: Store service key in a cookie

Location:
dottoro-theme-updater/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • dottoro-theme-updater/trunk/dottoro-theme-updater.php

    r543393 r641779  
    33Plugin Name: Dottoro Theme Updater
    44Plugin URI: http://wordpress.org/extend/plugins/dottoro-theme-updater/
    5 Description: Dottoro Updater plugin is an automation tool to update your Dottoro themes migrating their actual skin settings to the updated ones.
    6 Version: 1.4
     5Description: Dottoro Updater plugin is an automation tool to update your Dottoro themes migrating their actual skin settings to the updated ones. <a href="themes.php?page=dottoro-theme-updater/dottoro-theme-updater.php">Theme Updater configuration page</a>
     6Version: 1.5
    77Author: Dottoro.com
    88Author URI: http://themeeditor.dottoro.com
     
    1515
    1616/*
    17 Copyright 2010  Dottoro.com  (email : [email protected])
     17Copyright 2012  Dottoro.com  (email : [email protected])
    1818
    1919This program is free software; you can redistribute it and/or modify
     
    4040        $this->plugin_path = plugin_basename(__FILE__);
    4141        $this->option_service_key = 'dottoro_updater_service_key';
     42        $this->service_key_cookie = 'dottoro_updater_service_key';
     43        $this->settings_option_key = 'dottoro_updater_settings';
    4244        $this->theme_update_option_key = 'dottoro_theme_updates';
    4345
     
    4850        $this->editor_docs_url = $this->editor_url . 'docs/';
    4951
     52        $this->form_saved = false;
     53
    5054            // languages files
    5155        load_plugin_textdomain('dottoro_updater', false, basename( dirname( __FILE__ ) ) . '/languages' );
     
    5660        } else {
    5761                // single menu
     62            add_action ( 'admin_init', array (&$this, 'init_admin') );
    5863            add_action ( 'admin_menu', array (&$this, 'add_menus') );
    5964        }
     
    6974    }
    7075
     76    function init_admin () {
     77        $_POST = stripslashes_deep( $_POST );
     78        $this->form_saved = $this->process_form();
     79    }
     80
    7181    function add_mu_menus () {
    7282        add_submenu_page( 'plugins.php', __('Dottoro Updater', 'dottoro_updater'), __('Dottoro Updater', 'dottoro_updater'), 'switch_themes', $this->plugin_path, array( &$this, 'admin_page' ) );
     
    8393        }
    8494
    85         $_POST = stripslashes_deep( $_POST );
    86         $form_saved = $this->process_form();
    87 
    88 
    89         $service_key = get_site_option ($this->option_service_key);
     95        $settings = $this->get_settings ();
     96        $service_key = $this->get_service_key ();
     97        if ($this->form_saved) {
     98            $service_key = $_POST['service_key'];
     99        }
    90100    ?>
    91101        <style>
     
    104114
    105115            <?php
    106                 if ( $form_saved ) {
     116                if ( $this->form_saved ) {
    107117                    echo('<p class="notice">' . __('Service Key Saved. Thank You.', 'dottoro_updater') . '</p>');
    108118                }
     
    123133                                    <div>
    124134                                        <small><?php __('Here you can set your service key.', 'dottoro_updater'); ?></small>
     135                                    </div>
     136                                </td>
     137                            </tr>
     138                            <tr valign="top">
     139                                <th scope="row">
     140                                    <label for="save_in_cookie">
     141                                        <?php _e('Store service key in a cookie', 'dottoro_updater'); ?>
     142                                    </label>
     143                                </th>
     144                                <td>
     145                                    <input name="save_in_cookie" id="save_in_cookie" <?php checked ($settings['save_in_cookie']); ?> type="checkbox"/>
     146                                    <div>
     147                                        <small><?php __('Check if you want to store the service key in a cookie. Please select this checkbox, if you want to give someone full control of the site to ensure the security of your service key. The cookie is deleted on logout.', 'dottoro_updater'); ?></small>
    125148                                    </div>
    126149                                </td>
     
    197220                return;
    198221            }
    199             update_site_option ( $this->option_service_key, trim ( $_POST['service_key'] ) );
     222
     223            $settings = $this->save_settings ( $_POST );
     224            $this->set_service_key ( trim ( $_POST['service_key'] ), $settings['save_in_cookie'] );
    200225            return true;
    201226        }
     
    203228    }
    204229
    205 
     230    function get_settings ()
     231    {
     232        $settings = array (
     233            'save_in_cookie' => false,
     234        );
     235       
     236        $saved_settings = get_site_option ($this->settings_option_key);
     237        if ($saved_settings) {
     238            $settings = array_merge ($settings, $saved_settings);
     239        }
     240        return $settings;
     241    }
     242
     243    function save_settings ( $datas = array () )
     244    {
     245        $settings = array (
     246            'save_in_cookie' => false,
     247        );
     248
     249        if ( isset( $datas['save_in_cookie'] ) ) {
     250            $settings['save_in_cookie'] = true;
     251        }
     252        update_site_option ( $this->settings_option_key, $settings );
     253       
     254        return $settings;
     255    }
     256
     257    function get_service_key ( )
     258    {
     259        $service_key = '';
     260        $settings = $this->get_settings ();
     261        if ( $settings['save_in_cookie'] ) {
     262            if ( isset ($_COOKIE[$this->service_key_cookie]) && $_COOKIE[$this->service_key_cookie] ) {
     263                $service_key = $_COOKIE[$this->service_key_cookie];
     264                $service_key = $this->basic_decrypt ($service_key);
     265            }
     266        } else {
     267            $service_key = get_site_option ($this->option_service_key);
     268        }
     269        return $service_key;
     270    }
     271
     272    function set_service_key ( $service_key, $in_cookie = false )
     273    {
     274        $service_key = $service_key ? $service_key : '';
     275
     276        if ( $in_cookie ) {
     277            $service_key = $this->basic_encrypt ($service_key);
     278            setcookie ($this->service_key_cookie, $service_key, 0, SITECOOKIEPATH, COOKIE_DOMAIN, false, true);
     279            return delete_site_option ( $this->option_service_key );
     280        }
     281
     282        setcookie ($this->service_key_cookie, "", time() - 3600, SITECOOKIEPATH, COOKIE_DOMAIN, false, true);
     283        return update_site_option ( $this->option_service_key, trim ( $service_key ) );
     284    }
     285
     286    function basic_encrypt ( $str, $key = '' )
     287    {
     288        $key = $this->get_basic_crypt_key ( $key );
     289        $iv_size = mcrypt_get_iv_size ( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB );
     290        $iv = mcrypt_create_iv ( $iv_size, MCRYPT_RAND );
     291        return base64_encode ( mcrypt_encrypt ( MCRYPT_RIJNDAEL_256, $key, $str, MCRYPT_MODE_ECB, $iv ) );
     292    }
     293
     294    function basic_decrypt ( $str, $key = '' )
     295    {
     296        $key = $this->get_basic_crypt_key ( $key );
     297        $iv_size = mcrypt_get_iv_size ( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB );
     298        $iv = mcrypt_create_iv ( $iv_size, MCRYPT_RAND );
     299        return rtrim ( mcrypt_decrypt ( MCRYPT_RIJNDAEL_256, $key, base64_decode ($str), MCRYPT_MODE_ECB, $iv ), "\0" );
     300    }
     301
     302    function get_basic_crypt_key ( $key = '' )
     303    {
     304        if ($key == '') {
     305            $key = wp_salt ();
     306            $key = substr ($key, 0, mcrypt_get_key_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC));
     307        }
     308        return $key;
     309    }
    206310
    207311/**************************
     
    427531        }
    428532
    429         $service_key = get_site_option ( $this->option_service_key );
     533        $service_key = $this->get_service_key ();
    430534
    431535        $settings = array (
  • dottoro-theme-updater/trunk/languages/default.po

    r543393 r641779  
    33"Project-Id-Version: Dottoro Updater\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2012-05-12 19:46+0100\n"
    6 "PO-Revision-Date: 2012-05-12 19:46+0100\n"
     5"POT-Creation-Date: 2012-12-19 01:03+0100\n"
     6"PO-Revision-Date: 2012-12-19 01:04+0100\n"
    77"Last-Translator: Dottoro <[email protected]>\n"
    8 "Language-Team: Dottoro <[email protected]>\n"
     8"Language-Team: \n"
    99"MIME-Version: 1.0\n"
    1010"Content-Type: text/plain; charset=UTF-8\n"
     
    1212"X-Poedit-KeywordsList: _;__;_e\n"
    1313"X-Poedit-Basepath: ./../\n"
     14"X-Generator: Poedit 1.5.4\n"
    1415"X-Poedit-SearchPath-0: .\n"
    1516
    16 #: dottoro-theme-updater.php:72
    17 #: dottoro-theme-updater.php:76
     17#: dottoro-theme-updater.php:82 dottoro-theme-updater.php:86
    1818msgid "Dottoro Updater"
    1919msgstr ""
    2020
    21 #: dottoro-theme-updater.php:82
     21#: dottoro-theme-updater.php:92
    2222msgid "You do not have sufficient permissions to see this page."
    2323msgstr ""
    2424
    25 #: dottoro-theme-updater.php:98
     25#: dottoro-theme-updater.php:108
    2626msgid "Dottoro Theme Updater"
    2727msgstr ""
    2828
    29 #: dottoro-theme-updater.php:101
     29#: dottoro-theme-updater.php:111
    3030#, php-format
    31 msgid "You need a service key to use Dottoro Theme Updater. You can request a service key on your account page on Dottoro.com under <a href=\"%1$s\" target=\"_blank\">Service Keys</a>"
     31msgid ""
     32"You need a service key to use Dottoro Theme Updater. You can request a "
     33"service key on your account page on Dottoro.com under <a href=\"%1$s\" "
     34"target=\"_blank\">Service Keys</a>"
    3235msgstr ""
    3336
    34 #: dottoro-theme-updater.php:107
     37#: dottoro-theme-updater.php:117
    3538msgid "Service Key Saved. Thank You."
    3639msgstr ""
    3740
    38 #: dottoro-theme-updater.php:118
     41#: dottoro-theme-updater.php:128
    3942msgid "Service Key"
    4043msgstr ""
    4144
    42 #: dottoro-theme-updater.php:124
     45#: dottoro-theme-updater.php:134
    4346msgid "Here you can set your service key."
    4447msgstr ""
    4548
    46 #: dottoro-theme-updater.php:133
     49#: dottoro-theme-updater.php:141
     50msgid "Store service key in a cookie"
     51msgstr ""
     52
     53#: dottoro-theme-updater.php:147
     54msgid ""
     55"Check if you want to store the service key in a cookie. Please select this "
     56"checkbox, if you want to give someone full control of the site to ensure the "
     57"security of your service key. The cookie is deleted on logout."
     58msgstr ""
     59
     60#: dottoro-theme-updater.php:156
    4761msgid "Save Service Key"
    4862msgstr ""
    4963
    50 #: dottoro-theme-updater.php:137
    51 msgid "<b>Important:</b> The service key is a security code; treat it like you treat your passwords. With the service key, anyone can download and modify your skins. If you suspect that someone might have got access to your service key, delete it and request a new one on your account page on Dottoro.com."
     64#: dottoro-theme-updater.php:160
     65msgid ""
     66"<b>Important:</b> The service key is a security code; treat it like you "
     67"treat your passwords. With the service key, anyone can download and modify "
     68"your skins. If you suspect that someone might have got access to your "
     69"service key, delete it and request a new one on your account page on Dottoro."
     70"com."
    5271msgstr ""
    5372
    54 #: dottoro-theme-updater.php:142
     73#: dottoro-theme-updater.php:165
    5574msgid "Dottoro Theme Updater checks for updates every 12 hours."
    5675msgstr ""
    5776
    58 #: dottoro-theme-updater.php:143
    59 msgid "If you want to force it to check for updates immediately, click on this button:"
     77#: dottoro-theme-updater.php:166
     78msgid ""
     79"If you want to force it to check for updates immediately, click on this "
     80"button:"
    6081msgstr ""
    6182
    62 #: dottoro-theme-updater.php:147
     83#: dottoro-theme-updater.php:170
    6384msgid "Check Now"
    6485msgstr ""
    6586
    66 #: dottoro-theme-updater.php:157
     87#: dottoro-theme-updater.php:180
    6788msgid "<b>The following themes have new versions available:</b>"
    6889msgstr ""
    6990
    70 #: dottoro-theme-updater.php:178
     91#: dottoro-theme-updater.php:201
    7192#, php-format
    7293msgid "Go to <a href=\"%1$s\">WordPress Updates</a> to update your themes."
    7394msgstr ""
    7495
    75 #: dottoro-theme-updater.php:181
     96#: dottoro-theme-updater.php:204
    7697msgid "<b>No updates were found.</b>"
    7798msgstr ""
    7899
    79 #: dottoro-theme-updater.php:400
     100#: dottoro-theme-updater.php:504
    80101#, php-format
    81102msgid "Theme %s not found."
    82103msgstr ""
    83104
    84 #: dottoro-theme-updater.php:420
     105#: dottoro-theme-updater.php:524
    85106msgid "Could not create Temporary file."
    86107msgstr ""
    87108
    88 #: dottoro-theme-updater.php:426
     109#: dottoro-theme-updater.php:530
    89110msgid "No skins found."
    90111msgstr ""
    91 
  • dottoro-theme-updater/trunk/readme.txt

    r543393 r641779  
    33Tags: dottoro, theme, update, updater, skin
    44Requires at least: 3.2
    5 Tested up to: 3.3.2
    6 Stable tag: 1.4
     5Tested up to: 3.5
     6Stable tag: 1.5
    77
    88Dottoro Updater plugin is an automation tool to update your Dottoro themes migrating their actual skin settings to the updated ones.
     
    4141== Changelog ==
    4242
     43= 1.5 =
     44* new option added: Store service key in a cookie
     45
    4346= 1.4 =
    4447* skin settings update fix
Note: See TracChangeset for help on using the changeset viewer.