/** * コールバックメソッド * * @return bool サスペンドフラグ */ public function execute() { $id = null; if (isset($this->get->id)) { $id = $this->get->id; } $path = implode(DS, array($this->conf->execpath, 'wiki', $id . '.wiki')); $path = str_replace('_', DS, $path); if ($this->_checkOS('win')) { $path = mb_convert_encoding_deep($path, 'sjis', 'utf-8'); } if (file_exists($path)) { $wiki = new xFrameworkPX_Wiki(); exit($wiki->wiki(file_get_contents($path))); } }
function beforeFilter() { if (!empty($this->params['prefix']) && $this->params['prefix'] === 'm') { $this->data = mb_convert_encoding_deep($this->data, "UTF-8", "SJIS-win"); //header("Content-type: text/html; charset=utf-8"); Configure::write('debug', 0); } $this->AppInit->urlUnion($this); $this->Auth->allow('display'); $this->Auth->allow('view'); $this->Auth->loginError = 'IDとパスワードが一致しません'; $this->Auth->authError = '権限がありません'; $this->Auth->loginAction = '/users/login'; $this->Auth->loginRedirect = '/admin/users/index'; $this->Auth->logoutRedirect = '/users/login'; }
function admin_index() { $this->Import->set($this->data); //Configure::write('debug',2); if (!empty($this->data) && $this->Import->validates()) { $up_file = $this->data['Import']['csv']['tmp_name']; $csv = $this->__csvRead($up_file); $csv = mb_convert_encoding_deep($csv, "UTF-8", "SJIS-win"); //varidate追加 $this->Import->setValidation('import'); $users = $alreadyUsers = array(); $errorLine = array(); foreach ($csv as $line) { if (count($line) < 20) { continue; } $data = array('no' => $this->__no($line[0]), 'type' => $this->__type($line[1]), 'subject' => $this->__subject($line[2]), 'name' => $line[3], 'furigana' => $line[4], 'sex' => $line[5], 'mail' => $line[6], 'zip01' => $line[7], 'zip02' => $line[8], 'address01' => $line[9], 'address02' => $line[10], 'birthday' => $this->__birthday($line[11]), 'tel01' => $line[12], 'tel02' => $line[13], 'tel03' => $line[14], 'highschool' => $line[15], 'school_year' => $line[16], 'bus' => $this->__bus($line[19]), 'schedule_id' => $this->__schedule($this->__no($line[0]), $line[17], $line[18]), 'created' => $line[20], 'code' => $line[0], 'doc' => '', 'mail_status' => 1); $recursive = array('conditions' => array('Import.mail' => $data['mail']), 'fields' => array('Import.id')); $userData = $this->Import->find('all', $recursive); if (empty($userData)) { $this->Import->set($data); if ($this->Import->validates()) { $users[] = $data; } else { //エラーメッセージ取得 $errorLine[] = array('name' => $data['name'], 'errorMessage' => $this->Import->invalidFields()); } } else { $alreadyUsers[] = $data; } } $this->set('errorLine', $errorLine); if (!empty($users) && $this->Import->saveAll($users)) { $this->set('insertCount', count($users)); $this->Session->setFlash('登録完了しました。'); } else { $this->Session->setFlash('登録できませんでした。'); } $this->set('alreadyUsers', $alreadyUsers); } }
function conv($var) { return mb_convert_encoding_deep($var, 'utf8', 'eucjp-Win'); }