function showDate($date) { $stf = 0; $current_time = time(); $diff = $current_time - $date; $seconds = array('секунду', 'секунды', 'секунд'); $minutes = array('минуту', 'минуты', 'минут'); $hours = array('час', 'часа', 'часов'); $days = array('день', 'дня', 'дней'); $weeks = array('неделю', 'недели', 'недель'); $months = array('месяц', 'месяца', 'месяцев'); $years = array('год', 'года', 'лет'); $phrase = array($seconds, $minutes, $hours, $days, $weeks, $months, $years); $length = array(1, 60, 3600, 86400, 604800, 2630880, 31570560); for ($i = sizeof($length) - 1; $i >= 0 && ($no = $diff / $length[$i]) <= 1; $i--) { } if ($i < 0) { $i = 0; } $_time = $current_time - $diff % $length[$i]; $no = floor($no); $value = sprintf("%d %s ", $no, getPhrase($no, $phrase[$i])); if ($stf == 1 && $i >= 1 && $current_time - $_time > 0) { $value .= time_ago($_time); } if (strCaseCmp($value, '1 день ') == 0) { return 'вчера'; } else { return $value . ' назад'; } }
<?php define('IMPASS_CHECK', true); include "../jcr_settings.php"; @($action = $_GET['action']); @($getIP = $_GET['ip']); @($getPort = $_GET['port']); if ($action == 'status' && $getIP != null && $getPort != null) { if (!$pauseMon) { for ($i = 0; $i < count($pauseSelMon); $i++) { $splitServer = explode(" :: ", $pauseSelMon[$i]); $contains = strCaseCmp($splitServer[0], $getIP) . strCaseCmp($splitServer[1], $getPort); if ($contains == '00') { break; } } if ($contains != '00') { $Server = new ServerStatus($IP = $getIP, $Port = $getPort); $status = $Server->Online ? true : false; if ($Server && $status) { $players = preg_replace('/\\D/', '', $Server->OnlinePlayers); $maxplayers = preg_replace('/\\D/', '', $Server->MaxPlayers); if (empty($maxplayers)) { echo 'TechWork'; } else { echo $players . '<::>' . $maxplayers; } } else { echo 'OFF'; } } else {
function gs_user_external_numbers_get($user) { if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) { return new GsError('User must be alphanumeric.'); } # connect to db # $db = gs_db_master_connect(); if (!$db) { return new GsError('Could not connect to database.'); } # get user_id # $user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\''); if ($user_id < 1) { return new GsError('Unknown user.'); } # get external numbers # switch (GS_EXTERNAL_NUMBERS_BACKEND) { case 'ldap': //ldapsearch -x -D 'cn=root,dc=example,dc=com' -w secret -b 'ou=People,dc=example,dc=com' '(uid=demo2)' telephoneNumber $ldap = gs_ldap_connect(); if (!$ldap) { return new GsError('Could not connect to LDAP server.'); } $ldap_user = $user; if (gs_get_conf('GS_LVM_USER_6_DIGIT_INT')) { $ldap_user = preg_replace('/^0+/', '', $ldap_user); # if the usernames in your LDAP are integers without a # leading "0" } $userArr = gs_ldap_get_first($ldap, GS_LDAP_SEARCHBASE, GS_LDAP_PROP_USER . '=' . $ldap_user, array(GS_EXTERNAL_NUMBERS_LDAP_PROP)); if (isGsError($userArr)) { return new GsError($userArr->getMsg()); } if (!is_array($userArr)) { //return new GsError( 'User "'. GS_LDAP_PROP_USER .'='. $user .','. GS_LDAP_SEARCHBASE .'" not in LDAP.' ); $numbers = array(); } else { foreach ($userArr as $key => $arr) { if (strCaseCmp($key, GS_EXTERNAL_NUMBERS_LDAP_PROP) == 0) { $numbers = $arr; sort($numbers); break; } } } gs_ldap_disconnect($ldap); break; case 'db': default: $rs = $db->execute('SELECT `number` FROM `users_external_numbers` WHERE `user_id`=' . $user_id . ' ORDER BY `number`'); if (!$rs) { return new GsError('Failed to get external numbers.'); } $numbers = array(); while ($r = $rs->fetchRow()) { $numbers[] = $r['number']; } break; } return $numbers; }
/** * TODOリストを更新して保存する */ private function _updateList() { $oldCat = new Todo($_POST['oldcat']); //変更前のカテゴリ $newPath = $this->getPath(); if (is_file(strToUpper(__FILE__))) { //ファイルパスで大文字小文字を区別しない場合 $change = strCaseCmp($oldCat->cat, $this->cat); } else { $change = $oldCat->cat != $this->cat; } if ($change && is_file($newPath)) { return; //変更後のカテゴリが既に存在する場合は更新しない } $oldPath = $oldCat->getPath(); if ($oldCat->isValidCat() && is_file($oldPath)) { rename($oldPath, $oldPath . '.' . date('YmdHis')); //バックアップ } foreach ($_POST['todo'] as $post) { if ($post[1] != '') { //TODO未入力は削除 $data .= implode("\t", array_map(array($this, '_encode'), $post)) . "\n"; } } file_put_contents($newPath, $data); }
/** * <p>Sortierungs-Funktion zur Nutzung mittels * {@link http://de.php.net/manual/de/function.usort.php}.</p> * @param array|ArrayAccess $a * @param array|ArrayAccess $b * @return int <p>-1, wenn das $a vor $b im Array stehen soll, ansonsten 1.</p> */ public function sort($a, $b) { $compare = 0; $orders = $this->_criteria->getOrders(); foreach ($orders as $key => $direction) { $key = $this->_transformAlias($key); if (is_array($a) && is_array($b) || $a instanceof ArrayAccess && $b instanceof ArrayAccess) { $compare = strCaseCmp($a[$key], $b[$key]); } else { $compare = strCaseCmp($a->{$key}, $b->{$key}); } if ($direction == Dkplus_Model_Criteria::ORDER_ASC) { $compare *= -1; } if ($compare != 0) { break; } } return $compare; }