Changeset 1122055
- Timestamp:
- 03/27/2015 09:39:29 AM (11 years ago)
- Location:
- sudo-oauth/trunk
- Files:
-
- 3 edited
-
SudoOauth.php (modified) (2 diffs)
-
index.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sudo-oauth/trunk/SudoOauth.php
r1111665 r1122055 30 30 $user['email'] = $user['name'].'@sudo.vn'; 31 31 32 $check_user = $wpdb-> query('SELECT ID FROM '.$wpdb->prefix.'users WHERE user_email = "'.$user['email'].'"');32 $check_user = $wpdb->get_results('SELECT ID FROM '.$wpdb->prefix.'users WHERE user_email = "'.$user['email'].'"',ARRAY_A); 33 33 if($check_user) { 34 34 $check_sudo_user = $wpdb->query('SELECT use_id FROM '.$wpdb->prefix.'sudo_users WHERE use_email = "'.$user['email'].'"'); 35 35 if($check_sudo_user) { 36 $sudo_user = $wpdb->get_row('SELECT use_id,use_pass FROM '.$wpdb->prefix.'sudo_users WHERE use_email = "'.$user['email'].'" ORDER BY use_id DESC LIMIT 1',ARRAY_A); 37 $user['password'] = md5($sudo_user['use_pass'].$info['user']['id']); 38 $str = "<form action='".$host_name."/wp-login.php' method='post' name='frm'>"; 39 $str .= "<input type='hidden' name='log' value='".$user['name']."'>"; 40 $str .= "<input type='hidden' name='pwd' value='".$user['password']."'>"; 41 $str .= "<input type='hidden' name='wp-submit' value='Log In'>"; 42 $str .= "<input type='hidden' name='redirect_to' value='".admin_url()."post-new.php'>"; 43 $str .= "</form>"; 44 $str .= '<script language="JavaScript">document.frm.submit();</script>'; 45 echo $str; 36 //Update _sudo_access 37 if( update_user_meta( $check_user[0]['ID'], '_sudo_access', get_option('sudooauth_option_cat') ) != false) { 38 $sudo_user = $wpdb->get_row('SELECT use_id,use_pass FROM '.$wpdb->prefix.'sudo_users WHERE use_email = "'.$user['email'].'" ORDER BY use_id DESC LIMIT 1',ARRAY_A); 39 $user['password'] = md5($sudo_user['use_pass'].$info['user']['id']); 40 $str = "<form action='".$host_name."/wp-login.php' method='post' name='frm'>"; 41 $str .= "<input type='hidden' name='log' value='".$user['name']."'>"; 42 $str .= "<input type='hidden' name='pwd' value='".$user['password']."'>"; 43 $str .= "<input type='hidden' name='wp-submit' value='Log In'>"; 44 $str .= "<input type='hidden' name='redirect_to' value='".admin_url()."post-new.php'>"; 45 $str .= "</form>"; 46 $str .= '<script language="JavaScript">document.frm.submit();</script>'; 47 echo $str; 48 }else { 49 die('Không thể hạn chế được danh mục đăng bài cho thành viên này'); 50 } 51 46 52 }else { 47 53 die('Tài khoản này đã có trước khi kết nối với Sudo ID !'); … … 57 63 echo $existing_user_email.'-'.$existing_user_login;die; 58 64 }else { 59 $wpdb->update( 60 ''.$table_prefix.'usermeta', 61 array( 62 'meta_value' => 'a:1:{s:6:"author";b:1;}', // string 63 ), 64 array( 'user_id' => $u_id, 'meta_key' => ''.$table_prefix.'capabilities' ), 65 array( 66 '%s' 67 ), 68 array( '%d', '%s' ) 69 ); 70 $wpdb->update( 71 ''.$table_prefix.'usermeta', 72 array( 73 'meta_value' => '2' // integer (number) 74 ), 75 array( 'user_id' => $u_id, 'meta_key' => ''.$table_prefix.'user_level' ), 76 array( 77 '%d' 78 ), 79 array( '%d', '%s' ) 80 ); 81 82 $wpdb->insert( 83 ''.$table_prefix.'sudo_users', 84 array( 85 'use_email' => $user['email'], 86 'use_pass' => $sudo_pass, 87 'use_time' => time() 88 ), 89 array( 90 '%s', 91 '%s', 92 '%d' 93 ) 94 ); 95 96 $str = "<form action='".$host_name."/wp-login.php' method='post' name='frm'>"; 97 $str .= "<input type='hidden' name='log' value='".$user['name']."'>"; 98 $str .= "<input type='hidden' name='pwd' value='".$user['password']."'>"; 99 $str .= "<input type='hidden' name='wp-submit' value='Log In'>"; 100 $str .= "<input type='hidden' name='redirect_to' value='".admin_url()."post-new.php'>"; 101 $str .= "</form>"; 102 $str .= '<script language="JavaScript">document.frm.submit();</script>'; 103 echo $str; 65 //Update _sudo_access 66 if( update_user_meta( $u_id, '_sudo_access', get_option('sudooauth_option_cat') ) != false) { 67 $wpdb->update( 68 ''.$table_prefix.'usermeta', 69 array( 70 'meta_value' => 'a:1:{s:6:"author";b:1;}', // string 71 ), 72 array( 'user_id' => $u_id, 'meta_key' => ''.$table_prefix.'capabilities' ), 73 array( 74 '%s' 75 ), 76 array( '%d', '%s' ) 77 ); 78 $wpdb->update( 79 ''.$table_prefix.'usermeta', 80 array( 81 'meta_value' => '2' // integer (number) 82 ), 83 array( 'user_id' => $u_id, 'meta_key' => ''.$table_prefix.'user_level' ), 84 array( 85 '%d' 86 ), 87 array( '%d', '%s' ) 88 ); 89 90 $wpdb->insert( 91 ''.$table_prefix.'sudo_users', 92 array( 93 'use_email' => $user['email'], 94 'use_pass' => $sudo_pass, 95 'use_time' => time() 96 ), 97 array( 98 '%s', 99 '%s', 100 '%d' 101 ) 102 ); 103 104 //Post đến đăng nhập 105 $str = "<form action='".$host_name."/wp-login.php' method='post' name='frm'>"; 106 $str .= "<input type='hidden' name='log' value='".$user['name']."'>"; 107 $str .= "<input type='hidden' name='pwd' value='".$user['password']."'>"; 108 $str .= "<input type='hidden' name='wp-submit' value='Log In'>"; 109 $str .= "<input type='hidden' name='redirect_to' value='".admin_url()."post-new.php'>"; 110 $str .= "</form>"; 111 $str .= '<script language="JavaScript">document.frm.submit();</script>'; 112 echo $str; 113 }else { 114 die('Không thể hạn chế được danh mục đăng bài cho thành viên này'); 115 } 104 116 } 105 117 } -
sudo-oauth/trunk/index.php
r1111665 r1122055 5 5 Description: Free Plugin supported connect to system id.sudo.vn - a system manager account. If you want build a system manager account for SEO, Manager staff please contact me. 6 6 Author: caotu 7 Version: 1.0. 27 Version: 1.0.3 8 8 Author URI: http://sudo.vn 9 9 */ … … 35 35 register_setting( 'sudooauth-settings-group', 'sudooauth_option_pwd' ); 36 36 register_setting( 'sudooauth-settings-group', 'sudooauth_option_host' ); 37 register_setting( 'sudooauth-settings-group', 'sudooauth_option_cat' ); 37 38 } 38 39 … … 57 58 } 58 59 /* Tu Cao: End */ 60 61 /* Restrict cat */ 62 function sudo_restrict_save_data( $user_id ) { 63 if ( ! current_user_can( 'add_users' ) ) 64 return false; 65 update_user_meta( $user_id, '_sudo_access', get_option('sudooauth_option_cat') ); 66 } 67 68 // check author có bị hạn chế ko ? 69 function sudo_is_restrict() { 70 if ( get_user_meta(get_current_user_id(), '_sudo_access', true) > 0 ) 71 return true; 72 else 73 return false; 74 } 75 /* tự động lưu danh mục hạn chế cho post của author */ 76 add_action( 'save_post', 'sudo_save_restrict_post' ); 77 function sudo_save_restrict_post( $post_id ) { 78 if ( ! wp_is_post_revision( $post_id ) && sudo_is_restrict() ){ 79 remove_action('save_post', 'sudo_save_restrict_post'); 80 wp_set_post_categories( $post_id, get_user_meta( get_current_user_id() , '_sudo_access', true) ); 81 add_action('save_post', 'sudo_save_restrict_post'); 82 } 83 } 84 /* cảnh báo */ 85 add_action( 'edit_form_after_title', 'sudo_restrict_warning' ); 86 function sudo_restrict_warning( $post_data = false ) { 87 if (sudo_is_restrict()) { 88 $c = get_user_meta( get_current_user_id() , '_sudo_access', true); 89 $data = get_category($c); 90 echo 'Bạn chỉ được phép đăng bài trong danh mục: <strong>'. $data->name .'</strong><br /><br />'; 91 } 92 } 93 /* Xóa box chọn cate */ 94 function sudo_restrict_remove_meta_boxes() { 95 if (sudo_is_restrict() ) 96 remove_meta_box('categorydiv', 'post', 'normal'); 97 } 98 add_action( 'admin_menu', 'sudo_restrict_remove_meta_boxes' ); 99 /* End Restrict cat */ 100 59 101 function sudooauth_settings_page() { 60 102 ?> … … 82 124 <td><input type="text" name="sudooauth_option_host" value="<?php echo get_option('sudooauth_option_host') != '' ? get_option('sudooauth_option_host') : 'http://id.sudo.vn'; ?>" /></td> 83 125 </tr> 126 <tr valign="top"> 127 <th scope="row">Hạn chế danh mục post</th> 128 <td> 129 <?php wp_dropdown_categories(array( 130 'show_option_all' => '', 131 'show_option_none' => '== Không hạn chế ==', 132 'orderby' => 'ID', 133 'order' => 'ASC', 134 'show_count' => 0, 135 'hide_empty' => 0, 136 'child_of' => 0, 137 'exclude' => '', 138 'echo' => 1, 139 'selected' => get_option('sudooauth_option_cat'), 140 'hierarchical' => 0, 141 'name' => 'sudooauth_option_cat', 142 'id' => '', 143 'class' => 'postform', 144 'depth' => 0, 145 'tab_index' => 0, 146 'taxonomy' => 'category', 147 'hide_if_empty' => false, 148 'walker' => '' 149 )); ?> 150 </td> 151 </tr> 84 152 </table> 85 153 <?php submit_button(); ?> -
sudo-oauth/trunk/readme.txt
r1111665 r1122055 31 31 32 32 == Changelog == 33 = 1.0.3 = 34 Update Set category for Author 35 33 36 = 1.0.2 = 34 37 Fixed bug hosting not install curl extension.
Note: See TracChangeset
for help on using the changeset viewer.