<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 .

By Ed, 2023-07-28 10:51:07
<?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

By baueri, 2022-05-31 17:30:21

//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;
}
By Anonymous, 2022-05-30 18:28:02
          //////////////////////////////////////////
          // Add ROI coordinates into Environment
          //////////////////////////////////////////
          AddROIcoordinatesIntoEnvironment();

It really helped me understand the code.

By Anonymous, 2022-05-30 00:49:45
public static function getUser(){
    return \App\Models\User::all();
}
By mamadSiah, 2022-02-23 14:35:19
const handleBoolean = value => {
        switch (value) {
            case "true":
                return true;
            case true:
                return "true";
            case "false":
                return false;
            case false:
                return "false"
            default:
                return null;
        }
    }
By Ifncn, 2022-01-27 07:49:16

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.

By peakvalleytech, 2021-11-13 00:07:44
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

By Anonymous, 2021-05-28 01:16:05
<?php
$arr = [
    ["price" => 1],
    ["price" => 2]
];

$update = $arr;
$update[0]["price"] = 4;

$arr = $update;
By mamadSiah, 2021-05-11 11:06:19
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

By Samuel, 2021-03-29 17:52:33
// 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

By kadet, 2021-03-08 23:28:18
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

By sergma33, 2020-12-23 15:30:45
<?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...

By Anonymous, 2020-11-10 06:08:16
while (true) {
  if ($current === $requested) {
     break;
  }
  if (! in_array($requested, $available)) {
     break;
  }
  session()->put('locale', $requested);
  break;
}
By Ed, 2020-08-05 15:26:32
#1344 PHP +32
$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

By Anonymous, 2020-07-14 20:28:49