Example #1
0
	function beforeRender() {
		$this->layout='base';
		$this->user=$this->Auth->user();

		//usersテーブル検索
		$this->loadModel('Users');
		$username=$this->user['User']['username'];
		$users=$this->Users->find('all', array('conditions' => "username='******'"));
		if ( count($users) > 0 ){
			$this->user['User']['authority']=$users[0]['Users']['authority'];
		}

		//権限情報が未設定の場合(LDAP認証やWebHiveリポジトリでauthorityが未設定の場合)
		if ( empty($this->user['User']['authority']) ){
			$this->user['User']['authority']=LDAP_AUTH;

			//初回ログイン時はDB登録
			$reg=array();
			$reg['Users']['username']=$this->user['User']['username'];
			$reg['Users']['authority']=$this->user['User']['authority'];
			$this->Users->create();
			$this->Users->save($reg, array('username','authority'));
		}

		$this->set('user', $this->user);
		$this->set('app_title_msg', CommonComponent::GetSubTitle());
	}
	function beforeFilter() {
		$this->set('app_title_msg', CommonComponent::GetSubTitle());

                //admin権限以外はHiveQL画面表示不可
		$ck=0;
                $user=$this->Auth->user();
                if ( !empty($user) ){
                	if ( $user['User']['authority'] == 1 ){ $ck=1; }
		}
		if ( $ck == 0 ){ $this->redirect('/errors'); }
        }
Example #3
0
File: Params.php Project: neel/bong
    public function generate()
    {
        $data = <<<'TEMPLATESTR'
<?php
$params->title = "Page Title";
$params->js = array();
$params->css = array();
?>
TEMPLATESTR;
        return parent::generate($data);
    }
Example #4
0
	function index() {
		$tips="";
		if ( ($fp=fopen(TIPS_FILE,"r")) ){
			while(!feof($fp)){
				$data = fgets($fp, 512);
				$tips .= $data;
			}
			fclose($fp);
		}

		$this->set('app_title_msg', CommonComponent::GetSubTitle());
		$this->set("tips" , array("tips" => "$tips"));
	}
Example #5
0
 /**
  * append some more infos to better track down the error
  * @return string
  * 2011-12-21 ms
  */
 public static function traceDetails()
 {
     App::uses('CommonComponent', 'Tools.Controller/Component');
     $currentUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'n/a';
     $refererUrl = CommonComponent::getReferer();
     //Router::getRequest()->url().'
     App::uses('CakeSession', 'Model/Datasource');
     $uid = CakeSession::read('Auth.User.id');
     if (empty($uid)) {
         $uid = !empty($_SESSION) && !empty($_SESSION['Auth']['User']['id']) ? $_SESSION['Auth']['User']['id'] : null;
     }
     $data = array(@CakeRequest::clientIp(), $currentUrl . (!empty($refererUrl) ? ' (' . $refererUrl . ')' : ''), $uid, env('HTTP_USER_AGENT'));
     return implode(' - ', $data);
 }
Example #6
0
	function index() {
		//インフォメーションファイル
		$info="";
		if ( ($fp=fopen(INFORMATION_FILE,"r")) ){
			while(!feof($fp)){
				$data = fgets($fp, 512);
				$info .= $data;
			}
			fclose($fp);
		}

		$this->set('app_title_msg', CommonComponent::GetSubTitle());
		$this->set("info" , array("info" => "$info"));
	}
Example #7
0
	function jobcancel() {
		//ajaxリクエスト以外
		if( !$this->RequestHandler->isAjax() ) {
			$this->set("result" , array("result" => "not ajax"));
			return;
		}

		//パラメータ解析
		$u_userid=$this->params['form']['u'];
		$u_id=$this->params['form']['id'];
		$this->log("RequestID=$u_id",LOG_DEBUG);
		if ( $u_userid == "" or $u_id == "" ){
			$this->set("result" , array("result" => "parameter error"));
			return;
		}
		CommonComponent::UpdateRunhistsResult($u_id,100);

		//ファイル名
		$out_file=DIR_RESULT."/${u_userid}/${u_id}.out";
		$pid_file=DIR_RESULT."/${u_userid}/${u_id}.pid";

		//JOBキャンセルループ
		for ($cancel_loop=0; $cancel_loop < JOBCANCEL_RETRY_MAX; $cancel_loop++){

			$cancel_loop_max=JOBCANCEL_RETRY_MAX;
			$this->log("JOB CANCEL ($cancel_loop/$cancel_loop_max)",LOG_DEBUG);

			//hiveクライアントスクリプトが完了しているか?
			if ( !file_exists($pid_file) ){
				$this->set("result" , array("result" => "ok"));
				return;
			}

			//hadoop JobID取得
			$jobid=CommonComponent::GetJobId($out_file);

			//JOBキャンセル
			if ( $jobid != "" ){
				$cmd=CMD_HADOOP." job \-kill $jobid";
				$this->log("CMD=$cmd",LOG_DEBUG);
				exec("$cmd > /dev/null 2>&1",$result,$retval);
				$this->log("CMD=$cmd => $retval",LOG_DEBUG);
			}

			sleep(JOBCANCEL_RETRY_WAIT);
		}

		$this->set("result" , array("result" => "retry over"));
	}
Example #8
0
 /**
  * Convenience function for normal urls.
  * Useful for layout links and links inside elements etc if you don't want to
  * verbosely reset all parts of it (prefix, plugin, ...).
  *
  * @params same as Html::url($url, $full)
  * @return string URL
  */
 public function defaultUrl($url = null, $full = false)
 {
     if ($this->_linkDefaults === null) {
         if (!class_exists('CommonComponent')) {
             App::uses('CommonComponent', 'Tools.Controller/Component');
         }
         $this->_linkDefaults = CommonComponent::defaultUrlParams();
     }
     if ($url !== null && is_array($url)) {
         $url = array_merge($this->_linkDefaults, $url);
     }
     return $this->url($url, $full);
 }
Example #9
0
 /**
  * Check if session works due to allowed cookies
  *
  * @param bool Success
  */
 public function sessionCheck()
 {
     return !CommonComponent::cookiesDisabled();
     /*
      if (!empty($_COOKIE) && !empty($_COOKIE[Configure::read('Session.cookie')])) {
      return true;
      }
      return false;
     */
 }
Example #10
0
 /**
  * Add a message on the fly
  *
  * @param string $msg
  * @param string $class
  * @return void
  */
 public function addFlashMessage($msg, $class = null)
 {
     CommonComponent::transientFlashMessage($msg, $class);
 }
Example #11
0
	function index() {
		$this->set('app_title_msg', CommonComponent::GetSubTitle());
	}
	function beforeRender() {
		$this->set('app_title_msg', CommonComponent::GetSubTitle());
	}
 /**
  * CountriesController::admin_import()
  *
  * @return void
  */
 public function import()
 {
     if ($this->Common->isPosted()) {
         if (!empty($this->request->data['Form'])) {
             $count = 0;
             foreach ($this->request->data['Form'] as $key => $val) {
                 $this->Countries->create();
                 $data = ['iso3' => $val['iso3'], 'iso2' => $val['iso2'], 'name' => $val['name']];
                 if (empty($val['confirm'])) {
                     # do nothing
                 } elseif ($this->Countries->save($data)) {
                     $count++;
                     unset($this->request->data['Form'][$key]);
                 } else {
                     //$this->request->data['Form'][$key]['confirm'] = 0;
                     $this->request->data['Error'][$key] = $this->Countries->validationErrors;
                 }
             }
             $this->Flash->success(__('record import {0} saved', $count));
         } else {
             $list = $this->request->data['Country']['import_content'];
             if (!empty($this->request->data['Country']['import_separator_custom'])) {
                 $separator = $this->request->data['Country']['import_separator_custom'];
                 $separator = str_replace(['{SPACE}', '{TAB}'], [Country::separators(SEPARATOR_SPACE, true), Country::separators(SEPARATOR_TAB, true)], $separator);
             } else {
                 $separator = $this->request->data['Country']['import_separator'];
                 $separator = Country::separators($separator, true);
             }
             # separate list into single records
             $countries = CommonComponent::parseList($list, $separator, false, false);
             if (empty($countries)) {
                 $this->Countries->invalidate('import_separator', 'falscher Separator');
             } elseif (!empty($this->request->data['Country']['import_pattern'])) {
                 $pattern = str_replace(['{SPACE}', '{TAB}'], [Country::separators(SEPARATOR_SPACE, true), Country::separators(SEPARATOR_TAB, true)], $this->request->data['Country']['import_pattern']);
                 # select part that matches %name
                 foreach ($countries as $key => $danceStep) {
                     $tmp = sscanf($danceStep, $pattern);
                     # returns array
                     # write back into $countries array
                     if (!empty($tmp[2])) {
                         $this->request->data['Form'][$key] = ['name' => $tmp[2], 'confirm' => 1];
                         if (!empty($tmp[1])) {
                             $this->request->data['Form'][$key]['iso2'] = $tmp[1];
                         }
                         if (!empty($tmp[0])) {
                             $this->request->data['Form'][$key]['iso3'] = $tmp[0];
                         }
                     }
                     $countries[$key] = $tmp;
                 }
                 if (empty($this->request->data['Form'])) {
                     $this->Countries->invalidate('import_pattern', 'falsches Muster');
                 }
             } else {
                 foreach ($countries as $key => $country) {
                     $this->request->data['Form'][$key] = ['name' => $country, 'confirm' => 1];
                 }
             }
         }
         $this->set(compact('countries'));
     }
 }
Example #14
0
	function beforeRender() {
		$this->user=$this->Auth->user();
		$this->set('user', $this->user);
		$this->set('app_title_msg', CommonComponent::GetSubTitle());
	}
Example #15
0
 /**
  * @param length (defaults to defaultLength)
  * @return string codekey
  * 2009-05-13 ms
  */
 function generateKey($length = null)
 {
     if (empty($length)) {
         $length = $defaultLength;
     } else {
         if ((class_exists('CommonComponent') || App::import('Component', 'Common')) && method_exists('CommonComponent', 'generatePassword')) {
             return CommonComponent::generatePassword($length);
         } else {
             return $this->_generateKey($length);
         }
     }
 }
Example #16
0
 /**
  * checks if a url is valid
  * @param string url
  * 2009-02-27 ms
  */
 function _validUrl($url = null)
 {
     App::import('Component', 'Tools.Common');
     $headers = CommonComponent::getHeaderFromUrl($url);
     if ($headers !== false) {
         $headers = implode("\n", $headers);
         return (bool) preg_match('#^HTTP/.*\\s+[(200|301|302)]+\\s#i', $headers) && !(bool) preg_match('#^HTTP/.*\\s+[(404|999)]+\\s#i', $headers);
     }
     return false;
 }
Example #17
0
 public function testGetGroup()
 {
     $list = array('Models' => array('1' => 'Foo', '2' => 'Bar'), 'Mitarbeiter' => array('3' => 'Some', '4' => 'Thing'));
     $matching = array('Models' => 'Model', 'Mitarbeiter' => 'Contributor');
     $res = CommonComponent::getGroup($list, 111);
     $this->assertEquals('', $res);
     $res = CommonComponent::getGroup($list, 2);
     $this->assertEquals('Models', $res);
     $res = CommonComponent::getGroup($list, 2, $matching);
     $this->assertEquals('Model', $res);
     $res = CommonComponent::getGroup($list, 3, $matching);
     $this->assertEquals('Contributor', $res);
 }
Example #18
0
	function CheckExplainDatabase($u_userid,$u_id,$u_databases) {

		//$this->log("CheckExplainDatabase($u_userid,$u_id,$u_databases)",LOG_DEBUG);
		if ( $u_databases == "" ){ return 0; }

		//EXPLAIN結果ファイル読み込み
		$ck_flg=0;
		$cur_db="";
		$exp_file=DIR_RESULT."/${u_userid}/${u_id}.exp";
		if ( !($fp=fopen($exp_file,"r")) ){ return -1; }
		while(!feof($fp)){
			$data = fgets($fp, 10240);
			$data=str_replace(array("\r\n","\n","\r"), '', $data);
			if ( eregi("^use ",$data) ){
				list($dummy,$cur_db)=split("[ ;]",$data); 
			}

			if ( eregi("TOK_QUERY|TOK_CREATETABLE|TOK_DROPTABLE",$data) ){
				$array=preg_split("/[\(\)]+/",$data); 
				foreach ($array as $i => $value) {
					$data=$array[$i];
					if ( !eregi("^TOK_TABNAME",$data) ){ continue; }
					$array2 = split(" ",$data); 
					if ( empty($array2[2]) ){
						$sql_db="";
						$sql_tbl=$array2[1];
					}else{
						$sql_db=$array2[1];
						$sql_tbl=$array2[2];
					}
					if ( $sql_db == "" ){ $sql_db=$cur_db; }

					//クエリを許可するか判定
					if ( CommonComponent::CheckDatabase($u_databases,$sql_db) != 0 ){
						$ck_flg++;
					}
				}
			}
		}
		fclose($fp);

		return $ck_flg;
	}
Example #19
0
 /**
  * logs attempts
  * @param bool errorsOnly (only if error occured, otherwise always)
  * @returns null if not logged, true otherwise
  * 2009-12-18 ms
  */
 protected function _logAttempt($errorsOnly = true)
 {
     if ($errorsOnly === true && empty($this->error) && empty($this->internalError)) {
         return null;
     }
     if (!$this->settings[$this->Model->alias]['log']) {
         return null;
     }
     //App::import('Component', 'RequestHandler');
     $msg = 'IP \'' . CakeRequest::clientIP() . '\', Agent \'' . env('HTTP_USER_AGENT') . '\', Referer \'' . env('HTTP_REFERER') . '\', Host-Referer \'' . CommonComponent::getReferer() . '\'';
     if (!empty($this->error)) {
         $msg .= ', ' . $this->error;
     }
     if (!empty($this->internalError)) {
         $msg .= ' (' . $this->internalError . ')';
     }
     $this->log($msg, 'captcha');
     return true;
 }