| 1 | <?php
|
| 2 | //this file is designed to be used as an include that is part of a loop.
|
| 3 | //If a valid match is found, it should give $caller_id a value
|
| 4 | //available variables for use are: $thenumber
|
| 5 | //retreive website contents using get_url_contents($url);
|
| 6 |
|
| 7 | //configuration / display parameters
|
| 8 | //The description cannot contain "a" tags, but can contain limited HTML. Some HTML (like the a tags) will break the UI.
|
| 9 | $source_desc = "This source will send the number and the Caller ID to XBMC.<br>This datasource should be one of the 'last data sources on your list, as it does not provide any data of its own, and can only send what information has been collected 'before it is run.<br>This data source requires Superfecta Module version 2.2.3 or higher.";
|
| 10 | $source_param = array();
|
| 11 | $source_param['URL_Address']['desc'] = 'Specify The IP To The XMBC Installation. (Example: 192.168.0.155)';
|
| 12 | $source_param['URL_Address']['type'] = 'text';
|
| 13 | $source_param['URL_Address']['default'] = '192.168.0.155';
|
| 14 | $source_param['URL_Port']['desc'] = 'Specify The PORT Defined On Your XMBC Installation. (Example: 8080)';
|
| 15 | $source_param['URL_Port']['type'] = 'text';
|
| 16 | $source_param['URL_Port']['default'] = '8080';
|
| 17 | $source_param['URL_UserName']['desc'] = 'Specify The Username Defined In Your XBMC Installation. Blank For None.';
|
| 18 | $source_param['URL_UserName']['type'] = 'text';
|
| 19 | $source_param['URL_UserName']['default'] = '';
|
| 20 | $source_param['URL_PassWord']['desc'] = 'Specify The Password Defined In Your XBMC Installation. Blank For None.';
|
| 21 | $source_param['URL_PassWord']['type'] = 'text';
|
| 22 | $source_param['URL_PassWord']['default'] = '';
|
| 23 | $source_param['Change_Volume']['desc'] = 'Change Volume When Call Comes In, Range Is 100 to 0. Blank = No Change';
|
| 24 | $source_param['Change_Volume']['type'] = 'text';
|
| 25 | $source_param['Change_Volume']['default'] = '';
|
| 26 | $source_param['Pause_PlayBack']['desc'] = 'Pause Whatever Is Playing When A Call Comes In.';
|
| 27 | $source_param['Pause_PlayBack']['type'] = 'checkbox';
|
| 28 | $source_param['Pause_PlayBack']['default'] = 'off';
|
| 29 | $source_param['Format_Incomming_Number']['desc'] = 'Specify The Way You Want The Number To Be Displayed On Your XMBC';
|
| 30 | $source_param['Format_Incomming_Number']['type'] = 'select';
|
| 31 | $source_param['Format_Incomming_Number']['option'][1] = '(132) 456-7890';
|
| 32 | $source_param['Format_Incomming_Number']['option'][2] = '132-456-7890';
|
| 33 | $source_param['Format_Incomming_Number']['option'][3] = '12 34 56 78 90';
|
| 34 | $source_param['Format_Incomming_Number']['option'][4] = 'No Formatting';
|
| 35 | $source_param['Format_Incomming_Number']['default'] = 4;
|
| 36 |
|
| 37 |
|
| 38 | if($usage_mode == 'post processing')
|
| 39 | {
|
| 40 | if ($run_param['URL_Address'] && $run_param['URL_Port'] != '')
|
| 41 | {
|
| 42 | $thenumberformated = $thenumber;
|
| 43 | switch ($run_param['Format_Incomming_Number'])
|
| 44 | {
|
| 45 | case 1:
|
| 46 | if (strlen($thenumber)==10)
|
| 47 | {
|
| 48 | $thenumberformated='('.substr($thenumber,0,3).') '.substr($thenumber,3,3).'-'.substr($thenumber,6,4);
|
| 49 | }
|
| 50 | break;
|
| 51 | case 2:
|
| 52 | if (strlen($thenumber)==10)
|
| 53 | {
|
| 54 | $thenumberformated=substr($thenumber,0,3).'-'.substr($thenumber,3,3).'-'.substr($thenumber,6,4);
|
| 55 | }
|
| 56 | break;
|
| 57 | case 3:
|
| 58 | if (strlen($thenumber)==10)
|
| 59 | {
|
| 60 | $thenumberformated=substr($thenumber,0,2).' '.substr($thenumber,2,2).' '.substr($thenumber,4,2).' '.substr($thenumber,6,2).' '.substr($thenumber,8,2);
|
| 61 | }
|
| 62 | break;
|
| 63 | }
|
| 64 |
|
| 65 | $clidxbmc = urlencode($thenumberformated . ',' . $first_caller_id);
|
| 66 |
|
| 67 | $url = 'http://';
|
| 68 |
|
| 69 | if ($run_param['URL_UserName'] && $run_param['URL_PassWord'] != '')
|
| 70 | {
|
| 71 | $url = $run_param['URL_UserName'] . ':' . $run_param['URL_PassWord'] . '@';
|
| 72 | }
|
| 73 |
|
| 74 | $url1 = $url . $run_param['URL_Address'] . ':' . $run_param['URL_Port'] . '/xbmcCmds/xbmcHttp?command=SetVolume(' . $run_param['Change_Volume'] . ')';
|
| 75 | $url2 = $url . $run_param['URL_Address'] . ':' . $run_param['URL_Port'] . '/xbmcCmds/xbmcHttp?command=Pause()';
|
| 76 | $url3 = $url . $run_param['URL_Address'] . ':' . $run_param['URL_Port'] . '/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.Notification(' . $clidxbmc . ')';
|
| 77 |
|
| 78 | if($debug)
|
| 79 | {
|
| 80 | if ($run_param['Change_Volume'] !='') { print 'Send to XBMC: ' . $url1 . '<br>'; }
|
| 81 | if ($run_param['Pause_PlayBack'] = "on") { print 'Send to XMBC: ' . $url2 . ' Value: ' . $run_param['Pause_PlayBack'] . '<br>'; }
|
| 82 | print 'Send to XBMC: ' . $url3 . '<br><br>';
|
| 83 | }
|
| 84 |
|
| 85 |
|
| 86 | // Send Out The Strings
|
| 87 |
|
| 88 | if ($run_param['Change_Volume'] !='') { $value = get_url_contents($url1); }
|
| 89 | if ($run_param['Pause_PlayBack'] = "on") { $value = get_url_contents($url2); }
|
| 90 | $value = get_url_contents($url3);
|
| 91 | }
|
| 92 | }
|
| 93 | ?>
|
| 94 | |