Changeset 2778948
- Timestamp:
- 09/01/2022 04:48:33 PM (4 years ago)
- Location:
- password-generator/trunk
- Files:
-
- 2 edited
-
outerbridge-password-generator.php (modified) (7 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
password-generator/trunk/outerbridge-password-generator.php
r1663097 r2778948 2 2 /* 3 3 Plugin Name: Password Generator 4 Plugin URI: http 2://outerbridge.co.uk/4 Plugin URI: https://outerbridge.co.uk/ 5 5 Description: Password Generator is a plugin written by Outerbridge which adds a widget to WordPress which generates various length random passwords (with or without special characters). 6 6 Author: Outerbridge 7 Version: 1. 67 Version: 1.7 8 8 Author URI: https://outerbridge.co.uk/ 9 9 Tags: password generator, special characters, strong password … … 14 14 /** 15 15 * 16 * v1.7 220901 Various fixes. Tested and stable up to WP6.0 17 * 16 18 * v1.6 170523 Made translatable 17 *18 19 * v1.5 170503 Updated to remove old style constructor and general tidy up 19 20 * v1.4 150818 Updated WP_Widget functionality for WP4.3 … … 26 27 */ 27 28 28 class obr_password_generator extends WP_Widget {29 class obr_password_generator extends WP_Widget { 29 30 // version 30 public $obr_password_generator = '1. 6';31 public $obr_password_generator = '1.7'; 31 32 32 33 //contructor 33 function __construct() {34 parent::__construct( 'obr_pass_gen', __('Outerbridge Password Generator', 'password-generator'), array('classname' => 'oouterbridge_pass_gen_widget', 'description' => __('Create strong passwords quickly and easily using this widget. Various password lengths available as well as the option to use symbols as well as alphanumerics.', 'password-generator')));35 register_activation_hook( __FILE__, array($this, 'obr_install'));36 register_deactivation_hook( __FILE__, array($this, 'obr_uninstall'));37 add_action( 'wp_loaded', array($this, 'obr_plugin_update_check'));38 add_action( 'wp_head', array($this, 'obr_header'));34 function __construct() { 35 parent::__construct( 'obr_pass_gen', __( 'Outerbridge Password Generator', 'password-generator' ), array( 'classname' => 'oouterbridge_pass_gen_widget', 'description' => __( 'Create strong passwords quickly and easily using this widget. Various password lengths available as well as the option to use symbols as well as alphanumerics.', 'password-generator' ) ) ); 36 register_activation_hook( __FILE__, array( $this, 'obr_install' ) ); 37 register_deactivation_hook( __FILE__, array( $this, 'obr_uninstall' ) ); 38 add_action( 'wp_loaded', array( $this, 'obr_plugin_update_check' ) ); 39 add_action( 'wp_head', array( $this, 'obr_header' ) ); 39 40 } 40 41 41 42 // functions 42 function widget($args, $instance){ 43 extract($args); 44 $title = apply_filters('widget_title', $instance['title']); 43 function widget( $args, $instance ) { 44 extract( $args ); 45 $title = ''; 46 if ( isset( $instance[ 'title' ] ) ) { 47 $title = apply_filters( 'widget_title', $instance[ 'title' ] ); 48 } 45 49 echo $before_widget; 46 if ( $title){47 echo $before_title, $title,$after_title;50 if ( strlen( $title ) > 0 ) { 51 echo $before_title, $title, $after_title; 48 52 } else { 49 echo $before_title, __('Password Generator', 'password-generator'),$after_title;50 } 51 if ( isset($_POST['pg_length'])){53 echo $before_title, __( 'Password Generator', 'password-generator' ), $after_title; 54 } 55 if ( isset( $_POST[ 'pg_length' ] ) ) { 52 56 $formposted = true; 53 $pg_length = strip_tags( stripslashes($_POST['pg_length']));54 if ( $pg_length > 20 || $pg_length < 8){57 $pg_length = strip_tags( stripslashes( $_POST[ 'pg_length' ] ) ); 58 if ( $pg_length > 20 || $pg_length < 8 ) { 55 59 $pg_length = 14; 56 60 } 57 61 $chk_symbols = ''; 58 if ( isset($_POST['chk_symbols'])){59 $chk_symbols = strip_tags( stripslashes($_POST['chk_symbols']));62 if ( isset( $_POST[ 'chk_symbols' ] ) ) { 63 $chk_symbols = strip_tags( stripslashes( $_POST[ 'chk_symbols' ] ) ); 60 64 } 61 65 } else { … … 65 69 } 66 70 echo '<form action="'; 67 $path = $_SERVER[ 'REQUEST_URI'];68 if ( strlen($path)){71 $path = $_SERVER[ 'REQUEST_URI' ]; 72 if ( strlen( $path ) ) { 69 73 echo $path; 70 74 } else { … … 73 77 echo '" method="POST">'; 74 78 echo '<ul><li>'; 75 _e( 'Password length?', 'password-generator');79 _e( 'Password length?', 'password-generator' ); 76 80 echo '<select name="pg_length" title="'; 77 _e( 'Password length?', 'password-generator');81 _e( 'Password length?', 'password-generator' ); 78 82 echo '"><optgroup label="'; 79 _e( 'Recommended Lengths', 'password-generator');83 _e( 'Recommended Lengths', 'password-generator' ); 80 84 echo '">'; 81 for ( $i = 14; $i <= 20; $i++){85 for ( $i = 14; $i <= 20; $i++ ) { 82 86 echo '<option'; 83 if ( $i == $pg_length){87 if ( $i == $pg_length ) { 84 88 echo ' selected="selected"'; 85 89 } 86 echo ' value="', $i,'">',$i,'</option>';90 echo ' value="', $i, '">', $i, '</option>'; 87 91 } 88 92 echo '</optgroup>'; 89 93 echo '<optgroup label="'; 90 _e( 'Shorter Lengths', 'password-generator');94 _e( 'Shorter Lengths', 'password-generator' ); 91 95 echo '">'; 92 for ( $i = 8; $i <= 13; $i++){96 for ( $i = 8; $i <= 13; $i++ ) { 93 97 echo '<option'; 94 if ( $i == $pg_length){98 if ( $i == $pg_length ) { 95 99 echo ' selected="selected"'; 96 100 } 97 echo ' value="', $i,'">',$i,'</option>';101 echo ' value="', $i, '">', $i, '</option>'; 98 102 } 99 103 echo '</optgroup></select></li>'; 100 104 echo '<li><label for="chk_symbols">'; 101 _e( 'Include symbols?', 'password-generator');105 _e( 'Include symbols?', 'password-generator' ); 102 106 echo '</label><input name="chk_symbols"'; 103 if ( $chk_symbols){107 if ( $chk_symbols ) { 104 108 echo ' checked="checked"'; 105 109 } 106 110 echo 'type="checkbox" title="'; 107 _e( 'Include symbols?', 'password-generator');111 _e( 'Include symbols?', 'password-generator' ); 108 112 echo '" /></li></ul>'; 109 113 echo '<input type="submit" value="'; 110 _e( 'Generate password', 'password-generator');114 _e( 'Generate password', 'password-generator' ); 111 115 echo '" name="submit" /><br />'; 112 if ( $formposted){116 if ( $formposted ) { 113 117 echo '<p>'; 114 printf( __('New Password: %s', 'password-generator'), '<strong>'.$this->obr_generate_password($pg_length, $chk_symbols).'</strong>');118 printf( __( 'New Password: %s', 'password-generator' ), '<strong>' . $this->obr_generate_password( $pg_length, $chk_symbols ) . '</strong>' ); 115 119 echo '</p>'; 116 120 } … … 119 123 } 120 124 121 function obr_generate_password( $length, $symbols){125 function obr_generate_password( $length, $symbols ) { 122 126 $random_chars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 123 if ( $symbols){127 if ( $symbols ) { 124 128 $random_chars .= "+-=_*!@#$%+-=_*!@#$%+-=_*!@#$%+-=_*!@#$%"; 125 129 } 126 130 $getstring = ""; 127 131 $password = ""; 128 while( strlen($password) < $length){129 $addstring = substr( $random_chars, mt_rand(0, strlen($random_chars) - 1), 1);132 while( strlen( $password ) < $length ) { 133 $addstring = substr( $random_chars, mt_rand( 0, strlen( $random_chars ) - 1 ), 1 ); 130 134 // Avoid duplicates 131 if ( strlen($getstring) > 0){132 if ( !strstr($password, $getstring)){135 if ( strlen( $getstring ) > 0 ) { 136 if ( !strstr( $password, $getstring ) ) { 133 137 //append to the password 134 138 $password .= $addstring; … … 143 147 function obr_header(){ 144 148 echo "\n<!-- "; 145 printf( __('Using Outerbridge Password Generator. Find out more at %s', 'password-generator'), 'https://outerbridge.co.uk/');149 printf( __( 'Using Outerbridge Password Generator. Find out more at %s', 'password-generator' ), 'https://outerbridge.co.uk/' ); 146 150 echo "-->\n"; 147 151 } 148 152 149 function update( $new_instance, $old_instance){153 function update( $new_instance, $old_instance ) { 150 154 $instance = $old_instance; 151 $instance[ 'title'] = strip_tags(stripslashes($new_instance['title']));155 $instance[ 'title' ] = strip_tags( stripslashes( $new_instance[ 'title' ] ) ); 152 156 return $instance; 153 157 } 154 158 155 function form( $instance){156 $instance = wp_parse_args( (array) $instance, array('title'=>'Password Generator'));157 $title = htmlspecialchars( $instance['title']);158 echo '<p style="text-align:right;"><label for="' .$this->get_field_name('title').'">'.__('Title:', 'password-generator').' <input style="width: 250px;" id="'.$this->get_field_id('title').'" name="'.$this->get_field_name('title').'" type="text" value="'.$title.'" /></label></p>';159 } 160 161 function obr_install() {162 add_option( 'obr_password_generator', $this->obr_password_generator);159 function form( $instance ) { 160 $instance = wp_parse_args( (array) $instance, array( 'title'=>'Password Generator' ) ); 161 $title = htmlspecialchars( $instance[ 'title' ] ); 162 echo '<p style="text-align:right;"><label for="' . $this->get_field_name( 'title' ) . '">' . __( 'Title:', 'password-generator' ) . ' <input style="width: 250px;" id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" type="text" value="' . $title . '" /></label></p>'; 163 } 164 165 function obr_install() { 166 add_option( 'obr_password_generator', $this->obr_password_generator ); 163 167 $this->obr_plugin_update_check(); 164 168 } 165 169 166 function obr_uninstall() {167 delete_option( 'obr_password_generator');168 } 169 170 function obr_plugin_update_check() {171 $installed_ver = get_option( 'obr_password_generator');172 if( $installed_ver != $this->obr_password_generator){170 function obr_uninstall() { 171 delete_option( 'obr_password_generator' ); 172 } 173 174 function obr_plugin_update_check() { 175 $installed_ver = get_option( 'obr_password_generator' ); 176 if( $installed_ver != $this->obr_password_generator ) { 173 177 $charset_collate = ''; 174 if ( !empty($wpdb->charset)){178 if ( !empty( $wpdb->charset ) ) { 175 179 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 176 180 } 177 if ( !empty($wpdb->collate)){181 if ( !empty( $wpdb->collate ) ) { 178 182 $charset_collate .= " COLLATE $wpdb->collate"; 179 183 } 180 184 $mysql = ""; 181 require_once( ABSPATH.'wp-admin/includes/upgrade.php');182 dbDelta( $mysql);185 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 186 dbDelta( $mysql ); 183 187 184 188 echo '<div id="message" class="updated fade"><p><strong>'; 185 printf( __('Outerbridge Password Generator updated to version %s', 'password-generator'), $this->obr_password_generator);189 printf( __( 'Outerbridge Password Generator updated to version %s', 'password-generator' ), $this->obr_password_generator ); 186 190 echo '</strong></p></div>'; 187 update_option( 'obr_password_generator', $this->obr_password_generator);191 update_option( 'obr_password_generator', $this->obr_password_generator ); 188 192 } 189 193 } 190 194 } 191 195 192 function obr_password_generator_init() {193 register_widget( 'obr_password_generator');196 function obr_password_generator_init() { 197 register_widget( 'obr_password_generator' ); 194 198 } 195 add_action( 'widgets_init', 'obr_password_generator_init');196 199 add_action( 'widgets_init', 'obr_password_generator_init' ); 200 -
password-generator/trunk/readme.txt
r2585893 r2778948 1 === OuterbridgePassword Generator ===1 === Password Generator === 2 2 Contributors: outerbridge 3 3 Author URI: https://outerbridge.co.uk/ 4 4 Tags: password generator, special characters, strong password 5 5 Requires at least: 4.7 6 Tested up to: 5.86 Tested up to: 6.0 7 7 Stable tag: trunk 8 8 … … 46 46 == Changelog == 47 47 48 = 1.7 = 49 - (01 Sep 2022) Various fixes. Tested and stable up to WP6.0 50 48 51 = 1.6 = 49 52 - (23 May 2017) Made translatable … … 74 77 75 78 79 = 1.7 = 80 - Various fixes. Tested and stable up to WP6.0 81 76 82 = 1.6 = 77 83 - Made translatable
Note: See TracChangeset
for help on using the changeset viewer.