Exemple #1
0
 public function main()
 {
     $this->load_pool_config();
     if ($this->pool_config->is_empty()) {
         $this->pool_config->add_group('default', 0, 0);
     }
     $rig_names = array();
     $available_miners = array();
     foreach ($this->config->rigs as $rig => $rig_data) {
         if (!empty($rig_data['shortname'])) {
             $rig_names[] = $rig_data['shortname'];
         } else {
             $rig_names[] = $rig;
         }
         foreach ($this->get_rpc($rig)->get_available_miners() as $miner) {
             $available_miners[$miner] = $miner;
         }
     }
     $pools = array();
     foreach ($this->pool_config->get_groups() as $group) {
         if ($group === 'donate') {
             continue;
         }
         $groupdata = $this->pool_config->get_group($group);
         $groupdata['id'] = preg_replace("/[^a-zA-Z0-9]/", "_", $group);
         $pools[$group] = array('group' => $groupdata, 'pools' => $this->pool_config->get_pools($group));
     }
     $this->js_config('pools', $pools);
     $this->js_config('can_change', AccessControl::getInstance()->has_permission(AccessControl::PERM_CHANGE_POOL_GROUP));
     $this->js_config('rig_names', $rig_names);
     $this->js_config('available_miners', $available_miners);
 }
Exemple #2
0
 /**
  * Add/Change a group.
  */
 public function group_add()
 {
     AccessControl::check_permission(AccessControl::PERM_MANAGE_USERS);
     $params = new ParamStruct();
     $params->add_param('old_name', PDT_STRING, '');
     $params->add_required_param('name', PDT_STRING);
     $params->add_param('permissions', PDT_ARR, array());
     $params->fill();
     if (!$params->is_valid()) {
         AjaxModul::return_code(AjaxModul::ERROR_INVALID_PARAMETER);
     }
     $old = $params->old_name;
     if ($params->name !== $old && AccessControl::getInstance()->get_config()->group_exists($params->name)) {
         AjaxModul::return_code(AjaxModul::ERROR_INVALID_PARAMETER, null, true, 'This group already exists.');
     }
     if (empty($old)) {
         $result = $this->access_control->get_config()->group_add($params->name);
     } else {
         $this->access_control->get_config()->group_revoke_all_permission($old);
         $result = $this->access_control->get_config()->group_change($old, $params->name);
     }
     foreach ($params->permissions as $permission) {
         $this->access_control->get_config()->group_grant_permission($params->name, $permission);
     }
     if ($result) {
         AjaxModul::return_code(AjaxModul::SUCCESS);
     }
     AjaxModul::return_code(AjaxModul::ERROR_DEFAULT, null, true, 'Could not add or update the user');
 }
 /**
  * Load all needed things (configs, api).
  * @throws PHPMinerException
  */
 public function setup_controller()
 {
     global $system_conf;
     // Process updates.
     new Update();
     if (isset($system_conf['directory'])) {
         $this->assign('docroot', $system_conf['directory']);
         $this->js_config('docroot', $system_conf['directory']);
     }
     // Get the own config.
     $this->config = Config::getInstance();
     $this->access_control = AccessControl::getInstance();
     // We only enable access control in a real web request, from cron we have to let it disabled.
     if ($this->config->enable_access_control && !defined('IS_CRON')) {
         $this->access_control->enable();
         if (!$this->access_control->get_config()->is_empty() && !$this->access_control->check_login()) {
             $this->fatal_error('You are not logged in. Access denied!');
         }
     }
     if ($this->controller_name === 'access' && !$this->access_control->is_enabled()) {
         $this->fatal_error('Access control is disabled, to view this page you have to enable it first under main settings. If you run this on your local machine and only you have access, this is not required.', Controller::MESSAGE_TYPE_ERROR);
     }
     $this->assign('current_version', implode('.', $system_conf['version']));
     if (isset($system_conf['directory']) && !empty($this->config->latest_version) && $system_conf['version'] !== $this->config->latest_version) {
         $this->add_message('A new version is available, current version <b>' . implode('.', $system_conf['version']) . '</b> - latest version <b>' . implode('.', $this->config->latest_version) . '</b>. <a href="https://phpminer.com" target="_blank">Download</a>. After updating to a new version, do not forget to copy the new index.php from the phpminer_rpcclient and restart the service."', Controller::MESSAGE_TYPE_INFO);
     }
     if (empty($this->config->cron_last_run)) {
         $this->add_message('The cronjob never ran! If you configurated it correctly, just wait 1 or 2 minutes, after the cronjob was executed, this message will disappear. If not configurated please have a look at the <a href="' . $system_conf['directory'] . '/README.md" target="_blank">Readme</a>', Controller::MESSAGE_TYPE_INFO);
     } else {
         if (round((TIME_NOW - $this->config->cron_last_run) / 60) > 5) {
             $this->add_message('The cronjob has not been executed since 5 minutes. Please check your cronjob config.', Controller::MESSAGE_TYPE_INFO);
         }
     }
     // We can not process as a normal controller action when we check for connection within the setup or in case of disconnected connection while reconnecting.
     if ($this->controller_name === 'main' && ($this->action_name === 'check_connection' || $this->action_name === 'connection_reconnect')) {
         return;
     }
 }
    ?>
 /><label for="enable_paging"></label></div></td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <td></td><td style="border-left:0px;"><div class="btn btn-primary" id="save_config">Save config</div></td>
                    </tr>
                </tfoot>
            </table>
        </td>
        <?php 
}
?>
        <?php 
if (AccessControl::getInstance()->has_permission(AccessControl::PERM_CHANGE_MINER_SETTINGS)) {
    ?>
        <?php 
    $rigs = $this->get_variable('rigs');
    ?>
        <td style="width:50%">
            <h2>CGMiner/SGMiner config per rig</h2>
            <div class="tabs">
            <?php 
    if (empty($rigs)) {
        ?>
                No rigs are configurated, please configurate at least one rig.
            <?php 
    } else {
        ?>
                <?php 
Exemple #5
0
<?php

if (AccessControl::getInstance()->has_permission(AccessControl::PERM_CHANGE_POOL_GROUP)) {
    ?>
<a class="btn btn-primary" id="add-group" style="margin-bottom: 10px;padding-left: 5px;"><i class="icon-plus"></i>Add a group</a>
<?php 
}
?>
<div class="panel-group pool_groups" id="accordion">
</div>