/libraries/classes/Config/SpecialSchemaLinks.php

http://github.com/phpmyadmin/phpmyadmin · PHP · 485 lines · 425 code · 7 blank · 53 comment · 0 complexity · 006d33a89e29711418451574258c4c35 MD5 · raw file

  1. <?php
  2. /**
  3. * Links configuration for MySQL system tables
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Config;
  7. use PhpMyAdmin\Url;
  8. use PhpMyAdmin\Util;
  9. class SpecialSchemaLinks
  10. {
  11. /**
  12. * This array represent the details for generating links inside
  13. * special schemas like mysql, information_schema etc.
  14. * Major element represent a schema.
  15. * All the strings in this array represented in lower case
  16. *
  17. * Array structure ex:
  18. * array(
  19. * // Database name is the major element
  20. * 'mysql' => array(
  21. * // Table name
  22. * 'db' => array(
  23. * // Column name
  24. * 'user' => array(
  25. * // Main url param (can be an array where represent sql)
  26. * 'link_param' => 'username',
  27. * // Other url params
  28. * 'link_dependancy_params' => array(
  29. * 0 => array(
  30. * // URL parameter name
  31. * // (can be array where url param has static value)
  32. * 'param_info' => 'hostname',
  33. * // Column name related to url param
  34. * 'column_name' => 'host'
  35. * )
  36. * ),
  37. * // Page to link
  38. * 'default_page' => './' . Url::getFromRoute('/server/privileges')
  39. * )
  40. * )
  41. * )
  42. * );
  43. *
  44. * @return array<string,array<string,array<string,array<string,array<int,array<string,string>>|string>>>>
  45. * @phpstan-return array<
  46. * string, array<
  47. * string, array<
  48. * string,
  49. * array{
  50. * 'link_param': string,
  51. * 'link_dependancy_params'?: array<
  52. * int,
  53. * array{'param_info': string, 'column_name': string}
  54. * >,
  55. * 'default_page': string
  56. * }>
  57. * >
  58. * >
  59. * }
  60. */
  61. public static function get(): array
  62. {
  63. global $cfg;
  64. $defaultPage = './' . Util::getScriptNameForOption($cfg['DefaultTabTable'], 'table');
  65. return [
  66. 'mysql' => [
  67. 'columns_priv' => [
  68. 'user' => [
  69. 'link_param' => 'username',
  70. 'link_dependancy_params' => [
  71. 0 => [
  72. 'param_info' => 'hostname',
  73. 'column_name' => 'host',
  74. ],
  75. ],
  76. 'default_page' => './' . Url::getFromRoute('/server/privileges'),
  77. ],
  78. 'table_name' => [
  79. 'link_param' => 'table',
  80. 'link_dependancy_params' => [
  81. 0 => [
  82. 'param_info' => 'db',
  83. 'column_name' => 'Db',
  84. ],
  85. ],
  86. 'default_page' => $defaultPage,
  87. ],
  88. 'column_name' => [
  89. 'link_param' => 'field',
  90. 'link_dependancy_params' => [
  91. 0 => [
  92. 'param_info' => 'db',
  93. 'column_name' => 'Db',
  94. ],
  95. 1 => [
  96. 'param_info' => 'table',
  97. 'column_name' => 'Table_name',
  98. ],
  99. ],
  100. 'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
  101. ],
  102. ],
  103. 'db' => [
  104. 'user' => [
  105. 'link_param' => 'username',
  106. 'link_dependancy_params' => [
  107. 0 => [
  108. 'param_info' => 'hostname',
  109. 'column_name' => 'host',
  110. ],
  111. ],
  112. 'default_page' => './' . Url::getFromRoute('/server/privileges'),
  113. ],
  114. ],
  115. 'event' => [
  116. 'name' => [
  117. 'link_param' => 'item_name',
  118. 'link_dependancy_params' => [
  119. 0 => [
  120. 'param_info' => 'db',
  121. 'column_name' => 'db',
  122. ],
  123. ],
  124. 'default_page' => './' . Url::getFromRoute('/database/events', ['edit_item' => 1]),
  125. ],
  126. ],
  127. 'innodb_index_stats' => [
  128. 'table_name' => [
  129. 'link_param' => 'table',
  130. 'link_dependancy_params' => [
  131. 0 => [
  132. 'param_info' => 'db',
  133. 'column_name' => 'database_name',
  134. ],
  135. ],
  136. 'default_page' => $defaultPage,
  137. ],
  138. 'index_name' => [
  139. 'link_param' => 'index',
  140. 'link_dependancy_params' => [
  141. 0 => [
  142. 'param_info' => 'db',
  143. 'column_name' => 'database_name',
  144. ],
  145. 1 => [
  146. 'param_info' => 'table',
  147. 'column_name' => 'table_name',
  148. ],
  149. ],
  150. 'default_page' => './' . Url::getFromRoute('/table/structure'),
  151. ],
  152. ],
  153. 'innodb_table_stats' => [
  154. 'table_name' => [
  155. 'link_param' => 'table',
  156. 'link_dependancy_params' => [
  157. 0 => [
  158. 'param_info' => 'db',
  159. 'column_name' => 'database_name',
  160. ],
  161. ],
  162. 'default_page' => $defaultPage,
  163. ],
  164. ],
  165. 'proc' => [
  166. 'name' => [
  167. 'link_param' => 'item_name',
  168. 'link_dependancy_params' => [
  169. 0 => [
  170. 'param_info' => 'db',
  171. 'column_name' => 'db',
  172. ],
  173. 1 => [
  174. 'param_info' => 'item_type',
  175. 'column_name' => 'type',
  176. ],
  177. ],
  178. 'default_page' => './' . Url::getFromRoute('/database/routines', ['edit_item' => 1]),
  179. ],
  180. 'specific_name' => [
  181. 'link_param' => 'item_name',
  182. 'link_dependancy_params' => [
  183. 0 => [
  184. 'param_info' => 'db',
  185. 'column_name' => 'db',
  186. ],
  187. 1 => [
  188. 'param_info' => 'item_type',
  189. 'column_name' => 'type',
  190. ],
  191. ],
  192. 'default_page' => './' . Url::getFromRoute('/database/routines', ['edit_item' => 1]),
  193. ],
  194. ],
  195. 'proc_priv' => [
  196. 'user' => [
  197. 'link_param' => 'username',
  198. 'link_dependancy_params' => [
  199. 0 => [
  200. 'param_info' => 'hostname',
  201. 'column_name' => 'Host',
  202. ],
  203. ],
  204. 'default_page' => './' . Url::getFromRoute('/server/privileges'),
  205. ],
  206. 'routine_name' => [
  207. 'link_param' => 'item_name',
  208. 'link_dependancy_params' => [
  209. 0 => [
  210. 'param_info' => 'db',
  211. 'column_name' => 'Db',
  212. ],
  213. 1 => [
  214. 'param_info' => 'item_type',
  215. 'column_name' => 'Routine_type',
  216. ],
  217. ],
  218. 'default_page' => './' . Url::getFromRoute('/database/routines', ['edit_item' => 1]),
  219. ],
  220. ],
  221. 'proxies_priv' => [
  222. 'user' => [
  223. 'link_param' => 'username',
  224. 'link_dependancy_params' => [
  225. 0 => [
  226. 'param_info' => 'hostname',
  227. 'column_name' => 'Host',
  228. ],
  229. ],
  230. 'default_page' => './' . Url::getFromRoute('/server/privileges'),
  231. ],
  232. ],
  233. 'tables_priv' => [
  234. 'user' => [
  235. 'link_param' => 'username',
  236. 'link_dependancy_params' => [
  237. 0 => [
  238. 'param_info' => 'hostname',
  239. 'column_name' => 'Host',
  240. ],
  241. ],
  242. 'default_page' => './' . Url::getFromRoute('/server/privileges'),
  243. ],
  244. 'table_name' => [
  245. 'link_param' => 'table',
  246. 'link_dependancy_params' => [
  247. 0 => [
  248. 'param_info' => 'db',
  249. 'column_name' => 'Db',
  250. ],
  251. ],
  252. 'default_page' => $defaultPage,
  253. ],
  254. ],
  255. 'user' => [
  256. 'user' => [
  257. 'link_param' => 'username',
  258. 'link_dependancy_params' => [
  259. 0 => [
  260. 'param_info' => 'hostname',
  261. 'column_name' => 'host',
  262. ],
  263. ],
  264. 'default_page' => './' . Url::getFromRoute('/server/privileges'),
  265. ],
  266. ],
  267. ],
  268. 'information_schema' => [
  269. 'columns' => [
  270. 'table_name' => [
  271. 'link_param' => 'table',
  272. 'link_dependancy_params' => [
  273. 0 => [
  274. 'param_info' => 'db',
  275. 'column_name' => 'table_schema',
  276. ],
  277. ],
  278. 'default_page' => $defaultPage,
  279. ],
  280. 'column_name' => [
  281. 'link_param' => 'field',
  282. 'link_dependancy_params' => [
  283. 0 => [
  284. 'param_info' => 'db',
  285. 'column_name' => 'table_schema',
  286. ],
  287. 1 => [
  288. 'param_info' => 'table',
  289. 'column_name' => 'table_name',
  290. ],
  291. ],
  292. 'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
  293. ],
  294. ],
  295. 'key_column_usage' => [
  296. 'table_name' => [
  297. 'link_param' => 'table',
  298. 'link_dependancy_params' => [
  299. 0 => [
  300. 'param_info' => 'db',
  301. 'column_name' => 'constraint_schema',
  302. ],
  303. ],
  304. 'default_page' => $defaultPage,
  305. ],
  306. 'column_name' => [
  307. 'link_param' => 'field',
  308. 'link_dependancy_params' => [
  309. 0 => [
  310. 'param_info' => 'db',
  311. 'column_name' => 'table_schema',
  312. ],
  313. 1 => [
  314. 'param_info' => 'table',
  315. 'column_name' => 'table_name',
  316. ],
  317. ],
  318. 'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
  319. ],
  320. 'referenced_table_name' => [
  321. 'link_param' => 'table',
  322. 'link_dependancy_params' => [
  323. 0 => [
  324. 'param_info' => 'db',
  325. 'column_name' => 'referenced_table_schema',
  326. ],
  327. ],
  328. 'default_page' => $defaultPage,
  329. ],
  330. 'referenced_column_name' => [
  331. 'link_param' => 'field',
  332. 'link_dependancy_params' => [
  333. 0 => [
  334. 'param_info' => 'db',
  335. 'column_name' => 'referenced_table_schema',
  336. ],
  337. 1 => [
  338. 'param_info' => 'table',
  339. 'column_name' => 'referenced_table_name',
  340. ],
  341. ],
  342. 'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
  343. ],
  344. ],
  345. 'partitions' => [
  346. 'table_name' => [
  347. 'link_param' => 'table',
  348. 'link_dependancy_params' => [
  349. 0 => [
  350. 'param_info' => 'db',
  351. 'column_name' => 'table_schema',
  352. ],
  353. ],
  354. 'default_page' => $defaultPage,
  355. ],
  356. ],
  357. 'processlist' => [
  358. 'user' => [
  359. 'link_param' => 'username',
  360. 'link_dependancy_params' => [
  361. 0 => [
  362. 'param_info' => 'hostname',
  363. 'column_name' => 'host',
  364. ],
  365. ],
  366. 'default_page' => './' . Url::getFromRoute('/server/privileges'),
  367. ],
  368. ],
  369. 'referential_constraints' => [
  370. 'table_name' => [
  371. 'link_param' => 'table',
  372. 'link_dependancy_params' => [
  373. 0 => [
  374. 'param_info' => 'db',
  375. 'column_name' => 'constraint_schema',
  376. ],
  377. ],
  378. 'default_page' => $defaultPage,
  379. ],
  380. 'referenced_table_name' => [
  381. 'link_param' => 'table',
  382. 'link_dependancy_params' => [
  383. 0 => [
  384. 'param_info' => 'db',
  385. 'column_name' => 'constraint_schema',
  386. ],
  387. ],
  388. 'default_page' => $defaultPage,
  389. ],
  390. ],
  391. 'routines' => [
  392. 'routine_name' => [
  393. 'link_param' => 'item_name',
  394. 'link_dependancy_params' => [
  395. 0 => [
  396. 'param_info' => 'db',
  397. 'column_name' => 'routine_schema',
  398. ],
  399. 1 => [
  400. 'param_info' => 'item_type',
  401. 'column_name' => 'routine_type',
  402. ],
  403. ],
  404. 'default_page' => './' . Url::getFromRoute('/database/routines'),
  405. ],
  406. ],
  407. 'schemata' => [
  408. 'schema_name' => [
  409. 'link_param' => 'db',
  410. 'default_page' => $defaultPage,
  411. ],
  412. ],
  413. 'statistics' => [
  414. 'table_name' => [
  415. 'link_param' => 'table',
  416. 'link_dependancy_params' => [
  417. 0 => [
  418. 'param_info' => 'db',
  419. 'column_name' => 'table_schema',
  420. ],
  421. ],
  422. 'default_page' => $defaultPage,
  423. ],
  424. 'column_name' => [
  425. 'link_param' => 'field',
  426. 'link_dependancy_params' => [
  427. 0 => [
  428. 'param_info' => 'db',
  429. 'column_name' => 'table_schema',
  430. ],
  431. 1 => [
  432. 'param_info' => 'table',
  433. 'column_name' => 'table_name',
  434. ],
  435. ],
  436. 'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
  437. ],
  438. ],
  439. 'tables' => [
  440. 'table_name' => [
  441. 'link_param' => 'table',
  442. 'link_dependancy_params' => [
  443. 0 => [
  444. 'param_info' => 'db',
  445. 'column_name' => 'table_schema',
  446. ],
  447. ],
  448. 'default_page' => $defaultPage,
  449. ],
  450. ],
  451. 'table_constraints' => [
  452. 'table_name' => [
  453. 'link_param' => 'table',
  454. 'link_dependancy_params' => [
  455. 0 => [
  456. 'param_info' => 'db',
  457. 'column_name' => 'table_schema',
  458. ],
  459. ],
  460. 'default_page' => $defaultPage,
  461. ],
  462. ],
  463. 'views' => [
  464. 'table_name' => [
  465. 'link_param' => 'table',
  466. 'link_dependancy_params' => [
  467. 0 => [
  468. 'param_info' => 'db',
  469. 'column_name' => 'table_schema',
  470. ],
  471. ],
  472. 'default_page' => $defaultPage,
  473. ],
  474. ],
  475. ],
  476. ];
  477. }
  478. }