Пример #1
0
 function __construct()
 {
     global $parametersMod;
     global $cms;
     $elements = array();
     $element = new \Library\Php\StandardModule\element_text("text");
     $element->name = $parametersMod->getValue('administrator', 'administrators', 'admin_translations', 'name');
     $element->db_field = "name";
     $element->required = true;
     $element->show_on_list = true;
     // $element->searchable = true;
     $elements[] = $element;
     $element = new \Library\Php\StandardModule\element_pass("text");
     $element->name = $parametersMod->getValue('administrator', 'administrators', 'admin_translations', 'password');
     $element->db_field = "pass";
     $element->show_on_list = false;
     //   $element->searchable = true;
     $elements[] = $element;
     $element = new element_administrators("select");
     $element->set_name($parametersMod->getValue('administrator', 'administrators', 'admin_translations', 'permissions'));
     // $element->set_db_field("id");
     $modules = \Backend\Db::modules(true);
     $values = array();
     foreach ($modules as $key => $group) {
         $tmp_values = array();
         foreach ($group as $key2 => $module) {
             $value = array();
             $value[] = $module['id'];
             $value[] = $module['translation'];
             $tmp_values[] = $value;
         }
         $values[] = array("title" => $key, "values" => $tmp_values);
     }
     $element->set_values($values);
     $code = '
     global $cms;
     
    $sql = " select translation from `".DB_PREF."module` where `id` = \'".$value."\' ";
    $rs = mysql_query($sql);
    if ($rs && $lock = mysql_fetch_assoc($rs)){
       $value = htmlspecialchars($lock[\'translation\']);
    }else
     $value = \'\';
    
    if(!$rs)
     trigger_error("Can\'t get field value translation ".$sql); 
  ';
     $element->set_php_code_for_preview($code);
     $element->set_show_on_list(false);
     $elements[] = $element;
     $area0 = new mod_administrator_area();
     $area0->db_table = "user";
     $area0->name = $parametersMod->getValue('administrator', 'administrators', 'admin_translations', 'administrators');
     $area0->db_key = "id";
     $area0->elements = $elements;
     $area0->sort_field = "row_number";
     $this->standard_module = new \Library\Php\StandardModule\StandardModule($area0);
 }
 function genHtml($class)
 {
     global $cms;
     $answer = '';
     $moduleGroups = \Backend\Db::modules();
     foreach ($moduleGroups as $key => $group) {
         $answer .= '<div class="moduleGroup">' . htmlspecialchars($key) . '</div>';
         foreach ($group as $key2 => $module) {
             if (isset($_POST[$this->name . '[' . $module['id'] . ']']) || $this->value) {
                 $answer .= '<div class="module"><input checked class="' . $class . ' checkbox" type="checkbox" name="' . $this->name . '[' . $module['m_name'] . '][' . $module['g_name'] . ']" value="' . $module['id'] . '"/> ' . htmlspecialchars($module['translation']) . '</div>';
             } else {
                 $answer .= '<div class="module"><input class="' . $class . ' checkbox" type="checkbox" name="' . $this->name . '[' . $module['g_name'] . '][' . $module['m_name'] . ']"  value="' . $module['id'] . '"/>' . htmlspecialchars($module['translation']) . "</div>";
             }
         }
     }
     return $answer;
 }
Пример #3
0
 public function getDeleteError($moduleGroupKey, $moduleKey, $ignoreGroupId = null)
 {
     global $parametersMod;
     $moduleGroups = \Backend\Db::modules();
     foreach ($moduleGroups as $group) {
         foreach ($group as $module) {
             if ($module['g_id'] != $ignoreGroupId) {
                 if (!$module['core']) {
                     $configuration = new ConfigurationFile(BASE_DIR . PLUGIN_DIR . $module['g_name'] . '/' . $module['m_name'] . '/install/plugin.ini');
                     if ($configuration) {
                         foreach ($configuration->getRequiredModules() as $requiredModule) {
                             if ($requiredModule['module_group_key'] == $moduleGroupKey && $requiredModule['module_key'] == $moduleKey) {
                                 $error = $parametersMod->getValue('developer', 'modules', 'admin_translations', 'error_delete_required_module') . ' ' . $module['g_name'] . '/' . $module['m_name'];
                                 return $error;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #4
0
 /**
  * Output management tools
  *
  * @access public
  * @return string Option
  */
 function manage()
 {
     global $parametersMod;
     //log off
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == "logout" && !isset($_REQUEST['module_id'])) {
         $this->session->logout();
         $this->html->headerModules();
         $this->html->html('<script type="text/javascript">window.top.location=\'admin.php\';</script>');
         $this->deleteTmpFiles();
         $this->html->footer();
         $this->html->send();
         \db::disconnect();
         exit;
     }
     //eof log off
     //log in
     if (isset($_REQUEST['action']) && isset($_REQUEST['f_name']) && isset($_REQUEST['f_pass']) && $_REQUEST['action'] == "login" && !isset($_REQUEST['module_id'])) {
         if (\Backend\Db::incorrectLoginCount($_REQUEST['f_name'] . '(' . $_SERVER['REMOTE_ADDR'] . ')') > 2) {
             $this->loginError = $parametersMod->getValue('standard', 'configuration', 'system_translations', 'login_suspended');
             \Backend\Db::log('system', 'backend login suspended', $_REQUEST['f_name'] . '(' . $_SERVER['REMOTE_ADDR'] . ')', 2);
         } else {
             $id = \Backend\Db::userId($_REQUEST['f_name'], $_REQUEST['f_pass']);
             if ($id !== false) {
                 $this->session->login($id);
                 \Backend\Db::log('system', 'backend login', $_REQUEST['f_name'] . ' (' . $_SERVER['REMOTE_ADDR'] . ')', 0);
                 header("location:ip_backend_frames.php");
             } else {
                 $this->loginError = $parametersMod->getValue('standard', 'configuration', 'system_translations', 'login_incorrect');
                 \Backend\Db::log('system', 'backend login incorrect', $_REQUEST['f_name'] . '(' . $_SERVER['REMOTE_ADDR'] . ')', 1);
             }
         }
     }
     //eof log in
     if ($this->session->loggedIn()) {
         //login check
         //create module
         if (isset($_GET['module_id']) && $_GET['module_id'] != '' && \Backend\Db::allowedModule($_GET['module_id'], $this->session->userId())) {
             /*new module*/
             $newModule = \Db::getModule($_GET['module_id']);
             if ($newModule['core']) {
                 require MODULE_DIR . $newModule['g_name'] . '/' . $newModule['m_name'] . '/manager.php';
             } else {
                 require PLUGIN_DIR . $newModule['g_name'] . '/' . $newModule['m_name'] . '/manager.php';
             }
             $this->curModId = $newModule['id'];
             eval('$this->module = new \\Modules\\' . $newModule['g_name'] . '\\' . $newModule['m_name'] . '\\Manager();');
         } else {
             if (isset($_GET['action']) && $_GET['action'] == 'first_module') {
                 /*first module*/
                 $newModule = \Backend\Db::firstAllowedModule($this->session->userId());
                 if ($newModule != false) {
                     $this->curModId = $newModule['id'];
                     if ($newModule['core']) {
                         require MODULE_DIR . $newModule['g_name'] . '/' . $newModule['m_name'] . '/manager.php';
                     } else {
                         require PLUGIN_DIR . $newModule['g_name'] . '/' . $newModule['m_name'] . '/manager.php';
                     }
                     eval('$this->module = new \\Modules\\' . $newModule['g_name'] . '\\' . $newModule['m_name'] . '\\Manager();');
                 }
             } elseif (isset($_GET['action']) && ($_GET['action'] = 'ping')) {
                 $this->html->html('');
             } elseif (!isset($_GET['action'])) {
                 $this->html->html('<html><body><script type="text/javascript">parent.window.top.location=\'ip_backend_frames.php\';</script></body></html>');
             }
         }
         //eof create module
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'tep_modules') {
             $this->html->headerModules();
             $this->html->modules(\Backend\Db::modules(true, $this->session->userId()));
             $this->html->footer();
         } else {
             if ($this->module) {
                 $this->html->html($this->module->manage());
             }
         }
     } else {
         if (strpos(BASE_URL, $_SERVER['HTTP_HOST']) != 7 && strpos(BASE_URL, $_SERVER['HTTP_HOST']) != 8) {
             /*check if we are in correct subdomain. www.yoursite.com not allways equal to yoursite.com from session perspective)*/
             header("location: " . BASE_URL . "admin.php");
             \db::disconnect();
             exit;
         }
         $this->html->headerLogin();
         $this->html->html('<script type="text/javascript">if(parent.header && parent.content)parent.window.top.location=\'admin.php\';</script>');
         $this->html->loginForm($this->loginError);
         //login window
         $this->html->footer();
     }
     $this->html->send();
 }