if (isset($data['phone_id']) && !empty($data['phone_id'])) {
$userPhone = $this->getDoctrine()->getRepository('STODBBundle:Phones')->find($data['phone_id']);
if ($userPhone->getPhoneNumber() != $data['phone'] || $userPhone->getMobileProviderCode()->getId() != $data['phone_code']) {
if ($data['smsCode'] ?? false) {
if ($sessionSmsCode !== $data['smsCode']) {
$aData['smsCodeShow'] = false;
$aData['isWrongCode'] = true;
} else {
$aData['isWrongCode'] = false;
$checkCode = $data['smsCode'];
}
} else {
$aData['smsCodeShow'] = true;
$aData['isWrongCode'] = true;
}
} elseif (!$userPhone->getCodeCheck()) {
if ($data['smsCode'] ?? false) {
if ($sessionSmsCode !== $data['smsCode']) {
$aData['smsCodeShow'] = false;
$aData['isWrongCode'] = true;
} else {
$aData['isWrongCode'] = false;
$checkCode = $data['smsCode'];
}
} else {
$aData['smsCodeShow'] = true;
}
} else {
$aData['isWrongCode'] = false;
}
} else {
if ($data['smsCode'] ?? false) {
if ($sessionSmsCode !== $data['smsCode']) {
$aData['smsCodeShow'] = false;
$aData['isWrongCode'] = true;
} else {
$aData['isWrongCode'] = false;
$checkCode = $data['smsCode'];
}
} else {
$aData['smsCodeShow'] = true;
}
}
shit ... this junior
private static function derivePrice(...)
{
$price = self::derivePriceUnchecked($vars);
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
if (isset($price)) {
// CODE HERE
}
return $price;
}
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
Never, ever define developer environment and debug as default thing! #pdk
<?php
$arr = [
["price" => 1],
["price" => 2]
];
$update = $arr;
$update[0]["price"] = 4;
$arr = $update;
while (true) {
if ($current === $requested) {
break;
}
if (! in_array($requested, $available)) {
break;
}
session()->put('locale', $requested);
break;
}
if (preg_match("/^N/",$postcode)) {
if (preg_match("/^NW/", $postcode)) {
if (!preg_match("/^NW1/", $postcode)) {
// NORTH WEST (NW2, NW3, NW4, NW5, NW6, NW7, NW8, NW9, NW10)
$property['Prop_area'] = 'NW';
} else {
// NW1 which is Central
$property['Prop_area'] = 'SW';
}
} else {
// NORTH (N1, N2, N3, N4, N5 etc)
$property['Prop_area'] = 'N';
}
} else if (preg_match("/^W/",$postcode)) {
if (
!preg_match("/^W1 /",$postcode)
&& !preg_match("/^W2 /",$postcode)
&& !preg_match("/^W8/",$postcode)
&& !preg_match("/^W11/",$postcode)
) {
// WEST includes (W3, W4, W5, W6, W7, W9, W10, W12, W13, W14)
$property['Prop_area'] = 'W';
} else {
//W1 and W2, W8, W11 which are Central
$property['Prop_area'] = 'SW';
}
} else {
if (
preg_match("/^SW/",$postcode)
|| preg_match("/^EC/",$postcode)
|| preg_match("/^WC/",$postcode)
) {
// CENTRAL includes (W1, W2, EC, WC, NW1, SW1, SW3, SW5, SW7, W8, W11)
$property['Prop_area'] = 'SW';
} else {
// OTHER includes South and East and everything else
return 'SE';
}
}
$arrival_time = $obj->{'s1_6-2-'.strval($i).'date'} . ' ' . $obj->{'s1_6-2-'.strval($i).'time'} . ':00';
public function get($paymentType, $carrier, $gds, $clearingCompany, $allowDirectPayment)
{
AcqData::preload();
$carrier = strtoupper($carrier);
if($paymentType == 'cc') {
$gdsVal = $this->acqData->getGdsVal($gds);
if(!$allowDirectPayment ||
!$gdsVal ||
!isset($gdsVal['lr'], $gdsVal['direct'], $gdsVal['lr_commission_acq'], $gdsVal['direct_commission_acq'])
) {
$ccDefaultVal = $this->acqData->getPaymentTypeVal($paymentType);
return [[$ccDefaultVal, $ccDefaultVal], false];
}
$commission = $gdsVal['direct_commission_acq'];
$isDirect = $this->isDirect($carrier, $gds, $clearingCompany);
if(!$isDirect) {
$gdsVal['direct'] = $gdsVal['lr'];
$commission = $gdsVal['lr'];
}
return [
[$gdsVal['direct'], $commission],
$isDirect
];
}
$paymentTypeVal = $this->acqData->getPaymentTypeVal($paymentType);
return [
[$paymentTypeVal, $paymentTypeVal],
false
];
}
$ccDefaultVal = $this->acqData->getPaymentTypeVal($paymentType); is duplicated in two branches...
function mysql_escape_string($str) {
$pattern = [
'/\x00/',
'/\n/',
'/\r/',
'/\//',
"/'/",
'/"/',
'/\x1a/',
];
$replacement = [
'\\x00',
'\\n',
'\\r',
'\\',
"\'",
'\"',
'\\x1a',
];
$res = preg_replace($pattern, $replacement, $str);
return $res;
}
<?php
$payload = '{ "products": [';
foreach ($products as $product) {
$payload .= $product->toJson() . ',';
}
$payload = substr($payload, 0, \strlen($payload) - 1);
$payload .= ']}';
$partnerChargesRegular = $row['charges'];
$partnerChargesIrregular = $row['charges'];
if (!isset($partnerChargesIrregular) || $partnerChargesIrregular == "") {
$partnerChargesIrregular = $partnerChargesRegular;
}
Look. We take A from X and B from X. Then, you make a check, and if it is true you assing A to B. BUT A AND B ARE TAKEN FROM THE SAME X PLACE!!! HOW CAN THEY DIFFER?!?!!!?!?!?!?!!
<?php
public function parse($package)
{
if(isset($package["type"]) && $package["type"] == "unavailable")
{
if(((time() - self::$xmpp->users[(string)$package["from"]]["jointime"] < 30 && (isset(self::$xmpp->users[(string)$package["from"]]["messages"]) && self::$xmpp->users[(string)$package["from"]]["messages"] < 2) && (time() - self::$xmpp->startTime) > 50)) || (!isset(self::$xmpp->users[(string)$package["from"]]["messages"]) && time() - self::$xmpp->users[(string)$package["from"]]["jointime"] < 900 && (time() - self::$xmpp->startTime) > 900))
{
if(!array_search(strstr(self::$xmpp->users[(string)$package["from"]]["jid"], "/", true), explode("\n", file_get_contents("friends.txt"))))
{
self::$xmpp->ban(strstr($package["from"], "/", true), self::$xmpp->users[(string)$package["from"]]["jid"]);
self::$xmpp->groupMessage(strstr($package["from"], "/", true), substr(strstr($package["from"], "/"), 1)." został zbanowany/a za przeciąg!");
}
}
else
if(!array_search(strstr(self::$xmpp->users[(string)$package["from"]]["jid"], "/", true), explode("\n", file_get_contents("friends.txt"))))
file_put_contents("friends.txt", file_get_contents("friends.txt")."\n".strstr(self::$xmpp->users[(string)$package["from"]]["jid"], "/", true));
}
}
In fact whole project is shitty as hell, if you want have some fun grab popcorn and read all the sources: XPBot on sourceforge
$command = 'curl -X GET -H "application/json" -H "X-Api-Key: '.$key.'" https://some-api.com/resource';
exec($command, $output);
$array = json_decode($output[0], true);
Using curl in PHP is boring. Let execute a command for
$config = Config::getConfig('common');
$contract_carriers = $config[$market . "_" . $clearing . '_contract_carriers']; // f**ing php array
$interline_carriers = $config[$market . "_" . $clearing . '_interline_carriers']; // another f**ing array
// $marketing_carriers - is also array
$sets = [];
foreach ($marketing_carriers as $mc) {
$sets[] = array_unique(array_intersect(
array_merge(
[$mc],
array_intersect(
isset(self::$interlines[$mc]) ? self::$interlines[$mc] : [],
array_merge(
$marketing_carriers,
$interline_carriers
)
)
),
$contract_carriers
));
}
in_array($this->market, ["ru"])
There is an old mysterious legend, which says that those conditions are lightening fast which are using in_array($source, ["target"]) instead of just "==". Is says always that probably you never do code refactoring, and keep all shit alive