Changeset 14150
- Timestamp:
- 06/18/12 11:52:43 (1 year ago)
- Files:
-
- modules/branches/2.10/backup/functions.inc/class.backup.php (modified) (5 diffs)
- modules/branches/2.10/core/page.advancedsettings.php (modified) (1 diff)
- modules/branches/2.10/fax/bin/fax2mail.php (modified) (3 diffs)
- modules/branches/2.10/fax/functions.inc.php (modified) (7 diffs)
- modules/branches/2.10/fax/install.php (modified) (1 diff)
- modules/branches/2.10/findmefollow/functions.inc.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.10/backup/functions.inc/class.backup.php
r14037 r14150 93 93 94 94 function init() { 95 //$this->b['_dirpath'] = $this->amp_conf['ASTSPOOLDIR'] . '/backup/' . $this->b['_dirname'];95 $this->b['_dirpath'] = $this->amp_conf['ASTSPOOLDIR'] . '/backup/' . $this->b['_dirname']; 96 96 $this->b['_tmpdir'] = $this->amp_conf['ASTSPOOLDIR'] . '/tmp/backup-' . $this->b['id']; 97 97 $this->b['_tmpfile'] = $this->amp_conf['ASTSPOOLDIR'] . '/tmp/' . $this->b['_file'] . '.tgz'; … … 360 360 $cmd[] = $s['key']; 361 361 $cmd[] = $s['user'] . '\@' . $s['host']; 362 $cmd[] = '-p ' . $s['port']; 362 363 $cmd[] = 'mkdir -p ' . $s['path'] 363 364 . '/' . $this->b['_dirname']; … … 369 370 $cmd[] = fpbx_which('scp'); 370 371 $cmd[] = '-o StrictHostKeyChecking=no -i'; 372 $cmd[] = '-P ' . $s['port']; 371 373 $cmd[] = $s['key']; 372 374 $cmd[] = $this->b['_tmpfile']; … … 511 513 $cmd[] = $data['key']; 512 514 $cmd[] = $data['user'] . '\@' . $data['host']; 515 $cmd[] = '-p ' . $data['port']; 513 516 $cmd[] = 'ls -1 ' . $data['path'] . '/' . $this->b['_dirname']; 514 517 exec(implode(' ', $cmd), $dir); … … 568 571 $cmd[] = $data['key']; 569 572 $cmd[] = $data['user'] . '\@' . $data['host']; 573 $cmd[] = '-p ' . $data['port']; 570 574 $cmd[] = 'rm ' . $data['path'] . '/' . '/' . $this->b['_dirname'] . '/' . $file; 571 575 exec(implode(' ', $cmd)); modules/branches/2.10/core/page.advancedsettings.php
r13399 r14150 36 36 case 'AMPMGRUSER': 37 37 fpbx_ami_update($var['value'], false); 38 break; 39 case 'ASTMGRWRITETIMEOUT': 40 fpbx_ami_update(false, false, true); 38 41 break; 39 42 } modules/branches/2.10/fax/bin/fax2mail.php
r13919 r14150 7 7 } 8 8 9 exec('/bin/hostname', $hostname); 10 $var['hostname'] = $hostname[0]; 9 $var['hostname'] = gethostname(); 11 10 $var['from'] = sql('SELECT value FROM fax_details WHERE `key` = "sender_address"','getOne'); 12 11 $var['from'] = $var['from'] ? $var['from'] : 'fax@freepbx.pbx'; … … 14 13 $var = array_merge($var, get_opt()); 15 14 $var['callerid'] = $var['callerid'] === true ? '' : $var['callerid'];//prevent callerid from being blank 15 $var['keep_file'] = $var['delete'] == 'true' ? false : true; 16 16 17 //double check some of the options17 //double check some of the options 18 18 foreach ($var as $k => $v) { 19 19 switch ($k) { … … 42 42 43 43 //if file is a tif, try to convert it to a pdf 44 $var['file'] = fax_tiff2pdf($var['file']) == true 45 ? substr($var['file'], 0, strrpos($var['file'], '.')) . '.pdf' 46 : $var['file']; 44 $var['file'] = fax_file_convert('tif2pdf', $var['file'], '', $var['keep_file']); 47 45 48 46 $msg = 'Enclosed, please find a new fax '; modules/branches/2.10/fax/functions.inc.php
r13956 r14150 140 140 function fax_delete_incoming($extdisplay){ 141 141 global $db; 142 $opts=explode('/', $extdisplay);$extension=$opts['0'];$cidnum=$opts['1']; //set vars 143 sql("DELETE FROM fax_incoming WHERE cidnum = '".$db->escapeSimple($cidnum)."' and extension = '".$db->escapeSimple($extension)."'"); 142 $opts = explode('/', $extdisplay); 143 $extension = $opts['0']; 144 $cidnum = $opts['1']; //set vars 145 sql("DELETE FROM fax_incoming WHERE cidnum = '" 146 . $db->escapeSimple($cidnum) 147 . "' and extension = '" 148 . $db->escapeSimple($extension) 149 . "'"); 144 150 } 145 151 146 152 function fax_delete_user($faxext) { 147 153 global $db; 148 $faxext =$db->escapeSimple($faxext);149 sql('DELETE FROM fax_users where user = "' .$faxext.'"');154 $faxext = $db->escapeSimple($faxext); 155 sql('DELETE FROM fax_users where user = "' . $faxext . '"'); 150 156 } 151 157 … … 256 262 $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: ${FAX_FOR}, From: ${CALLERID(all)}')); 257 263 $ext->add($context, $exten, '', new ext_set('FAX_RX_EMAIL', $row['faxemail'])); 258 $ext->add($context, $exten, 'receivefax', new ext_goto('receivefax','s'));264 $ext->add($context, $exten, 'receivefax', new ext_goto('receivefax','s')); 259 265 } 260 266 } … … 315 321 $ext->add($context, $exten, '', new ext_noop_trace('PROCESSING FAX with status: [${FAXSTATUS}] for: [${FAX_RX_EMAIL}], From: [${CALLERID(all)}]')); 316 322 $ext->add($context, $exten, 'process', new ext_gotoif('$[${LEN(${FAX_RX_EMAIL})} = 0]','noemail')); 317 $ext->add($context, $exten, '', new ext_system('${ASTVARLIBDIR}/bin/fax2mail.php --to "${FAX_RX_EMAIL}" --dest "${FROM_DID}" --callerid \'${CALLERID(all)}\' --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif --exten "${FAX_FOR}"')); 323 //delete is a variable so that other modules can prevent it should then need to prosses the file further 324 $ext->add($context, $exten, 'delete_opt', new ext_set('DELETE_AFTER_SEND', 'true')); 325 $ext->add($context, $exten, '', new ext_system('${ASTVARLIBDIR}/bin/fax2mail.php --to "${FAX_RX_EMAIL}" --dest "${FROM_DID}" --callerid \'${CALLERID(all)}\' --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif --exten "${FAX_FOR}" --delete "${DELETE_AFTER_SEND}"')); 318 326 319 327 $ext->add($context, $exten, 'end', new ext_macro('hangupcall')); … … 391 399 } 392 400 393 function fax_get_user($faxext ){401 function fax_get_user($faxext = ''){ 394 402 global $db; 395 if($faxext){ 396 $sql="SELECT * FROM fax_users WHERE user = '".$faxext."'"; 397 $settings = $db->getRow($sql, DB_FETCHMODE_ASSOC); 398 }else{ 399 $sql="SELECT * FROM fax_users"; 400 $settings = $db->getAll($sql, DB_FETCHMODE_ASSOC); 401 } 402 if(!is_array($settings)){$settings=array();}//make sure were retuning an array (even if its blank) 403 if ($faxext) { 404 $sql = "SELECT * FROM fax_users WHERE user = ?"; 405 $settings = $db->getRow($sql, array($faxext), DB_FETCHMODE_ASSOC); 406 } else { 407 $sql = "SELECT * FROM fax_users"; 408 $settings = $db->getAll($sql, DB_FETCHMODE_ASSOC); 409 } 410 db_e($settings); 411 412 //make sure were retuning an array (even if its blank) 413 if (!is_array($settings)) { 414 $settings = array(); 415 } 416 403 417 return $settings; 404 418 } … … 427 441 if(!$extension && !$cidnum){//set $extension,$cidnum if we dont already have them 428 442 if ($extdisplay) { 429 $opts =explode('/', $extdisplay);430 $extension =$opts['0'];431 $cidnum =$opts['1'];443 $opts = explode('/', $extdisplay); 444 $extension = $opts['0']; 445 $cidnum = isset($opts['1']) ? $opts['1'] : ''; 432 446 } else { 433 447 $extension = $cidnum = ''; … … 625 639 } 626 640 627 function fax_save_user($faxext,$faxenabled,$faxemail ){641 function fax_save_user($faxext,$faxenabled,$faxemail = '') { 628 642 global $db; 629 $faxext=$db->escapeSimple($faxext); 630 $faxenabled=$db->escapeSimple($faxenabled); 631 $faxemail=$db->escapeSimple($faxemail); 632 sql('REPLACE INTO fax_users (user, faxenabled, faxemail) VALUES ("'.$faxext.'","'.$faxenabled.'","'.$faxemail.'")'); 643 $sql = 'REPLACE INTO fax_users (user, faxenabled, faxemail) VALUES (?, ?, ?)'; 644 $ret = $db->query($sql, array($faxext, $faxenabled, $faxemail)); 645 db_e($ret); 646 647 return true; 633 648 } 634 649 635 650 function fax_sip_faxdetect(){ 636 651 global $asterisk_conf; 637 return true;652 return true; 638 653 } 639 654 … … 662 677 } 663 678 664 function fax_tiff2pdf($file){ 665 exec('which tiff2pdf', $t2p); 666 $t2p = $t2p[0]; 667 if (!$t2p) { 679 /** 680 * Converts a file to different format 681 * @param string - conversion type in the format of 'from2to' 682 * @param string - path to origional file 683 * @param string - path to save new file 684 * @param bool - wether to keep or delete the orgional file 685 * 686 * @return string - path to fresh pdf 687 * 688 * Supported conversions: 689 * - pdf2tiff 690 * - tif2pdf 691 * - ps2tif 692 */ 693 function fax_file_convert($type, $in, $out = '', $keep_orig = false, $opts = array()) { 694 global $amp_conf; 695 //ensure file exists 696 if (!is_file($in)) { 668 697 return false; 669 698 } 670 699 671 //make pdf 672 $cmd = $t2p . ' -z -c "Converted by FreePBX" -a "www.freepbx.org" -o ' 673 . substr($file, 0, strrpos($file, '.')) . '.pdf' . ' ' . $file; 674 exec($cmd, $o, $error); 675 676 return $error === 0 ? true : false; 700 //set out filename if not specified 701 if (!$out) { 702 switch ($type) { 703 case 'pdf2tif': 704 case 'ps2tif': 705 $ext = '.tif'; 706 break; 707 case 'tif2pdf': 708 $ext = '.pdf'; 709 break; 710 } 711 $pathinfo = pathinfo($in); 712 $out = $pathinfo['dirname'] 713 . '/' 714 . $pathinfo['filename'] 715 . $ext; 716 } 717 718 //if file exists, assume its been converted already 719 if (file_exists($out)) { 720 return $out; 721 } 722 723 //ensure cli command exists 724 switch ($type) { 725 case 'pdf2tif': 726 case 'ps2tif': 727 $gs = fpbx_which('gs'); 728 if (!$gs) { 729 dbug('gs not found, not converting ' . $in); 730 return $in; 731 } 732 $gs = $gs . ' -q -dNOPAUSE -dBATCH -sPAPERSIZE=letter '; 733 break; 734 case 'tif2pdf': 735 $tiff2pdf = fpbx_which('tiff2pdf'); 736 if (!$tiff2pdf) { 737 dbug('tiff2pdf not found, not converting ' . $in); 738 return $in; 739 } 740 break; 741 } 742 743 //convert! 744 switch ($type) { 745 case 'pdf2tif': 746 case 'ps2tif': 747 $cmd = $gs 748 . '-sDEVICE=tiffg4 ' 749 . '-sOutputFile=' . $out . ' ' . $in; 750 break; 751 case 'tif2pdf': 752 $cmd = $tiff2pdf 753 . ' -z ' 754 . '-c "PBXact by Schmooze Communications" ' 755 . '-a "' . $amp_conf['PDFAUTHOR'] . '" ' 756 . (isset($opts['title']) ? '-t "' . $opts['title'] . '" ' : '') 757 . '-o ' . $out . ' ' . $in; 758 break; 759 default: 760 break; 761 } 762 763 exec($cmd, $ret, $status); 764 765 //remove original 766 if ($status === 0 && !$keep_orig) { 767 unlink($in); 768 } 769 770 return $status === 0 ? $out : $in; 771 } 772 773 /** 774 * Get info on a tiff file. Require tiffinfo 775 * @param string - absolute path to file 776 * @param string - specifc option to receive 777 * 778 * @return mixed - if $opt & exists returns a string, else bool false, 779 * otherwise an array of details 780 */ 781 function fax_tiffinfo($file, $opt = '') { 782 //ensure file exists 783 if (!is_file($file)) { 784 return false; 785 } 786 787 $tiffinfo = fpbx_which('tiffinfo'); 788 $info = array(); 789 790 if (!$tiffinfo) { 791 return false; 792 } 793 exec($tiffinfo . ' ' . $file, $output); 794 795 if ($output && strpos($output[0], 'Not a TIFF or MDI file') === 0) { 796 return false; 797 } 798 799 foreach ($output as $out) { 800 $o = explode(':', $out, 2); 801 $info[trim($o[0])] = isset($o[1]) ? trim($o[1]) : ''; 802 } 803 804 if (!$info) { 805 return false; 806 } 807 808 //special case prossesing 809 //Page Number: defualt format = 0-0. Use only first set of digits, increment by 1 810 $info['Page Number'] = explode('-', $info['Page Number']); 811 $info['Page Number'] = $info['Page Number'][0] + 1; 812 813 if ($opt) { 814 return isset($info[$opt]) ? $info[$opt] : false; 815 } 816 817 return $info; 677 818 } 678 819 ?> modules/branches/2.10/fax/install.php
r13091 r14150 272 272 out(_("already done")); 273 273 } 274 275 $set['value'] = 'www.freepbx.org'; 276 $set['defaultval'] =& $set['value']; 277 $set['readonly'] = 1; 278 $set['hidden'] = 1; 279 $set['module'] = ''; 280 $set['category'] = 'Styling and Logos'; 281 $set['emptyok'] = 0; 282 $set['name'] = 'tiff2pdf Author'; 283 $set['description'] = "Author to pass to tiff2pdf's -a option"; 284 $set['type'] = CONF_TYPE_TEXT; 285 $freepbx_conf =& freepbx_conf::create(); 286 $freepbx_conf->define_conf_setting('PDFAUTHOR', $set, true); 274 287 ?> modules/branches/2.10/findmefollow/functions.inc.php
r14132 r14150 544 544 // extensions and users. 545 545 // 546 if ( $amp_conf['FOLLOWME_AUTO_CREATE']) {546 if (isset($amp_conf['FOLLOWME_AUTO_CREATE']) && $amp_conf['FOLLOWME_AUTO_CREATE']) { 547 547 function findmefollow_configprocess() { 548 548 global $amp_conf;
