PHP/MySQL - Secure PHP Connection file for outside users

Discussion in 'PHP' started by JXI, Jul 14, 2012.

  1. #1
    Forgive me for I am not the best at describing setups such as this.
    That is why I have included a visual representation below of what I am trying to achieve.

    I'm developing an application that will use a central database.
    That central database is local to my server/website and connects by a php file.

    Now, the setup is to have client servers/websites connect to this same database by a php file.
    Except I need to find a way to give them that file without revealing the username and password to the database.

    Maybe some sort of encrypted file? But then if in the wrong hands that could possibly be decrypted?

    I'm open to any suggestions!
    Thanks!

    DatabaseConnection.jpg
     
    JXI, Jul 14, 2012 IP
  2. shubhamm

    shubhamm Member

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    Just make a php file with the function which your Client wants i don't think there is any other way to connect if you encode / encrypt it you have to give a key & when you give key it will be easily to decode/ decrypt for it

    so what you can do is make a php file with the function what your client wants and tell them to run function using php file
     
    shubhamm, Jul 17, 2012 IP
  3. jeet25

    jeet25 Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you can encrypt it using MD5 hash function.
     
    jeet25, Jul 17, 2012 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    Who are you trying to avoid revealing the user/password on the remote server to?
     
    jestep, Jul 17, 2012 IP
  5. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #5
    You're better off using another language for this, preferably a compiled one, such as C#. Unless someone goes out of their way to decompile the program, they won't be able to get your database details.

    If you still want to use PHP why not have a middle-man script that can accept and relay commands to/from the database? This way you don't need your clients to directly connect to the DB.

    For example:

    [Client's script] <-----HTTP POST request-----> [DB adapter] <-----> [DB]

    1. User uses a form to send an SQL query
    2. DB adapter script receives via $_POST
    3. DB adapter script uses direct connect to execute the query
    3. DB adapter sends result back to client

    This can also be done with sockets and would be a better method, but using HTTP is much easier.
     
    Last edited: Jul 21, 2012
    BRUm, Jul 21, 2012 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #6
    download sqlyog's trial version and see what they do with their "tunnel" script.
     
    sarahk, Jul 23, 2012 IP