Jump to content

Drupal PHP block problem


twsowerby

Recommended Posts

Hi all,

 

Ok I cant figure something out. I have this code:

 

<?php
$vars = array('user'=>'demo',
              'password'=>'demo',
              'skey'=>'abc123',
              'request'=>'Dashboard',
              'userID'=>'2');
              
$data = apiGetD($vars);

function apiGetD($vars) {   
        $accessURL = 'www.eve-tool.com';
        $apiURL = '/api/class/class.access.php';
        $poststring = http_build_query($vars);
        $fp = fsockopen($accessURL, 80);

        fputs($fp, "POST " . $apiURL . " HTTP/1.0\r\n");
        fputs($fp, "Host: " .  $accessURL . "\r\n");
        fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
        fputs($fp, "User-Agent: PHPApi\r\n");
        fputs($fp, "Content-Length: " . strlen($poststring) . "\r\n");
        fputs($fp, "Connection: close\r\n\r\n");

        if (strlen($poststring) > 0)
            fputs($fp, $poststring . "\r\n");

        $contents = "";
        while (!feof($fp)) {
            $contents .= fgets($fp);
        }
        fclose($fp);
        $start = strpos($contents, "\r\n\r\n");

        if ($start !== false) {
            return substr($contents, $start + strlen("\r\n\r\n"));

        }
    }
    
    print_r($data);
?> 

 

Which is meant to connect to a class on another server and return an array. When I run it in a standalone "test.php" file on the same server as my drupal installation it works perfectly and I get the correct return.

 

If I then take that exact same code and insert it into a drupal block with the php filter on, it doesnt seem to be sending the "skey" variable and I get this pre-programmed error array back:

 

Array ( [0] => Array ( [message] => Authorization fail. [user] => demo [request] => [iP] => 74.208.43.153 [stamp] => 1232445084 ) [1] => Array ( [message] => No siteKey found. [user] => demo [request] => [iP] => 74.208.43.153 [stamp] => 1232445084 ) ) 

 

Note the "No siteKey found" error. Does anyone have any idea what might be messing this up? Or a way around it that I could try?

 

Cheers,

 

Tom

Link to comment
Share on other sites

Nothing very specific shows up in Google or on the Drupal forum searches.

 

From looking around, it appears the siteKey has something to do with multi-site usage with Drupal.

 

This could have something to do with security from Drupal and the multi-site functionality.

Link to comment
Share on other sites

Hmmm the sitekey variable I'm using is just used for passing a value into the class which sits on another server, surely it cant be conflicting with any Drupal sitekeys?

 

The error message im getting is nothing to do with drupal, its an array that is returned from a standalone function when it cant reference the value being passed in.

Link to comment
Share on other sites

You noted that you are dropping it into a drupal block when you get the error.  Without seeing the code from your class, I can't tell for sure.  I found a couple posts on drupal talking about a multi-site key, you noted cross server class calls, which I why I pointed that out.

 

If you get it, please post your findings.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.