- Timestamp:
- Mar 31, 2009, 5:31:30 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
locker/sql/bin/get-password
r382 r1037 12 12 global $env_user; 13 13 $cnfFile = file_get_contents($path); 14 preg_match('/\[mysql\][^\[]*host=([^\n]*)/',$cnfFile,$match); 15 $host = $match[1]; 16 preg_match('/\[mysql\][^\[]*user=([^\n]*)/',$cnfFile,$match); 17 $user = $match[1]; 18 preg_match('/\[mysql\][^\[]*password=([^\n]*)/',$cnfFile,$match); 19 $password = $match[1]; 20 if (empty($host)) $host = 'sql.mit.edu'; 21 if (empty($user)) $user = $env_user; 22 if (empty($password)) $password = 'password'; 14 if (preg_match('/\[mysql\][^\[]*host *= *([^\n]*)/',$cnfFile,$match)) { 15 $host = $match[1]; 16 } elseif (preg_match('/\[client\][^\[]*host *= *([^\n]*)/',$cnfFile,$match)) { 17 $host = $match[1]; 18 } else { 19 $host = 'sql.mit.edu'; 20 } 21 if (preg_match('/\[mysql\][^\[]*user *= *([^\n]*)/',$cnfFile,$match)) { 22 $user = $match[1]; 23 } elseif (preg_match('/\[client\][^\[]*user *= *([^\n]*)/',$cnfFile,$match)) { 24 $user = $match[1]; 25 } else { 26 $user = $env_user; 27 } 28 if (preg_match('/\[mysql\][^\[]*password *= *([^\n]*)/',$cnfFile,$match)) { 29 $password = $match[1]; 30 } elseif (preg_match('/\[client\][^\[]*password *= *([^\n]*)/',$cnfFile,$match)) { 31 $password = $match[1]; 32 } else { 33 $password = 'password'; 34 } 23 35 return array($host,$user,$password); 24 36 }
Note: See TracChangeset
for help on using the changeset viewer.