/** * sort an array according to the file name * */ function filesort($a, $b) { $aKey = ""; if (!empty($a["FILE"])) { $aKey = basename($a["FILE"]); } else { if (!empty($a["file"])) { $aKey = basename($a["file"]); } } $bKey = ""; if (!empty($b["FILE"])) { $bKey = basename($b["FILE"]); } else { if (!empty($b["file"])) { $bKey = basename($b["file"]); } } return compareStrings($aKey, $bKey, true); // Case-insensitive compare }
<?php header('Access-Control-Allow-Origin: *'); define("SCRIPT_DIR", dirname(__FILE__)); require SCRIPT_DIR . "/src/lp_b24_config.php"; //*/ ///////// WORK ///////// // only UTF-8 if (!defined('TOKEN') || TOKEN == '' || TOKEN == 'HERE_TO_INSERT_CODE') { Response::setValue('response', array('status' => 'error', 'message' => 'token key not set in config at hosting')); Response::setValue('values', iLPB24HOSTINGVER); //update_ver Response::sendValues(); die; } elseif (!isset($_REQUEST['token']) || !compareStrings(getToken(), $_REQUEST['token']) && !compareStrings(md5(getToken()), $_REQUEST['token'])) { Response::setValue('response', array('status' => 'error', 'message' => 'bad token key')); Response::setValue('values', iLPB24HOSTINGVER); //update_ver Response::sendValues(); die; } elseif (!isset($_REQUEST['projectId']) || intval($_REQUEST['projectId']) < 1) { Response::setValue('response', array('status' => 'error', 'message' => 'bad project ID')); Response::sendValues(); die; } try { // decode angular response /////////////////////// if (isset($_REQUEST['prepere'])) { $params = json_decode(trim(file_get_contents('php://input')), true); if (count($params) > 0) { foreach ($params as $kode => $val) {
static function _name_name_rsort($a, $b) { return compareStrings(strip_prefix($b['name']), strip_prefix($a['name']), true); // Case-insensitive compare }
<?php $string1 = " hi, how are you doing"; $string2 = " hi, how are you"; echo 'Compare result: ' . compareStrings($string1, $string2) . '%'; //60% function compareStrings($s1, $s2) { //one is empty, so no result if (strlen($s1) == 0 || strlen($s2) == 0) { return 0; } //replace none alphanumeric charactors //i left - in case its used to combine words $s1clean = preg_replace("/[^A-Za-z0-9-]/", ' ', $s1); $s2clean = preg_replace("/[^A-Za-z0-9-]/", ' ', $s2); //remove double spaces while (strpos($s1clean, " ") !== false) { $s1clean = str_replace(" ", " ", $s1clean); } while (strpos($s2clean, " ") !== false) { $s2clean = str_replace(" ", " ", $s2clean); } //create arrays $ar1 = explode(" ", $s1clean); $ar2 = explode(" ", $s2clean); $l1 = count($ar1); $l2 = count($ar2); //flip the arrays if needed so ar1 is always largest. if ($l2 > $l1) { $t = $ar2;
static function Compare($x, $y) { if ($x->canDisplayName()) { if ($y->canDisplayName()) { return compareStrings($x->getSortName(), $y->getSortName()); } else { return -1; // only $y is private } } else { if ($y->canDisplayName()) { return 1; // only $x is private } else { return 0; // both $x and $y private } } }