Exemple #1
0
/** redirect to a given commsy page
 * first save session than
 * redirect to the commsy page by the given url (use curl_function)
 *
 * @param   $url   url as result of a curl function
 */
function redirect_with_url($url)
{
    global $environment;
    $session = $environment->getSessionItem();
    // only save session when the session has not reseted
    if (isset($session)) {
        $session_id = $session->getSessionID();
        if (!empty($session_id)) {
            $session_manager = $environment->getSessionManager();
            $session_manager->save($session);
        }
    }
    if (isset($_POST)) {
        $post_content = array2XML($_POST);
    } else {
        $post_content = '';
    }
    $log = false;
    $post_content_big = mb_strtoupper($post_content, 'UTF-8');
    if (empty($post_content_big) or !empty($post_content_big) and (mb_stristr($post_content_big, 'SELECT') !== false or mb_stristr($post_content_big, 'INSERT') !== false or mb_stristr($post_content_big, 'UPDATE') !== false)) {
        $log = true;
    }
    if ($log) {
        $array = array();
        if (isset($_GET['iid'])) {
            $array['iid'] = $_GET['iid'];
        } elseif (isset($_POST['iid'])) {
            $array['iid'] = $_POST['iid'];
        }
        if (isset($_SERVER['HTTP_USER_AGENT'])) {
            $array['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
        } else {
            $array['user_agent'] = 'No Info';
        }
        $current_user = $environment->getCurrentUser();
        $array['remote_addr'] = $_SERVER['REMOTE_ADDR'];
        $array['script_name'] = $_SERVER['SCRIPT_NAME'];
        $array['query_string'] = $_SERVER['QUERY_STRING'];
        $array['request_method'] = $_SERVER['REQUEST_METHOD'];
        $array['post_content'] = $post_content;
        $array['user_item_id'] = $current_user->getItemID();
        $array['user_user_id'] = $current_user->getUserID();
        $array['context_id'] = $environment->getCurrentContextID();
        $array['module'] = $environment->getCurrentModule();
        $array['function'] = $environment->getCurrentFunction();
        $array['parameter_string'] = $environment->getCurrentParameterString();
        $log_manager = $environment->getLogManager();
        $log_manager->saveArray($array);
        unset($log_manager);
    }
    header('Location: ' . $url);
    header('HTTP/1.0 302 Found');
    exit;
}
Exemple #2
0
 public function getStatistics($session_id, $date_start, $date_end)
 {
     $result = '';
     $session_id = $this->_encode_input($session_id);
     if ($this->_isSessionValid($session_id)) {
         $this->_environment->setSessionID($session_id);
         $session = $this->_environment->getSessionItem();
         $user_id = $session->getValue('user_id');
         $auth_source_id = $session->getValue('auth_source');
         $context_id = $session->getValue('commsy_id');
         $this->_environment->setCurrentContextID($context_id);
         $user_manager = $this->_environment->getUserManager();
         $user_manager->setContextLimit($context_id);
         $user_manager->setUserIDLimit($user_id);
         $user_manager->setAuthSourceLimit($auth_source_id);
         $user_manager->select();
         $user_list = $user_manager->get();
         if ($user_list->getCount() == 1) {
             $user_item = $user_list->getFirst();
             if ($user_item->isRoot()) {
                 if (!empty($date_start)) {
                     $date_start = $this->_encode_input($date_start);
                     if (!empty($date_end)) {
                         $date_end = $this->_encode_input($date_end);
                     } else {
                         $date_end = 'NOW';
                     }
                     if ($date_end == 'NOW') {
                         $date_end = date('Y-m-d') . ' 23:59:59';
                     }
                     $server_item = $this->_environment->getServerItem();
                     if (!empty($server_item)) {
                         include_once 'functions/misc_functions.php';
                         $result = array2XML($server_item->getStatistics($date_start, $date_end));
                     } else {
                         $info = 'ERROR: GET STATISTICS';
                         $info_text = 'server_item is empty';
                         $result = new SoapFault($info, $info_text);
                     }
                 } else {
                     $info = 'ERROR: GET STATISTICS';
                     $info_text = 'date_start (second parameter) is empty';
                     $result = new SoapFault($info, $info_text);
                 }
             } else {
                 $info = 'ERROR: GET STATISTICS';
                 $info_text = 'only root is allowed to use this function';
                 $result = new SoapFault($info, $info_text);
             }
         } else {
             $info = 'ERROR: GET STATISTICS';
             $info_text = 'multiple user (' . $user_id . ') with auth source (' . $auth_source_id . ')';
             $result = new SoapFault($info, $info_text);
         }
     } else {
         $info = 'ERROR: GET STATISTICS';
         $info_text = 'session id (' . $session_id . ') is not valid';
         $result = new SoapFault($info, $info_text);
     }
     return $result;
 }
Exemple #3
0
    $environment = $this->_environment;
}
$l_current_user = $environment->getCurrentUserItem();
$array = array();
if (isset($_GET['iid'])) {
    $array['iid'] = $_GET['iid'];
} elseif (isset($_POST['iid'])) {
    $array['iid'] = $_POST['iid'];
}
if (isset($_SERVER['HTTP_USER_AGENT'])) {
    $array['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
} else {
    $array['user_agent'] = 'No Info';
}
if (isset($_POST)) {
    $post_content = array2XML($_POST);
} else {
    $post_content = '';
}
$current_context = $environment->getCurrentContextItem();
$server_item = $environment->getServerItem();
//Datenschutz
//if($current_context->withLogIPCover() or $server_item->withLogIPCover()){
if ($server_item->withLogIPCover()) {
    // if datasecurity is active dont show last two fields
    $remote_adress_array = explode('.', $_SERVER['REMOTE_ADDR']);
    $array['remote_addr'] = $remote_adress_array['0'] . '.' . $remote_adress_array['1'] . '.' . $remote_adress_array['2'] . '.XXX';
} else {
    $array['remote_addr'] = $_SERVER['REMOTE_ADDR'];
}
unset($server_item);
function array2XML_old($array, $level = 1)
{
    if (!is_array($array)) {
        return $array;
    }
    $xml = '';
    if ($level == 1) {
        $xml .= '<data>';
    }
    foreach ($array as $key => $value) {
        //if (is_int($key)) $key = 'node_'.$key;
        if (is_int($key)) {
            $key = 'node';
        }
        if (is_array($value)) {
            $xml .= str_repeat("\t", $level) . "<{$key}>\n";
            $xml .= array2XML($value, $level + 1);
            $xml .= str_repeat("\t", $level) . "</{$key}>\n";
        } else {
            $make_cdata = true;
            if (stripos($key, 'XML')) {
                $make_cdata = false;
            }
            if (is_numeric($value)) {
                $make_cdata = false;
            }
            if (substr($value, 0, 6) == '<data>') {
                $make_cdata = false;
            }
            if (preg_match("/^(\\t|\\r|\\n)*\\<data.*/", $value)) {
                $make_cdata = false;
            }
            if ($make_cdata) {
                $value = '<![CDATA[' . $value . ']]>';
            }
            $xml .= str_repeat("\t", $level) . "<{$key}>{$value}</{$key}>\n";
        }
    }
    if ($level == 1) {
        $xml .= '</data>';
    }
    return $xml;
}
      $extra = $row[1];
      update_progress_bar($count_rooms);
   }

   // portal
   $query  = "SELECT item_id, extras FROM portal WHERE deletion_date IS NULL ORDER BY item_id;";
   $result = select($query);
   $row = mysql_fetch_row($result);
   $room_id = $row[0];
   $extra = $row[1];
   while ($room_id) {
      if ( !empty($newsletter_enabled_for) and in_array($room_id,$newsletter_enabled_for) ) {

         $extra_array = XML2Array( $extra );
         $extra_array['EXTRA_CONFIG']['NEWSLETTER'] = 1;
         $extra = array2XML($extra_array);

         // save room
         $insert_query = 'UPDATE portal SET extras="'.addslashes($extra).'" WHERE item_id="'.$room_id.'"';
         select($insert_query);
      }
      $row = mysql_fetch_row($result);
      $room_id = $row[0];
      $extra = $row[1];
      update_progress_bar($count_rooms);
   }
}

if ($success) {
   echo('[ <font color="#00ff00">done</font> ]<br/>'."\n");
} else {
 private static function _outputArray($array = array())
 {
     // Convert to XML
     $output_dom = new DomDocument('1.0', 'UTF-8');
     $output = array2XML($array);
     // Strip out any <?xml stuff
     $output = preg_replace('/\\<\\?xml.+\\?\\>/', '', $output, 1);
     $output_dom->loadXML($output);
     return $output_dom;
 }
Exemple #7
0
function array2XML($obj, $array)
{
    foreach ($array as $key => $value) {
        if (is_numeric($key)) {
            $key = 'item' . $key;
        }
        if (is_array($value)) {
            $node = $obj->addChild($key);
            array2XML($node, $value);
        } else {
            $obj->addChild($key, htmlspecialchars($value));
        }
    }
}
Exemple #8
0
 private function _loadPageXML($item = array(), $primary = TRUE, $get_children = TRUE)
 {
     if (array_key_exists('path', $item)) {
         if (strpos($item[path], 'JSON/')) {
             $item[path] = str_replace('JSON/', '', $item[path]);
         }
     }
     $pages = $this->_loadPageData($item, $primary);
     $return = '';
     if ($primary && !count($pages)) {
         return $this->_show404('Page not found in database.');
     }
     foreach ($pages as $page) {
         if ($page['template_options']['xml_action'] == 'deny') {
             if ($primary) {
                 // Only show friendly error is this is a top level request.
                 show_error('The page you requested has not been enabled for XML viewing.');
             } else {
                 // TODO: Make it more obvious when a page is being omitted. It can get confusing when listing children.
                 //$return .= '<!-- Skipping page '.$page['page_id'].': Has not been enabled for XML viewing.	 -->';
                 //continue;
             }
         } else {
             if ($page['type'] == 'redirect') {
                 $this->_show404('Redirect pages can not be viewed as XML.');
                 return false;
             }
         }
         // Stuff to do if this is the primary request only
         if ($primary) {
             $this->current_id = $page['page_id'];
             $this->current_title = $page['title'];
             $this->layout->appendTitle($page['title']);
             if ($this->SITE_CONF['cache_enabled'] && $page['template_options']['cache_time'] != 'none') {
                 $this->page_cache_period = $page['template_options']['cache_time'];
             }
             // React to different page types
             if ($page['type'] == 'redirect' && !empty($page['options_json']['redirect_path'])) {
                 // REDIRECT PAGE TYPE
                 redirect($page['options_json']['redirect_path'], 'location', 301);
             } else {
                 if ($page['type'] == 'secure_section' || $page['type'] == 'secure_page') {
                     $this->page_cache_period = false;
                     $this->_loginSecureUser($page);
                 }
             }
         }
         // Static page request. This needs to happen after the primary information above is set.
         if ($page['type'] == 'static') {
             $return .= $page['content'];
         } else {
             $transform_xsl = false;
             if (in_array($page['type'], array('section', 'mirror_section', 'mirror_section_source', 'mirror_calendar', 'mirror_calendar_source')) && strpos($page['template_options']['xml_action'], 'show_w_') === 0) {
                 // Return children
                 $xml_action = $page['template_options']['xml_action'];
                 $get_children = is_bool($get_children) ? $get_children : TRUE;
                 // Is this a section, get it's children
                 if ($get_children) {
                     $next_children = $xml_action == 'show_w_all' ? TRUE : FALSE;
                     $l_item = array('parent_id' => $page['page_id']);
                     $page['children'] = $this->_loadPageXML($l_item, FALSE, $next_children);
                 }
             }
             if ($primary && !empty($page['template_xml_xsl_path'])) {
                 $transform_xsl = $page['template_xml_xsl_path'];
             }
             // Assign attributes
             if (!empty($this->PAGE_CONF['xml_attribute_nodes'])) {
                 foreach ($this->PAGE_CONF['xml_attribute_nodes'] as $node) {
                     if (isset($page[$node])) {
                         $page['@' . $node] = $page[$node];
                     }
                 }
             }
             // Strip out unwanted values
             if (!empty($this->PAGE_CONF['xml_remove_nodes'])) {
                 foreach ($this->PAGE_CONF['xml_remove_nodes'] as $node) {
                     if (isset($page[$node])) {
                         unset($page[$node]);
                     }
                 }
             }
             //	pr($page);
             if ($transform_xsl) {
                 $return .= $this->xsl_transform->transform($transform_xsl, array('page' => $page));
             } else {
                 // Plain item xml
                 $return .= array2XML($page);
             }
         }
     }
     // We need this for caching
     if (!empty($page['page_id'])) {
         $this->page_cache_id = $page['page_id'];
     }
     return $return;
 }