function getPlatform() { global $conn_id; global $platformTestCount; if ($_SESSION["win_lin"] == "") { $ftp_rawlist = ftp_rawlist($conn_id, "."); // Check for content in array if (sizeof($ftp_rawlist) == 0) { $platformTestCount++; // Create a test folder if (@ftp_mkdir($conn_id, "test")) { if ($platformTestCount < 2) { getPlatform(); @ftp_rmdir($conn_id, "test"); } } } else { // Get first item in array $ff = $ftp_rawlist[0]; // Split up array into values $ff = preg_split("/[\\s]+/", $ff, 9); // First item in Linux rawlist is permissions. In Windows it's date. // If length of first item in array line is 8 chars, without a-z, it's a date. if (strlen($ff[0]) == 8 && !preg_match("/[a-z]/i", $ff[0], $matches)) { $win_lin = "win"; } if (strlen($ff[0]) == 10 && !preg_match("/[0-9]/i", $ff[0], $matches)) { $win_lin = "lin"; } if ($ff[0] == "total") { $ff = $ftp_rawlist[1]; $ff = preg_split("/[\\s]+/", $ff, 9); if (strlen($ff[0]) == 10 && !preg_match("/[0-9]/i", $ff[0], $matches)) { $win_lin = "mac"; } } $_SESSION["win_lin"] = $win_lin; } } }
} // get the correct version number $known = array('Version', $browser, 'other'); $pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; if (!preg_match_all($pattern, $userAgent, $matches)) { // we have no matching number just continue } // see how many we have $i = count($matches['browser']); if ($i != 1) { // we will have two since we are not using 'other' argument yet // see if version is before or after the name if (strripos($userAgent, "Version") < strripos($userAgent, $browser)) { $version = $matches['version'][0]; } else { $version = $matches['version'][1]; } } else { $version = $matches['version'][0]; } return array($browserName, $version); } echo '<pre>'; echo 'UserAgent: ' . $userAgent . '<br />'; $platform = getPlatform($userAgent); echo 'Platform: ' . $platform[0] . ' ' . $platform[1]; echo '<br />'; $browser = getBrowser($userAgent); echo 'Browser: ' . $browser[0] . ' ' . $browser[1]; echo '<br />'; echo 'IP adress: ' . $userIpAddress;
function attemptLogin() { global $conn_id; global $ftpHost; global $ftpPort; global $ftpMode; global $ftpSSL; global $ftpDir; global $lang_missing_fields; global $lang_ip_conflict; if (connectFTP(0) == 1 && $_POST["login"] != 1) { // Check for hijacked session if ($_SESSION["ip_check"] == 1) { if ($_SERVER['REMOTE_ADDR'] == $_SESSION["user_ip"]) { $_SESSION["loggedin"] = 1; } else { $_SESSION["errors"] = $lang_ip_conflict; sessionExpired($lang_ip_conflict); logOut(); } } else { $_SESSION["loggedin"] = 1; } } else { if ($_POST["login"] == 1) { // Check for login errors if (checkLoginErrors() == 1) { $_SESSION["login_error"] = $lang_missing_fields; displayLoginForm(1); } else { // Set POST vars to SESSION if ($ftpHost == "") { $_SESSION["ftp_host"] = trim($_POST["ftp_host"]); $_SESSION["ftp_port"] = trim($_POST["ftp_port"]); $_SESSION["ftp_pasv"] = empty($_POST["ftp_pasv"]) ? 0 : 1; $_SESSION["ftp_ssl"] = empty($_POST["ftp_ssl"]) ? 0 : 1; } else { $_SESSION["ftp_host"] = $ftpHost; $_SESSION["ftp_port"] = $ftpPort; $_SESSION["ftp_pasv"] = $ftpMode; $_SESSION["ftp_ssl"] = $ftpSSL; } $_SESSION["ftp_user"] = trim($_POST["ftp_user"]); $_SESSION["ftp_pass"] = trim($_POST["ftp_pass"]); $_SESSION["interface"] = empty($_POST["interface"]) ? "" : "adv"; $_SESSION["skin"] = empty($_POST["skin"]) ? "" : $_POST["skin"]; $_SESSION["lang"] = $_POST["lang"]; $_SESSION["ip_check"] = $_POST["ip_check"]; if (connectFTP(1) == 1) { $_SESSION["loggedin"] = 1; // Save user's IP address $_SESSION["user_ip"] = $_SERVER['REMOTE_ADDR']; // Set platform getPlatform(); // Change dir if one set if ($ftpDir != "") { if (@ftp_chdir($conn_id, $ftpDir)) { $_SESSION["dir_current"] = $ftpDir; } else { if (@ftp_chdir($conn_id, "~" . $ftpDir)) { $_SESSION["dir_current"] = "~" . $ftpDir; } } } } else { displayLoginForm(1); } } } else { displayLoginForm(0); } } }
function calendar($value, $name, $id, $format = '%Y-%m-%d', $class) { switch (getPlatform()) { case 'CMS_JOOMLA10': case 'CMS_MAMBO46': $html = '<input class="' . $class . '" type="text" name="' . $name . '" id="' . $id . '" size="25" maxlength="19" value="' . $value . '"/>'; $html .= '<input name="reset" type="reset" class="button" onclick="return showCalendar(\'' . $id . '\', \'' . $format . '\');" value="..." />'; return $html; break; case 'CMS_JOOMLA15': return JHTML::_('calendar', $value, $name, $id, $format, array('class' => $class)); break; } }
function showStep2($option, $profilerId, $separator, $csv_utf8, $headers, $rowFields, $fileName, $rowJReviewFields) { if (getPlatform() == CMS_JOOMLA15) { $alias_column = 'alias'; } else { $alias_column = 'title_alias'; } ?> <form method="POST" name="adminForm" id="adminForm" action="index2.php"> <table class="csvimport_subheading"> <tr> <td><h1>Step 2: Associate Columns and Fields </h1> <p>Specify the Joomla or jReviews field to which each column in your CSV file should be associated. To skip a column, choose the "Ignore" option in the right-hand column.</p> </th> </td> </tr> </table> <table class="adminform" width="100%"> <tr> <th>CSV Field/Column</th> <th> </th> <th width="100%">Joomla/jReviews Field </th> </tr> <?php $totalFields = 0; for ($i = 0, $n = count($headers); $i < $n; $i++) { $header = $headers[$i]; if ($rowFields) { $rowField = $rowFields[$i]; $columnNo = $rowField->column_no; $columnTitle = $rowField->column_title; $field = $rowField->field; $arrFields = explode(".", $field); $tableName = $arrFields[0]; $columnName = $arrFields[1]; } if ($header) { $totalFields++; ?> <tr class="row<?php echo $i % 2; ?> "> <td><input type="text" name="columns[]2" value="<?php echo $header; ?> " size="60" style="width:250px;" readonly="true" /></td> <td><img src="components/com_csv_import/arrow.gif" alt="Associate with..." /></td> <td><select name="fields[]2" style="width:250px;" id="field_<?php echo $totalFields - 1; ?> "> <optgroup label="jos_content"> <!-- Added ignore field--> <option value="jos_jreviews_fields.ignore" <?php if ($columnName == "ignore") { echo "selected"; } ?> >Ignore</option> <!-- End of ignore field--> <option value="jos_content.created_by" <?php if ($columnName == "created_by" && $tableName == "jos_content") { echo "selected"; } ?> >Author ID</option> <option value="jos_content.title" <?php if ($columnName == "title" && $tableName == "jos_content") { echo "selected"; } ?> >Title</option> <option value="jos_content.<?php echo $alias_column; ?> " <?php if ($columnName == $alias_column && $tableName == "jos_content") { echo "selected"; } ?> >Title Alias</option> <option value="jos_content.introtext" <?php if ($columnName == "introtext" && $tableName == "jos_content") { echo "selected"; } ?> >Intro text</option> <option value="jos_content.fulltext" <?php if ($columnName == "fulltext" && $tableName == "jos_content") { echo "selected"; } ?> >Fulltext</option> <option value="jos_content.images" <?php if ($columnName == "images" && $tableName == "jos_content") { echo "selected"; } ?> >Images</option> <option value="jos_content.sectionid" <?php if ($columnName == "sectionid" && $tableName == "jos_content") { echo "selected"; } ?> >Section ID</option> <option value="jos_content.catid" <?php if ($columnName == "catid" && $tableName == "jos_content") { echo "selected"; } ?> >Category ID</option> <option value="jos_content.metakey" <?php if ($columnName == "metakey" && $tableName == "jos_content") { echo "selected"; } ?> >Meta Keywords</option> <option value="jos_content.metadesc" <?php if ($columnName == "metadesc" && $tableName == "jos_content") { echo "selected"; } ?> >Meta Description</option> <option value="jos_content.created" <?php if ($columnName == "created" && $tableName == "jos_content") { echo "selected"; } ?> >Created Date</option> <option value="jos_content.publish_up" <?php if ($columnName == "publish_up" && $tableName == "jos_content") { echo "selected"; } ?> >Publish Start Date</option> <option value="jos_content.publish_down" <?php if ($columnName == "publish_down" && $tableName == "jos_content") { echo "selected"; } ?> >End Start Date</option> </optgroup> <optgroup label="jos_jreviews_fields"> <?php for ($k = 0, $m = count($rowJReviewFields); $k < $m; $k++) { $rowJreviewField = $rowJReviewFields[$k]; ?> <option value="jos_jreviews_fields.<?php echo $rowJreviewField->name; ?> " <?php if ($columnName == $rowJreviewField->name && $tableName == "jos_jreviews_fields") { echo "selected"; } ?> > <?php echo $rowJreviewField->name; ?> </option> <?php } ?> </optgroup> </select></td> </tr> <?php } } ?> </table> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="task" value="" /> <input type="hidden" name="filename" value="<?php echo $fileName; ?> " /> <input type="hidden" name="profiler_id" value="<?php echo $profilerId; ?> " /> <input type="hidden" name="separator" value="<?php echo $separator; ?> " /> <input type="hidden" name="csv_utf8" value="<?php echo $csv_utf8; ?> " /> </form> <script language="javascript"> var totalField=<?php echo $totalFields; ?> ; function submitbutton(pressButton) { //Update class Name for(var i=0;i<totalField-1;i++) { var select=document.getElementById("field_"+i); select.className="inputbox"; } if(pressButton=="") { submitform(pressButton); } else { //Check to see if there are any columns are duplicate var success=true; for(var i=0;i<totalField-1;i++) { var parentSelect=document.getElementById("field_"+i); if(parentSelect.value!="jos_jreviews_fields.ignore") { for(var j=i+1;j<totalField;j++) { childSelect=document.getElementById("field_"+j); if(parentSelect.value==childSelect.value) { success=false; parentSelect.className="error"; childSelect.className="error"; return; } } } } if(!success) { alert("One CSV column must match one field on database"); } else { submitform(pressButton); } } } </script> <?php }