log.php

File Type: php File Location: monofiles/ File name: log.php
<?php

    
if (is_dir('monofiles'))
        
$rot_log 'monofiles/';
    
    elseif(
is_dir('filesinfo'))
        
$rot_log '';
    
    else
        
$rot_log '../../monofiles/';
    
    
// get log
    
function get_log() {
        
        global 
$rot_log;
        
        
$loginfoxml simplexml_load_file($rot_log.'filesinfo/log.xml');
        
        
$i_log = array(
        
'posts' => (string)$loginfoxml->info->posts,
        
'pages' => (string)$loginfoxml->info->pages,
        
'failed' => (string)$loginfoxml->info->failed,
        
'modified' => (string)$loginfoxml->info->modified
        
);
        
        return 
$i_log;
        
    }
    
    
// get account info using a 'username' or a 'userid' as a parameter.
    
function get_account($value 'null') {
        
        global 
$rot_log;
        
        
$log simplexml_load_file($rot_log.'filesinfo/log.xml');
        
        
$account_info = array();
        
$c=0;
        foreach(
$log->user as $userinfo){
            
            if ( (
$userinfo->userID == $value || $userinfo->name == $value) ){
                
                
$account_info = array('name' => (string)$log->user[$c]->name,
                                      
'pshs' => (string)$log->user[$c]->pshs,
                                      
'rights' => (string)$log->user[$c]->rights,
                                      
'login' => (string)$log->user[$c]->login,
                                      
'ip' => (string)$log->user[$c]->ip,
                                      
'icon' => (string)$log->user[$c]->icon,
                                      
'userID' => (string)$log->user[$c]->userID,
                                      
'description' => (string)$log->user[$c]->description,
                                      
'signposts' => (string)$log->user[$c]->signposts,
                                      
'results_posts' => (string)$log->user[$c]->results->posts,
                                      
'results_pages' => (string)$log->user[$c]->results->pages,
                                      
'results_images' => (string)$log->user[$c]->results->images
                                     
);

                break;
            }
            
$c++;
        }
            
    return 
$account_info;
    
    }
    
    
    
// update log
    
function update_log($tag 'tagname',$value){
            
            global 
$rot_log;
            
$log $rot_log.'filesinfo/log.xml';
    
            
$log_element = new simpleXMLElement($log,null,true);
            
            
$log_element->info->$tag $value;
            
$log_element->info->modified time();
            
            
$log_element->asXML($log);
            
            return 
true;

    }
    
    
// update account info using userID and an action.
    
    
function update_account($id,$action 'set'){
        
        global 
$rot_log;
        
$log $rot_log.'filesinfo/log.xml';
        
$logsave = new simpleXMLElement($log,null,true);
        
        
$c=0;
        
$upd false;
        foreach(
$logsave->user as $user) {
                
                if ((
$user->userID == $id) && ($user->pshs != '-')) {
                    
                    if (
$action == 'delete') {
                    
                        
$logsave->user[$c]->name = (string)$logsave->user[$c]->name.'[deleted]';
                        
$logsave->user[$c]->pshs '-';
                        
$logsave->user[$c]->rights '-';
                        
$logsave->user[$c]->icon '-';
                        
$logsave->user[$c]->description '-';
                        
$logsave->user[$c]->signposts '-';
                        
$logsave->user[$c]->results->posts '0';
                        
$logsave->user[$c]->results->pages '0';
                        
$logsave->user[$c]->results->images '0';
                        
$logsave->user[$c]->sidemenu 'off';
                        
                        if (
$_SESSION['userID'] == $id)
                            
session_destroy();
                    }

                    if (
$action == 'set'){

                        
$values = array('name' => $_POST['username'],
                                        
'pshs' => $_POST['password'],// new value of POST['password']
                                        
'rights' => $_POST['accounttype'],
                                        
'icon' => $_SESSION['usericon'],
                                        
'description' => $_POST['userdescription'],
                                        
'signposts' => $_POST['signposts'],
                                        
'posts' => $_GET['postsperpage'],
                                        
'pages' => $_GET['pagesperpage'],
                                        
'images' => $_GET['imgsperpage']
                                        );
                                        
                        foreach(
$values as $tag => $set){
                            
                                if (isset(
$set)) {
                                    
                                    if ((
$tag == 'posts')||($tag == 'pages')||($tag == 'images'))                                        
                                        
$logsave->user[$c]->results->$tag $set;
                                        
                                    
                                    else    
                                    
$logsave->user[$c]->$tag $set;
                                }
                        }
                    
                    }
                    
$logsave->asXML($log);
                    
$upd true;
                    break;
                }
                
$c++;
        }
        
        return 
$upd;
    }
?>