Esempio n. 1
0
/**
 * Perform database initialization.
 *
 * @param boolean $create_database
 * @return boolean
 */
function database_initialize($create_database)
{
    global $db, $db_config, $data_path;
    $result = false;
    $database_exists = false;
    $sql_file = 'units/database/init.sql';
    $xml_file = $data_path . 'system_init.xml';
    if (!file_exists($sql_file) || !file_exists($xml_file)) {
        trigger_error('Can not initialize database, missing configuration!', E_USER_ERROR);
        return $result;
    }
    // make a log entry
    trigger_error('Initializing database: ' . $db_config['name'], E_USER_NOTICE);
    // get initialization SQL
    $sql = file_get_contents($sql_file);
    // create database if needed
    if ($create_database) {
        try {
            $db->create($db_config['name']);
            $db->select($db_config['name']);
            $database_exists = true;
        } catch (Exception $error) {
            $database_exists = false;
        }
    } else {
        $database_exists = true;
    }
    // create database
    if ($database_exists && $db->multi_query($sql)) {
        $module_manager = ModuleManager::getInstance();
        $module_handler = ModuleHandler::getInstance();
        $admin_manager = UserManager::getInstance();
        // populate tables
        $raw_data = file_get_contents($xml_file);
        $data = new XMLParser($raw_data, $xml_file);
        $data->parse();
        // go over XML file and insert data
        foreach ($data->document->tagChildren as $item) {
            switch ($item->tagName) {
                case 'module':
                    // insert data
                    $module_manager->insertData(array('name' => $item->tagAttrs['name'], 'order' => $item->tagAttrs['order'], 'preload' => $item->tagAttrs['preload'] == 'yes' ? 1 : 0, 'active' => 1));
                    // initialize module
                    $module = $module_handler->_loadModule($item->tagAttrs['name']);
                    if (!is_null($module)) {
                        $module->onInit();
                    }
                    break;
                case 'user':
                    $salt = hash('sha256', UserManager::SALT . strval(time()));
                    $password = hash_hmac('sha256', $item->tagAttrs['password'], $salt);
                    $admin_manager->insertData(array('username' => $item->tagAttrs['username'], 'password' => $password, 'fullname' => $item->tagAttrs['fullname'], 'level' => $item->tagAttrs['level'], 'verified' => 1, 'salt' => $salt));
                    break;
            }
        }
        // set result
        $result = true;
    }
    return $result;
}
Esempio n. 2
0
 /**
  * Load all modules in specified path
  *
  * @param boolean $include_only
  */
 function loadModules($include_only = false)
 {
     global $db_use, $data_path;
     $preload_list = array();
     $normal_list = array();
     if ($db_use) {
         // database available, form module list from database entries
         $manager = ModuleManager::getInstance();
         // get priority module list
         $preload_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 1), array('order'));
         // get normal module list
         $normal_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 0), array('order'));
         foreach ($preload_raw as $preload_item) {
             $preload_list[] = $preload_item->name;
         }
         foreach ($normal_raw as $normal_item) {
             $normal_list[] = $normal_item->name;
         }
     } else {
         // no database available use system initialization file
         $file = $data_path . 'system_init.xml';
         if (file_exists($file)) {
             $xml = new XMLParser(@file_get_contents($file), $file);
             $xml->Parse();
             foreach ($xml->document->tagChildren as $xml_tag) {
                 if ($xml_tag->tagName == 'module') {
                     $normal_list[] = $xml_tag->tagAttrs['name'];
                 }
             }
         }
     }
     // load modules
     if (count($preload_list) > 0) {
         foreach ($preload_list as $module_name) {
             $this->_loadModule($module_name);
         }
     }
     if (count($normal_list) > 0) {
         if ($include_only) {
             foreach ($normal_list as $module_name) {
                 $this->_includeModule($module_name);
             }
         } else {
             foreach ($normal_list as $module_name) {
                 $this->_loadModule($module_name);
             }
         }
     }
 }
Esempio n. 3
0
 public function getTreeFromDatabase($id,$ebene)
 {
     $aktDate=date("Y")."-".date("n")."-".date("j");
     $SQLQuery="Select ".$this->articleTable.".article_id, ".$this->articleTable.".article_type, "
                 .$this->descriptionTable.".alias_external_link, "
                 .$this->descriptionTable.".article_linktext, "
                 .$this->descriptionTable.".Module, "
                 .$this->descriptionTable.".module_has_tree, "
                 .$this->descriptionTable.".article_url, "
                 .$this->descriptionTable.".article_content, "
                 .$this->descriptionTable.".article_as_link, "
                 .$this->descriptionTable.".module_parameter, "
                 .$this->descriptionTable.".show_navi, "
                 .$this->parentIDTable.".parent_id, ".$this->descriptionTable.".farbe " .
                 "FROM ".$this->articleTable." " .
                 "join ".$this->descriptionTable." USING (article_id) ".
                 "join ".$this->parentIDTable." USING (article_id) ";
     $SQLQuery.="where ".$this->parentIDTable.".parent_id='".$id."' " .
                 "and ".$this->articleTable.".published='1' and ".$this->articleTable.".viewable='1' and language_id='".$this->lang."' ".
                 " ORDER by sort_order";
     $result =  AGDO::getInstance()->GetAll($SQLQuery);
     if(!empty($result))
     {
         for ($zaehler=0; $zaehler< count($result);$zaehler++ )
         {
             if ($result[$zaehler]['article_id']=="4")
                 $this->home=$result[$zaehler];
             if ($ebene==2)
             {
                 $this->setFlavour($result[$zaehler]['article_id']);
             }
             if ($ebene==4)
             {
                 $this->setSecondFlavour($result[$zaehler]['parent_id']);
             }
             if ($result[$zaehler]['article_type']=="4" && $result[$zaehler]['article_as_link'])
                 $result[$zaehler]['article_url']=$this->getArticleURL($result[$zaehler]['article_content']);
             $result[$zaehler]['mark']=false;
             if (!empty($this->user))
                 $result[$zaehler]['permission']=$this->getPermission($result[$zaehler]['article_id'], $this->user);
             else
             {
                 $result[$zaehler]['permission']="2";  ///
             }
             $moduleTree=array();
             if (!empty($result[$zaehler]['Module'])&& $result[$zaehler]['show_navi'])
             {
                 $modul = ModuleManager::getInstance()->getModuleByName($result[$zaehler]['Module']);
                 if (!empty($modul))
                 {
                     $modul->setConnection(AGDO::getInstance());
                     if ($modul->hasFrontendNavigation())
                         $moduleTree = $modul->getFrontendNavigationData(Request::getInstance()->getRequests(),$result[$zaehler]);
                 }
             }
             //if ($result[$zaehler]['show_navi'])
                 $result[$zaehler]['Child']=$this->getTreeFromDatabase($result[$zaehler]['article_id'],($ebene+1));
             /*else
                 $result[$zaehler]['Child']=array();*/
             if (!empty($moduleTree))
                 $result[$zaehler]['Child']=array_merge($result[$zaehler]['Child'], $moduleTree);
             if ($ebene>2)
             {
                 $this->flavourArray[$result[$zaehler]['article_id']]=$this->getFlavour();
                 $result[$zaehler]['flavour']=$this->getFlavour();
             }
             if ($ebene>3)
             {
                 $this->flavourArray2[$result[$zaehler]['article_id']]=$result[$zaehler]['parent_id'];
                 $result[$zaehler]['flavour2']=$result[$zaehler]['parent_id'];
                 $this->setSecondFlavour($result[$zaehler]['parent_id']);
                 $result[$zaehler]['self']=$result[$zaehler]['article_id'];
             }
         }
     }
     return $result;
 }
Esempio n. 4
0
    public function generate($array, $langshort, $langID, $mode)
    {
        //print_r($array);
	//echo $langID;
        Logger::getInstance()->Log($_POST, LOG_ABLAUF);
        //$array['article_url_de'] = iconv('ISO-8859-1',"UTF-8",$array['article_url_de']);
        Logger::getInstance()->Log($array, LOG_ABLAUF);
        $arrayKeys = array_keys($array);
        $returnArray=array();
        if (ModuleManager::getInstance()->getModuleByName('Rechteverwaltung'))
        {
            $rechteverwaltung = ModuleManager::getInstance()->getModuleByName('Rechteverwaltung');
            $rechteverwaltung->setConnection(AGDO::getInstance());
            $rechteverwaltung->setLanguage(1);
            $rechteverwaltung->calculate();
            $permissions = array();
            foreach ($arrayKeys as $keys)
            {

                if (!(strpos($keys,'role_')===false))
                {
                    //echo strpos($keys,'e_');
                    $roleID = substr($keys,5);
                    //echo $roleID;
                    $permission = $array['GroupSelect_'.$roleID];
                    $permissions[]=array('permission'=>$permission,'role_id'=>$roleID);
                    //
                }
            }
            if (isset( $array['ID']))
              $rechteverwaltung->setPermissions($permissions, $array['ID']);
            if (isset($array['rolerekursiv']))
            {
                $this->updateRecPermission($rechteverwaltung, $permissions, $array['ID']);
            }
        }
        if (isset($array['tag_new']))
            $returnArray['tags']=$array['tag_new'];
        else
	{
           if (isset($array['tags'])) 
		$returnArray['tags']=$array['tags'];
	   else 
		$returnArray['tags']="";
	}
        if (isset($array['kopfbild_de']))
                $returnArray['kopfbild']=$array['kopfbild_de'];
        if(empty($array['kopfbildgalerie_on_de']))
            $returnArray['kopfbildgalerie_on'] = 'no';
	if (isset($array['kopfbild_slideshow']))
	     $returnArray['kopfbild_slideshow']=$array['kopfbild_slideshow'];
        else
            $returnArray['kopfbild_slideshow']='';
        if (isset($array['facebook']))
            $returnArray['facebook']=1;
        else
            $returnArray['facebook']=0;
        if (isset($array['twitter']))
            $returnArray['twitter']=1;
        else
            $returnArray['twitter']=0;
        if (empty($array['twitter_text']))
            $returnArray['twitter_text']="";
        if (empty($array['facebook_title']))
            $returnArray['facebook_title']="";
        if (empty($array['facebook_description']))
            $returnArray['facebook_description']="";
        if (empty($array['facebook_image']))
            $returnArray['facebook_image']="";
        if (isset($array['tags']) && $array['tags']=='Keine')
            $returnArray['tags']=NULL;
        // JA 09.03.2010 Rating

        $returnArray['rating_enabled'] = !empty($array['rating_enabled']) + '';
        $returnArray['show_rating'] = !empty($array['show_rating']) + '';
        if(isset($array['avg_rating']))
            $returnArray['avg_rating'] = $array['avg_rating']; 
        if(!empty($array['reset_rating'])){
            // reset data
            $returnArray['avg_rating'] = $returnArray['rating_count'] = 0;
            
            // delete rating info
            $settings = unserialize(SETTINGS);
            $table = $this->dbconnector->getPrefix() . $settings['rating']['table'];
            
            $query = "DELETE FROM $table 
                    WHERE article_id = ".$array['article_id'];
             $result = $this->dbverbindung->Execute($query);
        }
        
        foreach ($arrayKeys as $keys)
        {
            // JA 23.06.2009: that method is unsafe and kills description.
            /* 
            if (strpos($keys,"_".$langshort)>0)
            {
                $newkey=substr($keys,0,strpos($keys,"_".$langshort));
                $returnArray[$newkey]=$array[$keys];
            }
            */
            $parts = explode('_',$keys);
            if( count($parts) > 1 and end($parts) === $langshort)
            {
                array_pop($parts);
                $returnArray[join($parts,'_')]=$array[$keys];
            }
        }
        if (isset($returnArray['Modul']))                    //05.07.2007
            $returnArray['Module']=$returnArray['Modul'];
        else                                                //10.10.2007
            $returnArray['Module']="";                        //10.10.2007
        if (isset($returnArray['Modul_parameter']))                    //05.07.2007
            $returnArray['module_parameter']=$returnArray['Modul_parameter'];
        else                                                //10.10.2007
            $returnArray['module_parameter']="";
        
         if (isset($returnArray['Modul_parameter_2']))                    //05.07.2007
            $returnArray['module_parameter_2']=$returnArray['Modul_parameter_2'];
        else                                                //10.10.2007
            $returnArray['module_parameter_2']="";
        $bereinigterArtikelName="";
        if (!isset($returnArray['article_as_link']))
            $returnArray['article_as_link']='0';
        if (isset($returnArray['article_name']))
        {
            //echo "update";
            /** No automated change of page title and menu title. JA 30.01.2009
            if ($mode=='UPDATE')
            {
                $isChangedArticleName= $this->checkArticleName(mb_convert_encoding($returnArray['article_name'],"HTML-ENTITIES","auto"),$array['article_id'],$langID);
                 if ($isChangedArticleName)
                 {
                    unset($returnArray['article_linktext']);
                    unset($returnArray['article_title']);
                    //unset($myArray['article_url_'.$this->languageID[$counter]['short']]);
                 }
            }
            **/
            $bereinigterArtikelName = str_replace("\'","",$returnArray['article_name']);
            $bereinigterArtikelName = str_replace("\\\"","",$bereinigterArtikelName);
            if (!isset($returnArray['article_linktext']))
            {
                $returnArray['article_linktext']=$bereinigterArtikelName;
            }
            if (!isset($returnArray['article_title']))
            {
                $returnArray['article_title']=$bereinigterArtikelName;
            }
            
            if (!isset($returnArray['article_url']))
            {

                $returnArray['article_url']=$this->convertArticleNameToArticleUrl($returnArray['article_name']);
                $returnArray['article_url']=$this->urlchecker->check($returnArray['article_url'], $array['article_id'],$langID);
            }
            else
            {
                $returnArray['article_url']=$this->urlchecker->check($returnArray['article_url'], $array['article_id'],$langID);
            }
        }
        else
        {
            
            $returnArray['article_name']="";
            if (!isset($returnArray['article_linktext']))
                $returnArray['article_linktext']="";
        }
        if (!isset($returnArray['Additional_Content']))                //MG 10.10.2007
            $returnArray['Additional_Content']=0;
        if (!isset($returnArray['article_teaser_link_1']))            //MG 02.10.2007
            $returnArray['article_teaser_link_1']=0;
        if (!isset($returnArray['article_teaser_link_2']))
            $returnArray['article_teaser_link_2']=0;
        if (!isset($returnArray['article_teaser_link_3']))
            $returnArray['article_teaser_link_3']=0;
        if (!isset($returnArray['article_teaser_link_4']))
            $returnArray['article_teaser_link_4']=0;
        if ($array['article_id']==4 && $langID==1)
            $returnArray['article_url']="/";
        //$returnArray['article_url']=$array['article_url_de'];
        if (isset($array['jslib']) && $array['jslib']!='keine')
            $returnArray['jslib']=$array['jslib'];
        else
            $returnArray['jslib']=NULL;
        $returnArray['article_name']=$this->checkString($returnArray['article_name']);
        //$returnArray['article_name']=str_replace("\'","&#39;",$returnArray['article_name']);
        $returnArray['article_id']=$array['article_id'];
        if (!isset($array['show_navi']))
            $returnArray['show_navi']=0;
        else
            $returnArray['show_navi']=1;
        if (!isset($array['template']))
            $returnArray['template']='MainTemplate.htm';
        else
            $returnArray['template']=$array['template'];
        $returnArray['language_id']=$langID;
        if (isset($returnArray['ta']) && $returnArray['ta']!="")                    //MG 04.10.2007
            $returnArray['article_content']=$this->checkString(mb_convert_encoding($returnArray['ta'],"HTML-ENTITIES","auto"));
        else
            $returnArray['article_content']="";    
        if (isset($returnArray['article_description']) && $returnArray['article_description']!="")                    //MG 04.10.2007
            $returnArray['article_description']=$this->checkString(mb_convert_encoding($returnArray['article_description'],"HTML-ENTITIES","auto"));
        else
            $returnArray['article_description']="";
        if (isset($array['article_type']))
            $returnArray['article_type']=$array['article_type'];
        else
            $returnArray['article_type']=1;
        $returnArray['article_name']=mb_convert_encoding($returnArray['article_name'],"HTML-ENTITIES","auto");
        if (isset($array['GroupID']))
            $returnArray['GroupID']=$array['GroupID'];
        else
            $returnArray['GroupID']=0;
        if (isset($array['UserID']))
            $returnArray['UserID']=$array['UserID'];
        else
            $returnArray['UserID']=0;
        if (isset($returnArray['article_linktext']))
            $returnArray['article_linktext']=mb_convert_encoding($returnArray['article_linktext'],"HTML-ENTITIES","auto");
        if (isset($returnArray['article_title']))
            $returnArray['article_title']=mb_convert_encoding($returnArray['article_title'],"HTML-ENTITIES","auto");
        if (!isset($returnArray['article_teaserhead']))
            $returnArray['article_teaserhead'] = $this->getTeaderHeadFromArticleName($returnArray['article_name']);
        else
            $returnArray['article_teaserhead']=$this->checkString($returnArray['article_teaserhead']);
        if (!isset($returnArray['article_teaser_content']))
            $returnArray['article_teaser_content']= $this->checkString($this->getTeaserContentFromArticleContent($returnArray['article_content']));
        $returnArray['article_teaser_content']= $this->checkString($returnArray['article_teaser_content']);                 //MG 26.09.2007
        if (isset($returnArray['picture_name']))
        {
            $returnArray['picture_name']= mb_convert_encoding($returnArray['picture_name'],"HTML-ENTITIES","auto");
            $returnArray['picture_name']=$this->checkString($returnArray['picture_name']);
        }
        else
            $returnArray['picture_name']="";
            
        
        $returnArray['newsdate']= empty($array['newsdate']) ? '0000-00-00' : $array['newsdate']; // 03.09.2008 JA
        Logger::getInstance()->Log("returnArray", LOG_ABLAUF);
        Logger::getInstance()->Log($returnArray, LOG_ABLAUF);
        //echo "langshort".$langshort;
        //echo "<!--\n".print_r($returnArray,true)."-->";
        return $returnArray;
    }
Esempio n. 5
0
 /**
  * Handle tag _module_list used to display list of all modules on the system
  *
  * @param array $params
  * @param array $children
  */
 public function tag_ModuleList($params, $children)
 {
     global $module_path;
     $list = array();
     $raw_list = $this->getModuleList();
     $manager = ModuleManager::getInstance();
     $modules_in_use = $manager->getItems(array('id', 'order', 'name', 'preload', 'active'), array(), array('preload', 'order'));
     // add modules from database
     foreach ($modules_in_use as $module) {
         if (in_array($module->name, $raw_list)) {
             // module in database exists on disk
             if ($module->active) {
                 $list[$module->name] = array('status' => 'active');
             } else {
                 $list[$module->name] = array('status' => 'inactive');
             }
         } else {
             // module does not exist on disk
             $list[$module->name] = array('status' => 'missing');
         }
         $list[$module->name]['active'] = $module->active;
         $list[$module->name]['preload'] = $module->preload;
         $list[$module->name]['order'] = $module->order;
     }
     // add missing modules available on drive
     foreach ($raw_list as $module_name) {
         if (!array_key_exists($module_name, $list)) {
             $list[$module_name] = array('status' => 'not_initialized', 'active' => 0, 'preload' => 0, 'order' => '');
         }
     }
     $template = new TemplateHandler(isset($params['template']) ? $params['template'] : 'module.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     foreach ($list as $name => $definition) {
         $icon_file = _BASEPATH . '/' . $module_path . $name . '/images/icon.svg';
         if (file_exists($icon_file)) {
             $icon = url_GetFromFilePath($icon_file);
         } else {
             $icon = url_GetFromFilePath($this->path . 'images/icons/16/modules.svg');
         }
         $params = array('name' => $name, 'icon' => $icon, 'status' => $definition['status'], 'active' => $definition['active'], 'active_symbol' => $definition['active'] ? CHAR_CHECKED : CHAR_UNCHECKED, 'preload' => $definition['preload'], 'preload_symbol' => $definition['preload'] ? CHAR_CHECKED : CHAR_UNCHECKED, 'order' => $definition['order'], 'item_activate' => url_MakeHyperlink($this->getLanguageConstant('activate'), window_Open($this->name . '_module_dialog', 300, $this->getLanguageConstant('title_module_activate'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'module_activate'), array('module_name', $name)))), 'item_deactivate' => url_MakeHyperlink($this->getLanguageConstant('deactivate'), window_Open($this->name . '_module_dialog', 300, $this->getLanguageConstant('title_module_deactivate'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'module_deactivate'), array('module_name', $name)))), 'item_initialise' => url_MakeHyperlink($this->getLanguageConstant('initialise'), window_Open($this->name . '_module_dialog', 300, $this->getLanguageConstant('title_module_initialise'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'module_initialise'), array('module_name', $name)))), 'item_disable' => url_MakeHyperlink($this->getLanguageConstant('disable'), window_Open($this->name . '_module_dialog', 300, $this->getLanguageConstant('title_module_disable'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'module_disable'), array('module_name', $name)))));
         $template->restoreXML();
         $template->setLocalParams($params);
         $template->parse();
     }
 }
Esempio n. 6
0
 /**
  * Of course, even exceptions shouldn't be fatal for the bot's run-time.
  * Therefore we want to catch exceptions which occur as well.
  * 
  * @param Exception $pException The exception that has occured.
  * @return true
  */
 public function processException(\Exception $pException)
 {
     if (self::$Context != null && self::$Context instanceof Bot) {
         $sExceptionSource = self::$Source;
         ModuleManager::getInstance()->onException(self::$Context, $sExceptionSource, $pException);
         self::$Source = null;
         return true;
     }
     echo '[Exception] Exception occured in "' . $pException->getFile() . '" on line ';
     echo $pException->getLine() . ': "' . $pException->getMessage() . '".' . PHP_EOL;
     return true;
 }