source-Vemringde_SE.php

nixi, 10/13/2009 08:37 am

Download (2.2 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
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://www.vemringde.se - Datasource from the Swedish vemringde.se directory devoted to identifying telemarketers. These listings are provided by other users of this service.";
10
$source_param = array();
11
$source_param['SPAM_Threshold']['desc'] = 'Specify the listings required to mark a call as spam.';
12
$source_param['SPAM_Threshold']['type'] = 'number'; 
13
$source_param['SPAM_Threshold']['default'] = 5;
14
//run this if the script is running in the "get caller id" usage mode.
15
if($usage_mode == 'get caller id')
16
{
17
        if($debug)
18
        {
19
                print "Searching Vemringde.se ... ";
20
        }
21
        $number_error = false;
22
        
23
        //check for the correct digits for Sweden in international format.
24
25
        
26
        // international dialing prefix + country code + number
27
        if (strlen($thenumber) > 8)
28
        {
29
                if (substr($thenumber,0,2) == '46')
30
                {
31
                        $thenumber = '0'.substr($thenumber, 2);
32
                }
33
                else if (substr($thenumber,0,4) == '0046')
34
                {
35
                        $thenumber = '0'.substr($thenumber, 4);
36
                }
37
                else if (substr($thenumber,0,5) == '01146')
38
                {
39
                        $thenumber = '0'.substr($thenumber,5);
40
                }                        
41
                else
42
                {
43
                        $number_error = true;
44
                }
45
        }        
46
        // number
47
       if(strlen($thenumber) < 11)
48
        {
49
                if (substr($thenumber,0,1) == '0')
50
                {
51
                        $number_error = false;
52
                }
53
                else
54
                {
55
                        $number_error = true;
56
                }
57
        }
58
        
59
        if(!$number_error)
60
        {
61
                $url="http://api.vemringde.se/?q=$thenumber&e=1&n=".$run_param['SPAM_Threshold']."";
62
                $value = get_url_contents($url);        
63
                if($debug)
64
65
                if($value == "0") //No information found
66
                {
67
                        $value = "";
68
                }        
69
70
                if (strlen($value) > 1)
71
                {
72
                        $spam = true;
73
                        $caller_id = strip_tags($value);
74
                }
75
                else if($debug)
76
                {
77
                        print "not found<br>\n";
78
                }
79
        }
80
        else if($debug)
81
        {
82
                print "Skipping Source - Non Swedish number: ".$thenumber."<br>\n";
83
        }
84
85
}
86
?>
87