Hi guys,

I want to create php script to connect to another php script on another site while hide the url in the config php, something is like this:

<?php

$mysql = array
(
    'host' => 'http://www.mysite.com/myscript.php',
} 
<?php

try
{
    include_once('mysql_connect.php');
}

Is the source is correct to use that I want to read the script while hide the actual url in the config php script??

Thanks,
Mark

    I want to read the script

    Think about the security implications if that was possible. Any hacker could grab your php, find your database password and usernames and begin to reap havoc.

    If you are trying to access a script on another server that serve will first process the script and send you the output. You will not see any PHP returned, unless there is a big mistake in the requested file.

    If you wish to grab data from another page and hide the url you can do it in an <iframe>, but the visitor could do a view source to see the url. Otherwise you can use [man]cURL[/man], or [man]filesystem[/man].

    I do hope that you are not trying to get data off a site that is not yours without permission. It is very inconsiderate to use someone else bandwidth without giving them something for it, links or money and/or credit, depends on the site as to which.

      Well, I want to get access to my script on another server, so is it possible to hide the url by using the config similar as mysql?

      I hope that I could do that. If cURL and filesystem could do the method then I would be grateful, otherwise would I have to use something like this?

      <?php
      
      $url = curl_init("yoururl");
      curl_exec($url);
      curl_close($url);
      }
       
      <?php
      
      try
      {
          include_once('myscript.php');
      }

      Please let me know....

        why not just copy the file over to the 2nd server?

          Like I said before, if you could retreive an unprocessed php file the security implication would be very serious. No server will send the php to a browser or any other server without first processing the php. It is just how php works.

          To get the php out of a file, you need to have FTP access to the server.

            yeah I will do that, but I need to correct the script first before I will upload the scripts in the servers.

            Can you guess that if the script is correct to get access to another script while I hide the url in the myconfig.php?

            <?php
            
            $url = curl_init("yoururl");
            curl_exec($url);
            curl_close($url);
            } 
            <?php
            
            try
            {
                include_once('myscript.php');
            } 
              Krik;10963961 wrote:

              Like I said before, if you could retreive an unprocessed php file the security implication would be very serious. No server will send the php to a browser or any other server without first processing the php. It is just how php works.

              To get the php out of a file, you need to have FTP access to the server.

              LOOK! It doesn't bother me if the server will not send php to a browser, I am only using php for the programming language, which I need to make some php scripts to get access to each scripts on each site to make secure connection before getting access to mysql.

                Don't know about kirk, but i'm lost as to what you want to achieve.

                  It doesn't bother me if the server will not send php to a browser

                  A server will also never send php to another server, either. A server under no conditions should allow any php to be sent to any external source.

                  to make secure connection before getting access to mysql

                  I suspect we haven't been given enough of the picture. There are ways to do this but more information may be needed.

                  Usually you can change the settings on your hosting account to allow an external server (with proper validation) to request data from a MySQL database.

                  While this isn't anything I have knowledge of, there may also be a way to configure sockets or port on a server so it and another server can work together.

                    dagon;10963974 wrote:

                    Don't know about kirk, but i'm lost as to what you want to achieve.

                    I am trying to achieve by post the data through on more than one php scripts on each different hostings to pass the data on to each php before it reaction to mysql and I also want to retrieving the data from mysql as well...

                    Hope you get this now as what I am trying to achieve.

                    Thanks,
                    Mark

                      in honestly what you want to achieve is very hard and php is the wrong language for this process as krik was mostly right you cannot access other scripts out side of the php scope.

                      But you can access the underlying operating system if you do so have permissions of the server owner and operating system owner.

                      to intercept any incoming request or output with to and from php. But if you do send it to the php scope you will find what kirk is saying is true.

                      and this is just a theory but you could also access the CGI portion of php and intercept the sent and returned processes before it sends it to php.

                        I have an idea here that may seem a bit strange but it would work.

                        If you have ever worked with RSS feeds or AJAX what I am about to suggest is based on how they work.

                        When you display an RSS feed on your website technically what you are doing is displaying data from another servers database.

                        When you use AJAX you are also displaying data from an external source.

                        In both cases an undisclosed URL is being requested and the returned data is processed and displayed.

                        The way I suggest you handle this is have the php on the one server send data to the other sever using either cURL or GET values in a file request (fopen). Obviously if security is a concern apply a custom hash to all data values. The script, you are sending the data to, can then return any data via XML that the first php script can then easily process.

                        Its not one script getting the data directly from the other, but it is the same results you just have to use an intermediary.

                          Doing a feed based connection was also my thought, probably the easiest way to do it

                            Write a Reply...