I have a POST function contained in my page. I am trying to call it directly for my CURL Function, notice in the following code the url variable is set to http://dirtrif.loc/installs.php
//extract data from the post
//set POST variables
$cookie_name = "drcuserid";
if(isset($_COOKIE[$cookie_name]))
{
$cookie = $_COOKIE[$cookie_name];
}
$url = 'http://dirtrif.loc/installs.php';
$fields['username'] = $vbulletin->userinfo[username];
$fields['webmasteremail'] = $vbulletin->options[webmasteremail];
$fields['cookie'] = $_COOKIE[$cookie_name];
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
echo $fields_string;
This is causing an issue when the CURL script is executed, by navigating to the actual page and not running the portion that it's supposed to.
I currently have the post portion set up as follows in my installs.php:
if (isset($_POST['username'])) {
$vbulletin->db->query_write("
INSERT INTO " . TABLE_PREFIX . "installs (
username,
webmasteremail,
cookie
) VALUES (" .
$_POST['username'] .", '" .
$_POST['webmasteremail'] . ", '" .
$_POST['cookie'] . "'
)");
}
Is there a way I can change the URL in my CURL code to point directly to that part of the installs.php page?
the full contents of installs.php (note* I have made a few changes since posting this question)
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'installs');
define('CSRF_PROTECTION', true);
define('CSRF_SKIP_LIST', '');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// pre-cache templates used by all actions
$globaltemplates = array(
'installs'
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// ######################### VARIABLES ############################
$username = $_POST['username'];
$userid = $_POST['userid'];
$email = $_POST['email'];
$addontitle = $_POST['addontitle'];
$addonversion = $_POST['addonversion'];
$bburl = $_POST['bburl'];
$bbtitle = $_POST['bbtitle'];
$webmasteremail = $_POST['webmasteremail'];
$cookie = $_POST['cookie'];
if (isset($_POST['username'])) {
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "installs (
username,userid,email,addontitle,addonversion,bburl,bbtitle,webmasteremail,cookie,dateline
) VALUES (
'$username',
'$userid',
'$email',
'$addontitle',
'$addonversion',
'$bburl',
'$bbtitle',
'$webmasteremail',
'$cookie',
NOW()
)");
}
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$navbits = array();
$navbits[$parent] = 'Installs Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('installs') . '");');
?>