本文整理汇总了PHP中MAX函数的典型用法代码示例。如果您正苦于以下问题:PHP MAX函数的具体用法?PHP MAX怎么用?PHP MAX使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MAX函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _timecheck
private function _timecheck(&$times, $sameday)
{
foreach ($times as &$range) {
//TODO interpet any sun-related times
$s = $sameday ? MAX($range[0], $tstart) : $range[0];
//TODO support roll-over to contiguous day(s) & time(s)
if ($range[1] >= $s + $length) {
unset($range);
return $s;
}
}
unset($range);
return FALSE;
}
示例2: page
function page($total = 0, $everpage = 10, $query = array())
{
$this->total = $this->totalItems = $total;
$this->everpage = $everpage;
$this->pages = max(1, abs(ceil($total / $everpage)));
$this->currentPage = max((int) $_GET['pageID'], 1);
//2
$num = ceil(3 / 2);
$this->max = MIN(MAX($this->currentPage + $num, 3), $this->pages);
$this->min = MAX(MIN($this->currentPage - $num, $this->pages - 3), 1);
$this->limit_1 = ($this->currentPage - 1) * $this->everpage;
$this->limit_2 = $this->everpage;
$this->limit_3 = $this->currentPage * $this->everpage;
$this->num_1 = '';
$this->num_3 = ' LIMIT ' . $this->limit_1 . ',' . $this->limit_2;
}
示例3: addLine
function addLine($worksheet_name, $clo)
{
$cfg = $this->worksheet_cfg[$worksheet_name];
$start_row = $this->start_row;
$formats = (array) $this->formats;
$worksheet = $this->worksheet;
$hasRender = false;
$r = 0;
$cl = $clo;
if (is_object($clo)) {
$cl = (array) $clo;
// lossless converstion..
}
if (isset($cfg['row_height'])) {
$worksheet->setRow($start_row + $r, $cfg['row_height']);
}
$line_height = isset($cfg['line_height']) ? $cfg['line_height'] : 12;
$height = 0;
foreach ($cfg['cols'] as $c => $col_cfg) {
if (isset($col_cfg['dataIndex']) && isset($cl[$col_cfg['dataIndex']])) {
$v = $cl[$col_cfg['dataIndex']];
} else {
if (isset($col_cfg['fillBlank'])) {
$worksheet->write($start_row + $r, $c, '', $formats[$col_cfg['fillBlank']]);
}
continue;
}
if (!isset($cl[$col_cfg['dataIndex']])) {
continue;
}
if (isset($col_cfg['txtrenderer'])) {
if (is_a($col_cfg['txtrenderer'], 'Closure')) {
$v = $col_cfg['txtrenderer']($cl[$col_cfg['dataIndex']], $worksheet, $r + 1, $c, $clo);
} else {
$v = call_user_func($col_cfg['txtrenderer'], $cl[$col_cfg['dataIndex']], $worksheet, $r + 1, $c, $clo);
}
if ($v === false) {
continue;
}
// var_dump($v);
}
if (isset($col_cfg['renderer'])) {
$hasRender = true;
continue;
}
$v = @iconv('UTF-8', 'UTF-8//TRANSLIT//IGNORE', $v);
$dataFormat = empty($col_cfg['dataFormat']) ? '' : $col_cfg['dataFormat'];
$format = isset($col_cfg['format']) && isset($formats[$col_cfg['format']]) ? $formats[$col_cfg['format']] : false;
// print_R(array($start_row+$r, $c, $v, $format));exit;
// handle 0 prefixes..
if (is_numeric($v) && strlen($v) > 1 && substr($v, 0, 1) == '0' && substr($v, 1, 1) != '.' || $dataFormat == 'string') {
$worksheet->writeString($start_row + $r, $c, $v, $format);
} else {
$worksheet->write($start_row + $r, $c, $v, $format);
}
if (isset($col_cfg['autoHeight'])) {
$vv = explode("\n", $v);
$height = MAX(count($vv) * $line_height, $height);
$worksheet->setRow($start_row + $r, $height);
}
}
$this->start_row++;
return $hasRender;
}
示例4: MAX
<?php
include "./config/connectDatabase.php";
$cancleFavSql = "DELETE FROM jobs_user_fav \n\t\t\t\t\tWHERE activity_id = '{$_POST['activityID']}' \n\t\t\t\t\tAND activity_type = '{$_POST['activityType']}'\n\t\t\t\t\tAND user_id = '{$_POST['userID']}'\n\t\t\t\t\tAND type = '{$_POST['userType']}';";
$conn->query($cancleFavSql);
$getFavNumSql = "SELECT fav_num \n\t\t\t\t\tfrom jobs_activity \n\t\t\t\t\tWHERE id = '{$_POST['activityID']}';";
$favNumResult = $conn->query($getFavNumSql);
$favNum = $favNumResult->fetch_row();
$newFavNum = MAX($favNum[0] - 1, 0);
$favNumDecreaseSql = "UPDATE jobs_activity \n SET fav_num = " . $newFavNum . " WHERE id = '{$_POST['activityID']}';";
$conn->query($favNumDecreaseSql);
mysql_errno();
$conn->close();
示例5: WriteFlowingBlock
//.........这里部分代码省略.........
/*-- CSS-FLOAT --*/
if (count($this->floatDivs)) {
list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->blklvl);
if ($r_exists) { $fpaddingR = $r_width; }
if ($l_exists) { $fpaddingL = $l_width; }
}
/*-- END CSS-FLOAT --*/
$usey = $this->y + 0.002;
if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) ) {
$usey += $this->blk[$this->blklvl]['margin_top'] + $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w'];
}
/*-- CSS-IMAGE-FLOAT --*/
// If float exists at this level
if (isset($this->floatmargins['R']) && $usey <= $this->floatmargins['R']['y1'] && $usey >= $this->floatmargins['R']['y0'] && !$this->floatmargins['R']['skipline']) { $fpaddingR += $this->floatmargins['R']['w']; }
if (isset($this->floatmargins['L']) && $usey <= $this->floatmargins['L']['y1'] && $usey >= $this->floatmargins['L']['y0'] && !$this->floatmargins['L']['skipline']) { $fpaddingL += $this->floatmargins['L']['w']; }
/*-- END CSS-IMAGE-FLOAT --*/
} // *TABLES*
//OBJECTS - IMAGES & FORM Elements (NB has already skipped line/page if required - in printbuffer)
if (substr($s,0,3) == "\xbb\xa4\xac") { //identifier has been identified!
$objattr = $this->_getObjAttr($s);
$h_corr = 0;
if ($is_table) { // *TABLES*
$maximumW = ($maxWidth/_MPDFK) - ($this->cellPaddingL + $this->cMarginL + $this->cellPaddingR + $this->cMarginR); // *TABLES*
} // *TABLES*
else { // *TABLES*
if (($newblock) && ($blockstate==1 || $blockstate==3) && ($lineCount == 0) && (!$is_table)) { $h_corr = $this->blk[$this->blklvl]['padding_top'] + $this->blk[$this->blklvl]['border_top']['w']; }
$maximumW = ($maxWidth/_MPDFK) - ($this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'] + $this->blk[$this->blklvl]['padding_right'] + $this->blk[$this->blklvl]['border_right']['w'] + $fpaddingL + $fpaddingR );
} // *TABLES*
$objattr = $this->inlineObject($objattr['type'],$this->lMargin + $fpaddingL + ($contentWidth/_MPDFK),($this->y + $h_corr), $objattr, $this->lMargin,($contentWidth/_MPDFK),$maximumW,$lineHeight,true,$is_table);
// SET LINEHEIGHT for this line ================ RESET AT END
$lineHeight = MAX($lineHeight,$objattr['OUTER-HEIGHT']);
$this->objectbuffer[count($content)-1] = $objattr;
// if (isset($objattr['vertical-align'])) { $valign = $objattr['vertical-align']; }
// else { $valign = ''; }
$contentWidth += ($objattr['OUTER-WIDTH'] * _MPDFK);
return;
}
$lbw = $rbw = 0; // Border widths
if (!empty($this->spanborddet)) {
if (isset($this->spanborddet['L'])) $lbw = $this->spanborddet['L']['w'];
if (isset($this->spanborddet['R'])) $rbw = $this->spanborddet['R']['w'];
}
if ($this->usingCoreFont) {
$tmp = strlen( $s );
}
else {
$tmp = mb_strlen( $s, $this->mb_enc );
}
// for every character in the string
for ( $i = 0; $i < $tmp; $i++ ) {
// extract the current character
// get the width of the character in points
if ($this->usingCoreFont) {
$c = $s[$i];
// Soft Hyphens chr(173)
$cw = ($this->GetCharWidthCore($c) * _MPDFK);
if ($this->kerning && $this->useKerning && $i > 0) {
if (isset($this->CurrentFont['kerninfo'][$s[($i-1)]][$c])) {
$cw += ($this->CurrentFont['kerninfo'][$s[($i-1)]][$c] * $this->FontSizePt / 1000 );
}
示例6: _buildHeaderParam
/**
* _buildHeaderParam()
*
* Encodes the paramater of a header.
*
* @param $name The name of the header-parameter
* @param $value The value of the paramter
* @param $charset The characterset of $value
* @param $language The language used in $value
* @param $maxLength The maximum length of a line. Defauls to 75
*
* @access private
*/
function _buildHeaderParam($name, $value, $charset = NULL, $language = NULL, $maxLength = 75)
{
//If we find chars to encode, or if charset or language
//is not any of the defaults, we need to encode the value.
$shouldEncode = 0;
$secondAsterisk = '';
if (preg_match('#([\\x80-\\xFF]){1}#', $value)) {
$shouldEncode = 1;
} elseif ($charset && strtolower($charset) != 'us-ascii') {
$shouldEncode = 1;
} elseif ($language && ($language != 'en' && $language != 'en-us')) {
$shouldEncode = 1;
}
if ($shouldEncode) {
$search = array('%', ' ', "\t");
$replace = array('%25', '%20', '%09');
$encValue = str_replace($search, $replace, $value);
$encValue = preg_replace('#([\\x80-\\xFF])#e', '"%" . strtoupper(dechex(ord("\\1")))', $encValue);
$value = "{$charset}'{$language}'{$encValue}";
$secondAsterisk = '*';
}
$header = " {$name}{$secondAsterisk}=\"{$value}\"; ";
if (strlen($header) <= $maxLength) {
return $header;
}
$preLength = strlen(" {$name}*0{$secondAsterisk}=\"");
$sufLength = strlen("\";");
$maxLength = MAX(16, $maxLength - $preLength - $sufLength - 2);
$maxLengthReg = "|(.{0,{$maxLength}}[^\\%][^\\%])|";
$headers = array();
$headCount = 0;
while ($value) {
$matches = array();
$found = preg_match($maxLengthReg, $value, $matches);
if ($found) {
$headers[] = " {$name}*{$headCount}{$secondAsterisk}=\"{$matches[0]}\"";
$value = substr($value, strlen($matches[0]));
} else {
$headers[] = " {$name}*{$headCount}{$secondAsterisk}=\"{$value}\"";
$value = "";
}
$headCount++;
}
$headers = implode(MAIL_MIMEPART_CRLF, $headers) . ';';
return $headers;
}
示例7: EndStayEvent
function EndStayEvent()
{
global $pricelist, $reslist;
$LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
$expeditionPoints = array();
foreach ($reslist['fleet'] as $ID) {
$expeditionPoints[$ID] = ($pricelist[$ID]['cost'][901] + $pricelist[$ID]['cost'][902]) / 1000000;
}
$expeditionPoints[202] = 12;
$expeditionPoints[203] = 47;
$expeditionPoints[204] = 12;
$expeditionPoints[205] = 110;
$expeditionPoints[206] = 47;
$expeditionPoints[207] = 160;
$fleetRaw = explode(";", $this->_fleet['fleet_array']);
$fleetPoints = 0;
$fleetCapacity = 0;
$find_stardust = 5;
$fleetArray = array();
$stardustCount = $GLOBALS['DATABASE']->query("SELECT COUNT(planetarium) as planetarium FROM " . PLANETS . " WHERE id_owner = " . $this->_fleet['fleet_end_id'] . ";");
$stardustCount = $GLOBALS['DATABASE']->fetch_array($stardustCount);
$find_stardust = $find_stardust + $stardustCount['planetarium'];
foreach ($fleetRaw as $Group) {
if (empty($Group)) {
continue;
}
$Class = explode(",", $Group);
$fleetArray[$Class[0]] = $Class[1];
$fleetCapacity += $Class[1] * $pricelist[$Class[0]]['capacity'];
$fleetPoints += $Class[1] * $expeditionPoints[$Class[0]];
}
$fleetCapacity -= $this->_fleet['fleet_resource_metal'] + $this->_fleet['fleet_resource_crystal'] + $this->_fleet['fleet_resource_deuterium'] + $this->_fleet['fleet_resource_darkmatter'];
/*if($GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['purchase_bonus_timer'] > TIMESTAMP || $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['cosmonaute'] == 1){
$GetEvent = mt_rand(1,7);
}else{
$GetEvent = mt_rand(1,6);
} */
$GetEvent = mt_rand(1, 7);
$combat_bonus = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . USERS . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
$Message = $LNG['sys_expe_nothing_' . mt_rand(1, 8)];
$chancetogetstar = mt_rand(0, 100);
if ($chancetogetstar < $find_stardust) {
$find_stardust = 1;
} else {
$find_stardust = 0;
}
switch ($GetEvent) {
case 1:
$WitchFound = mt_rand(1, 3);
$FindSize = mt_rand(0, 100);
$Factor = 0;
if (10 < $FindSize) {
$Factor = mt_rand(100, 500) / $WitchFound * $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['resource_multiplier'];
$Factor = $Factor + $Factor / 100 * $combat_bonus['combat_reward_expe'];
$Message = $LNG['sys_expe_found_ress_1_' . mt_rand(1, 4)];
} elseif (0 < $FindSize && 10 >= $FindSize) {
$Factor = mt_rand(520, 1000) / $WitchFound * $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['resource_multiplier'];
$Factor = $Factor + $Factor / 100 * $combat_bonus['combat_reward_expe'];
$Message = $LNG['sys_expe_found_ress_2_' . mt_rand(1, 3)];
} elseif (0 == $FindSize) {
$Factor = mt_rand(1020, 2000) / $WitchFound * $GLOBALS['CONFIG'][$this->_fleet['fleet_universe']]['resource_multiplier'];
$Factor = $Factor + $Factor / 100 * $combat_bonus['combat_reward_expe'];
$Message = $LNG['sys_expe_found_ress_3_' . mt_rand(1, 2)];
}
$StatFactor = $GLOBALS['DATABASE']->getFirstRow("SELECT MAX(total_points) as total FROM `" . STATPOINTS . "` WHERE `stat_type` = 1 AND `universe` = '" . $this->_fleet['fleet_universe'] . "';");
$MaxPoints = $StatFactor['total'] < 5000000 ? 9000 : 12000;
$Size = min($Factor * MAX(MIN($fleetPoints / 1000, $MaxPoints), 200), $fleetCapacity);
switch ($WitchFound) {
case 1:
$this->UpdateFleet('fleet_resource_metal', $this->_fleet['fleet_resource_metal'] + $Size);
break;
case 2:
$this->UpdateFleet('fleet_resource_crystal', $this->_fleet['fleet_resource_crystal'] + $Size);
break;
case 3:
$this->UpdateFleet('fleet_resource_deuterium', $this->_fleet['fleet_resource_deuterium'] + $Size);
break;
}
$GLOBALS['DATABASE']->query("UPDATE " . USERS . " set `achievements_expedition` = `achievements_expedition` + '1', `expedition_count` = `expedition_count` + '1' where `id` = '" . $this->_fleet['fleet_owner'] . "';");
$GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET stardust = stardust + '" . $find_stardust . "' where `id` = " . $this->_fleet['fleet_owner'] . ";");
$INFOR = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_users` WHERE id = " . $this->_fleet['fleet_owner'] . ";");
if ($GLOBALS['DATABASE']->numRows($INFOR) > 0) {
while ($xkf = mysqli_fetch_assoc($INFOR)) {
$ACTUA = $xkf['expedition_count'];
$ACTUAL = 10 * $xkf['achievements_misc_expe'] + 10;
$expe_lvl = $xkf['achievements_misc_expe'] + 1;
$expe_reward_points = 50;
$expe_reward_am = 50;
$expe_reward_points = $expe_reward_points + $xkf['achievements_misc_expe'] * $expe_reward_points;
$expe_reward_am = $expe_reward_am + $xkf['achievements_misc_expe'] * $expe_reward_am;
}
if ($ACTUA == $ACTUAL) {
$GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET achievements_misc_expe = achievements_misc_expe + '1', antimatter = antimatter + " . $expe_reward_am . " WHERE id = " . $this->_fleet['fleet_owner'] . ";");
$msg = '<img alt="" style="float:left; width:60px; margin-right:6px;" src="styles/images/achiev/ach_expedition.png">reached: <span class="achiev_mes_head">expeditions lvl. ' . $expe_lvl . '</span><br> received:<br> ' . $expe_reward_am . ' antimatter <br> ' . $expe_reward_points . ' achievement points';
SendSimpleMessage($this->_fleet['fleet_owner'], '', TIMESTAMP, 4, 'System', 'Achievements', $msg);
}
}
break;
case 2:
$FindSize = mt_rand(0, 100);
//.........这里部分代码省略.........
示例8:
<?php } ?>
<?php
$emp_roll_no = EmployeeInfo::model()->findAll();
$empno='';
if(Yii::app()->controller->action->id=='create')
{
if(empty($emp_roll_no))
{
$empno=$info->employee_unique_id=1;
}
else
{
foreach($emp_roll_no as $s)
{
$emp[]=$s['employee_unique_id'];
$empno=MAX($emp)+1;
}
}
}
else
{
if(!empty($emp_roll_no))
{
$empno=$info->employee_unique_id;
}
}
/* if(empty($emp_roll_no))
{
$empno=$info->employee_unique_id=1;
}
示例9: sync
public function sync()
{
$user = $this->Users->get($this->Auth->user('id'));
$atts = TableRegistry::get('Attendees');
$attRef = $atts->find('all')->where(['user_attendee' => true, 'user_id' => $user->id]);
$attName = $atts->find('all')->where(['firstname' => $user->firstname, 'lastname' => $user->lastname, 'user_id' => $user->id]);
$count = MAX($attRef->count(), $attName->count());
if ($count == 1) {
if ($attRef->count() == 1) {
$att = $attRef->first();
} else {
$att = $attName->first();
}
} else {
$newAttendeeData = ['dateofbirth' => '01-01-1990'];
$att = $atts->newEntity($newAttendeeData);
}
$attendeeData = ['user_id' => $user->id, 'firstname' => $user->firstname, 'lastname' => $user->lastname, 'address_1' => $user->address_1, 'address_2' => $user->address_2, 'city' => $user->city, 'county' => $user->county, 'user_attendee' => true, 'postcode' => $user->postcode, 'role_id' => $user->role_id, 'scoutgroup_id' => $user->scoutgroup_id, 'phone' => $user->phone];
$att = $atts->patchEntity($att, $attendeeData);
if ($atts->save($att)) {
$this->Flash->success(__('An Attendee for your User has been Syncronised.'));
} else {
$this->Flash->error(__('An Attendee for your User could not be Syncronised. Please, try again.'));
}
return $this->redirect(['controller' => 'Landing', 'action' => 'user_home']);
}
示例10: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model=new StudentTransaction;
$info =new StudentInfo;
$user =new User;
$photo =new StudentPhotos;
$address=new StudentAddress;
$lang=new LanguagesKnown;
$auth_assign = new AuthAssignment;
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation(array($info,$model,$user));
if(!empty($_POST['StudentTransaction']) || !empty($_POST['StudentInfo'] ))
{
$stud_roll_no = StudentInfo::model()->findAll();
if(Yii::app()->controller->action->id=='create'){
if(empty($stud_roll_no))
{
$rollno=$info->student_roll_no=1;
}
else
{
//$rand=mt_rand(1,2000);
foreach($stud_roll_no as $s)
{
$stud[]=$s['student_roll_no'];
$rollno_m=MAX($stud)+1;
}
if(StudentInfo::model()->exists('student_roll_no='.$rollno_m))
{
$rollno=$rollno_m+1;
}
else
{
$rollno=$rollno_m;
}
}
}
else
{
}
//echo $rollno; exit;
/*$batch_id=$_POST['StudentTransaction']['student_transaction_batch_id'];
$batch=Batch::model()->findByPk($batch_id);
$course=$batch->course_id;
$academic_year=AcademicTerm::model()->findByPk($course);
$model->academic_term_period_id=$academic_year->academic_term_period_id;
$model->course_id=$batch->course_id;
$model->academic_term_id=$batch->academic_term_id; */
$model->attributes=$_POST['StudentTransaction'];
$info->attributes=$_POST['StudentInfo'];
$user->attributes=$_POST['User'];
$info->student_created_by = Yii::app()->user->id;
$info->student_creation_date = new CDbExpression('NOW()');
$info->student_email_id_1=strtolower($user->user_organization_email_id);
$info->student_adm_date = date('Y-m-d',strtotime($_POST['StudentInfo']['student_adm_date']));
$info->student_roll_no=$rollno;
$info->passport_exp_date=date('Y-m-d',strtotime($_POST['StudentInfo']['passport_exp_date']));
$user->user_organization_email_id = strtolower($info->student_email_id_1);
$user->user_password = md5($info->student_email_id_1.$info->student_email_id_1);
$user->user_created_by = Yii::app()->user->id;
$user->user_creation_date = new CDbExpression('NOW()');
$user->user_type = "student";
if($info->save(false))
{
$user->save(false);
$address->save(false);
$lang->save(false);
$photo->student_photos_path = "no-images";
$photo->save();
}
//if(empty($model->student_transaction_batch_id))
//$model->student_transaction_batch_id=0;
//$model->academic_term_id=$_POST['StudentTransaction']['academic_term_id'];
//$model->academic_term_period_id=$_POST['StudentTransaction']['academic_term_period_id'];
$model->course_id=$_POST['StudentTransaction']['course_id'];
$model->student_transaction_languages_known_id= $lang->languages_known_id;
$model->student_transaction_student_id = $info->student_id;
$model->student_transaction_user_id = $user->user_id;
$model->student_transaction_student_address_id = $address->student_address_id;
$model->student_transaction_student_photos_id = $photo->student_photos_id;
$flag = Studentstatusmaster::model()->findByAttributes(array('status_name'=>'Regular'))->id;
$model->student_transaction_detain_student_flag = 1;
$model->save(false);
StudentInfo::model()->updateByPk($model->student_transaction_student_id, array('student_info_transaction_id'=>$model->student_transaction_id));
$auth_assign->itemname = 'Student';
//.........这里部分代码省略.........
示例11: json_encode
$res1t['opacity'] = 0;
}
$res[] = $res1t;
}
$responseData = json_encode($res, FALSE);
echo $responseData;
exit;
}
if ($action_ajax == 'add_links') {
if (!API::Host()->isWritable(array($hostid))) {
rightsErrorAjax();
}
$shost = $hostid;
foreach ($thostid as $thost) {
if (API::Host()->isWritable(array($hostid))) {
$newlink = array('host1' => MIN($shost, $thost), 'host2' => MAX($shost, $thost));
$res = DBimap::insert('hosts_links', array($newlink));
}
}
$responseData = json_encode(array('result' => $res), FALSE);
echo $responseData;
exit;
}
if ($action_ajax == 'update_link') {
if (!rightsForLink($linkid)) {
rightsErrorAjax();
}
$link = $linkid;
$newlink = array('values' => array('name' => $linkoptions['linkname']), 'where' => array('id' => $link));
$res = DBimap::update('hosts_links', array($newlink));
$res = DBimap::delete('hosts_links_settings', array('ids' => array($link)));
示例12: get_week_info
function get_week_info($tabrange, $week)
{
global $SESSION;
if ($this->course->numsections == FNMAXTABS) {
$tablow = 1;
$tabhigh = FNMAXTABS;
} else {
if ($tabrange > 1000) {
$tablow = $tabrange / 1000;
$tabhigh = $tablow + FNMAXTABS - 1;
} else {
if ($tabrange == 0 && $week == 0) {
$tablow = (int) ((int) ($this->course->numsections - 1) / (int) FNMAXTABS) * FNMAXTABS + 1;
$tabhigh = $tablow + FNMAXTABS - 1;
} else {
if ($tabrange == 0) {
$tablow = (int) ((int) $week / (int) FNMAXTABS) * FNMAXTABS + 1;
$tabhigh = $tablow + FNMAXTABS - 1;
} else {
$tablow = 1;
$tabhigh = FNMAXTABS;
}
}
}
}
$tabhigh = MIN($tabhigh, $this->course->numsections);
/// Normalize the tabs to always display FNMAXTABS...
if ($tabhigh - $tablow + 1 < FNMAXTABS) {
$tablow = $tabhigh - FNMAXTABS + 1;
}
/// Save the low and high week in SESSION variables... If they already exist, and the selected
/// week is in their range, leave them as is.
if ($tabrange >= 1000 || !isset($SESSION->FN_tablow[$this->course->id]) || !isset($SESSION->FN_tabhigh[$this->course->id]) || $week < $SESSION->FN_tablow[$this->course->id] || $week > $SESSION->FN_tabhigh[$this->course->id]) {
$SESSION->FN_tablow[$this->course->id] = $tablow;
$SESSION->FN_tabhigh[$this->course->id] = $tabhigh;
} else {
$tablow = $SESSION->FN_tablow[$this->course->id];
$tabhigh = $SESSION->FN_tabhigh[$this->course->id];
}
$tablow = MAX($tablow, 1);
$tabhigh = MIN($tabhigh, $this->course->numsections);
/// If selected week in a different set of tabs, move it to the current set...
if ($week != 0 && $week < $tablow) {
$week = $SESSION->G8_selected_week[$this->course->id] = $tablow;
} else {
if ($week > $tabhigh) {
$week = $SESSION->G8_selected_week[$this->course->id] = $tabhigh;
}
}
return array($tablow, $tabhigh, $week);
}
示例13: sprintf
require_once 'class/graph.php';
WEBPAGE::START();
$_LABELS = WEBPAGE::getCacheData(sprintf(WEBPAGE::_APP_LABELS_FILE, $_GET['lang']));
//get question list $ql_a
$sql = sprintf("SELECT question_list FROM tblSurveys WHERE id = '%s'", $_GET[survey_id]);
$row = current(WEBPAGE::$dbh->getAll($sql));
$ql = $row[question_list];
$ql_a = explode(',', $ql);
//get answer num - cal. $an_a
$sql = sprintf("SELECT id, answer_num, category FROM tblSurveyItems WHERE FIND_IN_SET(id, '%s')", $ql);
$mrow = WEBPAGE::$dbh->getAll($sql);
for ($i = 0; $i < count($mrow); $i++) {
$an_a_cal[$mrow[$i][id]] = explode('|', $mrow[$i][answer_num]);
$an_a_cat[$mrow[$i][id]] = $mrow[$i][category];
foreach ($an_a_cal[$mrow[$i][id]] as $key => $value) {
$an_a_cmax[$mrow[$i][id]] = MAX($an_a_cmax[$mrow[$i][id]], $value);
}
}
// get survey answers $sa
$sql = "SELECT client_id, answer_list FROM tblSurveyAnswers WHERE survey_id = '{$_GET['survey_id']}'";
$mrow = WEBPAGE::$dbh->getAll($sql);
for ($i = 0; $i < count($mrow); $i++) {
$sa_a_ref = explode(',', $mrow[$i][answer_list]);
unset($sa_a_cal);
foreach ($sa_a_ref as $key => $value) {
$sa_a_cal[] = $an_a_cal[$ql_a[$key]][$value - 1];
}
$sa_a[$mrow[$i][client_id]][] = $sa_a_cal;
}
// ready to graph
foreach ($sa_a as $key => $value) {
示例14: get_week_info
function get_week_info($tabrange, $week, $chapter = 0)
{
global $SESSION, $DB, $USER;
$c = $this->get_chapter($chapter);
// added by oncampus
$lections = $c['lections'];
// added by oncampus
//$fnmaxtab = $DB->get_field('course_config_fn', 'value', array('courseid' => $this->course->id, 'variable' => 'maxtabs'));
/* if ($fnmaxtab) {
$maximumtabs = $fnmaxtab;
} else {
$maximumtabs = 12;
} */
$maximumtabs = 6;
if ($lections < 6) {
$maximumtabs = $lections;
}
$last_lection = $this->get_last_lection();
// oncampus
if ($USER->username == 'rieger') {
//echo 'range: '.$tabrange.', week: '.$week.', chapter: '.$chapter.', last_section: '.$last_lection.'<br />';
}
if ($last_lection == $maximumtabs) {
// oncampus
//if ($USER->username == 'rieger') { echo '1<br />';}
$tablow = 1;
$tabhigh = $maximumtabs;
} else {
if ($maximumtabs < 6) {
//if ($USER->username == 'rieger') { echo '1.5<br />';}
$tablow = 1;
$tabhigh = $maximumtabs;
} else {
if ($tabrange > 1000) {
//if ($USER->username == 'rieger') { echo '2<br />';}
$tablow = (int) ($tabrange / 1000);
$tabhigh = (int) ($tablow + $maximumtabs - 1);
} else {
if ($tabrange == 0 && $week == 0) {
//if ($USER->username == 'rieger') { echo '3<br />';}
$tablow = (int) ((int) ($last_lection - 1) / (int) $maximumtabs) * $maximumtabs + 1;
$tabhigh = $tablow + $maximumtabs - 1;
} else {
if ($tabrange == 0) {
$tablow = $week;
//((int) ((int) $week / (int) $maximumtabs) * $maximumtabs) + 1;
$tabhigh = $tablow + $maximumtabs - 1;
//if ($USER->username == 'rieger') { echo 'nr. 4 ('.$tablow.' '.$tabhigh.')<br />';}
//echo '('.$tablow.' '.$tabhigh.')';
} else {
//if ($USER->username == 'rieger') { echo '5<br />';}
$tablow = 1;
$tabhigh = $maximumtabs;
}
}
}
}
}
$tabhigh = MIN($tabhigh, $last_lection);
/// Normalize the tabs to always display FNMAXTABS...
if ($tabhigh - $tablow + 1 < $maximumtabs) {
$tablow = $tabhigh - $maximumtabs + 1;
}
/// Save the low and high week in SESSION variables... If they already exist, and the selected
/// week is in their range, leave them as is.
if ($tabrange >= 1000 || !isset($SESSION->FN_tablow[$this->course->id]) || !isset($SESSION->FN_tabhigh[$this->course->id]) || $week < $SESSION->FN_tablow[$this->course->id] || $week > $SESSION->FN_tabhigh[$this->course->id]) {
$SESSION->FN_tablow[$this->course->id] = $tablow;
$SESSION->FN_tabhigh[$this->course->id] = $tabhigh;
} else {
$tablow = $SESSION->FN_tablow[$this->course->id];
$tabhigh = $SESSION->FN_tabhigh[$this->course->id];
}
$tablow = MAX($tablow, 1);
$tabhigh = MIN($tabhigh, $last_lection);
// oncampus
/* $low = $c['first_lection'] - ((int)(($maximumtabs - $lections) / 2));
if (($low + $maximumtabs - 1) > $last_lection) {
$low = $last_lection - $maximumtabs + 1;
}
$high = $low + $maximumtabs - 1;
if ($chapter != 0 and (($tabrange > $low and $tabrange <= $high) or $tabrange == 0 )) {
$tablow = $low;
$tabhigh = $high;
} */
// oncampus ende
unset($maximumtabs);
return array($tablow, $tabhigh, $week);
}
示例15: sync
//.........这里部分代码省略.........
}
if (empty($county)) {
$county = ucwords(strtolower('HERTFORDSHIRE'));
}
$postcode = str_replace(' ', '', $postcode);
$postcode = str_replace('-', '', $postcode);
$postcode = str_replace('/', '', $postcode);
$postcode = str_replace('.', '', $postcode);
$postcode = str_replace(',', '', $postcode);
$postcode = substr($postcode, 0, -3) . ' ' . substr($postcode, -3);
// GET TELEPHONE VALUES
$phone1 = Hash::get($phoneAddress, 18);
$phone2 = Hash::get($phoneAddress, 20);
if (empty($phone1) && empty($phone2)) {
$phoneAddress = Hash::get($customData, 1);
$phone1 = Hash::get($phoneAddress, 18);
$phone2 = Hash::get($phoneAddress, 20);
if (empty($phone1) && empty($phone2)) {
$phoneAddress = Hash::get($customData, 2);
$phone1 = Hash::get($phoneAddress, 18);
$phone2 = Hash::get($phoneAddress, 20);
if (empty($phone1) && empty($phone2)) {
$phoneAddress = Hash::get($customData, 3);
$phone1 = Hash::get($phoneAddress, 18);
$phone2 = Hash::get($phoneAddress, 20);
if (empty($phone1) && empty($phone2)) {
$phoneAddress = Hash::get($customData, 6);
$phone1 = Hash::get($phoneAddress, 18);
$phone2 = Hash::get($phoneAddress, 20);
}
}
}
}
$phone1 = trim($phone1);
$phone2 = trim($phone2);
if (empty($phone1) && empty($phone2)) {
$phone1 = 0700;
} elseif (empty($phone1)) {
$phone1 = $phone2;
$phone2 = null;
}
$phone1 = str_replace(' ', '', $phone1);
$phone1 = str_replace('-', '', $phone1);
$phone1 = str_replace('/', '', $phone1);
$phone1 = str_replace('+44', '0', $phone1);
$phone1 = substr($phone1, 0, 5) . ' ' . substr($phone1, 5);
if (!empty($phone2)) {
$phone2 = str_replace(' ', '', $phone2);
$phone2 = str_replace('-', '', $phone2);
$phone2 = str_replace('/', '', $phone2);
$phone2 = str_replace('+44', '0', $phone2);
$phone2 = substr($phone2, 0, 5) . ' ' . substr($phone2, 5);
if ($phone1 == $phone2) {
$phone2 = null;
}
}
//Debugger::dump($address);
$attsName = $atts->find('all')->where(['firstname' => $firstname, 'lastname' => $lastname, 'user_id' => $user->id]);
$attsID = $atts->find('all')->where(['osm_id' => $osmId, 'user_id' => $user->id]);
$count = MAX($attsID->count(), $attsName->count());
if ($count == 1) {
if ($attsID->count() == 1) {
$att = $attsID->first();
} else {
$att = $attsName->first();
}
$cubData = ['osm_id' => $osmId, 'dateofbirth' => $dateofbirth, 'address_1' => ucwords(strtolower($address1)), 'address_2' => ucwords(strtolower($address2)), 'city' => ucwords(strtolower($city)), 'county' => ucwords(strtolower($county)), 'postcode' => strtoupper($postcode), 'phone' => strtoupper($phone1), 'phone2' => strtoupper($phone2), 'osm_sync_date' => $now, 'deleted' => null];
} else {
$att = $atts->newEntity();
$cubData = ['firstname' => ucwords(strtolower($firstname)), 'lastname' => ucwords(strtolower($lastname)), 'osm_id' => $osmId, 'user_id' => $user->id, 'scoutgroup_id' => $user->scoutgroup_id, 'dateofbirth' => $dateofbirth, 'role_id' => $roleId, 'osm_generated' => true, 'address_1' => ucwords(strtolower($address1)), 'address_2' => ucwords(strtolower($address2)), 'city' => ucwords(strtolower($city)), 'county' => ucwords(strtolower($county)), 'postcode' => strtoupper($postcode), 'phone' => strtoupper($phone1), 'phone2' => strtoupper($phone2), 'osm_sync_date' => $now];
}
$att = $atts->patchEntity($att, $cubData);
if ($atts->save($att)) {
$successCnt = $successCnt + 1;
} else {
$errCnt = $errCnt + 1;
}
}
}
if (isset($errCnt) && $errCnt > 0) {
$this->Flash->error(__('There were ' . $errCnt . ' records which did not sync, please try again.'));
}
if (isset($successCnt) && $successCnt > 0) {
$this->Flash->success(__('Synced ' . $successCnt . ' records sucessfully.'));
}
$osmEnt = ['Entity Id' => null, 'Controller' => 'OSM', 'Action' => 'Sync', 'User Id' => $this->Auth->user('id'), 'Creation Date' => $now, 'Modified' => null, 'OSM' => ['ErrorNumber' => $errCnt, 'SuccessNumber' => $successCnt]];
$sets = TableRegistry::get('Settings');
$jsonOSM = json_encode($osmEnt);
$apiKey = $sets->get(13)->text;
$projectId = $sets->get(14)->text;
$eventType = 'Action';
$keenURL = 'https://api.keen.io/3.0/projects/' . $projectId . '/events/' . $eventType . '?api_key=' . $apiKey;
$http = new Client();
$response = $http->post($keenURL, $jsonOSM, ['type' => 'json']);
return $this->redirect(['action' => 'home']);
} else {
$this->Flash->error(__('There was a request error, please try again.'));
return $this->redirect(['action' => 'home']);
}
}