#!/usr/bin/php5 next()) { $matches = array(); $comment = ""; // Match any of the following: // ... - _MATCH_ // ... (_MATCH_) // \pL means 'any unicode letter' if (preg_match('/([\pL- ]+)(\((.*)\)| +- +(.*))$/', $full, $matches)) { $full_name = trim($matches[1]); $comment = trim($matches[count($matches) - 1]); } else { $full_name = $full; } $matches = array(); if (preg_match('/^([\pL.-]+) +(.*)/u', $full_name, &$matches)) { $dir_name = mb_strtoupper(trim($matches[2])) . " " . ucwords(trim($matches[1])); if ($comment != "") { if ($nb_assos > 1) { $errors[$hruid] = "Can't update comment to |$comment|: more than one asso ($nb_assos)."; continue; } if ($comm != null && $comm != "") { $errors[$hruid] = "Can't update comment to |$comment|: comment already set to |$comm|."; continue; } } echo "$hruid: |$full| => |$dir_name| (display: |$display|"; if ($comment != "") { echo "; comment: |$comment|"; } echo ").\n"; XDB::execute('UPDATE accounts SET directory_name = {?} WHERE hruid = {?}', $dir_name, $hruid); if ($comment != "") { XDB::execute('UPDATE group_members SET comm = {?} WHERE uid = {?} AND asso_id = {?}', $comm, $uid, $asso); } } else { $errors[$hruid] = "Unable to match |$full|."; } } echo "== ERRORS ==\n"; foreach($errors as $hruid => $error) { echo "$hruid\n\t$error\n"; } ?>