CID Lookup

Up
0
Down
  • Post
    Steve
    Participant

    I wanted to set up a CID Lookup using MySQL but the source doesn’t include MySQL or may it be somewhere else that I didn’t see?

    I wanted to do:

    local_cnam (name/description)

    Source: MySQL

    Host: localhost

    Port: normal MySQL Port

    Auth User: root

    Auth Password: mypassword

    Query String: select name from callerid where `number` LIKE ‘%[NUMBER]%’ 

    I would create my own database/table called callerid with number and name in the columns to do a lookup.

    TIA.

    I really like VitalPBX.  Thanks for a great alternative to FreePBX.

    0
Viewing 10 replies - 1 through 10 (of 10 total)
  • Replies

    You may use the source http/https to call a php file that contains a query to your database.

    0
    sakssalonatl
    Participant

    It would be nice if you could add field for direct SQL query.

    VitalPBX is very noob firendly and simple options like this further help in ease of use/customization.

    0
    Steve
    Participant

    Thank you for your reply.  I have no idea how to do that.  

    Database: sms

    table: callerid

    columns number, name

    How would I go about setting that up in CID Lookup?  TIA

    0
    Steve
    Participant

    Agreed.  That really would be very helpful.

    0
    Steve
    Participant

    Any offers for an example using http/https?

     

    Would it be possible in a future release to “It would be nice if you could add field for direct SQL query.”

    0

    We are going to take it into account for future release.

    0
    TrustedbyU
    Participant
    Posted by: Steve

    Any offers for an example using http/https?

     

    Would it be possible in a future release to “It would be nice if you could add field for direct SQL query.”

    Ah i see what you are trying to do now (from the comment you left on my question).

    Here’s a very quick example assuming you have a database on the same server as the php file, that contains nothing but names and numbers…. and we’ll call that database phonebook, with a table in it called numbers. In that table are 2 fields called contactName and telNumber I’m not going to clense the query or anything, so not suggested for use on a web facing server 😉

    <?php
    //simple script that looks for a variable called query, connects to a local database and returns a value with no realy error checking.

    //first grab the query into a quick simple variable we can use ie; this.php?query=0123456789,
    $number = $_REQUEST['query'];

    //connect to a database
    mysql_connect("localhost","dbusername","dbpassword") or die("Error Connecting to DB");
    //select the database we want to use
    mysql_select_db("phonebook");

    //build a simple query that returns the first matching record for the number we supplied
    $q = mysql_query("select * from `numbers` where `telNumber`='$number' LIMIT 1");
    //If you have found a result return the Name of the Person
    if(mysql_num_rows($q) > 0){
    //create an associative array of the feilds in the table for that record (ie it returns 'name' and 'telNumber' for the record in an array called a)
    $a = mysql_fetch_assoc($q);
    //output the contactName field for that record to the page
    echo $a['contactName'];
    }
    //If there was Less than 1 result (ie 0), just return the number sent to the output
    else
    {
    echo $number;
    }
    //close the connection to the database... You dont really need to do this, as when the page stops, it will close anyway. but on a busy server this will keep load down
    mysql_close();

    ?>

    This is by no means the Best and most secure way to do it, But if you're doing this lookup locally and not on a web facing server then it will get you started. If it is web facing, this is a good starting point to learn from
    I can knock up a script that will work from CSV if working that way is better.
    Hope this helps :)

    Mike.

    0
    Steve
    Participant

    Thank you, Mike.

    0
    TrustedbyU
    Participant
    Posted by: Steve

    Thank you, Mike.

    Anytime… If u need anything else just give me a shout and I’ll try help out when I have a few mins 🙂

    0

    In the latest version of VitalPBX it is possible to use MySQL as CID Lookup source: https://vitalpbx.org/en/vitalpbx-2-1-0/

    0
Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.