source-Who_Called.php

WhoCalled Script - 2.1.0+ Method Style - tshif, 05/21/2009 10:29 pm

Download (1.9 KB)

 
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, $npa, $nxx, $station, $TFnpa, $validnpa
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 = "http://whocalled.us - These listings are provided by other users of the whocalled service. This service requires authentication - which you configure in Who Called Extended Information, below.";
10
$source_param = array();
11
$source_param['Username']['desc'] = 'Your user account Login on the whocalled.us web site.';
12
$source_param['Username']['type'] = 'text';
13
$source_param['Password']['desc'] = 'Your user account Password on the whocalled.us web site.';
14
$source_param['Password']['type'] = 'password';
15
$source_param['SPAM_Threshold']['desc'] = 'Enter a number for your spam score threshold.  Callers rated above this threshold will be considered to be SPAM.';
16
$source_param['SPAM_Threshold']['type'] = 'number';
17
18
19
//run this if the script is running in the "get caller id" usage mode.
20
if($usage_mode == 'get caller id')
21
{
22
        if($debug)
23
        {
24
                print "Searching Who Called ... ";
25
        }
26
        
27
        $url = "http://whocalled.us/do?action=getScore&name=".$param['Who_Called']['Username']."&pass=".$param['Who_Called']['Password']."&phoneNumber=$thenumber";
28
        $value = get_url_contents($url);
29
        
30
        $st_success = strstr($value, "success");
31
        $st_score = strstr($value, "score");
32
        $success = substr($st_success,8,1);
33
        $score = substr($st_score,6);
34
        if($success=='1')
35
        {
36
          if($score>$param['Who_Called']['SPAM_Threshold'])
37
          {
38
                        $spam = true;
39
          }
40
          else if($debug)
41
                {
42
                        print "found but score not high enough<br>\n";
43
                }
44
        }
45
        else if($debug)
46
        {
47
                print "not found<br>\n";
48
        }
49
}
50
?>