예제 #1
0
 protected function _login()
 {
     $name = Dura::post('name');
     $icon = Dura::post('icon');
     $language = Dura::post('language');
     $name = trim($name);
     $icon = trim($icon);
     $language = trim($language);
     if ($name === '') {
         throw new Exception(t("Please input name."));
     }
     if (mb_strlen($name) > 10) {
         throw new Exception(t("Name should be less than 10 letters."));
     }
     $token = Dura::post('token');
     if (!Dura_Class_Ticket::check($token)) {
         throw new Exception(t("Login error happened."));
     }
     if (!isset($this->icons[$icon])) {
         $icons = array_keys($this->icons);
         $icon = reset($icons);
     }
     $user =& Dura_Class_User::getInstance();
     $user->login($name, $icon, $language);
     Dura_Class_Ticket::destory();
     Dura::redirect('lounge');
 }
예제 #2
0
 protected function _profile()
 {
     $user =& Dura::user();
     $icon = $user->getIcon();
     $icon = Dura_Class_Icon::getIconUrl($icon);
     $profile = array('icon' => $icon, 'name' => $user->getName());
     $this->output['profile'] = $profile;
 }
예제 #3
0
 protected function _escapeHtml(&$vars)
 {
     foreach ($vars as $key => &$var) {
         if (is_array($var)) {
             $this->_escapeHtml($var);
         } elseif (!is_object($var)) {
             $var = Dura::escapeHtml($var);
         }
     }
 }
예제 #4
0
 public static function execute()
 {
     $controller = self::get('controller', 'default');
     $action = self::get('action', 'default');
     self::$Controller = self::putintoClassParts($controller);
     self::$Action = self::putintoClassParts($action);
     self::$controller = self::putintoPathParts(self::$Controller);
     self::$action = self::putintoPathParts(self::$Action);
     self::$Action[0] = strtolower(self::$Action[0]);
     $class = 'Dura_Controller_' . self::$Controller;
     if (!class_exists($class)) {
         die("Invalid Access");
     }
     $instance = new $class();
     $instance->main();
     self::user()->updateExpire();
     unset($instance);
 }
예제 #5
0
 protected function _default()
 {
     $talks = array();
     $userId = Dura::user()->getId();
     foreach ($this->roomModels as $roomModel) {
         foreach ($roomModel->talks as $talk) {
             $time = (int) $talk->time;
             $id = (string) $talk->id;
             if (isset($talks[$time][$id])) {
                 continue;
             }
             $talks[$time][$id] = (array) $talk;
         }
     }
     ksort($talks);
     $talks = array_reverse($talks);
     $this->output['talks'] = $talks;
     $this->_view();
 }
예제 #6
0
 protected function _login()
 {
     $name = Dura::post('name');
     $pass = Dura::post('pass');
     $name = trim($name);
     $pass = trim($pass);
     if ($name === '') {
         throw new Exception(t("Please input name."));
     }
     $token = Dura::post('token');
     if (!Dura_Class_Ticket::check($token)) {
         throw new Exception(t("Login error happened."));
     }
     if ($name !== DURA_ADMIN_NAME or $pass !== DURA_ADMIN_PASS) {
         throw new Exception(t("ID or password is wrong."));
     }
     $user =& Dura_Class_User::getInstance();
     $user->login($name, 'admin', DURA_LANGUAGE, true);
     Dura_Class_Ticket::destory();
     Dura::redirect('lounge');
 }
예제 #7
0
 protected function _createRoom()
 {
     $userName = Dura::user()->getName();
     $userId = Dura::user()->getId();
     $userIcon = Dura::user()->getIcon();
     $roomHandler = new Dura_Model_RoomHandler();
     $roomModel = $roomHandler->create();
     $roomModel->name = $this->input['name'];
     $roomModel->update = time();
     $roomModel->limit = $this->input['limit'];
     $roomModel->host = $userId;
     $roomModel->language = $this->input['language'];
     $users = $roomModel->addChild('users');
     $users->addChild('name', $userName);
     $users->addChild('id', $userId);
     $users->addChild('icon', $userIcon);
     $users->addChild('update', time());
     if (Dura::$language != $this->input['language']) {
         $langFile = DURA_TRUST_PATH . '/language/' . $this->input['language'] . '.php';
         Dura::$catalog = (require $langFile);
     }
     $talk = $roomModel->addChild('talks');
     $talk->addChild('id', md5(microtime() . mt_rand()));
     $talk->addChild('uid', 0);
     $talk->addChild('name', $userName);
     $talk->addChild('message', "{1} logged in.");
     $talk->addChild('icon', '');
     $talk->addChild('time', time());
     $id = md5(microtime() . mt_rand());
     if (!$roomHandler->save($id, $roomModel)) {
         throw new Exception(t("Data Error: Room creating failed."));
     }
     Dura_Class_RoomSession::create($id);
     Dura::redirect('room');
 }
?>
</select>
</td>
</tr>

<tr style="position:fixed; top:99999%;">
<td>
<select name="language">
<?php 
foreach ($dura['languages'] as $langcode => $language) {
    ?>
<option value="<?php 
    e($langcode);
    ?>
"<?php 
    if ($langcode == Dura::user()->getLanguage()) {
        ?>
 selected="selected"<?php 
    }
    ?>
><?php 
    e($language);
    ?>
</option>
<?php 
}
?>
</select>
</td>
</tr>
예제 #9
0
 protected function _default()
 {
     session_destroy();
     Dura::redirect();
 }
예제 #10
0
<input type="hidden" name="token" value="<?php 
echo $dura['token'];
?>
" />

</form>

<?php 
if (file_exists(DURA_TEMPLATE_PATH . '/footer.html')) {
    ?>
<div class="footer">
<?php 
    require DURA_TEMPLATE_PATH . '/footer.html';
    ?>
</div>
<?php 
}
?>
<div class="copyright">
<a href="<?php 
e(Dura::url('admin'));
?>
"><?php 
e("Admin");
?>
</a> |
Durarara-like-chat Copyright (c) 2010 <a href="http://suin.asia/">Suin</a> | <a href="https://github.com/drrr-like-chat/drrr-like-chat">get this chat?</a></div>

</div>
예제 #11
0
 protected function _isHost($userId = null)
 {
     if ($userId === null) {
         $userId = Dura::user()->getId();
     }
     return $userId == (string) $this->roomModel->host;
 }
예제 #12
0
 *
 * PHP Version 5.2.0 or Upper version
 *
 * @package    Dura
 * @author     Hidehito NOZAWA aka Suin <http://suin.asia>
 * @copyright  2010 Hidehito NOZAWA
 * @license    http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
 *
 */
if (file_exists('setting.php')) {
    require 'setting.php';
} else {
    require 'setting.dist.php';
}
require 'dura.php';
Dura::setup();
if (!isset($_SESSION['room']['id'])) {
    // Session not exists.
    header('Content-Type: application/xml; charset=UTF-8');
    die('<?xml version="1.0" encoding="UTF-8"?><room><error>1</error></room>');
}
$id = $_SESSION['room']['id'];
$roomHandler = new Dura_Model_RoomHandler();
$roomModel = $roomHandler->load($id);
if (!$roomModel) {
    // Room not found.
    header('Content-Type: application/xml; charset=UTF-8');
    die('<?xml version="1.0" encoding="UTF-8"?><room><error>2</error></room>');
}
$file = $roomHandler->getFilePath($id);
$content = md5(file_get_contents($file));
예제 #13
0
" /></li>
<li class="name"><?php 
echo $dura['profile']['name'];
?>
</li>
<li class="logout">
<form action="<?php 
echo Dura::url('logout');
?>
" method="post">

<?php 
if (Dura::user()->isAdmin()) {
    ?>
<a href="<?php 
    e(Dura::url('admin_announce'));
    ?>
" style="font:12px UbuntuMonoBold,'Microsoft YaHei'; color:#F90; text-decoration:none;"><?php 
    e(t("Announce"));
    ?>
</a>
<?php 
}
?>
<input type="submit" class="input" value="<?php 
e(t("LOGOUT"));
?>
" />
</form>
</li>
</ul>
예제 #14
0
<?php

/**
 * A simple description for this script
 *
 * PHP Version 5.2.0 or Upper version
 *
 * @package    Dura
 * @author     Hidehito NOZAWA aka Suin <http://suin.asia>
 * @copyright  2010 Hidehito NOZAWA
 * @license    http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
 *
 */
if (file_exists('setting.php')) {
    require 'setting.php';
} else {
    require 'setting.dist.php';
}
require 'dura.php';
Dura::setup();
Dura::execute();