Beispiel #1
0
    public function compile($node_id, $mod_uniqueid = '')
    {
        $node_id = intval($node_id);
        $sql = "SELECT * FROM " . DB_PREFIX . "node WHERE id=" . $node_id;
        $nodeapi = $this->db->query_first($sql);
        if (!$nodeapi) {
            $program = '<?php	
			?>';
            if (hg_mkdir($this->mNodedir)) {
                hg_file_write($this->mNodedir . '0.php', $program);
            } else {
                exit($this->mNodedir . '目录不可写');
            }
            return $this->mNodedir . '0.php';
        }
        $application = hg_check_application(intval($nodeapi['application_id']));
        return $this->compile_show($nodeapi, $application, $mod_uniqueid);
    }
Beispiel #2
0
 private function _getApplication($mid)
 {
     $db = hg_checkDB();
     $sql = "SELECT * FROM " . DB_PREFIX . "modules WHERE id=" . $mid;
     $module = $db->query_first($sql);
     if (!$module) {
         exit('运行模块不存在');
     }
     $application = hg_check_application(intval($module['application_id']));
     if (!$application) {
         exit('应用不存在或已被删除');
     }
     return $application;
 }
Beispiel #3
0
    /**
     * 有分页必须提供count方法
     *
     */
    public function compile($module_id, $type = 'show')
    {
        $module_id = intval($module_id);
        $sql = "SELECT * FROM " . DB_PREFIX . "modules WHERE id=" . $module_id;
        $module = $this->db->query_first($sql);
        if (!$module) {
            $program = '<?php
				$this->ReportError(\'运行模块不存在\');
			?>';
            if (hg_mkdir(CACHE_DIR . 'program/' . $type)) {
                hg_file_write(CACHE_DIR . 'program/' . $type . '/' . $module_id . '.php', $program);
                return $module_id;
            } else {
                exit(CACHE_DIR . 'program/' . $type . '目录创建失败,请检查目录权限.');
            }
        }
        if ($module['settings']) {
            $module['settings'] = unserialize($module['settings']);
        } else {
            $module['settings'] = array();
        }
        $module['primary_key'] = $module['primary_key'] ? $module['primary_key'] : 'id';
        $application = hg_check_application(intval($module['application_id']));
        if (!$application) {
            exit('应用不存在或已被删除');
        }
        $func = 'compile_' . $type;
        if (!method_exists($this, $func)) {
            $func = 'compile_default';
        }
        return $this->{$func}($module, $application, $type);
    }