/**
* 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);
}
if(!isset($obj->{'s5_4-1'})) {
$obj->{'s5_4-1'} = 0;
}
if(!isset($obj->{'s5_4-2'})) {
$obj->{'s5_4-2'} = 0;
}
if(!isset($obj->{'s5_4-3'})) {
$obj->{'s5_4-3'} = 0;
}
if(!isset($obj->{'s5_4-4'})) {
$obj->{'s5_4-4'} = 0;
}
<?php
class CasinoCode
{
CONST POST = 'POST';
CONST GET = 'GET';
$data = $this->callAPI('/hidden', [], self::POST);
production code of an API with dozens of millions of requests per day.
if (isLink($content[$i][$j])) {
if (isImageLink($content[$i][$j])) {
$image_src = create_image($content[$i][$j], "img");
$cell = <<<HTML
<td>
<img {$image_src} {$img_style}></td></img>
</td>
HTML;
} else if (isNestedLink($content[$i][$j])) {
$links = explode("!", $content[$i][$j]);
$cell = <<<HTML
<td><a style="color: {$cards_button_bg_color};" href="{$links[1]}" $open_links_in >{$links[0]}</a></td>
HTML;
} else {
//Checking if it's a link or a button
if ($j == $table_button_column) {
//Button HTML
$table_button_text = explode("-", $content[0][$j])[0];
$cell = <<<HTML
<td><a {$open_links_in} href="{$content[$i][$j]}" style="background-color: {$cards_button_bg_color}; color: {$cards_button_text_color};" class="btn">{$table_button_text}</a></td>
HTML;
} else {
// Link HTML
$cell = <<<HTML
<td><a style="color: {$cards_button_bg_color};" href="{$content[$i][$j]}" $open_links_in >{$content[0][$j]}</a></td>
HTML;
}
}
public override List<Value> Values
{
get
{
if (_values == null && shouldLoadLazily)
{
_values = _lazerLoader.LoadValues<Value>()
}
return _values;
}
set
{
throw new InvalidOperationException("Values are actually readonly- please set in constructor")
}
}
How to create immutable fields in c#
$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.
$orderDateTS = strtotime($data['ordertime']);
$nowTS = strtotime('now');
$diff = $nowTS - $orderDateTS;
$diff = $diff / 86400;
$dayDiff = floor($diff);
found in a shopware plugin
public static function getUser(){
return \App\Models\User::all();
}
function prepareKeyword($keyword) {
$keyword = html_entity_decode($keyword);
$keyword = html_entity_decode($keyword);
$keyword = html_entity_decode($keyword);
$keyword = iconv("ISO-8859-1", "UTF-8", $keyword);
$keyword = cleanString($keyword);
$keyword = html_entity_decode($keyword);
if ($keyword != "") {
$keyword = mb_strtolower($keyword, "UTF-8");
$keyword = htmlentities($keyword, ENT_HTML5);
}
return $keyword;
}
if ($customerId > 0) {
$customerId = $customerId;
} else {
$customerId = $this->customerSession->getId();
}
if((strtotime(date("Y-m-d"))-strtotime(date("Y-m-d", filemtime($filename))))/(3600)<=$config->hourDiff) return true; else return false;
please notice the brackets around 3600
const handleBoolean = value => {
switch (value) {
case "true":
return true;
case true:
return "true";
case "false":
return false;
case false:
return "false"
default:
return null;
}
}
$guard = ($vars->a_payment) + (0) * $price;
if ($bless >= $guard) {
$amount = $bless;
}
Why not to write just 1 line?! $amount = max($bless, $vars->a_payment);
<?php
if(!defined('WPINC')) // MUST have WordPress.
exit ('Do not access this file directly.');
if(!class_exists('pluginName_options_page_class'))
{
/**
* Menu page blah
*
* @package blah
* @since 140617
*/
class pluginName_options_page_class
{
public function __construct()
{
echo '<div class="wrap menu-page">'."\n";
echo '<div class="wp-header-end"></div>'."\n";
echo '<div class="menu-page-toolbox">'."\n";
pluginName_some_other_class::display();
echo '</div>'."\n";
echo '<h2>Options</h2>'."\n";
echo '<table class="menu-page-table">'."\n";
echo '<tbody class="menu-page-table-tbody">'."\n";
echo '<tr class="menu-page-table-tr">'."\n";
echo '<td class="menu-page-table-l">'."\n";
echo '<form method="post" name="plugin_options_form" id="plugin--options-form" autocomplete="off">'."\n";
echo '<input type="hidden" name="plugin_options_save" id="plugin--options-save" value="'.esc_attr(wp_create_nonce('plugin--options-save')).'" />'."\n";
echo '<div class="menu-page-group" title="Account Details">'."\n";
/* includes things like this gem */
echo (!is_multisite() || !pluginName_utils_conds::is_multisite_farm() || is_main_site()) ? '<p>[ Really Long message about something ]</p>'."\n" : '';
/* ... continues until end ... */
echo '</div>'."\n";
}
}
}
new pluginName_options_page_class ();
The entire file is a single class with a constructor. The constructor is ~ 1150 lines of echo statements with a few PHP conditionals thrown in. There are no other methods. The class is instantiated as soon as it is defined. Clever...
function focused(evt, errors) {
let form = evt.target
const output = errors.map((error)=> {
// Find first component with error on form and set focus to it
let focusedInput = (Object.keys(error) == "phonebookId") ? Object.keys(error) :
(Object.keys(error) == "phonebook_str") ? Object.keys(error) :
(Object.keys(error) == "message") ? Object.keys(error) :
(Object.keys(error) == "image") ? Object.keys(error) :
(Object.keys(error) == "buttonLink") ? Object.keys(error) :
(Object.keys(error) == "messageSms") ? Object.keys(error) : false
return focusedInput.shift()
})
const selector = output.shift()
form.querySelector('[id="' + selector + '"]').focus()
return selector
Shitcode