function error($inMessage) { $inMessage = str_replace('"', '\\"', $inMessage); error_log($inMessage); //echo '/* ({error: true, message: "' . $inMessage . '"}) */'; echoJson(array('error' => true, 'message' => $inMessage)); exit; }
/** * Get list of source message category names * */ public function actionGetCategoryNames($term) { $res = array(); if ($term) { $command = Yii::app()->db->createCommand("SELECT DISTINCT category FROM source_message WHERE category LIKE :name ORDER BY category ASC LIMIT 20"); $command->bindValue(":name", '%' . $term . '%', PDO::PARAM_STR); $res = $command->queryColumn(); } echoJson($res); }
/** * Get city info by zip * */ public function actionGetCityInfoByZip($zipCode) { $city = USCity::model()->find('city_zip=:zipcode', array(':zipcode' => $zipCode)); if (!$city) { echoJson(array('error' => at('Sorry, That zip code does not exists.'))); } // Get state id $state = USState::model()->find('short=LOWER(:short)', array(':short' => strtolower($city->city_state))); // Get us country $country = Country::model()->find('short=LOWER(:short)', array(':short' => 'us')); $info = array('city_name' => $city->city_name, 'city_zip' => $city->city_zip, 'city_state' => $state ? $state->id : 0, 'country' => $country ? $country->id : 0); $text = at("Zip Code Exists.\nCity Name: {cityname}, State: {state}", array('{cityname}' => $city->city_name, '{state}' => $city->city_state)); echoJson(array('info' => $info, 'text' => $text)); }
/** * Get list of user names * */ public function actionGetUserNames($term) { $res = array(); $list = array(); if ($term) { $command = Yii::app()->db->createCommand("SELECT id, name FROM user WHERE name LIKE :name ORDER BY name ASC LIMIT 20"); $command->bindValue(":name", '%' . $term . '%', PDO::PARAM_STR); $res = $command->queryAll(); } if (count($res)) { foreach ($res as $row) { $list[] = array('label' => $row['id'], 'value' => $row['name']); } } echoJson($list); }
*/ require_once $_SERVER["DOCUMENT_ROOT"] . '/bamboo/config.php'; require_once $_SERVER["DOCUMENT_ROOT"] . '/bamboo/func.php'; try { $sql_select = "select /*일반글 키워드 갯수대로 리스팅*/ "; $sql_select .= "\tkeyword as '키워드' "; $sql_select .= " , count(*) as 'count' "; $sql_select .= "from tbl_keyword "; $sql_select .= "where b_code like '%G%' "; $sql_select .= "group by keyword "; $sql_select .= "order by count desc "; $sql_select .= "limit 0, 5; "; $rs = mysqli_query($connect, $sql_select); if (!$rs) { throw new Exception("error with query -1", 1); } $json_array = array(); while ($row = mysqli_fetch_assoc($rs)) { $keyword = $row['키워드']; $count = $row['count']; $json = array('keyword' => $keyword, 'count' => $count); array_push($json_array, $json); } echoJson($json_array); } catch (Exception $e) { $json = array('state' => '0', 'message' => $e->getMessage()); echoJson($json); exit; } //DB연결 해제 mysqli_close($connect);
/** * Echo a json string with the 500 error code * @param mixed $value */ function echoJsonError($value) { header('HTTP/1.1 500 Internal Server Error'); echoJson($value); }
public function set_score() { $work_id = I('work_id'); $dimension_data = I('dimension_data'); $type = I('dimension_data'); $data = []; $userId = $_SESSION['authId']; $all_score = 0; $workModel = new WorkModel(); $workModel->startTrans(); foreach ($dimension_data as $k => $v) { $dimensionid_score = split('__', $v); $dimensionid = $dimensionid_score[0]; $score = $dimensionid_score[1]; $work_dimension_data['work_id'] = $work_id; $work_dimension_data['dimension_id'] = $dimensionid; $work_dimension_data['score'] = $score; $work_dimension_data['user_id'] = $userId; $work_dimension = M('Work_dimension'); $res = $work_dimension->add($work_dimension_data); if (!$res) { $workModel->rollback(); echoJson('1', '添加打分详情失败'); } $percent = $this->get_percent($dimensionid); $all_score += $percent * $score / 100; if (false === $percent) { $workModel->rollback(); echoJson('1', '获取权重失败'); } } $all_score = sprintf('%f.2', $all_score); $work_data['score'] = $all_score; $work_data['is_have_score'] = '1'; $work = M('Work'); $res = $work->where(array('id' => $work_id))->save($work_data); if (!$res) { $workModel->rollback(); echoJson('1', '保存分数失败'); } $workModel->commit(); echoJson('0', '打分成功'); }
if (isPersonMatchingFilter(GET_uid(), $LEVEL1_FILTER)) { if (isPersonMatchingFilter(GET_uid(), $LEVEL2_FILTER)) { $allowExtendedInfo = 2; } else { $allowExtendedInfo = 1; } } } if ($allowExtendedInfo >= 1) { $LDAP_CONNECT = $allowExtendedInfo == 2 ? $LDAP_CONNECT_LEVEL2 : $LDAP_CONNECT_LEVEL1; global_ldap_open('reOpen'); } // most attributes visibility are enforced using ACLs on LDAP bind // here are a few special cases if ($allowExtendedInfo < 1) { foreach (array('memberOf', 'memberOf-all') as $attr) { unset($wanted_attrs[$attr]); } } if ($allowInvalidAccounts) { $allowInvalidAccounts = $allowExtendedInfo >= 1; } $attrRestrictions = array('allowListeRouge' => $allowExtendedInfo > 0 || @$isTrustedIp || GET_uid() && isStaffOrFaculty(GET_uid()), 'allowMailForwardingAddress' => $allowExtendedInfo > 1, 'allowEmployeeType' => $allowExtendedInfo > 1); $users = searchPeople(people_filters($token, $restriction, $allowInvalidAccounts), $attrRestrictions, $wanted_attrs, $KEY_FIELD, $maxRows); if ($allowExtendedInfo) { foreach ($users as &$u) { $u["allowExtendedInfo"] = $allowExtendedInfo; } } echoJson($users);
/** * Add participant to a topic * */ public function actionAddParticiapnt($userId, $topicId) { if (!checkAccess('op_personalmessages_add_participants')) { echoJson(array('error' => at('Sorry, You are not allowed to perform this action.'))); } // Load the topic id $topic = PersonalMessageTopic::model()->findByPk($topicId); if (!$topic) { echoJson(array('error' => at('Sorry, We could not find that topic.'))); } // Load the user id $user = User::model()->findByPk($userId); if (!$user) { echoJson(array('error' => at('Sorry, We could not find that user.'))); } // Make sure the user is not the author if ($topic->author_id == $userId) { echoJson(array('error' => at('Sorry, That user is the topic author. He can not be added as a participant.'))); } // Make sure the user is not part of the topic already $participantExists = PersonalMessageParticipant::model()->exists('topic_id=:topic AND user_id=:user', array(':user' => $userId, ':topic' => $topic->id)); if ($participantExists) { echoJson(array('error' => at('Sorry, That user is already a participant.'))); } // Add him $newParticipant = new PersonalMessageParticipant(); $newParticipant->topic_id = $topic->id; $newParticipant->user_id = $userId; $newParticipant->save(); // Load the new participants list $participantsList = $this->renderPartial('_participants', array('model' => $topic), true); // Load the new add participant form $addParticipantsForm = $this->renderPartial('_add_participant', array('model' => $topic), true); // Success message $html = at("{name} added to the topic.", array('{name}' => $user->name)); echoJson(array('html' => $html, 'participantsList' => $participantsList, 'addParticipantsForm' => $addParticipantsForm)); }
public function modPass() { $type = I('type'); $oldpass = I('oldpass'); $newpass = I('newpass'); if ('menu' == $type) { $this->display(); exit; } // 生成认证条件 $map = array(); // 支持使用绑定帐号登录 $ses = $_SESSION; $map['account'] = $_SESSION['login_count']; $map["status"] = array('gt', 0); $authInfo = Rbac::authenticate($map); // 使用用户名、密码和状态的方式进行认证 if (false === $authInfo) { $this->error('帐号不存在或已禁用!'); } else { if ($authInfo['password'] != md5($oldpass)) { echoJson('1', '原密码输入错误'); } else { $where['id'] = $_SESSION['authId']; $passdata['password'] = md5($newpass); $user = M('User'); $res = $user->where($where)->save($passdata); if ($res) { echoJson('0', '密码修改成功'); } else { echoJson('1', ' 服务器忙'); } } } }
/** * 修改部门信息 * */ public function dimensionedit() { $Dimension = M('Dimension'); $type = I('type'); $id = I('id'); $name = I('name'); $remark = I('remark'); $percent = I('percent'); if ('showedit' == $type) { $deptinfo = $Dimension->where("id={$id}")->find(); $this->assign('dimensioninfo', $deptinfo); $this->assign('deptid', $id); $this->display(); exit; } $data['name'] = $name; $data['percent'] = $percent; $data['remark'] = $remark; $where['Id'] = $id; $dimensionInfo = $Dimension->where($where)->select(); if ($dimensionInfo) { $old_percent = $dimensionInfo[0]['percent']; $num = $percent - $old_percent; $percent = $this->judge_percent(); $percent += $num; if ($percent > 100) { echoJson('1', '权重总值不能大于100'); } } else { echoJson('1', '保存失败'); } $res = $Dimension->where($where)->save($data); if ($res) { $percent = $this->judge_percent(); $num = 100 - $percent; echoJson('0', '保存成功,剩余权重:' . $num); } else { echoJson('1', '保存失败'); } }
$sql_select = "SELECT concat('U00000', ifnull(max(substring(b_code, -6))+1, '000001')) AS b_code FROM tbl_univ_board; "; $rs = mysqli_query($connect, $sql_select); $row = mysqli_fetch_assoc($rs); $b_code = $row['b_code']; $select_insert = "INSERT INTO `bamboo`.`tbl_univ_board` \n\t\t\t(`b_code`, `m_uuid`, `b_contents`,`regdt`,`img_url`, `mov_url`, `b_blind_yn`, `b_univ`, `b_notice_yn`, `b_notice_date`) \n\t\t\tVALUES ('" . $b_code . "', '" . $uuid . "', '" . $contents . "',date_format(now(),'%Y%m%d%H%i%s') ,'" . $fullUrl . "', '', 'N', '" . $univ . "', '" . $notice . "', ''); "; if ($notice = 'Y') { $sql_select = "select m_device_token from tbl_member where m_univ = '" . $univ . "'; "; $rs = mysqli_query($connect, $sql_select); if (!$rs) { throw new Exception("error with query -1", 1); } while ($row = mysqli_fetch_assoc($rs)) { $device_token = $row['m_device_token']; $alert = $univ . " 확성기 게시판에 새로운 글이 등록되었습니다."; pushApns($device_token, $alert); } } } } $rs = mysqli_query($connect, $select_insert); for ($i = 0; $i < $keywordArrCnt; $i++) { $sql_insert = "INSERT INTO `bamboo`.`tbl_keyword` (`b_code`, `keyword`) VALUES ('" . $b_code . "', '" . $keywordArr[$i] . "'); "; $rs = mysqli_query($connect, $sql_insert); } } else { $arrayToSend = array('status' => 'FAILED'); } //header('Content-Type:application/json'); echoJson($arrayToSend); //DB연결 해제 mysqli_close($connect);
/** * set file content */ public function actionAjaxSetThemeFileContent() { // Init $fileId = getPostParam('fileId'); $content = getPostParam('content'); // Access check if (!checkAccess('op_theme_file_edit')) { echoJson(array('error' => at('Sorry, You are not allowed to edit theme files.'))); } // Check to make sure the theme file exists $themeFile = ThemeFile::model()->with(array('theme'))->findByPk($fileId); if (!$themeFile) { echoJson(array('error' => at('Sorry, We could not located that file.'))); } // Update theme content $themeFile->content = $content; $themeFile->update(); // Log alog(at("Updated Theme '{name}', File {file}", array('{name}' => $themeFile->theme->name, '{file}' => $themeFile->file_location))); // Sync theme to save changes $themeFile->theme->syncTheme(); echoJson(array('html' => at('Theme File Saved!'))); }