<?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...
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
// 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
foreach($bookings as $booking) {
$status = $apiController->getBookingStatus($booking);
if($status->error == 1) {
switch($status->message) {
case "FIND_PRV_KO": continue; //Wrong parameters
case "ERR_PREN_NOTFOUND": continue; //Request booking cannot be found
case "ERR_PRV_NOTFOUND": continue; //Check-in not carried out
default: continue;
};
continue;
}
//DO SOME STUFF...
}
Found this on a production website
<?php
$arr = [
["price" => 1],
["price" => 2]
];
$update = $arr;
$update[0]["price"] = 4;
$arr = $update;
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
abstract class ASong(
var songId: Int = 0,
var title: String? = "",
var clipArt: String? = "",
var artist: String? = "",
var source: String? = "",
var songType: Int = 0,
var length: String? = "",
var downloadPath: String? = "",
var category: String? = ""
) : Parcelable {
@Transient
var totalDuration: Long = 0
@Transient
var currentPosition: Long = 0
@Transient
var playingPercent = 0
private fun calculatePlayingPercent(): Int {
return if (currentPosition == 0L || totalDuration == 0L) 0 else (currentPosition * 100 / totalDuration).toInt()
}
}
© 2021 GitHub, Inc
Probably meant to stand for AbstractSong. Ens up sounding awkward or like somebody who just wrote their first class.
const handleBoolean = value => {
switch (value) {
case "true":
return true;
case true:
return "true";
case "false":
return false;
case false:
return "false"
default:
return null;
}
}
public static function getUser(){
return \App\Models\User::all();
}
//////////////////////////////////////////
// Add ROI coordinates into Environment
//////////////////////////////////////////
AddROIcoordinatesIntoEnvironment();
It really helped me understand the code.
//https://gist.github.com/nim4n136/7fa38467181130f5a2270c39d495101e
function decrypt($msg_encrypted_bundle, $password){
$password = sha1($password);
$components = explode( ':', $msg_encrypted_bundle );
$iv = $components[0];
$salt = hash('sha256', $password.$components[1]);
$encrypted_msg = $components[2];
$decrypted_msg = openssl_decrypt(
$encrypted_msg, 'aes-256-cbc', $salt, null, $iv
);
if ( $decrypted_msg === false )
return false;
return $decrypted_msg;
}
<?php
// This code supposed to find adjacent items of a specific one
// $list is an array of ids
// $itemToSearch is an id that might be in the $list
foreach ($list as $item) {
next($list);
if ($item == $itemToSearch) {
break;
}
$previousItem = $item;
}
$nextItem = current($list);
The $list variable is a list of ids, e.g [1, 2, 3, 4, 5] The $itemToSearch is an id that might be in $list
<style type="text/css">
<?php echo file_get_contents(
\realpath(ROOT_PATH . '/public/').$this->assetPath('css/styles.css', true)
); ?>
</style>
Including style file (about 100kb) directly to HTML page. Thanks for developer, it's in
.