Наследование: extends Channel
Пример #1
1
 /**
  * [_is_auth_success 验证权限是否成功]
  * @param  [type]  $auths [description]
  * @return boolean        [description]
  */
 private function _is_auth_success($auths)
 {
     $route = Common::get_route();
     //需权限
     if (array_key_exists($route, $auths)) {
         $user = isset($_SESSION[$this->login_in_session_name]) ? $_SESSION[$this->login_in_session_name] : NULL;
         $user_role = isset($user['role']) ? $user['role'] : NULL;
         //有权限
         if (strstr($auths[$route], "|{$user_role}|")) {
             return TRUE;
         } else {
             //有登录权限
             if (strstr($auths[$route], "|1|")) {
                 //已登录
                 if (!empty($user)) {
                     return TRUE;
                 } else {
                     $this->error->output('NOTLOGIN_ERROR', array('script' => 'swal({title: "请登录后再进行操作",type: "warning",showCancelButton: true,confirmButtonColor: "#DD6B55",confirmButtonText: "注册/登录",closeOnConfirm: false},function () {showsign();});'));
                 }
             }
             //没有权限
             $this->error->output('NOAUTH_ERROR', array('script' => 'window.location.href ="' . base_url() . '";'));
         }
     } else {
         return TRUE;
     }
 }
Пример #2
0
 function tinlienquan($idtloai, $datatin = null, $idtin = null)
 {
     $where = " ";
     if (isset($idtin)) {
         $where = " AND id_tintuc<>" . $idtin;
     }
     $datatin = isset($datatin) ? $datatin : null;
     $nd = new Common();
     $output = '<div class="clear more left">';
     $output .= '<div class="tinthem left"><div class="left iconleft"></div>MORE</div>';
     $data = $nd->query("SELECT tieude,id_tintuc,ngaythang, solanxem,id_theloai FROM tbltintucs WHERE id_theloai=" . $idtloai . " " . $where . "  ORDER BY ngaythang DESC LIMIT 0,5");
     foreach ($data as $item) {
         if (!$this->checkDisplay($item, $datatin)) {
             $id_tintuc = $item['tbltintucs']['id_tintuc'];
             $tieude = $item['tbltintucs']['tieude'];
             $date = $item['tbltintucs']['ngaythang'];
             $d = getdate(strtotime($date));
             $ngay = $d['mday'] . '/' . $d['mon'] . '/' . $d['year'];
             $solanxem = $item['tbltintucs']['solanxem'];
             $tt = $item['tbltintucs']['tieude'];
             $output .= '<div class="left"><span class="icontin"></span>' . $this->link($tt, array('controller' => 'Tbltintucs', 'action' => 'view', $item['tbltintucs']['id_tintuc'])) . "<p style='margin-left:10px;'><span class='bitsmall'>({$ngay})</span><span class='bitsmall'>({$solanxem} lần xem)</span></p></div>";
         }
     }
     $output .= '</div>';
     return $output;
 }
Пример #3
0
 /**
  * 上传图片
  */
 public function actionUpload()
 {
     $Common = new Common();
     $fn = $_GET['CKEditorFuncNum'];
     $url = $Common->getCompleteUrl();
     $imgTypeArr = $Common->getImageTypes();
     if (!in_array($_FILES['upload']['type'], $imgTypeArr)) {
         echo '<script type="text/javascript">
             window.parent.CKEDITOR.tools.callFunction("' . $fn . '","","图片格式错误!");
             </script>';
     } else {
         $projectPath = Wave::app()->projectPath;
         $uploadPath = $projectPath . 'data/uploadfile/substance';
         if (!is_dir($uploadPath)) {
             mkdir($uploadPath, 0777);
         }
         $ym = $Common->getYearMonth();
         $uploadPath .= '/' . $ym;
         if (!is_dir($uploadPath)) {
             mkdir($uploadPath, 0777);
         }
         $imgType = strtolower(substr(strrchr($_FILES['upload']['name'], '.'), 1));
         $imageName = time() . '_' . rand() . '.' . $imgType;
         $file_abso = $url . '/data/uploadfile/substance/' . $ym . '/' . $imageName;
         $SimpleImage = new SimpleImage();
         $SimpleImage->load($_FILES['upload']['tmp_name']);
         $SimpleImage->resizeToWidth(800);
         $SimpleImage->save($uploadPath . '/' . $imageName);
         echo '<script type="text/javascript">
             window.parent.CKEDITOR.tools.callFunction("' . $fn . '","' . $file_abso . '","上传成功");
             </script>';
     }
 }
Пример #4
0
 function groupsLdap($param)
 {
     $ldap_host = $GLOBALS['phpgw_info']['server']['ldap_host'];
     $ldap_root_dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
     $ldap_root_pw = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
     $ldap_context = $GLOBALS['phpgw_info']['server']['ldap_context'];
     $result_groups = '';
     //Organizations Ldap
     $organization = 'ou=' . $param . "," . $ldap_context;
     if ($param == $ldap_context) {
         $organization = $ldap_context;
     }
     //Commons Functions
     $common = new Common();
     // Ldap Connection
     $ldap = $common->ldapConnect($ldap_host, $ldap_root_dn, $ldap_root_pw);
     if ($ldap) {
         $filter = "(&(phpgwAccountType=g)(cn=grupo*-im))";
         $justthese = array("cn", "gidNumber");
         $search = ldap_search($ldap, $organization, $filter, $justthese);
         $entry = ldap_get_entries($ldap, $search);
         if ($entry) {
             foreach ($entry as $tmp) {
                 if ($tmp['gidnumber'][0] != "") {
                     $result_groups[] = $tmp['cn'][0] . ";" . $tmp['gidnumber'][0];
                 }
             }
         }
         natsort($result_groups);
     }
     return $result_groups;
 }
Пример #5
0
function getConfirmPassword()
{
    $COMMON = new Common($debug);
    $sql = "SELECT * FROM `Proj2Advisors` WHERE `New` = 'true'";
    $rs = $COMMON->executeQuery($sql, "Advising Appointments");
    $row = mysql_fetch_row($rs);
    return $row[5];
}
Пример #6
0
function getAdvisor()
{
    $COMMON = new Common($debug);
    $sID = $_SESSION["studID"];
    $sql = "select * from Proj2Students where `StudentID` = '{$sID}'";
    $rs = $COMMON->executeQuery($sql, $_SERVER["SCRIPT_NAME"]);
    $row = mysql_fetch_row($rs);
    return $row[7];
}
Пример #7
0
 public function insertdata($url)
 {
     $common_obj = new Common();
     $set = array(CURLOPT_URL => "{$url}", CURLOPT_RETURNTRANSFER => true);
     $ch = curl_init();
     curl_setopt_array($ch, $set);
     $data1 = curl_exec($ch);
     $pattern = '/<li>(.*?)<\\/li>/is';
     preg_match_all($pattern, $data1, $str);
     $strall = $str[0];
     $listparse = parse_url($url);
     foreach ($strall as $k => $v) {
         preg_match('/<a href="(.*?)">(.*?)<\\/a><\\/div>/is', $v, $title);
         $conurl = parse_url($title[1]);
         if ($courl['scheme'] == null) {
             $scheme = 'http://';
         }
         if ($courl['host'] == null) {
             $host = $listparse['host'];
         }
         if ($courl['path'] == null) {
             $path = $listparse['path'];
         }
         $conquery = '?' . $conurl['query'];
         $contenturl = trim($scheme . $host . $path . $conquery);
         $md5url = md5("{$contenturl}");
         $csql = "select urlmd5 from " . DB_PREFIX . "gather where urlmd5='" . $md5url . "'";
         $query = $this->db->query($csql);
         $checkurl = $this->db->fetch_array($query);
         if ($checkurl) {
             continue;
         }
         //内容页preg
         curl_setopt($ch, CURLOPT_URL, $contenturl);
         $href_content = curl_exec($ch);
         preg_match('/<\\!\\-\\- m2o content start \\-\\->(.*?)<\\!\\-\\- m2o content end \\-\\->/is', $href_content, $maincontent);
         preg_match('/<div class="brief">(.*?)<\\/div>/is', $v, $brief);
         preg_match('/<div class="pubdate">(.*?)<\\/div>/is', $v, $pubdate);
         preg_match('/<div class="subtitle">(.*?)<\\/div>/is', $v, $subtitle);
         preg_match('/<div class="keywords">(.*?)<\\/div>/is', $v, $keywords);
         preg_match('/<div class="author">(.*?)<\\/div>/is', $v, $author);
         preg_match('/<img src="(.*?)" class="indexpic"\\/>/is', $v, $indexpic);
         $arr = array('title' => $title[2], 'brief' => $brief[1], 'pubdate' => $pubdate[1], 'subtitle' => $subtitle[1], 'keywords' => $keywords[1], 'author' => $author[1], 'indexpic' => $indexpic[1], 'content' => $maincontent[1], 'source_url' => $contenturl);
         $resultdata[] = array_reverse($arr);
     }
     foreach ($resultdata as $key => $value) {
         $common_obj->post_datagather($value, $this->sort_id);
         //更新接入状态
         $urlstatus = array('urlmd5' => md5($contenturl), 'url' => $contenturl, 'is_publish' => 1, 'title' => $title[2], 'create_time' => TIMENOW);
         $this->updata->creategather($urlstatus);
     }
     curl_close($ch);
     return TRUE;
 }
Пример #8
0
 function getStudent()
 {
     $debug = false;
     $COMMON = new Common($debug);
     //Use this as base for student access method
     $sql = "select * from Proj2Students where `StudentID` = '{$this->ID}'";
     $rs = $COMMON->executeQuery($sql, $_SERVER["SCRIPT_NAME"]);
     $studRow = mysql_fetch_row($rs);
     return $studRow;
     //end
 }
Пример #9
0
 public static function modify_settings($settings)
 {
     $Common = new Common();
     $settings_filename = '../require/settings.php';
     $content = file_get_contents($settings_filename);
     $fh = fopen($settings_filename, 'w');
     foreach ($settings as $settingname => $value) {
         if ($value == 'TRUE' || $value == 'FALSE') {
             $pattern = '/\\$' . $settingname . " = " . '(TRUE|FALSE)' . "/";
             $replace = '\\$' . $settingname . " = " . $value . "";
         } elseif (is_array($value)) {
             $pattern = '/\\$' . $settingname . " = array\\(" . '(.*)' . "\\)/";
             if ($Common->isAssoc($value)) {
                 foreach ($value as $key => $data) {
                     if (!isset($array_value)) {
                         $array_value = "'" . $key . "' => '" . $data . "'";
                     } else {
                         $array_value .= ",'" . $key . "' => '" . $data . "'";
                     }
                 }
             } else {
                 foreach ($value as $data) {
                     if (!isset($array_value)) {
                         $array_value = "'" . $data . "'";
                     } else {
                         $array_value .= ",'" . $data . "'";
                     }
                 }
             }
             if (!isset($array_value)) {
                 $array_value = '';
             }
             $replace = '\\$' . $settingname . " = array(" . $array_value . ")";
             unset($array_value);
         } else {
             $pattern = '/\\$' . $settingname . " = '" . '(.*)' . "'/";
             $replace = '\\$' . $settingname . " = '" . $value . "'";
         }
         $rep_cnt = 0;
         $content = preg_replace($pattern, $replace, $content, 1, $rep_cnt);
         /// If setting was a string and is now an array
         if ($rep_cnt == 0 && is_array($value)) {
             $pattern = '/\\$' . $settingname . " = '" . '(.*)' . "'/";
             $content = preg_replace($pattern, $replace, $content, 1, $rep_cnt);
         }
         // If setting is not in settings.php (for update)
         if ($rep_cnt == 0) {
             $content = preg_replace('/\\?>/', $replace . ";\n?>", $content, 1, $rep_cnt);
         }
     }
     fwrite($fh, $content);
     fclose($fh);
 }
Пример #10
0
 function __construct()
 {
     global $db, $common, $config;
     // connect to db
     $db = new Database();
     // get an instance of the other classes
     $common = new Common();
     // run under certain conditions
     $common->checkPaths();
     // see if all this is an authorized use of the script
     $this->checkSession();
     // load some html parts we are going to use
     require 'admin/php/content.php';
 }
Пример #11
0
 public function execute()
 {
     GWF_Website::plaintext();
     GWF3::setConfig('store_last_url', false);
     $lat = $this->module->lat();
     $lon = $this->module->lon();
     $descr = trim(Common::getGetString('pp_descr'));
     $descr = $descr === '' ? null : $descr;
     $id = Common::getGetInt('pp_id', 0);
     $user = GWF_User::getStaticOrGuest();
     $uid = $user->getID();
     if (!GWF_ProfilePOI::changeAllowed($id, $uid)) {
         $this->module->ajaxError('Permission error!');
     }
     $count = $id === 0 ? GWF_ProfilePOI::getPOICount($uid) : 0;
     $max_pois = $this->module->cfgAllowedPOIs();
     if ($count >= $max_pois) {
         $this->module->ajaxErr('err_poi_exceed');
     }
     $poi = new GWF_ProfilePOI(array('pp_id' => $id, 'pp_uid' => $uid, 'pp_lat' => $lat, 'pp_lon' => $lon, 'pp_descr' => $descr));
     $poi->replace();
     $data = $poi->getGDOData();
     $data['user_name'] = $user->getVar('user_name');
     die(json_encode($data));
 }
Пример #12
0
 public function exchangeSilver($xSilver, $floor)
 {
     $this->xSilver = $xSilver;
     for ($ctr = 0; $ctr < count($this->playerInfo['ret']['user']['city']); $ctr++) {
         start:
         $time = time();
         $var = @file_get_contents($this->server . "game/get_cityinfo_api.php?jsonpcallback=jsonp" . $time . "&_=" . ($time + 1485495) . "&key=" . $this->key . "&city=" . $this->playerInfo['ret']['user']['city'][$ctr]['id'] . "&_l=en&_p=RE");
         if (!(strpos($var, '})') !== false)) {
             goto start;
         }
         parent::setTime($time);
         $city = parent::stripTojSon($var);
         if ($city['ret']['city'][2] < $xSilver) {
             echo "\nInsuficient Silver in" . $this->playerInfo['ret']['user']['city'][$ctr]['name'] . "\n";
         } else {
             # Exchange Food
             if ($city['ret']['city'][4] < $floor) {
                 $this->exchangeFood($this->playerInfo['ret']['user']['city'][$ctr]['id']);
             }
             # Exchange Wood
             if ($city['ret']['city'][6] < $floor) {
                 $this->exchangeWood($this->playerInfo['ret']['user']['city'][$ctr]['id']);
             }
             # Exchange Iron
             if ($city['ret']['city'][8] < $floor) {
                 $this->exchangeIron($this->playerInfo['ret']['user']['city'][$ctr]['id']);
             }
         }
     }
 }
Пример #13
0
 public function execute()
 {
     if (false === Common::isFile(GWF_GESHI_PATH)) {
         return '';
         // FIXME: {gizmore} log it? GESHI_PATH is may not readable
     }
     require_once GWF_GESHI_PATH;
     $geshi = new GeSHi();
     $langs = $geshi->get_supported_languages(false);
     $key = htmlspecialchars(Common::getGetString('key', ''), ENT_QUOTES);
     sort($langs);
     //		$this->niceArray($langs, false, '-------')
     $this->niceArray($langs, 'python', 'Python');
     $this->niceArray($langs, 'perl', 'Perl');
     $this->niceArray($langs, 'cpp', 'CPP');
     $this->niceArray($langs, 'php', 'PHP');
     $back = $this->module->lang('th_lang') . ':' . PHP_EOL;
     $back .= '<select id="bb_code_lang_sel_' . $key . '">' . PHP_EOL;
     $back .= '<option value="0">' . $this->module->lang('th_lang') . '</option>' . PHP_EOL;
     foreach ($langs as $lang) {
         $back .= sprintf('<option value="%s">%s</option>', $lang, $lang) . PHP_EOL;
     }
     $back .= '</select>' . PHP_EOL;
     $back .= $this->module->lang('th_title') . ': <input type="text" id="bb_code_title_' . $key . '" size="20" value="" />' . PHP_EOL;
     $back .= '<input type="submit" value="' . $this->module->lang('btn_code') . '" onclick="return bbInsertCodeNow(\'' . $key . '\');" />' . PHP_EOL;
     return $back;
 }
Пример #14
0
 public function create($mundane_id)
 {
     if (trimlen($this->request->Action) > 0) {
         $this->request->save('Unit_create', true);
         if (!isset($this->session->user_id)) {
             header('Location: ' . UIR . 'Login/login/Unit/create/' . $mundane_id);
         } else {
             if ($_FILES['Heraldry']['size'] > 0 && Common::supported_mime_types($_FILES['Heraldry']['type'])) {
                 if (move_uploaded_file($_FILES['Heraldry']['tmp_name'], DIR_TMP . sprintf("um_%05d", $mundane_id))) {
                     $h_im = file_get_contents(DIR_TMP . sprintf("um_%05d", $mundane_id));
                     $h_imdata = base64_encode($h_im);
                 } else {
                     $Status = ['Status' => 1000, 'Error' => 'File IO Error', 'Detail' => 'File could not be moved to .../tmp'];
                 }
             }
             $r = $this->Unit->create_unit(['Heraldry' => $h_imdata, 'HeraldryMimeType' => $_FILES['Heraldry']['type'], 'Name' => $this->request->Unit_create->Name, 'Type' => $this->request->Unit_create->Type, 'Description' => $this->request->Unit_create->Description, 'History' => $this->request->Unit_create->History, 'Url' => $this->request->Unit_create->Url, 'Token' => $this->session->token, 'MundaneId' => $mundane_id]);
             if ($r['Status'] == 0) {
                 $this->request->clear('Unit_create');
                 header('Location: ' . UIR . 'Unit/index/' . $r['Detail']);
             } else {
                 if ($r['Status'] == 5) {
                     header('Location: ' . UIR . 'Login/login/Unit/create/' . $mundane_id);
                 } else {
                     $this->data['Error'] = $r['Error'] . ':<p>' . $r['Detail'];
                 }
             }
         }
     }
     if ($this->request->exists('Unit_create')) {
         $this->data['Unit_create'] = $this->request->Unit_create->Request;
     }
     $this->data['MundaneId'] = $mundane_id;
 }
Пример #15
0
 public function execute()
 {
     return $_SERVER['REMOTE_ADDR'];
     $ip = Common::getGetString('ip', false);
     $type = Common::getGetString('type', GWF_IP6::INT_32);
     return GWF_IP6::getIP($type, $ip);
 }
Пример #16
0
 public function payNotice($params = array(), $slave_url)
 {
     $output = Common::httpRequest($slave_url, $params, 'post');
     echo $output;
     Common::logGameResponse($slave_url . '|' . $output);
     exit;
 }
Пример #17
0
 public function execute()
 {
     if (false === ($user = GWF_User::getByID(Common::getGet('userid')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     $tmpfile = GWF_PATH . 'extra/temp/gpg/' . $user->getVar('user_id');
     if (!is_file($tmpfile) || !is_readable($tmpfile)) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($tmpfile));
     }
     if (false === ($file_content = file_get_contents($tmpfile))) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($tmpfile));
     }
     if (false === unlink($tmpfile)) {
         return GWF_HTML::err('ERR_WRITE_FILE', array($tmpfile));
     }
     if (false === ($fingerprint = GWF_PublicKey::grabFingerprint($file_content))) {
         return $this->module->error('err_gpg_key');
     }
     if (Common::getGet('token') !== $fingerprint) {
         return $this->module->error('err_gpg_token');
     }
     if (false === GWF_PublicKey::updateKey($user->getID(), $file_content)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $user->saveOption(GWF_User::EMAIL_GPG, true)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_setup_gpg');
 }
Пример #18
0
 public function onNPCTalk(SR_Player $player, $word, array $args)
 {
     $price = 800 - Common::clamp($player->get('negotiation'), 0, 10) * 10;
     $time = 1000 * $player->get('charisma') * 60;
     $b = chr(2);
     switch ($word) {
         case 'shadowrun':
             return $this->reply("I am in for a run, Do you want to {$b}hire{$b} my hacking skills?");
         case 'yes':
             return $this->reply("Yes, {$b}hire{$b} me and i'll aid you in combat and hacking.");
         case 'no':
             if ($player->hasTemp(self::MANIFESTO)) {
                 return $this->reply('Yes, no, what else?');
             } else {
                 $this->reply("This is our world now... The world of the electron and the switch, the beauty of the baud.");
                 $this->reply("We make use of a service already existing without paying for what could be dirt-cheap if it wasn't run by profiteering gluttons, and you call us criminals.");
                 $this->reply("We explore... And you call us criminals. We seek after knowledge... And you call us criminals. We exist without skin color, without nationality, without religious bias... And you call us criminals.");
                 $this->reply("You build atomic bombs, you wage wars, you murder, cheat, and lie to us and try to make us believe it's for our own good, yet we're the criminals.");
                 $this->reply("Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.");
                 $this->reply("I am a hacker, and this is my manifesto. You may stop this individual, but you can't stop us all... After all, we're all alike.");
                 $player->setTemp(self::MANIFESTO, 1);
                 return true;
             }
             break;
         case 'hire':
             return $this->reply($this->onHire($player, $price, $time));
         default:
             return $this->reply("Need a hacker?");
             break;
     }
 }
Пример #19
0
 /**
  * Before Save callback
  * @param $Model
  */
 function beforeSave(&$Model)
 {
     $action = Common::isUuid($Model->id) ? 'update' : 'create';
     $details = print_r($Model->data, true);
     $this->__deferred = true;
     $this->__log($Model->alias, $action, $details, $Model->id);
 }
Пример #20
0
 public function get()
 {
     $arLotinfoTypes = $this->getLotinfoTypes();
     if (!empty($arLotinfoTypes)) {
         Common::recRMDir($this->arParams['XML_DIR']);
         Common::recRMDir($this->arParams['TMP_DIR']);
         foreach ($arLotinfoTypes as $arType) {
             $curlResult = Curl::getFile($this->arParams['XML_FILE'], $this->arParams['XML_DIR'], $arType, $this->arParams['API_URL'], ['apiKey' => $this->arParams['API_KEY'], 'cmd' => $this->arParams['API_CMD'], 'getData' => $this->arParams['GET_PARAMS']]);
             if (!$curlResult or !file_exists($curlResult)) {
                 $this->errors .= \Helper::boldColorText("Curl::getFile error: " . Curl::$ERROR, "red");
             } else {
                 try {
                     $parseXml = new ParseXml($curlResult, $this->arParams['TMP_DIR']);
                     $result = $parseXml->getData();
                     if (!$result) {
                         $this->errors .= \Helper::boldColorText("ObjectType - {$arType}: " . $parseXml->error, "red");
                     } else {
                         $this->message .= \Helper::boldColorText("ObjectType - {$arType}: Файл получен и обработан", "green");
                     }
                 } catch (Exception $e) {
                     $this->errors .= \Helper::boldColorText($e->getMessage(), "red");
                 }
             }
         }
     } else {
         $this->errors = \Helper::boldColorText("Нет номеров объектов Лотинфо", "red");
     }
     $log = !empty($this->errors) ? \Helper::boldColorText("Errors", "black") . $this->errors : "";
     $log .= !empty($this->message) ? \Helper::boldColorText("Messages", "black") . $this->message : "";
     file_put_contents($this->arParams['LOG_FILE'], $log, FILE_APPEND);
 }
Пример #21
0
 public function actionIndex()
 {
     $this->hasPrivilege(Acl::ACTION_VIEW);
     $this->pageTitle = Lang::t(Common::pluralize($this->resourceLabel));
     $searchModel = Dept::model()->searchModel(array(), $this->settings[Constants::KEY_PAGINATION], 'name');
     $this->render('default/index', array('model' => $searchModel));
 }
Пример #22
0
 /**
  *
  * @todo poll only new revisions and append to changelogfile (extend GDO or modulevar?)
  *  if GDO: repository url dynamically
  * @todo add to WC Cronjob
  * @todo rename
  * @author spaceone
  */
 public static function main()
 {
     $svn = new GWF_SvnInfo();
     $svn->setRepository('https://svn.gwf3.gizmore.org/GWF3');
     $startrev = 422;
     //292;
     $logs = $svn->getLog($startrev, $svn->getCurrentRevision());
     # Known users and their WeChall profiles
     $users = array('spaceone' => 'space', 'gizmore' => 'Gizmore');
     $back = '';
     foreach ($logs as $log) {
         $comment = $log['comment'];
         $thx = '';
         if (Common::startsWith($comment, 'WC') || false !== strpos(strtolower($comment), 'wechall')) {
             # TODO: GWF_Date::toString
             if (0 < preg_match_all('/\\(\\s*?thx +([^\\)]+)\\)/', $comment, $matches)) {
                 foreach ($matches[1] as $match) {
                     foreach (preg_split('/[\\s,;]+/', $match) as $username) {
                         $username = htmlspecialchars(trim($username));
                         $username = isset($users[$username]) ? $users[$username] : $username;
                         $thx .= sprintf('<a title="%s" href="%sprofile/%s">%s</a>' . PHP_EOL, $username, GWF_WEB_ROOT, $username);
                     }
                 }
             }
             # TODO: HTML formatting
             $creator = isset($users[$log['creator-displayname']]) ? $users[$log['creator-displayname']] : $log['creator-displayname'];
             $pattern = 'Revision: %s; by <a href="%s/profile/%s">%s</a>; on %s;' . PHP_EOL . '  %s' . PHP_EOL . '%s' . PHP_EOL;
             $back .= sprintf($pattern, $log['version-name'], GWF_WEB_ROOT, $creator, $creator, $log['date'], str_replace("\n", "\n  ", $comment), $thx);
         }
     }
     if (false === file_put_contents(GWF_WWW_PATH . self::$outfile, $back)) {
         # TODO
     }
 }
Пример #23
0
 public function show_related_posts($post_id, $list_size, $format)
 {
     /** 输出格式为空?*/
     if (empty($format) || !is_numeric($post_id) || empty($list_size)) {
         return;
     }
     /** 参数初始化 */
     $post_id = intval($post_id);
     $list_size = $list_size && is_numeric($list_size) ? intval($list_size) : 10;
     $date_format = setting_item('post_date_format');
     $date_format = !empty($date_format) ? $date_format : 'Y-m-d';
     $this->_CI->metas_mdl->get_metas($post_id);
     $tags = implode(',', Common::array_flatten($this->_CI->metas_mdl->metas['tag'], 'mid'));
     if (empty($tags)) {
         echo "<p>没有相关文章</p>\r\n";
         return;
     }
     $posts = $this->_CI->db->select('posts.slug, posts.title, posts.created')->from('posts')->join('relationships', 'posts.pid = relationships.pid', 'INNER')->where_in('relationships.mid', $tags)->where('posts.pid <>', $post_id)->where('posts.status', 'publish')->where('posts.type', 'post')->order_by('posts.created', 'DESC')->limit($list_size)->offset(0)->get()->result();
     if ($posts) {
         foreach ($posts as $post) {
             $wildcards = array('{permalink}', '{title}', '{date}');
             $replaces = array(site_url('posts/' . $post->slug), $post->title, date($date_format, $post->created));
             echo str_replace($wildcards, $replaces, $format) . "\r\n";
         }
     }
     return;
 }
Пример #24
0
 public function run($id = false, $model = false, $forceDelete = false)
 {
     $modelName = $this->model && is_string($this->model) ? $this->model : (request()->getParam('model') ? request()->getParam('model') : $this->controller->model);
     if ($id) {
         //delete one model
         $result = $this->controller->loadModel($modelName, $id)->delete();
         if (!request()->isAjaxRequest && $result) {
             $this->controller->redirect(user()->gridIndex);
         }
         Common::jsonSuccess(true);
     } else {
         $items = Common::getChecked('items');
         if ($items) {
             if (!$forceDelete) {
                 foreach ($items as $id) {
                     $this->controller->loadModel($modelName, $id)->delete();
                 }
             } else {
                 $criteria = new SDbCriteria();
                 $criteria->compare('id', $items);
                 CActiveRecord::model($modelName)->deleteAll($criteria);
             }
             Common::jsonSuccess(true);
         }
     }
     Common::jsonError("Ошибка");
 }
Пример #25
0
 public function validate_password2($chall, $arg)
 {
     if (Common::getPostString('password1') !== $arg) {
         return $chall->lang('err_retype');
     }
     return false;
 }
Пример #26
0
 public function index($pid)
 {
     if (!is_numeric($pid)) {
         show_404();
     }
     $production = $this->production_service->get_production_by_id($pid);
     if (empty($production)) {
         show_404();
     }
     $production['pic_thumb'] = Common::get_thumb_url($production['pic'], 'thumb2_');
     if (isset($this->user['id'])) {
         $production['like_status'] = $this->production_service->check_has_like($pid, $this->user['id']);
     } else {
         $production['like_status'] = 0;
     }
     $body['production'] = $production;
     $uid = isset($this->user['id']) ? $this->user['id'] : NULL;
     //获取相关联的专题
     //$data['topic'] 			= $this->production_service->get_topic_by_production($pid,$uid);
     $data['css'] = array('font-awesome/css/font-awesome.min.css', 'base.css', 'alert.css');
     $data['javascript'] = array('jquery.js', 'alert.min.js', 'masonry.pkgd.min.js', 'jquery.imageloader.js', 'error.js', 'validate.js', 'zoomtoo.js', 'zoom.js');
     $user['user'] = $this->user;
     $data['title'] = $production['name'];
     $body['top'] = $this->load->view('common/top', $user, TRUE);
     $body['sign'] = $this->load->view('common/sign', '', TRUE);
     $body['footer'] = $this->load->view('common/footer', '', TRUE);
     $body['user'] = $this->user;
     $this->load->view('common/head', $data);
     $this->load->view('production_detail', $body);
 }
Пример #27
0
 public function action_ajax_query()
 {
     $querytype = $this->params['querytype'];
     $querydate = $this->params['querydate'];
     if ($querytype == 'uselog') {
         $templet = 'uselog';
         $out = $this->sms->querySendLog($querydate);
     }
     if ($querytype == 'faillog') {
         $templet = 'faillog';
         $out = $this->sms->queryFailLog($querydate);
     }
     if ($querytype == 'buylog') {
         $templet = 'buylog';
         $out = $this->sms->queryBuyLog($querydate);
     }
     $data = json_decode($out)->Data;
     $datalist = array();
     foreach ($data as $row) {
         $datalist[] = Common::objectToArray($row);
     }
     echo json_encode($datalist);
     // $this->assign('datalist',$datalist);
     //  $this->display('stourtravel/sms/'.$templet);
 }
Пример #28
0
 function add_comment_catalog($params)
 {
     Common::call_common_instance('catalog');
     $catalog = catalog_module_common::getInstance();
     $marker = $catalog->obj_tree->ReadNodeParam($params['id'], 'Name');
     $this->result["result_code"] = $this->_addcomment(array('CobjectId' => $params['id'], 'tread' => $params['tread'], 'Module' => 'catalog', 'Marker' => $marker), $params['comment']);
 }
Пример #29
0
 public function actionView()
 {
     $radioId = Yii::app()->request->getParam("id", 0);
     $radioName = WapRadioModel::model()->findByPk($radioId)->name;
     $albumId = WapRadioModel::model()->getAlbumByRadio($radioId, "c2.id");
     $radioAvatar = RadioModel::model()->getAvatarUrl($radioId, 's1');
     $album = WapAlbumModel::model()->published()->findByPk($albumId);
     if (!$album) {
         $this->forward("/site/error", true);
     }
     $songsOfAlbum = WapSongModel::model()->getSongsOfAlbum($albumId);
     $artists = AlbumArtistModel::model()->getArtistsByAlbum($albumId);
     $phone = yii::app()->user->getState('msisdn');
     $errorCode = 'success';
     $errorDescription = '';
     $registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT');
     ///meta tag
     $AlbumDetail = AlbumModel::model()->findByPk($albumId);
     $artistId = !empty($artists) ? $artists[0]->artist_id : $AlbumDetail->artist_id;
     $ArtistInfo = ArtistModel::model()->findByPk($artistId);
     $this->itemName = $AlbumDetail->name;
     $this->artist = $ArtistInfo->name;
     $this->thumb = AlbumModel::model()->getAvatarUrl($albumId, 's1');
     $this->url = URLHelper::buildFriendlyURL("album", $albumId, Common::makeFriendlyUrl($ArtistInfo->name));
     $this->description = strip_tags($AlbumDetail->description);
     //get other radio
     $parent_id = Yii::app()->params['horoscope']['parent_id'];
     $radioListOther = WapRadioModel::model()->getHoroscopes($parent_id);
     $this->render('detail', array('album' => $album, 'songsOfAlbum' => $songsOfAlbum, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'registerText' => $registerText, 'radioListOther' => $radioListOther, 'radioAvatar' => $radioAvatar));
 }
Пример #30
0
 /**
  * 记录交易流水
  * @param unknown $bills_data 支付交易信息
  * @param unknown $pay_info 支付状态信息
  * @throws Exception
  * @return boolean
  * @author yuanxiaolin@dachuwang.com
  */
 public static function add_trade_bill($bills_data = array(), $pay_info = array())
 {
     $log = Common::LogInit();
     $data = array();
     if (empty($bills_data) || empty($pay_info)) {
         throw new Exception('bills_data or pay_info required, but one of is empty');
     }
     // 支付状态信息
     $data['order_id'] = $pay_info['id'];
     $data['pay_type'] = $pay_info['pay_type'];
     $data['pay_status'] = $pay_info['pay_status'];
     // $data['pay_discount'] = $pay_info['pay_discount'];
     // 订单交易信息
     $data['transaction_id'] = $bills_data['transaction_id'];
     $data['trade_no'] = $bills_data['out_trade_no'];
     $data['total_fee'] = $bills_data['total_fee'];
     $data['cash_fee'] = $bills_data['cash_fee'];
     $data['created_time'] = $data['updated_time'] = time();
     $data['full_data'] = $bills_data;
     $post_data['add_fields'] = serialize($data);
     $result = Common::DoApi(Config::API_ADD_PAY_BILLS, $post_data, 'POST');
     // 记录新增支付流水debug日志
     $log::DEBUG(sprintf('call trade::add_trade_bill api info:|api_url:%s|post_data:%s|api_return:%s', Config::API_ADD_PAY_BILLS, json_encode($post_data), json_encode($result)));
     if (isset($result['status']) && $result['status'] == Config::API_SUCCESS_CODE) {
         return true;
     } else {
         $log::ERROR(sprintf('call trade::add_trade_bill api error|api_url:%s|post_data:%s|api_return:%s', Config::API_ADD_PAY_BILLS, json_encode($post_data), json_encode($result)));
         return false;
     }
 }