JFIF  H H (ICC_PROFILE   0 mntrRGB XYZ acsp   - desc trXYZ d gXYZ x bXYZ  rTRC  (gTRC  (bTRC  (wtpt  cprt  ب V 7eud akt !Q ,*R G PQ NČzŬb 56 6 6p z  "c8 3' 'Mq 6 G i t q l@ 9 0.ۚA c N|li: 9 蠃p / ^ Zn L  x84 v ;[#$ n h '  c 3 2o 8Ɛ5K Av*_ ?n X ?  p y ֆ ̈́# z 2 3 F0O e> { Gu . V (C ' h/ o%> x1X r:(>} { yc X 8b ] U : dO Ms VA p 'Z 3'3E - y bj: > j Ov Uw # 2cl~ @gF C jț bz ^: -t df j{XTh  8aU  M ^+d Al "(KK m1$$ X K K q rž o q g V FF#pG~ : ] ֦ !!Ң :pC+ A  zӬ ]. t `= ' h _/ }   @L \ , x㌼ z԰+ J - v + Y  [ '8 '  % X q= [4 Sj~ 4 ݢ # d ʂē R L5k X؊  > l :t\ ba B A\Q3 8 ( < A ; d ) n ӓLr Œ * |J : Ƒ 2rF G A 8 &\ A - J) /j `t.  E  A : T m "%Cb"! 7 wΦ Æ % ; [ ] U zmF kx + 7 ^ Ү R  "7 N+- b7 c ,.55 H T E`) P T ci 20y=MڭyٽS Odc i UJnq&~zn$ Rp )fG' 2 '  . mEϙ Z oV 𶛒u S ] | A @. )<  + '> ө :& $ ' L #   d{q H >*5; jDo ˷ Y m Ԉ*[9* 5 t Uf %3 = GU W\ ' AR _ W 4 _ P պ - | 4R F  JZ v0 d[ˠzJ| PU 8 ;鯌 ' V  cL , κ >   *e b)f, 0 "j1  1 v՘; b J ++ C Oz7 % > N U ,=z \ c EV K >Ic 7} . jHn;^觱GHI  H V ǂO: ߊ{mSV?K|@ A iA T`2 j 1 ~ K8’$ ~]=9ឦG * 9 E Mּm5X f 9 Q ĸ}i D% +t+;F : v : - & h _ rD | !  Ә ;Z l 븂' : C & Ҁae Kkm6 uT".}J&\ hci B2B + T 7 t?EPþЌ m A F\ l c2 ЊABm E,cն\Q J ]d 5  `O  Y@ 8 ?lx#  K iI& Ri1f R2f1N %_ g *T Ө ??N: }+ל ɀ h٭ q L ,ʈ B r c  u  Bmz  ̢TV^  뙏8' u fUX 3㓏 >NG : / ; H p饕 B 1 K  /%iɫ V Q% : _ - 1o L ? R oa\i^ F| W*Na)  P  X #y㯨 z+C ح\  в j i rm *d W ҡQb BȨ i'% NEb ? '[ h =`Oi U϶ u n R }GW 4f VJm  i R ~ J|l%m' % " LW  V 2 7 Ns X b ?_ = {s }ij4 Ý=SN jx FV "ԎI( E  )] ӝ Ж m [4 m `5 -7W f 󪥎 b Z K a#Vb% K Y 5 T $y` 4 6 ̼ p C 7 HM 'l{Oi + Pw~j,S5T4(F Ԩ; A `*HJ TP g t (6/ cg 5 U 1@Qb8 Y!  r < r 6h ) [{h h 8 3  0< y+V >BzOQ KF+6 v %= ~XD PpW c _-:߈   #c 坣 C W1 : ^ Q 06Ӭ q@ Dj $ UW $ ?9 F \cS M5 = 2> hב\,( ) JB k ; J #j徻W (p= o Q D #U Mh U *F  c ?N = n F5 Ӑ12 w 0 5Z 뀩4ڣ 霅 uC1 y %n J 8Ԑ *c r R 9W= H 9 , A ׻, . ZF b QEGVNs, q ' ;O Mm btN Vq Ow*֙kPѬ؈ X J  I ӯ E Wo k + R { %   j;   Y x 7&& , LԜ Y bw" lI (* `۹F A S - #$ 4 13)Q pڤ3Rx O J $c P]v i uq { k y N. - B ,@󪳪ڸ Ao  r% X0 U N b  9 򍕑 7)* 23 3 | Rn b @ q |E U y ́$!7 & ["X O y  ~ƓtADhP  ] m G 파 9 p= ԜZ]ӭ ሎ O eyq ! b I GU : 5~ F o L S T[е $]$g * w] ! ; m@ ޠ &IU ڬ{ ҄բ-.Sm Ғ `    vU"o L ; ' 5s " W )  @ ä  L 1i  } ^Y5 $+ P  v0o  HU @ȓ s Q M )  ? M\ 4 Q  $2 ;g  WJ /NwF JG D : y ό  Mf  W!  QUZ%a zҳ  DK _ X h M ^r ԝ^!d '<#ﴛ O { /F ? + $ Y ' wg'$ l  jG AH 7l 4   x Ѷ c }  I *e s g ~ ;ͤ t@  B 2 iB' 9C a 8 f TR: %  N O  @ m 3 s v w .@ 濾   ,FYrT0m UW _v>>d [ A 6 ڊx : Y T L Hv Ӻ! n S D} >[m E T0 _ ,'C] p  j  V ᅷ PDZ[- V0`  > } ܟpmֻ 2O6 O* ݹ X HS N(J / +1՟ #( P *g EO # w&j 6 ?; ڡ )+ U ]l \ /{莄 * I /  9 <'$ '#' y t/& -\\WP L`/p9 q  a' e ¨ E] f A A E Y nGtm, ϮwXT >AaN#  F j  ŵj Q Fd  q^< H? y J ܃2 * 3 T4 Ч H **W; (ꭽ ¾ P f= e yA 4 FJ 6{e ]J q OC  f#3 S J f i MM\ i T $ rG 8$ 9>2 :  M) Q #N K e &" E 8    . z <  mHk ? # t ˒ A ]; G0H : f! i ! j { 1 m } o 7 u; $   99Ӱ \n c z:zA Lq ޶w y K  T<  4 X, '!Y; Ͱ6 q G M~_ ~܂} t> ( z l }:r  L 9 fe}.- R*<`c6 o ܛ= pr ҽGB)nQ% )s*&i΍ %—Zb{ m[ N Nkb wB w Q* d F HP iܛ ; aV68j}\e I  GI'͔B ;yA  :^ bn - m # @ S6 ˎr  ; ~ cm ƻgU  : X6 G % < r ' dzX^} - H X D -C W`#  کpNH5 E y = 1 G # 꽁  C 5Yx z Y_"& A * C +q7Km 1Pm @in 88  N ^c.d p >[ g c {]c 4 ) f psgY ˅ > *"1 }2<1 7  5)] V5)kd kM ~` ΂  :{ 4  nG PTT b   뎱 ϶w FFᓂG8 >z F _ H  9_r D l: ҶH5  Z!Bj.y k} e rb:SOT ]!ǎ?n:H ε Z s y z tn [ 7N  Z#UQO$ . J #]Cr# Y X  9 c < '$ z 9  . $ $P nDS n 2 u5 X g\  ? |A  ᬰⶵ >> bE) Cb  -ruMc ׺ *,\)`^ m ge \k . ۫8  گ oK 1 gWM p U޻zI=EE rz: # 6 - -/ Wm \z8 מ 0x t A _c ?Ծ  c ^Mژ I MyO> l0 ċ }t7[ \ ʲ9̜ m_a[ 姯 rְ j P \k x 1 ' Cdm vF70e +  m- ]a ?ݝK uSMUm 8f Yb! ) 2Z.U  D \~: ܽ8z R ̪K c b s  &ߦ  1 $ , w \gc  3F$  iU#< ` : I 4{w . 2  a Q $ EX < p} x>N o?Gm N N rE $#J n҉ ! A H'< w  i i͗k ;  S;(PY y, | v G!H $ 4 ƴ @  V !қ 7  $ { O y W SY : I doI 5b _ s G q $ qIOg - B H]_ V  G  ! w0 p$    n U #ROMB $Zn: BD U KE 4 ec q } 3 ^  n BZ j b W  `l  Z d " " b ]nm!ij. {&*   F O? c u ]  u VQbj: J B .Xg J Fsq d祚N x ʣR ;! $ : F cU $R1- K 'ɋ I x8 Ϗoߠ F~ z " _^v 2 - f K  kW8 c . Ms- 6 =eV = ev \  L = g n22p< ׵?r Fۏ >z eP z Rog 8u ( tJ P߁ Z .p Ð ͢A ռ65 X syvm 6R W7W ; |0 >O үG @ ٳ< > om Լ()  kZJlK, F 4 )sn  O Q {u㌏ = A o  ,ծ ?eKB zG 6e6  f| C U _ 4 C[j͕M 8,%em M 8 \ c v COwTGi _9 4 BDf%  'ns 8 M P c  & - y"8R _j 3a +z+ N 9 Q lDQ 40 E V ۋ rH 2 I _ Y O ',:뿉 WN Hvﵐ0 B}n a*E zUb N# 0 e" f.Q  H  5" - H Vn= + #  Eiy- v8= g  `  o [ 鼛 2 . D ^ Q  eB  ؅q Ͽ R C~ B+J ۍ 8 4 * Ӗ Ν1 R B  I\  1[0 I 9y )  Y " 7 ]6 q g\ vP   s = Ѭ֕)פ  E < c` ϷU9 W ,: ? y 1h s U( T g e /룮 J A ]|   4a ZV AI eIhBI! l $ 3![q Hnw\7R { o M / ִ > 5&  gw j F E dc@K:V& W /k + = Y k[ @fU 5 zzmF ȖH,[  n -dc  w d[ z" g 4 ϘR r 0`B 8_; # $^Z  o5K ZYKj GY% s  "!a [9I2TF -  w# a ] ˒  I tٮ ei_ F pVЧ૱W 3e Ci 7 " } H  A pG> h  ֝ 5i T٧- ' `d X1   AF$ $< y  9~ , n  e boW >ޙ_ Z]ڷ T C U y J  G O }   > A" 5 a> Z U R - Z \9 jrW ݖQ Rݳ * ļ ] $ڵ Xq = / w z\ I  I # { ӭ l ^; F_R쵎 [ָ[gK KͰ o Q )W녕 і s *kuz ŨQde` WU_ KLE ~" g r< 2G y  އ L ( -V Y -Z( I U  0  | \ ; 8 C  m hl :̄D  k YHO k |:  *D Y ts س | zrO; 񍃌s T3 1 = j w y Ш ^nZ H m _G̮ 0W  󿓹 S ;  _$ mٛI D V =f -H } U  ]H A * vԶ  3\ Wh*I#$ @6  x ^ O Z C&J U 16 X D* if& B DGFY YP [KL X u X .Z h q Ghb  8 M# Mq t \c > aT 00= ㎨ʕ G Q Ԫ R ,Ĝ I9 zӦ JO 3Rn ` C 5 ܊@Q O1 N.ؔ"I\ YÖ Đ H d L \}IP~jm $ y ; :ZG  ZV Jv =&*UF#` `R`*S+p \=) ҭ 9 k  ̮Rš x 0' **ԑL kɺk +zJb # :|M Z ? j$ݼ & X )$ 6 F Y6ѕ/  ;  J *n l C *ų_ ԕ{ _ 6 :\47ڷ s 4R m Ċ = z * ʪ XT [ ] 5 Bl#a -˙bv 8 @ H   |R we9A%5& M % Z02T N)&&GfM 儀o Œ M ;= ./ /k~ E"a9/3 y ,> l j >  Z X y &ε Y P &h g e c< `` ] !}i'c KQ ulF Iʓ_\T58 ( +cJ q~ [d gm m/` Xڙ ht k q ו$ " c[P VY [uɜ&# 몵 "  Ⱦ qC  " Ü Ȕ!  <  M j8 u- d x * g ϫ t T Ld K laWڭ  \ ~ |  7 u` h( w ֋ c L= ˼ = F  vcG s } зU BS М; FI;  Q $8 +V|[C S 쮙 1 % YP Q% L VVK+& , c Ib ]  Vy i ~h  ?y F4  "5 A s- F ݆x5 5P&E :W@f;}  G y ^ ]U ITki 1 d﫠 *c N h ' c ؗY n s L :b  ? H :k M~ @ 8# I qɔ ~ :f ] P*i]H 'f jhx Tҗ 1 O : ^t $ 1]  UXz&  t OD T > (^ s &3 #N_ / x - 䬦? ~ v U- W$4  ' ӎ v RG |jy SW? u 4 ( 1 G[ ِ2 2jʎ hr m oյ ش gRͮ%ϟ Ѭ 9 o R  n-  &F - @  hgY _qN ;"2  !K J  šA ^, " aG 8` =1 4 =5 Mq k > U@UT  : R gj rK F. O$ I9'  =i }. _ One Hat Cyber Team
  • Your IP: 216.73.216.6
  • Server IP: 13.234.148.13
  • Server: Linux ip-172-31-36-101 5.15.0-1031-aws #35~20.04.1-Ubuntu SMP Sat Feb 11 16:19:06 UTC 2023 x86_64
  • Server Software: Apache/2.4.41 (Ubuntu)
  • PHP Version: 7.4.3-4ubuntu2.29
  • Buat File | Buat Folder
View File Name : Privileges.php
'; return array($title, $export); } /** * Get HTML for display Add userfieldset * * @param string $db the database * @param string $table the table name * * @return string html output */ public static function getAddUserHtmlFieldset($db = '', $table = '') { if (!$GLOBALS['is_createuser']) { return ''; } $rel_params = array(); $url_params = array( 'adduser' => 1 ); if (!empty($db)) { $url_params['dbname'] = $rel_params['checkprivsdb'] = $db; } if (!empty($table)) { $url_params['tablename'] = $rel_params['checkprivstable'] = $table; } return Template::get('privileges/add_user_fieldset') ->render( array( 'url_params' => $url_params, 'rel_params' => $rel_params ) ); } /** * Get HTML header for display User's properties * * @param boolean $dbname_is_wildcard whether database name is wildcard or not * @param string $url_dbname url database name that urlencode() string * @param string $dbname database name * @param string $username username * @param string $hostname host name * @param string $entity_name entity (table or routine) name * @param string $entity_type optional, type of entity ('table' or 'routine') * * @return string $html_output */ public static function getHtmlHeaderForUserProperties( $dbname_is_wildcard, $url_dbname, $dbname, $username, $hostname, $entity_name, $entity_type='table' ) { $html_output = '

' . "\n" . Util::getIcon('b_usredit') . __('Edit privileges:') . ' ' . __('User account'); if (! empty($dbname)) { $html_output .= ' \'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'' . "\n"; $html_output .= ' - '; $html_output .= ($dbname_is_wildcard || is_array($dbname) && count($dbname) > 1) ? __('Databases') : __('Database'); if (! empty($entity_name) && $entity_type === 'table') { $html_output .= ' ' . htmlspecialchars($dbname) . ''; $html_output .= ' - ' . __('Table') . ' ' . htmlspecialchars($entity_name) . ''; } elseif (! empty($entity_name)) { $html_output .= ' ' . htmlspecialchars($dbname) . ''; $html_output .= ' - ' . __('Routine') . ' ' . htmlspecialchars($entity_name) . ''; } else { if (! is_array($dbname)) { $dbname = array($dbname); } $html_output .= ' ' . htmlspecialchars(implode(', ', $dbname)) . ''; } } else { $html_output .= ' \'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'' . "\n"; } $html_output .= '

' . "\n"; $cur_user = $GLOBALS['dbi']->getCurrentUser(); $user = $username . '@' . $hostname; // Add a short notice for the user // to remind him that he is editing his own privileges if ($user === $cur_user) { $html_output .= Message::notice( __( 'Note: You are attempting to edit privileges of the ' . 'user with which you are currently logged in.' ) )->getDisplay(); } return $html_output; } /** * Get HTML snippet for display user overview page * * @param string $pmaThemeImage a image source link * @param string $text_dir text directory * * @return string $html_output */ public static function getHtmlForUserOverview($pmaThemeImage, $text_dir) { $html_output = '

' . "\n" . Util::getIcon('b_usrlist') . __('User accounts overview') . "\n" . '

' . "\n"; $password_column = 'Password'; $server_type = Util::getServerType(); $serverVersion = $GLOBALS['dbi']->getVersion(); if (($server_type == 'MySQL' || $server_type == 'Percona Server') && $serverVersion >= 50706 ) { $password_column = 'authentication_string'; } // $sql_query is for the initial-filtered, // $sql_query_all is for counting the total no. of users $sql_query = $sql_query_all = 'SELECT *,' . " IF(`" . $password_column . "` = _latin1 '', 'N', 'Y') AS 'Password'" . ' FROM `mysql`.`user`'; $sql_query .= (isset($_GET['initial']) ? self::rangeOfUsers($_GET['initial']) : ''); $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;'; $sql_query_all .= ' ;'; $res = $GLOBALS['dbi']->tryQuery( $sql_query, DatabaseInterface::CONNECT_USER, DatabaseInterface::QUERY_STORE ); $res_all = $GLOBALS['dbi']->tryQuery( $sql_query_all, DatabaseInterface::CONNECT_USER, DatabaseInterface::QUERY_STORE ); if (! $res) { // the query failed! This may have two reasons: // - the user does not have enough privileges // - the privilege tables use a structure of an earlier version. // so let's try a more simple query $GLOBALS['dbi']->freeResult($res); $GLOBALS['dbi']->freeResult($res_all); $sql_query = 'SELECT * FROM `mysql`.`user`'; $res = $GLOBALS['dbi']->tryQuery( $sql_query, DatabaseInterface::CONNECT_USER, DatabaseInterface::QUERY_STORE ); if (! $res) { $html_output .= self::getHtmlForViewUsersError(); $html_output .= self::getAddUserHtmlFieldset(); } else { // This message is hardcoded because I will replace it by // a automatic repair feature soon. $raw = 'Your privilege table structure seems to be older than' . ' this MySQL version!
' . 'Please run the mysql_upgrade command' . ' that should be included in your MySQL server distribution' . ' to solve this problem!'; $html_output .= Message::rawError($raw)->getDisplay(); } $GLOBALS['dbi']->freeResult($res); } else { $db_rights = self::getDbRightsForUserOverview(); // for all initials, even non A-Z $array_initials = array(); foreach ($db_rights as $right) { foreach ($right as $account) { if (empty($account['User']) && $account['Host'] == 'localhost') { $html_output .= Message::notice( __( 'A user account allowing any user from localhost to ' . 'connect is present. This will prevent other users ' . 'from connecting if the host part of their account ' . 'allows a connection from any (%) host.' ) . Util::showMySQLDocu('problems-connecting') )->getDisplay(); break 2; } } } /** * Displays the initials * Also not necessary if there is less than 20 privileges */ if ($GLOBALS['dbi']->numRows($res_all) > 20) { $html_output .= self::getHtmlForInitials($array_initials); } /** * Display the user overview * (if less than 50 users, display them immediately) */ if (isset($_GET['initial']) || isset($_GET['showall']) || $GLOBALS['dbi']->numRows($res) < 50 ) { $html_output .= self::getUsersOverview( $res, $db_rights, $pmaThemeImage, $text_dir ); } else { $html_output .= self::getAddUserHtmlFieldset(); } // end if (display overview) $response = Response::getInstance(); if (! $response->isAjax() || ! empty($_REQUEST['ajax_page_request']) ) { if ($GLOBALS['is_reload_priv']) { $flushnote = new Message( __( 'Note: phpMyAdmin gets the users’ privileges directly ' . 'from MySQL’s privilege tables. The content of these ' . 'tables may differ from the privileges the server uses, ' . 'if they have been changed manually. In this case, ' . 'you should %sreload the privileges%s before you continue.' ), Message::NOTICE ); $flushnote->addParamHtml( '' ); $flushnote->addParamHtml(''); } else { $flushnote = new Message( __( 'Note: phpMyAdmin gets the users’ privileges directly ' . 'from MySQL’s privilege tables. The content of these ' . 'tables may differ from the privileges the server uses, ' . 'if they have been changed manually. In this case, ' . 'the privileges have to be reloaded but currently, you ' . 'don\'t have the RELOAD privilege.' ) . Util::showMySQLDocu( 'privileges-provided', false, 'priv_reload' ), Message::NOTICE ); } $html_output .= $flushnote->getDisplay(); } } return $html_output; } /** * Get HTML snippet for display user properties * * @param boolean $dbname_is_wildcard whether database name is wildcard or not * @param string $url_dbname url database name that urlencode() string * @param string $username username * @param string $hostname host name * @param string $dbname database name * @param string $tablename table name * * @return string $html_output */ public static function getHtmlForUserProperties($dbname_is_wildcard, $url_dbname, $username, $hostname, $dbname, $tablename ) { $html_output = '
'; $html_output .= self::getHtmlHeaderForUserProperties( $dbname_is_wildcard, $url_dbname, $dbname, $username, $hostname, $tablename, 'table' ); $sql = "SELECT '1' FROM `mysql`.`user`" . " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'" . " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "';"; $user_does_not_exists = (bool) ! $GLOBALS['dbi']->fetchValue($sql); if ($user_does_not_exists) { $html_output .= Message::error( __('The selected user was not found in the privilege table.') )->getDisplay(); $html_output .= self::getHtmlForLoginInformationFields(); } $_params = array( 'username' => $username, 'hostname' => $hostname, ); if (! is_array($dbname) && strlen($dbname) > 0) { $_params['dbname'] = $dbname; if (strlen($tablename) > 0) { $_params['tablename'] = $tablename; } } else { $_params['dbname'] = $dbname; } $html_output .= '' . "\n"; if (! is_array($dbname) && strlen($tablename) === 0 && empty($dbname_is_wildcard) ) { // no table name was given, display all table specific rights // but only if $dbname contains no wildcards if (strlen($dbname) === 0) { $html_output .= self::getHtmlForAllTableSpecificRights( $username, $hostname, 'database' ); } else { // unescape wildcards in dbname at table level $unescaped_db = Util::unescapeMysqlWildcards($dbname); $html_output .= self::getHtmlForAllTableSpecificRights( $username, $hostname, 'table', $unescaped_db ); $html_output .= self::getHtmlForAllTableSpecificRights( $username, $hostname, 'routine', $unescaped_db ); } } // Provide a line with links to the relevant database and table if (! is_array($dbname) && strlen($dbname) > 0 && empty($dbname_is_wildcard)) { $html_output .= self::getLinkToDbAndTable($url_dbname, $dbname, $tablename); } if (! is_array($dbname) && strlen($dbname) === 0 && ! $user_does_not_exists) { //change login information $html_output .= ChangePassword::getHtml( 'edit_other', $username, $hostname ); $html_output .= self::getChangeLoginInformationHtmlForm($username, $hostname); } $html_output .= '
'; return $html_output; } /** * Get queries for Table privileges to change or copy user * * @param string $user_host_condition user host condition to * select relevant table privileges * @param array $queries queries array * @param string $username username * @param string $hostname host name * * @return array $queries */ public static function getTablePrivsQueriesForChangeOrCopyUser($user_host_condition, array $queries, $username, $hostname ) { $res = $GLOBALS['dbi']->query( 'SELECT `Db`, `Table_name`, `Table_priv` FROM `mysql`.`tables_priv`' . $user_host_condition, DatabaseInterface::CONNECT_USER, DatabaseInterface::QUERY_STORE ); while ($row = $GLOBALS['dbi']->fetchAssoc($res)) { $res2 = $GLOBALS['dbi']->query( 'SELECT `Column_name`, `Column_priv`' . ' FROM `mysql`.`columns_priv`' . ' WHERE `User`' . ' = \'' . $GLOBALS['dbi']->escapeString($_POST['old_username']) . "'" . ' AND `Host`' . ' = \'' . $GLOBALS['dbi']->escapeString($_POST['old_username']) . '\'' . ' AND `Db`' . ' = \'' . $GLOBALS['dbi']->escapeString($row['Db']) . "'" . ' AND `Table_name`' . ' = \'' . $GLOBALS['dbi']->escapeString($row['Table_name']) . "'" . ';', DatabaseInterface::CONNECT_USER, DatabaseInterface::QUERY_STORE ); $tmp_privs1 = self::extractPrivInfo($row); $tmp_privs2 = array( 'Select' => array(), 'Insert' => array(), 'Update' => array(), 'References' => array() ); while ($row2 = $GLOBALS['dbi']->fetchAssoc($res2)) { $tmp_array = explode(',', $row2['Column_priv']); if (in_array('Select', $tmp_array)) { $tmp_privs2['Select'][] = $row2['Column_name']; } if (in_array('Insert', $tmp_array)) { $tmp_privs2['Insert'][] = $row2['Column_name']; } if (in_array('Update', $tmp_array)) { $tmp_privs2['Update'][] = $row2['Column_name']; } if (in_array('References', $tmp_array)) { $tmp_privs2['References'][] = $row2['Column_name']; } } if (count($tmp_privs2['Select']) > 0 && ! in_array('SELECT', $tmp_privs1)) { $tmp_privs1[] = 'SELECT (`' . join('`, `', $tmp_privs2['Select']) . '`)'; } if (count($tmp_privs2['Insert']) > 0 && ! in_array('INSERT', $tmp_privs1)) { $tmp_privs1[] = 'INSERT (`' . join('`, `', $tmp_privs2['Insert']) . '`)'; } if (count($tmp_privs2['Update']) > 0 && ! in_array('UPDATE', $tmp_privs1)) { $tmp_privs1[] = 'UPDATE (`' . join('`, `', $tmp_privs2['Update']) . '`)'; } if (count($tmp_privs2['References']) > 0 && ! in_array('REFERENCES', $tmp_privs1) ) { $tmp_privs1[] = 'REFERENCES (`' . join('`, `', $tmp_privs2['References']) . '`)'; } $queries[] = 'GRANT ' . join(', ', $tmp_privs1) . ' ON ' . Util::backquote($row['Db']) . '.' . Util::backquote($row['Table_name']) . ' TO \'' . $GLOBALS['dbi']->escapeString($username) . '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\'' . (in_array('Grant', explode(',', $row['Table_priv'])) ? ' WITH GRANT OPTION;' : ';'); } return $queries; } /** * Get queries for database specific privileges for change or copy user * * @param array $queries queries array with string * @param string $username username * @param string $hostname host name * * @return array $queries */ public static function getDbSpecificPrivsQueriesForChangeOrCopyUser( array $queries, $username, $hostname ) { $user_host_condition = ' WHERE `User`' . ' = \'' . $GLOBALS['dbi']->escapeString($_POST['old_username']) . "'" . ' AND `Host`' . ' = \'' . $GLOBALS['dbi']->escapeString($_POST['old_hostname']) . '\';'; $res = $GLOBALS['dbi']->query( 'SELECT * FROM `mysql`.`db`' . $user_host_condition ); while ($row = $GLOBALS['dbi']->fetchAssoc($res)) { $queries[] = 'GRANT ' . join(', ', self::extractPrivInfo($row)) . ' ON ' . Util::backquote($row['Db']) . '.*' . ' TO \'' . $GLOBALS['dbi']->escapeString($username) . '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\'' . ($row['Grant_priv'] == 'Y' ? ' WITH GRANT OPTION;' : ';'); } $GLOBALS['dbi']->freeResult($res); $queries = self::getTablePrivsQueriesForChangeOrCopyUser( $user_host_condition, $queries, $username, $hostname ); return $queries; } /** * Prepares queries for adding users and * also create database and return query and message * * @param boolean $_error whether user create or not * @param string $real_sql_query SQL query for add a user * @param string $sql_query SQL query to be displayed * @param string $username username * @param string $hostname host name * @param string $dbname database name * @param string $alter_real_sql_query SQL query for ALTER USER * @param string $alter_sql_query SQL query for ALTER USER to be displayed * * @return array $sql_query, $message */ public static function addUserAndCreateDatabase( $_error, $real_sql_query, $sql_query, $username, $hostname, $dbname, $alter_real_sql_query, $alter_sql_query ) { if ($_error || (!empty($real_sql_query) && !$GLOBALS['dbi']->tryQuery($real_sql_query)) ) { $_POST['createdb-1'] = $_POST['createdb-2'] = $_POST['createdb-3'] = null; $message = Message::rawError($GLOBALS['dbi']->getError()); } elseif ($alter_real_sql_query !== '' && !$GLOBALS['dbi']->tryQuery($alter_real_sql_query)) { $_POST['createdb-1'] = $_POST['createdb-2'] = $_POST['createdb-3'] = null; $message = Message::rawError($GLOBALS['dbi']->getError()); } else { $sql_query .= $alter_sql_query; $message = Message::success(__('You have added a new user.')); } if (isset($_POST['createdb-1'])) { // Create database with same name and grant all privileges $q = 'CREATE DATABASE IF NOT EXISTS ' . Util::backquote( $GLOBALS['dbi']->escapeString($username) ) . ';'; $sql_query .= $q; if (! $GLOBALS['dbi']->tryQuery($q)) { $message = Message::rawError($GLOBALS['dbi']->getError()); } /** * Reload the navigation */ $GLOBALS['reload'] = true; $GLOBALS['db'] = $username; $q = 'GRANT ALL PRIVILEGES ON ' . Util::backquote( Util::escapeMysqlWildcards( $GLOBALS['dbi']->escapeString($username) ) ) . '.* TO \'' . $GLOBALS['dbi']->escapeString($username) . '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\';'; $sql_query .= $q; if (! $GLOBALS['dbi']->tryQuery($q)) { $message = Message::rawError($GLOBALS['dbi']->getError()); } } if (isset($_POST['createdb-2'])) { // Grant all privileges on wildcard name (username\_%) $q = 'GRANT ALL PRIVILEGES ON ' . Util::backquote( Util::escapeMysqlWildcards( $GLOBALS['dbi']->escapeString($username) ) . '\_%' ) . '.* TO \'' . $GLOBALS['dbi']->escapeString($username) . '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\';'; $sql_query .= $q; if (! $GLOBALS['dbi']->tryQuery($q)) { $message = Message::rawError($GLOBALS['dbi']->getError()); } } if (isset($_POST['createdb-3'])) { // Grant all privileges on the specified database to the new user $q = 'GRANT ALL PRIVILEGES ON ' . Util::backquote( $GLOBALS['dbi']->escapeString($dbname) ) . '.* TO \'' . $GLOBALS['dbi']->escapeString($username) . '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\';'; $sql_query .= $q; if (! $GLOBALS['dbi']->tryQuery($q)) { $message = Message::rawError($GLOBALS['dbi']->getError()); } } return array($sql_query, $message); } /** * Get the hashed string for password * * @param string $password password * * @return string $hashedPassword */ public static function getHashedPassword($password) { $password = $GLOBALS['dbi']->escapeString($password); $result = $GLOBALS['dbi']->fetchSingleRow( "SELECT PASSWORD('" . $password . "') AS `password`;" ); $hashedPassword = $result['password']; return $hashedPassword; } /** * Check if MariaDB's 'simple_password_check' * OR 'cracklib_password_check' is ACTIVE * * @return boolean if atleast one of the plugins is ACTIVE */ public static function checkIfMariaDBPwdCheckPluginActive() { $serverVersion = $GLOBALS['dbi']->getVersion(); if (!(Util::getServerType() == 'MariaDB' && $serverVersion >= 100002)) { return false; } $result = $GLOBALS['dbi']->tryQuery( 'SHOW PLUGINS SONAME LIKE \'%_password_check%\'' ); /* Plugins are not working, for example directory does not exists */ if ($result === false) { return false; } while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { if ($row['Status'] === 'ACTIVE') { return true; } } return false; } /** * Get SQL queries for Display and Add user * * @param string $username username * @param string $hostname host name * @param string $password password * * @return array ($create_user_real, $create_user_show, $real_sql_query, $sql_query * $password_set_real, $password_set_show, $alter_real_sql_query, $alter_sql_query) */ public static function getSqlQueriesForDisplayAndAddUser($username, $hostname, $password) { $slashedUsername = $GLOBALS['dbi']->escapeString($username); $slashedHostname = $GLOBALS['dbi']->escapeString($hostname); $slashedPassword = $GLOBALS['dbi']->escapeString($password); $serverType = Util::getServerType(); $serverVersion = $GLOBALS['dbi']->getVersion(); $create_user_stmt = sprintf( 'CREATE USER \'%s\'@\'%s\'', $slashedUsername, $slashedHostname ); $isMariaDBPwdPluginActive = self::checkIfMariaDBPwdCheckPluginActive(); // See https://github.com/phpmyadmin/phpmyadmin/pull/11560#issuecomment-147158219 // for details regarding details of syntax usage for various versions // 'IDENTIFIED WITH auth_plugin' // is supported by MySQL 5.5.7+ if (($serverType == 'MySQL' || $serverType == 'Percona Server') && $serverVersion >= 50507 && isset($_POST['authentication_plugin']) ) { $create_user_stmt .= ' IDENTIFIED WITH ' . $_POST['authentication_plugin']; } // 'IDENTIFIED VIA auth_plugin' // is supported by MariaDB 5.2+ if ($serverType == 'MariaDB' && $serverVersion >= 50200 && isset($_POST['authentication_plugin']) && ! $isMariaDBPwdPluginActive ) { $create_user_stmt .= ' IDENTIFIED VIA ' . $_POST['authentication_plugin']; } $create_user_real = $create_user_show = $create_user_stmt; $password_set_stmt = 'SET PASSWORD FOR \'%s\'@\'%s\' = \'%s\''; $password_set_show = sprintf( $password_set_stmt, $slashedUsername, $slashedHostname, '***' ); $sql_query_stmt = sprintf( 'GRANT %s ON *.* TO \'%s\'@\'%s\'', join(', ', self::extractPrivInfo()), $slashedUsername, $slashedHostname ); $real_sql_query = $sql_query = $sql_query_stmt; // Set the proper hashing method if (isset($_POST['authentication_plugin'])) { self::setProperPasswordHashing( $_POST['authentication_plugin'] ); } // Use 'CREATE USER ... WITH ... AS ..' syntax for // newer MySQL versions // and 'CREATE USER ... VIA .. USING ..' syntax for // newer MariaDB versions if ((($serverType == 'MySQL' || $serverType == 'Percona Server') && $serverVersion >= 50706) || ($serverType == 'MariaDB' && $serverVersion >= 50200) ) { $password_set_real = null; // Required for binding '%' with '%s' $create_user_stmt = str_replace( '%', '%%', $create_user_stmt ); // MariaDB uses 'USING' whereas MySQL uses 'AS' // but MariaDB with validation plugin needs cleartext password if ($serverType == 'MariaDB' && ! $isMariaDBPwdPluginActive ) { $create_user_stmt .= ' USING \'%s\''; } elseif ($serverType == 'MariaDB') { $create_user_stmt .= ' IDENTIFIED BY \'%s\''; } elseif (($serverType == 'MySQL' || $serverType == 'Percona Server') && $serverVersion >= 80011) { $create_user_stmt .= ' BY \'%s\''; } else { $create_user_stmt .= ' AS \'%s\''; } if ($_POST['pred_password'] == 'keep') { $create_user_real = sprintf( $create_user_stmt, $slashedPassword ); $create_user_show = sprintf( $create_user_stmt, '***' ); } elseif ($_POST['pred_password'] == 'none') { $create_user_real = sprintf( $create_user_stmt, null ); $create_user_show = sprintf( $create_user_stmt, '***' ); } else { if (! (($serverType == 'MariaDB' && $isMariaDBPwdPluginActive) || ($serverType == 'MySQL' || $serverType == 'Percona Server') && $serverVersion >= 80011)) { $hashedPassword = self::getHashedPassword($_POST['pma_pw']); } else { // MariaDB with validation plugin needs cleartext password $hashedPassword = $_POST['pma_pw']; } $create_user_real = sprintf( $create_user_stmt, $hashedPassword ); $create_user_show = sprintf( $create_user_stmt, '***' ); } } else { // Use 'SET PASSWORD' syntax for pre-5.7.6 MySQL versions // and pre-5.2.0 MariaDB versions if ($_POST['pred_password'] == 'keep') { $password_set_real = sprintf( $password_set_stmt, $slashedUsername, $slashedHostname, $slashedPassword ); } elseif ($_POST['pred_password'] == 'none') { $password_set_real = sprintf( $password_set_stmt, $slashedUsername, $slashedHostname, null ); } else { $hashedPassword = self::getHashedPassword($_POST['pma_pw']); $password_set_real = sprintf( $password_set_stmt, $slashedUsername, $slashedHostname, $hashedPassword ); } } $alter_real_sql_query = ''; $alter_sql_query = ''; if (($serverType == 'MySQL' || $serverType == 'Percona Server') && $serverVersion >= 80011) { $sql_query_stmt = ''; if ((isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y') || (isset($GLOBALS['Grant_priv']) && $GLOBALS['Grant_priv'] == 'Y') ) { $sql_query_stmt = ' WITH GRANT OPTION'; } $real_sql_query .= $sql_query_stmt; $sql_query .= $sql_query_stmt; $alter_sql_query_stmt = sprintf( 'ALTER USER \'%s\'@\'%s\'', $slashedUsername, $slashedHostname ); $alter_real_sql_query = $alter_sql_query_stmt; $alter_sql_query = $alter_sql_query_stmt; } // add REQUIRE clause $require_clause = self::getRequireClause(); $with_clause = self::getWithClauseForAddUserAndUpdatePrivs(); if (($serverType == 'MySQL' || $serverType == 'Percona Server') && $serverVersion >= 80011) { $alter_real_sql_query .= $require_clause; $alter_sql_query .= $require_clause; $alter_real_sql_query .= $with_clause; $alter_sql_query .= $with_clause; } else { $real_sql_query .= $require_clause; $sql_query .= $require_clause; $real_sql_query .= $with_clause; $sql_query .= $with_clause; } if (isset($create_user_real)) { $create_user_real .= ';'; $create_user_show .= ';'; } if ($alter_real_sql_query !== '') { $alter_real_sql_query .= ';'; $alter_sql_query .= ';'; } $real_sql_query .= ';'; $sql_query .= ';'; // No Global GRANT_OPTION privilege if (!$GLOBALS['is_grantuser']) { $real_sql_query = ''; $sql_query = ''; } // Use 'SET PASSWORD' for pre-5.7.6 MySQL versions // and pre-5.2.0 MariaDB if (($serverType == 'MySQL' && $serverVersion >= 50706) || ($serverType == 'MariaDB' && $serverVersion >= 50200) ) { $password_set_real = null; $password_set_show = null; } else { if ($password_set_real !== null) { $password_set_real .= ";"; } $password_set_show .= ";"; } return array( $create_user_real, $create_user_show, $real_sql_query, $sql_query, $password_set_real, $password_set_show, $alter_real_sql_query, $alter_sql_query ); } /** * Returns the type ('PROCEDURE' or 'FUNCTION') of the routine * * @param string $dbname database * @param string $routineName routine * * @return string type */ public static function getRoutineType($dbname, $routineName) { $routineData = $GLOBALS['dbi']->getRoutines($dbname); foreach ($routineData as $routine) { if ($routine['name'] === $routineName) { return $routine['type']; } } return ''; } }