Forum Moderators: coopster
I dont know where the action page is because the only thing there is a '?'.
[PHP]
<"form action="?" method="POST">
[/php]
Is anyone familiar with this type of thing?
In the attempt to find where the variables are posted to, i have looked in other pages downloaded with the software for a list of the variables. No Luck, i only found one page that makes them into an array:
PHP:
$res = array();
$res['database'] =
array('title' => INSTALL_CAT_DB,
'description' => INSTALL_CAT_DB_DESC,
'items' => array(array('var' => 'dbType',
'title' => INSTALL_DBTYPE,
'description' => INSTALL_DBTYPE_DESC,
'type' => 'list',
'default' => 'mysql',
'flags' => array('nosave', 'simpleInstall', 'probeDefault')),
array('var' => 'dbHost',
'title' => INSTALL_DBHOST,
'description' => INSTALL_DBHOST_DESC,
'type' => 'string',
'default' => 'localhost',
'flags' => array('nosave', 'simpleInstall')),
array('var' => 'dbUser',
'title' => INSTALL_DBUSER,
'description' => INSTALL_DBUSER_DESC,
'type' => 'string',
'default' => 'mem',
'flags' => array('nosave', 'simpleInstall')),
array('var' => 'dbPass',
'title' => INSTALL_DBPASS,
'description' => INSTALL_DBPASS_DESC,
'type' => 'protected',
'default' => '',
'flags' => array('nosave', 'hideValue', 'simpleInstall')),
--------------------------------------------------------------------------------
any idea where they variables [dbType, dbName etc] are posted to so i can set the CURLOPT_URL?
Is it possible that the form is bieng posted to a function? if so how can i set my CURLOPT_URL to ost to a function?
I would think this would solve my puzzle, it does not.
The puzzle: try to submit info to a form using cURL.
The puzzle variables:
1. the url of the form: www.mysite.com/userz/mel/sy_admin.php?sy[step]=2b
2. actual code of the page:
<?php
require_once 'sy/sy_admin.php';
?>note: sy/sy_admin.php is in my home directory. /home/sy/sy_admin.php
3. critical code of sy/sy_admin.php : [i think, may not be important]
[code]
<?php
include('sy_config.inc.php');
if (IS_installed === false) {
require_once(S9Y_INCLUDE_PATH . 'include/functions_installer.inc.php');
require_once S9Y_INCLUDE_PATH . 'include/functions_config.inc.php';
$css_file = 'sy.css.php?sy[css_mode]=sy_admin.css';
} else {
$css_file = sy_rewriteURL('sy_admin.css');
}
<html>
<head>
<title><?php echo sy_ADMIN_SUITE;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo LANG_CHARSET;?>" />
<link rel="stylesheet" type="text/css" href="<?php echo $css_file;?>" />
<script type="text/javascript">
function spawn() {
if (self.Spawnextended) {
Spawnextended();
}
if (self.Spawnbody) {
Spawnbody();
}
if (self.Spawnnugget) {
Spawnnugget();
}
}
function SetCookie(name, value) {
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + (60*60*24*30));
document.cookie = 'sy[' + name + ']='+escape(value) + ';expires=' + expire.toGMTString();
}
</script>
</head>
<body id="sy_admin_page" onload="spawn()">
<?php
if (!isset($sy['syPath']) ¦¦ IS_installed === false ¦¦ IS_up2date === false ) {
if (IS_installed === false) {
$file = 'include/admin/installer.inc.php';
} elseif ( IS_up2date === false ) {
$file = 'include/admin/upgrader.inc.php';
} else {
$file = ''; // For register_global, safety
}
?>
?>
Now one of the functions in installer.inc.php is to print the form template.
This may all be irrelevant in what i am trying to do, if so please let me know.
My current curl attempt is:
<?php $my_data = array(
'dbType' => 'mysql',
'dbHost' => 'localhost',
'dbUser' => 'mem',
'dbPass' => 'letmein',
'dbName' => 'mem_com_-_sy',
'dbPrefix' => 'mel_',
'dbPersistent' => 'false',
'syPath' => '/var/www/html/userz/mel/',
'uploadPath' => 'uploads/',
'syHTTPPath' => '/userz/mel/',
'templatePath' => 'templates/',
'uploadHTTPPath' => 'uploads/',
'baseURL' => 'http://www.mysite.com/userz/mel/',
'autodetect_baseURL' => 'false', //dont know if true should have quotes around it it doesnt in config file
'indexFile' => 'index.php',
'user' => 'mel',
'pass' => 'thanks',
'realname' => 'mel', //should get from signup p h p
'email' => 'michael@hotmail.com', //should get from signup p h p
'want_mail' => 'true', //dont know if true should have quotes around it it doesnt in config file
'allowSubscriptions' => 'true', //dont know if true should have quotes around it it doesnt in config file
'blogTitle' => 'John Does personal blog',
'blogDescription' => 'My little place on the web...',
'lang' => '', //dont know if true should have quotes around it it doesnt in config file
'lang_content_negotiation' => 'false', //dont know if true should have quotes around it it doesnt in config file
'fetchLimit' => '15', //dont know if true should have quotes around it it doesnt in config file
'useGzip' => 'true', //dont know if true should have quotes around it it doesnt in config file
'wysiwyg' => 'false', //dont know if true should have quotes around it it doesnt in config file
'XHTML11' => 'false', //dont know if true should have quotes around it it doesnt in config file
'enablePopup' => 'false', //dont know if true should have quotes around it it doesnt in config file
'embed' => 'false',
'top_as_links' => 'false', //dont know if true should have quotes around it it doesnt in config file
'blockReferer' => ',',
'rewrite' => 'array()', //dont know if true should have quotes around it it doesnt in config file
'serverOffsetHours' => '0', //dont know if true should have quotes around it it doesnt in config file
'showFutureEntries' => 'false', //dont know if true should have quotes around it it doesnt in config file
'magick' => 'false', //dont know if true should have quotes around it it doesnt in config file
'convert' => '/usr/local/bin/convert',
'thumbSuffix' => 'syThumb',
'thumbSize' => '110', //dont know if true should have quotes around it it doesnt in config file
);
// This section constructs the field/value pairs of the form
// field1=value1&field2=value2&field3=value3
$data_string = '';
$add_ampersand = FALSE;
foreach ($my_data as $key => $value)
{
if ($add_ampersand)
{
$data_string .= '&';
}
$data_string .= $key . '=' . $value;
$add_ampersand = TRUE;
}
// Get a CURL handle
$curl_handle = curl_init ();
curl_setopt($curl_handle, CURLOPT_URL, 'http://www.mysite.com/userz/mel/sy_admin.php?sy[step]=2b');
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)');
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_HEADER, 1);
$result=curl_exec ($curl_handle);
curl_close ($curl_handle);
preg_match_all("/Set\-Cookie\:.*?\;/", $result, $matches);
$cookiejar = "";
foreach ($matches[0] as $cookie) {
$cookiejar .= str_replace("Set-Cookie: ", "", $cookie).' ';
}
preg_match("/Location\:.*?\n/", $result, $matches);
$nexturl = str_replace("\r", "", str_replace("\n", "", str_replace("Location: ", "", $matches[0])));
// the 3 lines below were jst 4 test purposes to make sure the variables were getting set
print $cookie; // ex result: Set-Cookie: PHPSESSID=dcd730a95f8b428f7dbd9fc1e6687d1a
print $nexturl; // < got no result
print $cookiejar; // ex result PHPSESSID=dcd730a95f8b428f7dbd9fc1e6687d1a
// Get a CURL handle
$curl_handle = curl_init ();
curl_setopt($curl_handle, CURLOPT_URL, $nexturl);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)');
curl_setopt($curl_handle, CURLOPT_REFERER, 'http://www.mysite.com/userz/mel/sy_admin.php?sy[step]=2b?');
curl_setopt($curl_handle, CURLOPT_COOKIE, $cookiejar);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_HEADER, 1);
curl_setopt($curl_handle, CURLOPT_TIMEOUT, 300);
$result=curl_exec ($curl_handle);
curl_close ($curl_handle);
// Process the return
print $result;
?>
I notice that the initial form page is: [mysite.com...]
and after filling out the form the normal way