Esempio n. 1
0
 public function page()
 {
     self::$bundles = e::configure('manage')->bundle;
     $out = '<div style="padding: 30px;">';
     foreach (self::$bundles as $namespace => $link) {
         try {
             if (strlen($namespace) < 3) {
                 throw new Exception("Invalid namespace `{$namespace}` for manage page `{$link}`");
             }
             $class = "{$namespace}\\Manage";
             $manage = new $class();
             $tile = $manage->tile();
             if (is_null($tile)) {
                 continue;
             }
             if (!$tile instanceof Tile) {
                 throw new Exception("Bundle manager `{$class}` tile is not a valid Tile class");
             }
             $tiles[$manage->title] = $tile->output($manage->title);
         } catch (Exception $e) {
             e\trace_exception($e);
             $tile = $this->tile($e->getMessage());
             $tiles[$link] = $tile->output($link);
         }
     }
     ksort($tiles);
     foreach ($tiles as $tile) {
         $out .= $tile;
     }
     $out .= '</div>';
     return $out;
 }
Esempio n. 2
0
 protected function initial_data()
 {
     $this->user_id = null;
     $this->defunct = self::DEFUNCT_NO;
     $this->time = e::format_time();
     $this->importance = self::TYPE_NORMAL;
 }
Esempio n. 3
0
 public function _on_framework_security()
 {
     // Add manager
     e::configure('manage')->activeAddKey('bundle', __NAMESPACE__, 'security');
     $developer = false;
     // Check cookie login
     if (isset($_COOKIE['e-developer'])) {
         // Check cookie data
         $cookie = explode('_', $_COOKIE['e-developer'], 2);
         $name = $cookie[0];
         // Use key to encrypt cookie
         $keys = e::configure('developers');
         if (!isset($keys->{$name})) {
             throw new Exception("Invalid developer access username in cookie");
         }
         $key = $keys->{$name};
         $check = $this->genCookieSegment($name, $key);
         if ($check === $cookie[1]) {
             $developer = true;
         }
     }
     // Check file based access
     $file = realpath(e\root . "/../.e-developer");
     if ($file) {
         $cookie = explode('_', file_get_contents($file), 2);
         $name = $cookie[0];
         // Use key to encrypt cookie
         $keys = e::configure('developers');
         if (!isset($keys->{$name})) {
             throw new Exception("Invalid developer access username in file");
         }
         $key = $keys->{$name};
         $check = $this->genCookieSegment($name, $key);
         if ($check === $cookie[1]) {
             $developer = true;
         }
     }
     // Check credentials if not logged in
     if (!$developer) {
         $key = $this->getPOSTKey();
         if (!is_null($key)) {
             // Get the account name
             $name = $key[0];
             // Load the encoded version of the key
             $key = $this->validateCredentials($key);
             // Compare it to existing keys
             $keys = e::configure('developers');
             if ($keys->{$name} === $key) {
                 // Set the cookie
                 setcookie('e-developer', $name . '_' . $this->genCookieSegment($name, $key));
                 // Redirect to prevent pages that use postdata from accessing the credentials
                 e\Redirect($_SERVER['REQUEST_URI']);
             } else {
                 $this->page('access', 'You entered incorrect credentials');
             }
         }
     }
     $this->developer = $developer;
 }
Esempio n. 4
0
 public function test_contest_time()
 {
     ob_start();
     e::the_contest_time(3661);
     $content = ob_get_contents();
     ob_end_clean();
     $this->assertSame('01:01:01', $content);
 }
Esempio n. 5
0
 /**
  * Require dev mode before page load
  */
 public function _on_framework_loaded()
 {
     /**
      * Add to manager
      */
     e::configure('manage')->activeAddKey('bundle', __NAMESPACE__, 'environment');
     /**
      * Check dev mode to avoid issues later
      */
     e::$environment->requireVar('Development.Master', 'yes | no');
     e::$environment->requireVar('Development.Trace', 'yes | no');
 }
Esempio n. 6
0
 public function __initBundle()
 {
     /**
      * Set $_GET and $_POST to hooks
      */
     e::configure('lhtml')->activeAddKey('hook', ':get', array('--reference' => &$_GET));
     e::configure('lhtml')->activeAddKey('hook', ':post', array('--reference' => &$_POST));
     $url = $_SERVER['REDIRECT_URL'];
     /**
      * Router bundle access
      */
     if (substr($url, 0, 2) == '/@') {
         $this->__routeBundle($url);
     }
 }
Esempio n. 7
0
 public function __routeBundle($path)
 {
     /**
      * Security access for development
      */
     e::$security->developerAccess("EvolutionSDK Management Center");
     // Get name
     $name = array_shift($path);
     // Site sandbox TODO MOVE THIS SOMEWHERE ELSE?
     if ($name == 'sandbox') {
         $path = implode('/', $path);
         if ($path === '') {
             $path = 'index';
         }
         $file = e\site . '/sandbox/' . $path . '.php';
         $dir = dirname($file);
         if (!is_dir($dir)) {
             throw new Exception("Sandbox directory `{$dir}` does not exist");
         }
         chdir($dir);
         echo '<style>body {margin: 0; padding: 0; font-family: Tahoma, Lucida Grande, Sans, sans-serif;}</style>';
         echo '<div style="padding: 1em; background: black; box-shadow: 0 0 4px #000; color: #fff;"><b>Sandbox File </b>';
         echo '<pre style="display: inline">' . $file . '</pre></div>';
         require_once $file;
         e\complete();
     }
     if ($name === 'manage') {
         e\redirect('/@manage');
     }
     if ($name === '' || is_null($name)) {
         $name = 'manage';
     }
     $bundles = e::configure('manage')->bundle;
     $ns = array_search($name, $bundles);
     if ($ns === false) {
         throw new Exception("No manage panel for `{$name}`");
     }
     $class = $ns . '\\Manage';
     $panel = new $class();
     $title = "EvolutionSDK&trade; &rarr; " . $panel->title;
     $css = file_get_contents(__DIR__ . '/../debug/theme.css') . self::style();
     $header = '<span>EvolutionSDK</span> &rarr; <a href="/@manage">Manage System</a>' . ($name !== 'manage' ? " &rarr; <span>" . $panel->title . "</span>" : '');
     echo "<!doctype html><html><head><title>{$title}</title><style>{$css}</style></head><body class='_e_dump'><h1>{$header}</h1><div class='manage-page'>";
     echo $panel->page($path);
     echo "</div></body></html>";
     e\complete();
 }
Esempio n. 8
0
 public function action_index()
 {
     $page = $this->get_query('page', 1);
     $number_of_news = 10;
     if ($page == 1) {
         $top_news = Model_News::top_news();
         $number_of_news = $number_of_news - count($top_news);
     }
     $news_list = Model_News::fetch_public_news($page, $number_of_news);
     if (isset($top_news)) {
         $news_list = array_merge($top_news, $news_list);
     }
     $total_news = Model_News::number_of_public_news();
     $this->template_data['total'] = ceil($total_news / $number_of_news);
     $this->template_data['title'] = e::get_website_name();
     $this->template_data['news_list'] = $news_list;
 }
Esempio n. 9
0
 public function action_list()
 {
     $default_page = Session::instance()->get('volume', 1);
     // get user last volume
     $current_user = $this->get_current_user();
     if ($current_user) {
         $default_page = $current_user->get_last_volume();
     }
     $page = $this->request->param('id', $default_page);
     // save current volume
     Session::instance()->set('volume', $page);
     $total_volumes = Model_Problem::number_of_volume();
     $page = e::adjust_scope($page, $total_volumes);
     $this->template_data['problemlist'] = Model_Problem::problems_for_volume($page);
     $title = __('problem.list.problem_set_:id', array(':id' => $page));
     $this->template_data['title'] = $title;
     $this->template_data['page'] = $page;
     $this->template_data['pages'] = $total_volumes;
 }
Esempio n. 10
0
 public function _on_framework_loaded()
 {
     // Add manager
     e::configure('manage')->activeAddKey('bundle', __NAMESPACE__, 'unit');
 }
Esempio n. 11
0
<?php

$suffix = '';
if (isset($option['option_id'])) {
    $suffix = '/' . $option['option_id'];
}
?>
<form class="form-horizontal" role="form" method="post" action="<?php 
e::url("/admin/setting/edit{$suffix}");
?>
">
    <div class="form-group">
        <label for="name" class="col-sm-1 control-label"><?php 
echo __('admin.settings.edit.name');
?>
</label>
        <div class="col-sm-8">
            <input type="text" class="form-control" id="name" name="name" value="<?php 
echo $option['name'];
?>
">
            <p class="help-block"><?php 
echo __('admin.settings.edit.unique');
?>
</p>
        </div>
    </div>
    <div class="form-group">
        <label for="desc" class="col-sm-1 control-label"><?php 
echo __('admin.settings.edit.description');
?>
Esempio n. 12
0
echo __('admin.settings.index.name');
?>
</th>
        <th><?php 
echo __('admin.settings.index.description');
?>
</th>
    </tr>
    </thead>
    <tbody>
    <?php 
foreach (Model_Option::all_options() as $option) {
    ?>
        <tr>
            <td><a href="<?php 
    e::url("/admin/setting/edit/{$option['option_id']}");
    ?>
"><?php 
    echo $option['name'];
    ?>
</a></td>
            <td><?php 
    echo $option['desc'];
    ?>
</td>
        </tr>
    <?php 
}
?>
    </tbody>
</table>
Esempio n. 13
0
 protected function initial_data()
 {
     $this->new_mail = self::MAIL_NEW;
     $this->in_date = e::format_time();
     $this->reply = 0;
     $this->defunct = self::DEFUNCT_NO;
 }
Esempio n. 14
0
    ?>
</td>
        <td><?php 
    e::the_contest_time($team->time);
    ?>
</td>
        <?php 
    for ($i = 0; $i < $contest->number_of_problems(); $i++) {
        $pdata = $team->problem_status($i);
        ?>
        <td>
            <?php 
        if ($pdata['accept_at']) {
            ?>
                <?php 
            e::the_contest_time($pdata['accept_at']);
            ?>
                <?php 
            if ($pdata['wa_count']) {
                ?>
                    (-<?php 
                echo $pdata['wa_count'];
                ?>
)
                <?php 
            }
            ?>
            <?php 
        } else {
            ?>
                <?php 
Esempio n. 15
0
 protected function initial_data()
 {
     $this->time = e::format_time();
     $this->status = 0;
     $this->ip = Request::$client_ip;
 }
Esempio n. 16
0
    ?>
    <div class="form-group">
        <label class="col-sm-4 control-label" ><?php 
    echo __('user.login.captcha');
    ?>
</label>
        <div class="col-sm-8">
            <?php 
    echo View::factory('captcha/' . $mode);
    ?>
        </div>
    </div>
    <?php 
}
?>
    <div class="form-group">
        <div class="col-sm-offset-4 col-sm-8">
            <button type="submit" class="btn btn-primary col-sm-4"><?php 
echo __('user.login.login');
?>
</button><a href="<?php 
e::url('/help');
?>
" class="forget-password"><?php 
echo __('user.login.forget');
?>
</a>
        </div>
    </div>
</form>
Esempio n. 17
0
    ?>
</td>
            <td><?php 
    if ($u['solved'] == 0) {
        ?>
            0.00%
            <?php 
    } else {
        ?>
            <?php 
        echo sprintf("%.02lf%%", $u['solved'] / $u['submit'] * 100);
        ?>
            <?php 
    }
    ?>
            </td>
            <td><a class="edit-link" href="<?php 
    e::url("/admin/user/edit/{$u['user_id']}");
    ?>
"><?php 
    echo __('admin.user.list.edit');
    ?>
</a></td>
        </tr>
    <?php 
}
?>
    </tbody>
</table>
<?php 
echo View::factory('block/pager', array('base_url' => '/admin/user', 'total' => $total));
Esempio n. 18
0
    if ($i->result == 4) {
        echo $i->memory, 'kb';
    } else {
        echo '----';
    }
    ?>
</td>
        <td><?php 
    echo e::lang($i->language);
    ?>
</td>
        <td><?php 
    if ($current_user and $i->allow_view_code($current_user)) {
        ?>
        <a href="<?php 
        e::url("/solution/source/{$i->solution_id}");
        ?>
" title="click view details"><?php 
        echo $i->code_length;
        ?>
B</a>
        <?php 
    } else {
        ?>
        <?php 
        echo $i->code_length;
        ?>
B
        <?php 
    }
    ?>
Esempio n. 19
0
	</tr>
	</thead>
	<tbody>
<?php 
foreach ($list as $c) {
    ?>
<tr>
<td><?php 
    echo $c['contest_id'];
    ?>
</td>
<td><?php 
    echo HTML::anchor("/contest/show/{$c['contest_id']}", $c['title']);
    ?>
</td>
<td><?php 
    echo $c['end_time'];
    ?>
</td>
<td><?php 
    echo __(e::private_value($c['private']));
    ?>
</td>
</tr>
<?php 
}
?>
</tbody>
</table>
<?php 
echo View::factory('block/pager', array('base_url' => '/contest', 'total' => $total));
Esempio n. 20
0
<div class="edit-userinfo">
<h3 class="page-title"><?php 
echo __('user.edit.user_edit');
?>
</h3>
    <form action="<?php 
e::url(Request::current()->uri());
?>
" method="POST" class="form-horizontal" role="form">
        <div class="form-group">
            <label class="control-label col-sm-5" for="user_id"><?php 
echo __('user.register.username');
?>
</label>
            <div class="col-sm-7">
                <input class="form-control" type="text" id="user_id" disabled="disabled" value="<?php 
print $userinfo['user_id'];
?>
"/>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-5" for="nick"><?php 
echo __('user.register.nick');
?>
</label>
            <div class="col-sm-7">
                <input class="form-control" id="nick" name="nick" type="text" value="<?php 
print $userinfo['nick'];
?>
"/>
Esempio n. 21
0
    e::url('js/turbolinks.js');
    ?>
"></script>
<script type="text/javascript" src="<?php 
    e::url('js/jquery.turbolinks.js');
    ?>
"></script>
<script type="text/javascript" src="<?php 
    e::url('js/nprogress.js');
    ?>
"></script>
<script type="text/javascript" src="<?php 
    e::url('js/respond.js');
    ?>
"></script>
<script type="text/javascript" src="<?php 
    e::url('js/jquery.html5-placeholder-shim.js');
    ?>
"></script>
<?php 
}
?>
<script type="text/javascript" src="<?php 
e::url('js/jquery.bs.js');
?>
"></script>
<script type="text/javascript" src="<?php 
e::url('js/site.js');
?>
"></script>
Esempio n. 22
0
 public function display_order()
 {
     return e::contest_pid($this->num);
 }
Esempio n. 23
0
<?php

/* @var Model_Problem $problem */
if (isset($cid)) {
    echo View::factory('contest/header', array('title' => $title, 'contest' => $contest, 'cid' => $cid));
}
?>
<h1 class="page-title"><?php 
if (isset($cid)) {
    echo e::contest_pid($pid);
} else {
    echo $problem['problem_id'];
}
?>
    - <?php 
echo $problem['title'];
?>
</h1>
<div class="contest-info">
    <p>
        <?php 
echo __('problem.show.time_limit');
?>
<span class="label label-warning"><?php 
echo $problem['time_limit'];
echo __('problem.show.second');
?>
</span>
        <?php 
echo __('problem.show.memory_limit');
?>
Esempio n. 24
0
echo $title;
?>
</title>
    <?php 
echo View::factory('block/meta');
?>
</head>
<body>
<div class="navbar navbar-inverse" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <a class="navbar-brand" href="<?php 
e::home();
?>
"><?php 
echo e::get_website_name();
?>
</a>
            <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
        </div>
        <div class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<?php 
if (OJ::is_backend()) {
    echo View::factory('block/backend_nav');
} else {
    echo View::factory('block/frontend_nav');
Esempio n. 25
0
<form class="form-inline well" role="form" action="<?php 
e::url('/problem/search');
?>
" method="GET">
    <div class="form-group">
        <label class="sr-only" for="text"><?php 
echo __('problem.searchform.search_text');
?>
</label>
        <input placeholder="<?php 
echo __('problem.searchform.search');
?>
" name="text" id="text" class="form-control"/>
    </div>
    <div class="form-group">
        <label class="sr-only" for="area"><?php 
echo __('problem.searchform.type');
?>
</label>
        <select name="area" class="form-control">
            <option value="title"><?php 
echo __('problem.searchform.title');
?>
</option>
            <option value="source"><?php 
echo __('problem.searchform.source');
?>
</option>
        </select>
    </div>
    <input type="submit" value="<?php 
Esempio n. 26
0
" method="POST">
<fieldset>
<?php 
if ($cid) {
    ?>
    <input type="hidden" value="<?php 
    echo $cid;
    ?>
" name="cid"/>
    <input type="hidden" value="<?php 
    echo $cpid;
    ?>
" name="cpid"/>
    <div class="title-contest-problem">
        <h3><?php 
    echo __('problem.submit.problem_:cpid_of_:cid', array(':cpid' => e::contest_pid($cpid), ':cid' => $cid));
    ?>
</h3>
    </div>
<?php 
} else {
    ?>
<div class="form-group">
    <label class="control-label col-sm-3" for="pid"><?php 
    echo __('problem.submit.problem_id');
    ?>
</label>
    <div class="col-sm-9">
        <input class="form-control" name="pid" value="<?php 
    echo $pid;
    ?>
Esempio n. 27
0
<ul class="nav nav-pills nav-stacked">
    <li><a href="<?php 
e::url('user/register');
?>
"><?php 
echo __('admin.user.sidebar.new');
?>
</a></li>
</ul>
Esempio n. 28
0
    header('Location: out.php?last_message=' . urlencode($last_message));
} elseif (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'view_del_archive') {
    //publishable=2 for archive deletion
    $query = "SELECT id FROM {$GLOBALS['CONFIG']['db_prefix']}data WHERE publishable=2";
    $stmt = $pdo->prepare($query);
    $stmt->execute();
    $result = $stmt->fetchAll();
    $array_id = array();
    $i = 0;
    foreach ($result as $row) {
        $array_id[$i] = $row['id'];
        $i++;
    }
    $luserperm_obj = new UserPermission($_SESSION['uid'], $pdo);
    draw_header(msg('area_deleted_files'), $last_message);
    $page_url = e::h($_SERVER['PHP_SELF']) . '?mode=' . $_REQUEST['mode'];
    $user_obj = new User($_SESSION['uid'], $pdo);
    $userperms = new UserPermission($_SESSION['uid'], $pdo);
    $list_status = list_files($array_id, $userperms, $GLOBALS['CONFIG']['archiveDir'], true);
    if ($list_status != -1) {
        $GLOBALS['smarty']->assign('lmode', '');
        display_smarty_template('deleteview.tpl');
    }
} elseif (isset($_POST['submit']) && $_POST['submit'] == 'Delete file(s)') {
    isset($_REQUEST['checkbox']) ? $_REQUEST['checkbox'] : '';
    foreach ($_REQUEST['checkbox'] as $value) {
        if (!pmt_delete($value)) {
            header('Location: error.php?ec=21');
            exit;
        }
    }
Esempio n. 29
0
 static function getObj(){
     if(is_null(self::$obj)){
         self::$obj = new $e();
     }
     return self::$obj;
 }
Esempio n. 30
0
    ?>
 class="active" <?php 
}
?>
><?php 
echo HTML::anchor("/contest/statistics/{$cid}", __('contest.header.statistics'));
?>
</li>
    <li <?php 
if (Request::$current->action() == 'status') {
    ?>
 class="active" <?php 
}
?>
><a href="<?php 
e::url("/status?cid={$cid}");
?>
"><?php 
echo __('contest.header.status');
?>
</a></li>
    <li <?php 
if (Request::$current->action() == 'talk') {
    ?>
 class="active" <?php 
}
?>
><?php 
echo HTML::anchor("/contest/talk?cid={$cid}", __('contest.header.clarification'));
?>
</li>