Changeset 10753 for modules/branches
- Timestamp:
- 12/29/10 16:15:57 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/bootstrap-2.9/directory/agi-bin/directory.agi
r10680 r10753 4 4 set_error_handler("error_handler"); 5 5 6 dbug('entered dir!');6 verbose('entered dir!',6); 7 7 require_once(dirname(__FILE__).'/directory.lib.php'); 8 8 $loopcounter1 = 0; … … 57 57 if ($matches > 9) { 58 58 $search = rtrim($search,'#'); 59 dbug("Too many found: $matches, remove # if set and try again");59 verbose("Too many found: $matches, remove # if set and try again",6); 60 60 } 61 61 } else { … … 75 75 $validkeys .= $i; 76 76 } 77 dbug("valid keys for entries are: $validkeys");77 verbose("valid keys for entries are: $validkeys",6); 78 78 79 79 //playback entries … … 104 104 } 105 105 106 dbug("got result: ".$ret['result']);106 verbose("got result: ".$ret['result'],6); 107 107 if (trim($ret['result'])) { 108 108 call($matches[$ret['result']-1]); … … 136 136 } 137 137 138 //send debug to asterisk cli 139 function verbose($string, $level=3){ 140 global $dir; 141 $dir->agi->verbose($string, $level); 142 143 // send same message to debug log if enabled 144 dbug($string); 145 } 138 146 139 147 /* modules/branches/bootstrap-2.9/directory/agi-bin/directory.lib.php
r10680 r10753 106 106 $res=$this->db->getAll($sql,DB_FETCHMODE_ASSOC); 107 107 if(DB::IsError($res)) { 108 dbug("FATAL: got error from getAll query",1);109 dbug($res->get dbugInfo());108 verbose("FATAL: got error from getAll query",1); 109 dbug($res->getDebugInfo()); 110 110 } 111 111 $rec_file = array(); … … 168 168 $vm_dir = $this->agi->database_get('AMPUSER',$con['dial'].'/voicemail'); 169 169 $vm_dir = $vm_dir['data']; 170 dbug("got directory $vm_dir for user {$con['dial']}",6);170 verbose("got directory $vm_dir for user {$con['dial']}",6); 171 171 //check to see if we have a greet.* and play it. otherwise, fallback to spelling the name 172 172 if ($vm_dir && $vm_dir != 'novm') { … … 176 176 $dir = scandir($this->vmbasedir.$vm_dir.'/'.$con['dial']); 177 177 foreach ($dir as $file) { 178 dbug("looking for vm file $file using: ".basename($file),6);178 verbose("looking for vm file $file using: ".basename($file),6); 179 179 if (substr($file,0,5) == 'greet' && is_file($this->vmbasedir.$vm_dir.'/'.$con['dial'].'/'.$file)) { 180 180 $ret = $this->agi->stream_file($this->vmbasedir . $vm_dir . '/' . $con['dial'] . '/greet',$ keys); … … 216 216 $sql = 'SELECT filename from recordings where id = ?'; 217 217 $rec = $this->db->getOne($sql, array($con['audio'])); 218 dbug("got record id: {$con['audio']} file(s): $rec");218 verbose("got record id: {$con['audio']} file(s): $rec"); 219 219 if ($rec) { 220 220 $rec = explode('&',$rec); … … 228 228 } else { 229 229 //TODO: handle error 230 dbug("ERROR: unknown/undefined sound file");230 verbose("ERROR: unknown/undefined sound file"); 231 231 } 232 232 } … … 242 242 243 243 if (strstr($key,'0') !== false) { 244 dbug("user pressed 0 - bailing out");244 verbose("user pressed 0 - bailing out"); 245 245 $this->bail(); 246 246 } … … 250 250 $alph = array("[ \s@,-\!/+=\.']",'[abcABC]','[defDEF]','[ghiGHI]','[jklJKL]','[mnoMNO]','[pqrsPQRS]','[tuvTUV]','[wxyzWXYZ]','',''); 251 251 $this->searchstring = $this->db->escapeSimple(str_replace($num,$alph,$key)); 252 dbug("search string for regex: {$this->searchstring}",6);252 verbose("search string for regex: {$this->searchstring}",6); 253 253 254 254 //TODO: check db results for errors and fail gracefully … … 258 258 $res=$this->db->getOne($sql); 259 259 if (DB::IsError($res)) { 260 dbug("FATAL: got error from COUNT(*) query");261 dbug($res->get dbugInfo());262 } 263 dbug("Found $res possible matches from $key");260 verbose("FATAL: got error from COUNT(*) query"); 261 dbug($res->getDebugInfo()); 262 } 263 verbose("Found $res possible matches from $key"); 264 264 } else { 265 265 $sql = "SELECT * FROM $vtable WHERE name REGEXP \"(^| ){$this->searchstring}\""; 266 266 $res = $this->db->getAll($sql,DB_FETCHMODE_ASSOC); 267 267 if (DB::IsError($res)) { 268 dbug("FATAL: got error from getAll query");269 dbug($res->get dbugInfo());268 verbose("FATAL: got error from getAll query"); 269 dbug($res->getDebugInfo()); 270 270 } else { 271 dbug("Found the following matches:");271 verbose("Found the following matches:",6); 272 272 foreach ($res as $ent) { 273 dbug("name: {$ent['name']}, audio: {$ent['audio']}, dial: {$ent['dial']}");273 verbose("name: {$ent['name']}, audio: {$ent['audio']}, dial: {$ent['dial']}",6); 274 274 } 275 275 } … … 280 280 function bail() { 281 281 //do something if we are exiting due to to many tries 282 dbug("User pressed zero, passing back recording of {$this->dir['invalid_recording']}");282 verbose("User pressed zero, passing back recording of {$this->dir['invalid_recording']}"); 283 283 $this->agi->set_variable('DIR_INVALID_RECORDING',$this->dir['invalid_recording']); 284 284 if ($this->agi_get_var('IVR_CONTEXT')) { … … 296 296 297 297 } 298 298 // PHP 4 does not have file_put_contents so create an aproximation of what the real function does 299 // TODO: get rid of extinc php4 stuff as we dont support it anymore 300 // 301 if (!function_exists('file_put_contents')) { 302 function file_put_contents($filename, $data, $flags='', $context=null) { 303 $option = $flags == FILE_APPEND ? 'a' : 'w'; 304 if ($context !== null) { 305 $fd = @fopen($filename, $option); 306 } else { 307 $fd = @fopen($filename, $option, false, $context); 308 } 309 if (!$fd) { 310 return false; 311 } 312 if (is_array($data)) { 313 $data = implode('',$data); 314 } else if (is_object($data)) { 315 $data = print_r($data,true); 316 } 317 $bytes = fwrite($fd,$data); 318 fclose($fd); 319 320 return $bytes; 321 } 322 } 323 if (!function_exists('scandir')) { 324 function scandir($path,$sort=0) { 325 $fh = opendir($path); 326 $list = array(); 327 while(false !== ($filename = readdir($fh))) { 328 $list[] = $filename; 329 } 330 closedir($fh); 331 /* Not really needed here 332 if ($sort) { 333 sort($list); 334 } else { 335 rsort($list); 336 } 337 */ 338 return $list; 339 } 340 } 341 342 // non-utf8 version for php4 343 if(!function_exists('str_split')) { 344 function str_split($string, $split_length = 1) { 345 $array = explode("\r\n", chunk_split($string, $split_length)); 346 array_pop($array); 347 return $array; 348 } 349 } 299 350 ?>
