/**
  * construct method
  */
 public function __construct()
 {
     $route_action = Route::currentRouteAction();
     $this->module_name = 'laravel-modules-core::' . getModule($route_action) . '/';
     $this->route_name = Route::currentRouteName();
     $this->index_route_name = substr($this->route_name, 0, strrpos($this->route_name, '.') + 1) . 'index';
 }
Пример #2
0
 public function sendView($to, $view, $view_data = array(), $from_email = false, $from_name = false)
 {
     $text = getModule('Utils')->getRunView($view, $view_data);
     $subject = strtok($text, "\n");
     $text = substr($text, strlen($subject) + 1);
     $subject = strip_tags($subject);
     return $this->send($to, $subject, $text, $from_email, $from_name);
 }
 /**
  * change relation model
  */
 protected function changeRelationModel()
 {
     $module = getModule(get_called_class());
     $module = explode('-', $module);
     $module = ucfirst_tr($module[1]);
     $this->relations['thumbnails']['relation_model'] = "\\App\\{$module}Thumbnail";
     $this->relations['extras']['relation_model'] = "\\App\\{$module}Extra";
 }
 /**
  * @param \Illuminate\Database\Eloquent\Model $model
  * @param string $subBase
  * @return string
  */
 function getBaseName($model, $subBase = '')
 {
     $class = is_string($model) ? $model : get_class($model);
     $baseName = class_basename($class);
     $moduleName = studly_case(getModule($class));
     $namespace = "\\ErenMustafaOzdal\\{$moduleName}";
     $namespace .= $subBase ? "\\{$subBase}" : "";
     return $namespace . "\\{$baseName}";
 }
Пример #5
0
 public function unauth()
 {
     $Session = getModule('Session');
     unset($Session->data['auth_user_id']);
     unset($Session->data['auth_user_agent']);
     $Session->write();
     $this->auth_user_id = null;
     $this->auth_user_data = null;
 }
Пример #6
0
function getModule($name, $ver, $path, $output_file = '')
{
    global $code_path;
    global $module_path;
    global $output_list;
    #模块绝对路径
    $abs_path = realpath($code_path . '/' . $path);
    #检测路径,防止恶意用户通过给 path 加 ../ 访问模块之外的目录
    if (strpos($abs_path, $code_path) !== 0) {
        die("{$name}({$ver}) 模块路径错误!");
    }
    #拷贝模块到 tmp,备用
    system("rm -rf {$module_path}/{$path}");
    system("mkdir -p {$module_path}/{$path}");
    system("cp -r {$abs_path}/* {$module_path}/{$path}");
    #没有指定output_file,从模块package.json取默认的output
    if (empty($output_file)) {
        #读取模块 package.json 信息
        $package_file = $abs_path . '/package.json';
        if (!is_file($package_file)) {
            die("{$name}({$ver}) 模块的 package.json 不存在!");
        }
        #从 package.json 中,找到模块 output 的 JS 文件名
        $package_info = json_decode(file_get_contents($package_file), true);
        $output_file = trim($package_info['output']);
        if (empty($output_file)) {
            die("{$name}({$ver}) 模块的 output 不存在!");
        }
    }
    #如果之前添加过这个文件,直接返回
    if (false !== array_search($path . '/' . $output_file, $output_list)) {
        return;
    }
    #把 output 的 JS 文件名存起来(后面给模块具名时会用到)
    array_push($output_list, $path . '/' . $output_file);
    #解析依赖
    $output_content = file_get_contents($abs_path . '/' . $output_file);
    $rDep = "/((?:define|require|requirejs)\\([^\\[\\(\\{]*\\[)([^\\]]+)/";
    if (preg_match($rDep, $output_content, $matches)) {
        $deps = explode(',', preg_replace("/['\"]/", '', $matches[2]));
        #依赖的模块,也需要递归处理
        foreach ($deps as $dep) {
            $sections = explode('/', trim($dep));
            #不是「module/<模块名>/<模块版本>/<output>」格式的模块,不处理
            if (count($sections) <= 1 || $sections[0] !== 'module') {
                continue;
            }
            $name = $sections[1];
            $ver = $sections[2];
            $path = $name . '/' . $ver;
            $file = $sections[3] . '.js';
            getModule($name, $ver, $path, $file);
        }
    }
}
Пример #7
0
 public function auth($email, $password)
 {
     if (!($password_salt = $this->DB->select('password_salt')->from('users')->where('email', $email)->fetchVal())) {
         throw new MsgException('Incorrect email or password');
     }
     if (!($id = $this->DB->select('id')->from('users')->where(array('email' => $email, 'password' => hash('sha256', $password_salt . $password)))->fetchVal())) {
         throw new MsgException('Incorrect email or password');
     }
     getModule('Auth')->auth($id);
     return $id;
 }
 /**
  * set file options
  *
  * @param \Illuminate\Http\Request $request
  * @param array $params [ ['column_name' => 'option_name'] ]
  * @return void
  */
 protected function setToFileOptions($request, $params)
 {
     $module = getModule(get_called_class());
     $model = getModelSlug(get_called_class());
     $options = [];
     $elfinders = [];
     foreach ($params as $column => $optionName) {
         $isGroup = is_integer($column) && is_array($optionName) && isset($optionName['group']);
         $configName = $isGroup || isset($optionName['column']) ? $optionName['config'] : $optionName;
         $columnParts = explode('.', $isGroup || isset($optionName['column']) ? $optionName['column'] : $column);
         $inputName = count($columnParts) > 1 ? $columnParts[1] : $columnParts[0];
         $inputName = isset($optionName['inputPrefix']) ? $optionName['inputPrefix'] . $inputName : $inputName;
         $fullColumn = implode('.', $columnParts);
         // options set edilir
         if ($isGroup && (is_array($request->file($optionName['group'])) && $request->file("{$optionName['group']}.{$column}.{$inputName}") || $request->has("{$optionName['group']}.{$column}.{$inputName}")) || (is_array($request->file($inputName)) && $request->file($inputName)[0] || !is_array($request->file($inputName)) && $request->file($inputName)) || $request->has($inputName)) {
             $moduleOptions = config("{$module}.{$model}.uploads.{$configName}");
             // if column is array
             if (is_array($moduleOptions['column'])) {
                 $moduleOptions['column'] = $moduleOptions['column'][$inputName];
             }
             // is group
             if ($isGroup) {
                 $moduleOptions['group'] = $optionName['group'];
             }
             // add some data
             if ($isGroup || isset($optionName['column'])) {
                 $moduleOptions['index'] = $column;
                 if (isset($optionName['changeThumb'])) {
                     $moduleOptions['changeThumb'] = $optionName['changeThumb'];
                 }
                 if (isset($optionName['changeToHasOne'])) {
                     $moduleOptions['changeToHasOne'] = $optionName['changeToHasOne'];
                 }
                 if (isset($optionName['is_reset'])) {
                     $moduleOptions['is_reset'] = $optionName['is_reset'];
                 }
                 $moduleOptions['add_column'] = isset($optionName['add_column']) ? $optionName['add_column'] : [];
                 $moduleOptions['inputPrefix'] = isset($optionName['inputPrefix']) ? $optionName['inputPrefix'] : [];
             }
             array_push($options, $moduleOptions);
         }
         // elfinder mi belirtilir
         if ($isGroup && $request->has("{$optionName['group']}.{$column}.{$inputName}") || $request->has($inputName) && !$request->file($inputName)[0]) {
             $elfinderOption = $isGroup || isset($optionName['column']) ? ['index' => count($options) - 1, 'column' => $optionName['column']] : $fullColumn;
             array_push($elfinders, $elfinderOption);
         }
     }
     $this->setFileOptions($options);
     foreach ($elfinders as $elfinder) {
         $this->setElfinderToOptions($elfinder);
     }
 }
 /**
  * @brief 모듈 업데이트
  **/
 function procInstallAdminUpdate()
 {
     $module_name = Context::get('module_name');
     if (!$module_name) {
         return new object(-1, 'invalid_request');
     }
     $oModule =& getModule($module_name, 'class');
     if ($oModule) {
         $output = $oModule->moduleUpdate();
     } else {
         $output = new Object(-1, 'invalid_request');
     }
     return $output;
 }
Пример #10
0
 public function post()
 {
     $modules = request()->post('module', []);
     if (!is_array($modules)) {
         redirect(getURL('/module-manager'));
     }
     foreach ($modules as $module => $action) {
         if (!in_array($action, array('enable', 'disable', 'install', 'uninstall'))) {
             continue;
         }
         $module = getModule($module);
         if (!$module->exists()) {
             continue;
         }
         if ($module->{$action}()) {
             $text = r('Module <stron>@module</strong> was @action', ['module' => $module->name(), 'action' => t($action . 'd')]);
             System::alerts()->success($text);
         } else {
             $text = r('Module <stron>@module</strong> could not be @action', array('module' => $module->name(), 'action' => t($action . 'd')));
             System::alerts()->error($text);
         }
     }
     redirect(getURL('/module-manager'));
 }
Пример #11
0
function loadModules($str)
{
    $result = array();
    if ($str == "*") {
        $files = scandir(__DIR__ . '/modules/');
        foreach ($files as $file) {
            if ($file == '.' || $file == '..' || substr($file, -4) != ".php") {
                continue;
            }
            //require_once 'modules/'.$file;
            $module = getModule(substr($file, 0, -4));
            $result[] = $module;
        }
        return $result;
    }
    $tokens = explode(",", $str);
    foreach ($tokens as $k => $v) {
        $result[] = getModule($v);
    }
    return $result;
}
Пример #12
0
    }
    #从 package.json 中,找到模块 output 的 JS 文件名
    $package_info = json_decode(file_get_contents($package_file), true);
    $output_file = trim($package_info['output']);
    if (empty($output_file)) {
        die("{$name}({$ver}) 模块的 output 不存在!");
    }
    $full_output_file = $path . '/' . $output_file;
    #如果之前添加过这个模块,直接返回
    if (false !== array_search($full_output_file, $output_list)) {
        return;
    }
    #解析依赖
    $abs_output_file = $code_path . '/' . $full_output_file;
    if (!is_file($abs_output_file)) {
        return;
    }
    #把模块路径存到 list 中
    array_push($output_list, $full_output_file);
    $output_content = file_get_contents($abs_output_file);
    $rDep = "/((?:define|require|requirejs)\\([^\\[\\(\\{]*\\[)([^\\]]+)/";
    if (preg_match($rDep, $output_content, $matches)) {
        $deps = explode(',', preg_replace("/['\"]/", '', $matches[2]));
        #依赖的模块,也需要递归处理
        foreach ($deps as $dep) {
            getModuleByPath($dep);
        }
    }
}
getModule($name, $ver, $path);
echo json_encode($output_list);
Пример #13
0
/**
 * Create a class instance of the module
 *
 * @param string $module_name The module name to get a class instance
 * @return mixed Module class instance
 */
function getClass($module_name)
{
    return getModule($module_name, 'class');
}
Пример #14
0
 public function createTables()
 {
     $database = getSQLDB();
     $login = getModule("user");
     //UNITS
     $query = "CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "units (\r\n\t\t\t`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\r\n\t\t\t`name` VARCHAR(256) NOT NULL,\r\n\t\t\t`author_id` INT NOT NULL,\r\n\t\t\t`metadata` TEXT NOT NULL,\r\n\t\t\t`used_size` INT NOT NULL,\r\n\t\t\t`total_size` INT NOT NULL,\r\n\t\t\t`timestamp` TIMESTAMP NOT NULL)\r\n\t\t\tENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
     $result = $database->query($query);
     if ($result !== TRUE) {
         debug("Units table not created");
         $this->result["msg"] = "Units table not created";
         $this->result["status"] = -1;
         return false;
     } else {
         debug("Units table created");
     }
     //PRIVILEGES
     $query = "CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "privileges (\r\n\t\t\t`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\r\n\t\t\t`user_id` INT NOT NULL,\r\n\t\t\t`unit_id` INT NOT NULL,\r\n\t\t\t`timestamp` TIMESTAMP NOT NULL,\r\n\t\t\t`mode` ENUM('READ','WRITE','ADMIN') NOT NULL\r\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
     $result = $database->query($query);
     if ($result !== TRUE) {
         debug("Privileges table not created");
         $this->result["msg"] = "Privileges table not created";
         $this->result["status"] = -1;
         return false;
     } else {
         debug("Privileges table created");
     }
     //FILES
     $query = "CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "files (\r\n\t\t\t`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\r\n\t\t\t`unit_id` INT NOT NULL,\r\n\t\t\t`folder` VARCHAR(256) NOT NULL,\r\n\t\t\t`filename` VARCHAR(256) NOT NULL,\r\n\t\t\t`category` VARCHAR(256) NOT NULL,\r\n\t\t\t`metadata` TEXT NOT NULL,\r\n\t\t\t`author_id` INT NOT NULL,\r\n\t\t\t`size` INT NOT NULL,\r\n\t\t\t`timestamp` TIMESTAMP NOT NULL,\r\n\t\t\t`status` ENUM('DRAFT','PRIVATE','PUBLIC','BLOCKED') NOT NULL\r\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
     $result = $database->query($query);
     if ($result !== TRUE) {
         debug("Files table not created");
         $this->result["msg"] = "Files table not created";
         $this->result["status"] = -1;
         return false;
     } else {
         debug("Files table created");
     }
     //COMMENTS
     $query = "CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "comments (\r\n\t\t\t`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\r\n\t\t\t`file_id` INT UNSIGNED NOT NULL,\r\n\t\t\t`info` TEXT NOT NULL,\r\n\t\t\t`author_id` INT NOT NULL,\r\n\t\t\t`timestamp` TIMESTAMP NOT NULL\r\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
     $result = $database->query($query);
     if ($result !== TRUE) {
         debug("Comments table not created");
         $this->result["msg"] = "Comments table not created";
         $this->result["status"] = -1;
         return false;
     } else {
         debug("Comments table created");
     }
     return true;
 }
Пример #15
0
</title>
	<meta charset="utf-8">
	<link rel="stylesheet" href="templates/css/books.css">
	<link rel="icon" href="templates/images/eb.png">
</head>
<body>
	<header>
		<nav>
			<?php 
echo getMenu();
?>
		</nav>
	</header>
	<aside>
		<?php 
echo getModule();
?>
	</aside>
	<section id="section">
		<h2>Op safari met Doomla</h2>
	</section>
	<section>
		<article>
			<?php 
echo getContent($content)['content1'];
?>
		</article>
	</section>
	<footer>
		© 2016 Eline Boekweit
	</footer>
Пример #16
0
 /**
  * @brief trigger_name, called_position을 주고 trigger 호출
  **/
 function triggerCall($trigger_name, $called_position, &$obj)
 {
     // 설치가 안되어 있다면 trigger call을 하지 않고 바로 return
     if (!Context::isInstalled()) {
         return new Object();
     }
     $oModuleModel =& getModel('module');
     $triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
     if (!$triggers || !count($triggers)) {
         return new Object();
     }
     foreach ($triggers as $item) {
         $module = $item->module;
         $type = $item->type;
         $called_method = $item->called_method;
         $oModule = null;
         $oModule =& getModule($module, $type);
         if (!$oModule || !method_exists($oModule, $called_method)) {
             continue;
         }
         $output = $oModule->{$called_method}($obj);
         if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) {
             return $output;
         }
         unset($oModule);
     }
     return new Object();
 }
Пример #17
0
 /**
  * call a trigger
  * @param string $trigger_name trigger's name to call
  * @param string $called_position called position
  * @param object $obj an object as a parameter to trigger
  * @return Object
  * */
 function triggerCall($trigger_name, $called_position, &$obj)
 {
     // skip if not installed
     if (!Context::isInstalled()) {
         return new Object();
     }
     $oModuleModel = getModel('module');
     $triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
     if (!$triggers || count($triggers) < 1) {
         return new Object();
     }
     //store before trigger call time
     $before_trigger_time = NULL;
     if (__LOG_SLOW_TRIGGER__ > 0) {
         $before_trigger_time = microtime(true);
     }
     foreach ($triggers as $item) {
         $module = $item->module;
         $type = $item->type;
         $called_method = $item->called_method;
         // todo why don't we call a normal class object ?
         $oModule = getModule($module, $type);
         if (!$oModule || !method_exists($oModule, $called_method)) {
             continue;
         }
         $before_each_trigger_time = microtime(true);
         $output = $oModule->{$called_method}($obj);
         $after_each_trigger_time = microtime(true);
         $elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time;
         $slowlog = new stdClass();
         $slowlog->caller = $trigger_name . '.' . $called_position;
         $slowlog->called = $module . '.' . $called_method;
         $slowlog->called_extension = $module;
         if ($trigger_name != 'XE.writeSlowlog') {
             writeSlowlog('trigger', $elapsed_time_trigger, $slowlog);
         }
         if (is_object($output) && method_exists($output, 'toBool') && !$output->toBool()) {
             return $output;
         }
         unset($oModule);
     }
     return new Object();
 }
 /**
  * @brief 삭제해도 상관없는 트리거 목록 반환
  * @param boolean $advanced
  * @return array
  */
 function getTriggersToBeDeleted($advanced = FALSE)
 {
     // DB 상의 트리거 목록
     $trigger_list = $this->getTriggers();
     // 설치되어 있는 모듈 목록
     $module_list = $this->getModuleList();
     // 삭제해도 상관없는 트리거 목록
     $invalid_trigger_list = array();
     foreach ($trigger_list as $trigger) {
         if (in_array($trigger->module, $module_list)) {
             // 고급 삭제 옵션
             if ($advanced === TRUE) {
                 $oModule = getModule($trigger->module, strtolower($trigger->type));
                 if (!@method_exists($oModule, $trigger->called_method)) {
                     $invalid_trigger_list[] = $trigger;
                 }
             }
         } else {
             $invalid_trigger_list[] = $trigger;
         }
     }
     return $invalid_trigger_list;
 }
Пример #19
0
}
/*
 * Use $server_info to accumulate
 * information about the server
 * Always give an error if one of the modules
 * isn't found for reliance
 */
$server_info = new \stdClass();
$error = null;
// Get all the variables or only specific; less loading time
foreach ($modules as $module) {
    if (!isset($sources[$module])) {
        $error = 'Module \'' . $module . '\' not available';
        break;
    }
    $data = getModule($module, $sources[$module]);
    $server_info->{$module} = $data;
}
/*
 * Return a json formatted copy
 * of the server information.
 */
header('Content-Type: application/json;');
if ($error) {
    header("HTTP/1.0 400 Error");
    $response = ['error' => $error];
} else {
    $response = ['server_info' => $server_info];
    header("HTTP/1.0 200 OK");
}
echo json_encode($response);
 /**
  * set the module config
  *
  * @param $category
  * @param string $model
  * @param string $uploadType
  * @return void
  */
 protected function setModuleThumbnails($category, $model, $uploadType)
 {
     $module = getModule(get_called_class());
     if (is_null($category->thumbnails)) {
         return;
     }
     Config::set("{$module}.{$model}.uploads.{$uploadType}.thumbnails", $category->thumbnails->map(function ($item) {
         return ['width' => $item->photo_width, 'height' => $item->photo_height, 'slug' => $item->slug];
     })->keyBy('slug')->toArray());
 }
Пример #21
0
 function procSmartPhone($msg = null)
 {
     if (preg_match('/(iPopd|iPhone)/', $_SERVER['HTTP_USER_AGENT'])) {
         Context::addHtmlHeader('<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>');
     } else {
         if (preg_match('/PPC/', $_SERVER['HTTP_USER_AGENT'])) {
             Context::addHtmlHeader('<meta name="viewport" content="width=240; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>');
         }
     }
     if (is_a($this->output, 'Object') || is_subclass_of($this->output, 'Object') || $msg) {
         if ($msg) {
             $this->setContent(Context::getLang($msg));
         } else {
             $this->setContent($this->output->getMessage());
         }
         return;
     }
     if ($this->haveSmartphoneModule($this->module_info->module)) {
         $oSmartPhoneModule =& getModule($this->module_info->module, 'smartphone');
         $vars = get_object_vars($this->oModule);
         if (count($vars)) {
             foreach ($vars as $key => $val) {
                 $oSmartPhoneModule->{$key} = $val;
             }
         }
         $oSmartPhoneModule->procSmartPhone($this);
     } else {
         switch (Context::getLangType()) {
             case 'ko':
                 $msg = '스마트폰을 지원하지 않는 모듈입니다';
                 break;
             case 'jp':
                 $msg = 'このモジュールをサポートしていません。';
                 break;
             case 'zh-TW':
                 $msg = '該模塊不支持。';
                 break;
             case 'zh-CN':
                 $msg = '该模块不支持。';
                 break;
             default:
                 $msg = 'This module is not supported.';
                 break;
         }
         $this->setContent($msg);
     }
 }
Пример #22
0
<div class="container">
		<header>
		<section>
			<nav>
			 <?php 
echo getMenu($PageContent);
?>
			</nav>
		</section>
		</header>
			<article>
			  <?php 
echo getContent($PageContent);
?>
			</article>
			<aside>
			<?php 
echo getModule('contact');
?>
			</aside>
Пример #23
0
          }
          closedir($handle);
       }
       return $mod_found;
    }

    //richiamo tutte le aziende installate e vedo se l'utente  e' abilitato o no ad essa
    $table=$gTables['aziend'].' AS a';
    $what="a.codice AS id, ragso1 AS ragsoc, (SELECT COUNT(*) FROM ".$gTables['admin_module']." WHERE a.codice=".$gTables['admin_module'].".enterprise_id AND ".$gTables['admin_module'].".adminid='".$form['Login']."') AS set_co ";
    $co_rs=gaz_dbi_dyn_query($what,$table,1,"ragsoc ASC");
    while($co=gaz_dbi_fetch_array($co_rs)) {
      echo "<tr><td align=\"center\" colspan=\"3\">".$co['ragsoc'].'  - '.$co['set_co']."</tr>\n";
      echo "<tr><td class=\"FacetDataTD\">".$script_transl['mod_perm'].":</td>\n";
      echo "<td>".$script_transl['all']."</td>\n";
      echo "<td>".$script_transl['none']."</td></tr>\n";
      $mod_found=getModule($form['Login'],$co['id']);
      $co_id=sprintf('%03d',$co['id']);
      foreach ($mod_found as $mod) {
          echo "<tr>\n";
          echo "<td class=\"FacetFieldCaptionTD\">".$mod['transl_name'].' ('.$mod['name'].")</td>\n";
          if ($mod['moduleid'] == 0) {
              if ($toDo == 'insert') {
                  echo "  <td><input type=radio checked name=\"".$co_id."nusr_".$mod['name']."\" value=\"3\"></td>";
                  echo "  <td><input type=radio name=\"".$co_id."nusr_".$mod['name']."\" value=\"0\"></td>";
              } elseif ($co['set_co']==0) {
                  echo "  <td><input type=radio name=\"".$co_id."nusr_".$mod['name']."\" value=\"3\"></td>";
                  echo "  <td><input type=radio checked name=\"".$co_id."nusr_".$mod['name']."\" value=\"0\"></td>";
              } else {
                  echo "  <td class=\"FacetDataTDred\"><input type=radio name=\"".$co_id."new_".$mod['name']."\" value=\"3\">Trovato nuovo modulo!</td>";
                  echo "  <td class=\"FacetDataTDred\"><input type=radio checked name=\"".$co_id."new_".$mod['name']."\" value=\"0\"></td>";
              }
Пример #24
0
                 die('Unexpected multisite mode: ' . $bad . "\n");
             } else {
                 if ($interactive) {
                     $userInputNeeded['multisiteMode'] = true;
                 }
             }
         }
     }
 }
 // Now that we've validated as many parameters as possible, retrieve
 // user input where needed.
 if (isset($userInputNeeded['overrideDir'])) {
     $overrideDir = getOverrideDir($overrideDir);
 }
 if (isset($userInputNeeded['module'])) {
     $module = getModule();
 }
 if (isset($userInputNeeded['basePath'])) {
     $basePath = getBasePath($basePath);
 }
 if (isset($userInputNeeded['multisiteMode'])) {
     $multisiteMode = getMultisiteMode();
 }
 // Load supplemental multisite parameters:
 if ($multisiteMode == MULTISITE_HOST_BASED) {
     if ($opts->getOption('hostname')) {
         $host = $opts->getOption('hostname');
     } else {
         if ($interactive) {
             $host = getHost();
         }
Пример #25
0
 /**
  * Install module
  *
  * Call module's moduleInstall(), moduleUpdate() and create tables.
  *
  * @return void
  */
 function installModule()
 {
     $path = $this->package->path;
     if ($path != ".") {
         $path_array = explode("/", $path);
         $target_name = array_pop($path_array);
         $type = substr(array_pop($path_array), 0, -1);
     }
     if ($type == "module") {
         $oModuleModel = getModel('module');
         $oInstallController = getController('install');
         $module_path = ModuleHandler::getModulePath($target_name);
         if ($oModuleModel->checkNeedInstall($target_name)) {
             $oInstallController->installModule($target_name, $module_path);
         }
         if ($oModuleModel->checkNeedUpdate($target_name)) {
             $oModule = getModule($target_name, 'class');
             if (method_exists($oModule, 'moduleUpdate')) {
                 $oModule->moduleUpdate();
             }
         }
     }
 }
Пример #26
0
 /**
  * @brief Get a type and information of the module
  */
 function getModuleList()
 {
     // Create DB Object
     $oDB =& DB::getInstance();
     // Get a list of downloaded and installed modules
     $searched_list = FileHandler::readDir('./modules', '/^([a-zA-Z0-9_-]+)$/');
     sort($searched_list);
     $searched_count = count($searched_list);
     if (!$searched_count) {
         return;
     }
     for ($i = 0; $i < $searched_count; $i++) {
         // module name
         $module_name = $searched_list[$i];
         $path = ModuleHandler::getModulePath($module_name);
         if (!is_dir(FileHandler::getRealPath($path))) {
             continue;
         }
         // Get the number of xml files to create a table in schemas
         $tmp_files = FileHandler::readDir($path . 'schemas', '/(\\.xml)$/');
         $table_count = count($tmp_files);
         // Check if the table is created
         $created_table_count = 0;
         for ($j = 0; $j < $table_count; $j++) {
             list($table_name) = explode('.', $tmp_files[$j]);
             if ($oDB->isTableExists($table_name)) {
                 $created_table_count++;
             }
         }
         // Get information of the module
         $info = NULL;
         $info = $this->getModuleInfoXml($module_name);
         if (!$info) {
             continue;
         }
         $info->module = $module_name;
         $info->category = $info->category;
         $info->created_table_count = $created_table_count;
         $info->table_count = $table_count;
         $info->path = $path;
         $info->admin_index_act = $info->admin_index_act;
         // Check if DB is installed
         if ($table_count > $created_table_count) {
             $info->need_install = true;
         } else {
             $info->need_install = false;
         }
         // Check if it is upgraded to module.class.php on each module
         $oDummy = null;
         $oDummy = getModule($module_name, 'class');
         if ($oDummy && method_exists($oDummy, "checkUpdate")) {
             $info->need_update = $oDummy->checkUpdate();
         } else {
             continue;
         }
         $list[] = $info;
     }
     return $list;
 }
Пример #27
0
 /**
  * Returns target is removable
  *
  * @param string $path Path
  * @return bool
  */
 function checkRemovable($path)
 {
     $path_array = explode("/", $path);
     $target_name = array_pop($path_array);
     $oModule =& getModule($target_name, "class");
     if (!$oModule) {
         return false;
     }
     if (method_exists($oModule, "moduleUninstall")) {
         return true;
     } else {
         return false;
     }
 }
/**
 * Main process for searching for updates
 * 
 * @param type $params
 * 
 * @return type
 */
function searchForUpdates($params)
{
    // Initialisation du nom du répertoire de destination
    $catalogDir = transformPath($params['targetDir'], $params['version']);
    $modulesDir = $catalogDir . 'files/';
    if ($params['archiveModules']) {
        $archiveDir = transformPath($params['archiveDir'], $params['version']);
    }
    // Récupération du catalogue
    $catalog = getCatalog($params['catalogUrl'], $params['version']);
    // XMLisation du fichier de plugins
    $xml = simplexml_load_string($catalog);
    //debug($xml);
    // Recherche des modules
    $moduleGroups = array();
    // Recherche des modules sans groupes
    // On les place dans un tableau 'no_group'
    foreach ($xml->module as $xmlModule) {
        $moduleGroups['no_group']['modules'][] = getModule($xmlModule, $params['modulesUrl']);
    }
    // Recherche des groupes de modules
    foreach ($xml->module_group as $xmlModuleGroup) {
        $moduleGroups[] = getModuleGroup($xmlModuleGroup, $params['modulesUrl']);
    }
    // Récupération de la liste des plugins déjà téléchargés
    if ($params['archiveModules']) {
        $existingPlugins = glob($modulesDir . '*.{nbm,jar}', GLOB_BRACE);
    }
    //debug($existingPlugins);
    // Téléchargement des plugins
    $plugins = array();
    $plugins['downloaded'] = array();
    $plugins['not_downloaded'] = array();
    $plugins['seen'] = array();
    $plugins['removed'] = array();
    foreach ($moduleGroups as $moduleGroup) {
        foreach ($moduleGroup['modules'] as $module) {
            // Si le plugin existe déjà, on ne le télécharge pas
            if (!file_exists($modulesDir . $module['file']['folder'] . $module['file']['filename']) || filesize($modulesDir . $module['file']['folder'] . $module['file']['filename']) != $module['size']) {
                $plugins['downloaded'][] = $module;
            } else {
                $plugins['not_downloaded'][] = $module;
            }
            $plugins['seen'][] = $module['file']['folder'] . $module['file']['filename'];
        }
    }
    // Détermination des plugins qui ne sont plus dans le catalogue
    if ($params['archiveModules']) {
        foreach ($existingPlugins as $existingPlugin) {
            $existingPlugin = extractFileName($existingPlugin, $params['modulesUrl']);
            if (!in_array($existingPlugin['filename'], $plugins['seen'])) {
                $plugins['removed'][] = $existingPlugin['filename'];
            }
        }
    }
    //debug($plugins);
    return $plugins;
}
Пример #29
0
<?php

require "logic/coreLogic.php";
$template = "template.php";
$content = "erorr page not found";
$page = isset($_GET['page']) ? $_GET['page'] : "home";
$PageContent = menu($link, $page);
$submenu = getModule($page);
require "templates/header.php";
require "templates/content.php";
require "templates/footer.php";
Пример #30
0
<?php

//all responses must be JSON
header('Content-Type: application/json');
//require lib
if (!file_exists(__DIR__ . "/include/config.php")) {
    die('{"status":-10, "msg":"config.php not found, check include/config.sample-php, change it and rename it to include/config.php"}');
}
require_once 'include/core.php';
//check for actions
if (!isset($_REQUEST["action"])) {
    die('{"msg":"no action"}');
}
//retrieve module name and action
$action = $_REQUEST["action"];
$pos = strpos($action, "/");
if ($pos == false) {
    die('{"msg":"no module in action"}');
}
$module_name = substr($action, 0, $pos);
$module_action = substr($action, $pos + 1, strlen($action) - $pos - 1);
//get module
$module = getModule($module_name);
if ($module && method_exists($module, "processAction")) {
    $module->processAction($module_action);
} else {
    echo '{"msg":"module not found"}';
}
echo "\n";
closeSQLDB();