if ($this->getTestSku()) {
...
} elseif ($this->getTestOffset() >= 0 && $this->getTestLimit() > 0) {
...
} else {
Mage::throwException(sprintf("Invalid parameters for test mode: sku %s or offset %s and limit %s", $this->getTestSku(), $this->getTestOffset(), $this->getTestLimit()));
}
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
/**
* Creates hash of client/customer password
* @param string $password The actual password
* @return string MD5 hash of password with salt
*/
public static function hashPassword($password)
{
return md5($password . $password. 'SOME-SECRET-STRING' . $password);
}
$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?!?!!!?!?!?!?!!
$d = explode(".",$request->get("due_date",".."));
foreach ($d as $key => $val) $d[$key]=(int)$val;
if (
!is_numeric($d[0]) || $d[0]<1 ||$d[0]>31 ||
!is_numeric($d[1]) || $d[1]<1 ||$d[1]>12 ||
!is_numeric($d[2]) || $d[2]<2005 ||$d[2]>2100 ) {
$error["due_date"] = "Missing date.";
}
I think this was the last piece of code the developer wrote .... :D
<?php
$k =1;
for($v = 0; $v < $nt; $v++) {
$bgClass= 'blueBg';
if($k > 1 && $k%2 == 0){
$bgClass= 'whiteBg';
}
?>
<tr class="row_tr <?php echo $bgClass;?>">
<td class="row_td td_column_0"> </td>
<td class="row_td column_1"><?php echo $rows[$v]['nothing'];?></td>
...
<td class="row_td td_column_0"> </td>
</tr>
<?php
$k++;
}
?>
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;
}
$guard = ($vars->a_payment) + (0) * $price;
if ($bless >= $guard) {
$amount = $bless;
}
Why not to write just 1 line?! $amount = max($bless, $vars->a_payment);
if (isset(self::$proposals[$view])) {
$best_proposals = [];
$all_sources = [];
foreach (self::$proposals[$view] as $proposal_source => $proposal) {
if (!isset($this->backend_branch) || substr($this->backend_branch, 0, 11) != "adjust-for:" || substr($this->backend_branch, 11) == $proposal_source) {
if ($proposal['orig_base'] == $curr_base || $relax_checking) {
$age = time() - $proposal['updated_at'];
if ($age < self::MAX_AGE) {
foreach ($proposal['proposals'] as $proposal_label => $proposal_price) {
if (!in_array($proposal_label, [self::SK_LABEL_AVIASALES, self::SK_LABEL_SKYSCANNER, self::SK_LABEL_YANDEX, self::SK_LABEL_MOMONDO])) {
$proposal_key = $proposal_label;
if (!isset($best_proposals[$proposal_key]) || $best_proposals[$proposal_key]['price'] > $proposal_price) {
$best_proposals[$proposal_key] = [
'price' => $proposal_price,
'name' => $proposal_price . "@" . implode("~", array_map(function ($part) {
return preg_replace('/[~|=#@ ]/', '_', $part);
}, [
'label' => $proposal_label,
'source' => $proposal_source,
])),
'age' => $age,
];
$all_sources[$proposal_source] = null;
}
}
}
}
}
}
}
if ( $ordinal_competitors > 0 ) {
foreach( $ordinal_bests as $label => $tuple ) {
unset( $waste[ $tuple['id']->{ '$id' } ] );
$essential[ $search_str ][ $tuple['stamp'] ][ $tuple['source'] ]['updated_at'] = $tuple['updated'];
$essential[ $search_str ][ $tuple['stamp'] ][ $tuple['source'] ]['proposals'][ $label ] = $tuple['price'];
$final_count ++;
}
}
$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
));
}
if ($customerId > 0) {
$customerId = $customerId;
} else {
$customerId = $this->customerSession->getId();
}
foreach ($desired_components as $name => $junk) {
list($component_value, $component_comments) = self::unpackPair($desired_components[$name]);
$desired_components[$name] = self::packPair(round($component_value, 2), $component_comments);
}
$url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22https%3A%2F%2Fwww.google.com%2Ffinance%3Fq%3D' . $stock_identifier . '%26fstype%3Dii%26ei%3DCFrdWImFNdiGe_atlegC%22%20and%20compat%3D%22html5%22%20and%20xpath%3D' . "'%2F%2Ftable%5Bcontains(%40class%2C%22gf-table%20rgt%22)%5D'" . '&format=json&diagnostics=true&callback=';
$json = json_decode($this->getJsonFromYql($url), true);
$json = $json["query"]["results"]["table"];
//If the value is red, that means there is an additional span class which needs to be checked through.
$response["revanueValue"] = empty($json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["0"]["td"]["1"]["content"];
$response["costofRevanue"] = $json["1"]["tbody"]["tr"]["3"]["td"]["1"]["content"];
$response["operatingIncome"] = empty($json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["12"]["td"]["1"]["content"];
$response["netIncome"] = empty($json["1"]["tbody"]["tr"]["24"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["24"]["td"]["1"]["span"]["content"] : $json["0"]["tbody"]["tr"]["24"]["td"]["1"]["content"];
$response["dividendsPerShare"] = $json["1"]["tbody"]["tr"]["35"]["td"]["1"]["content"];
$response["dilutedNormalizedEps"] = empty($json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"]) ? $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["span"]["content"] : $json["1"]["tbody"]["tr"]["48"]["td"]["1"]["content"];
$response["minorityInterest"] = $json["1"]["tbody"]["tr"]["18"]["td"]["1"]["content"];
Website --> Json --> PHP Parsing Beautiful.