Exemplo n.º 1
0
/**
 * Used when checking if there is a client or user logged in via cookie.
 *
 * @see check_for_session
 */
function check_valid_cookie()
{
    if (isset($_COOKIE['password']) && isset($_COOKIE['loggedin']) && isset($_COOKIE['userlevel'])) {
        $cookie_pass = mysql_real_escape_string($_COOKIE['password']);
        $cookie_user = mysql_real_escape_string($_COOKIE['loggedin']);
        $cookie_level = mysql_real_escape_string($_COOKIE['userlevel']);
        /**
         * Compare the cookies to the database information. Level
         * and active are compared in case the cookie exists but
         * the client has been deactivated, or the user level has
         * changed.
         */
        $sql_cookie = mysql_query("SELECT * FROM tbl_users WHERE user='******' AND password='******' AND level='{$cookie_level}' AND active = '1'");
        $count = mysql_num_rows($sql_cookie);
        if ($count > 0) {
            if (!isset($_SESSION['loggedin'])) {
                /** Set SESSION values */
                $_SESSION['loggedin'] = $_COOKIE['loggedin'];
                $_SESSION['userlevel'] = $_COOKIE['userlevel'];
                $_SESSION['access'] = $_COOKIE['access'];
                while ($row = mysql_fetch_array($sql_cookie)) {
                    $log_id = $row['id'];
                    $log_name = $row['name'];
                }
                /** Record the action log */
                $new_log_action = new LogActions();
                $log_action_args = array('action' => 24, 'owner_id' => $log_id, 'owner_user' => $log_name);
                $new_record_action = $new_log_action->log_action_save($log_action_args);
            }
            return true;
        }
    }
}
Exemplo n.º 2
0
/**
 * Used when checking if there is a client or user logged in via cookie.
 *
 * @see check_for_session
 */
function check_valid_cookie()
{
    global $dbh;
    if (isset($_COOKIE['password']) && isset($_COOKIE['loggedin']) && isset($_COOKIE['userlevel'])) {
        $statement = $dbh->prepare("SELECT * FROM " . TABLE_USERS . " WHERE user= :cookie_user AND password= :cookie_pass AND level= :cookie_level AND active = '1'");
        $statement->execute(array(':cookie_user' => $_COOKIE['loggedin'], ':cookie_pass' => $_COOKIE['password'], ':cookie_level' => $_COOKIE['userlevel']));
        $count = $statement->rowCount();
        /**
         * Compare the cookies to the database information. Level
         * and active are compared in case the cookie exists but
         * the client has been deactivated, or the user level has
         * changed.
         */
        if ($count > 0) {
            if (!isset($_SESSION['loggedin'])) {
                /** Set SESSION values */
                $_SESSION['loggedin'] = $_COOKIE['loggedin'];
                $_SESSION['userlevel'] = $_COOKIE['userlevel'];
                $_SESSION['access'] = $_COOKIE['access'];
                $statement->setFetchMode(PDO::FETCH_ASSOC);
                while ($row = $statement->fetch()) {
                    $log_id = $row['id'];
                    $log_name = $row['name'];
                }
                /** Record the action log */
                $new_log_action = new LogActions();
                $log_action_args = array('action' => 24, 'owner_id' => $log_id, 'owner_user' => $log_name);
                $new_record_action = $new_log_action->log_action_save($log_action_args);
            }
            return true;
        }
    }
}
 function Miscellaneous()
 {
     $this->MakeSafe();
     $tmpDCEventLog = new DCEventLog();
     $tmpDCEventLog->DataCenterID = $this->DataCenterID;
     class_exists('LogActions') ? LogActions::LogThis($this, $tmpDCEventLog) : '';
 }
Exemplo n.º 4
0
<?php

require_once 'db.inc.php';
require_once 'facilities.inc.php';
if (isset($_POST['refresh'])) {
    $log = new LogActions();
    foreach ($log as $prop => $val) {
        if (isset($_POST[$prop])) {
            $log->{$prop} = $_POST[$prop];
        }
    }
    $data_array = array();
    if (isset($_POST['ListUnique'])) {
        $data_array = $log->ListUnique($_POST['ListUnique']);
    }
    if (isset($_POST['BuildTable'])) {
        echo BuildDataTable($log);
        exit;
    }
    header('Content-Type: application/json');
    echo json_encode($data_array);
    exit;
}
$subversion = __("Logging View/Export");
$datacenter = new DataCenter();
$dcList = $datacenter->GetDCList();
$templ = new DeviceTemplate();
$dept = new Department();
$dev = new Device();
$log = new LogActions();
function BuildDataTable($log_object)
Exemplo n.º 5
0
 function RemoveFromTemplatesAndDevices()
 {
     global $dbh;
     $this->AttributeID = intval($this->AttributeID);
     $sql = "DELETE FROM fac_DeviceTemplateCustomValue WHERE AttributeID={$this->AttributeID};";
     if (!$dbh->query($sql)) {
         $info = $dbh->errorInfo();
         error_log("RemoveDeviceCustomAttribute::PDO Error: {$info[2]} SQL={$sql}");
         return false;
     }
     $sql = "DELETE FROM fac_DeviceCustomValue WHERE AttributeID={$this->AttributeID};";
     if (!$dbh->query($sql)) {
         $info = $dbh->errorInfo();
         error_log("RemoveDeviceCustomAttribute::PDO Error: {$info[2]} SQL={$sql}");
         return false;
     }
     class_exists('LogActions') ? LogActions::LogThis($this) : '';
     return true;
 }
Exemplo n.º 6
0
 function CreateDevice()
 {
     global $dbh;
     $this->MakeSafe();
     $this->Label = transform($this->Label);
     $this->SerialNo = transform($this->SerialNo);
     $this->AssetTag = transform($this->AssetTag);
     $sql = "INSERT INTO fac_Device SET Label=\"{$this->Label}\", SerialNo=\"{$this->SerialNo}\", AssetTag=\"{$this->AssetTag}\", \n\t\t\t\t\tPrimaryIP=\"{$this->PrimaryIP}\", SNMPCommunity=\"{$this->SNMPCommunity}\", ESX={$this->ESX}, Owner={$this->Owner}, \n\t\t\t\t\tEscalationTimeID={$this->EscalationTimeID}, EscalationID={$this->EscalationID}, PrimaryContact={$this->PrimaryContact}, \n\t\t\t\t\tCabinet={$this->Cabinet}, Position={$this->Position}, Height={$this->Height}, Ports={$this->Ports}, \n\t\t\t\t\tFirstPortNum={$this->FirstPortNum}, TemplateID={$this->TemplateID}, NominalWatts={$this->NominalWatts}, \n\t\t\t\t\tPowerSupplyCount={$this->PowerSupplyCount}, DeviceType=\"{$this->DeviceType}\", ChassisSlots={$this->ChassisSlots}, \n\t\t\t\t\tRearChassisSlots={$this->RearChassisSlots},ParentDevice={$this->ParentDevice}, \n\t\t\t\t\tMfgDate=\"" . date("Y-m-d", strtotime($this->MfgDate)) . "\", \n\t\t\t\t\tInstallDate=\"" . date("Y-m-d", strtotime($this->InstallDate)) . "\", WarrantyCo=\"{$this->WarrantyCo}\", \n\t\t\t\t\tWarrantyExpire=\"" . date("Y-m-d", strtotime($this->WarrantyExpire)) . "\", Notes=\"{$this->Notes}\", \n\t\t\t\t\tReservation={$this->Reservation}, HalfDepth={$this->HalfDepth}, BackSide={$this->BackSide};";
     if (!$dbh->exec($sql)) {
         $info = $dbh->errorInfo();
         error_log("PDO Error: {$info[2]} SQL={$sql}");
         return false;
     }
     $this->DeviceID = $dbh->lastInsertId();
     class_exists('LogActions') ? LogActions::LogThis($this) : '';
     return $this->DeviceID;
 }
Exemplo n.º 7
0
    }
    print "</fieldset>\n";
}
?>
</div><!-- END div.right -->
<div class="table" id="pandn">
<div><div>
<div class="table style">
<?php 
// Operational log
// This is an optional block if logging is enabled
if (class_exists('LogActions') && $dev->DeviceID > 0) {
    print "\t<div>\n\t\t  <div><a>" . __("Operational Log") . "</a></div>\n\t\t  <div><div id=\"olog\" class=\"table border\">\n\t\t\t<div><div>" . __("Date") . "</div></div>\n";
    // Wrapping the actual log events with a table of their own and a div that we can style
    print "\t<div><div><div><div class=\"table\">\n";
    foreach (LogActions::GetLog($dev, false) as $logitem) {
        if ($logitem->Property == "OMessage") {
            print "\t\t\t<div><div>{$logitem->Time}</div><div>{$logitem->UserID}</div><div>{$logitem->NewVal}</div></div>\n";
        }
    }
    // Closing the row, table for the log events, and the stylable div
    print "\t</div></div></div></div>\n";
    // The input box and button
    print "\t\t\t<div><div><button type=\"button\">Add note</button><div><input /></div></div></div>\n";
    print "\t\t  </div></div>\n\t\t</div>\n";
    print "\t\t<!-- Spacer --><div><div>&nbsp;</div><div></div></div><!-- END Spacer -->\n";
    // spacer row
}
//HTML content condensed for PHP logic clarity.
// If $pwrCords is null then we're creating a device record. Skip power checking.
if (!is_null($pwrCords) && (isset($_POST['action']) && $_POST['action'] != 'Child' || !isset($_POST['action'])) && !in_array($dev->DeviceType, array('Physical Infrastructure', 'Patch Panel'))) {
Exemplo n.º 8
0
 function MakeConnection()
 {
     global $dbh;
     $this->MakeSafe();
     $sql = "INSERT INTO fac_PanelSchedule SET PanelID={$this->PanelID}, \n\t\t\tPolePosition={$this->PolePosition}, NumPoles={$this->NumPoles}, \n\t\t\tLabel=\"{$this->Label}\" ON DUPLICATE KEY UPDATE Label=\"{$this->Label}\", \n\t\t\tNumPoles={$this->NumPoles};";
     class_exists('LogActions') ? LogActions::LogThis($this) : '';
     return $dbh->query($sql);
 }
 function logout()
 {
     header("Cache-control: private");
     unset($_SESSION['loggedin']);
     unset($_SESSION['access']);
     unset($_SESSION['userlevel']);
     session_destroy();
     /** If there is a cookie, unset it */
     setcookie("loggedin", "", time() - COOKIE_EXP_TIME);
     setcookie("password", "", time() - COOKIE_EXP_TIME);
     setcookie("access", "", time() - COOKIE_EXP_TIME);
     setcookie("userlevel", "", time() - COOKIE_EXP_TIME);
     /** Record the action log */
     $new_log_action = new LogActions();
     $log_action_args = array('action' => 31, 'owner_id' => $logged_id, 'affected_account_name' => $global_name);
     $new_record_action = $new_log_action->log_action_save($log_action_args);
     header("location:index.php");
 }
Exemplo n.º 10
0
 function UpdatePeriod()
 {
     $this->MakeSafe();
     $oldperiod = new EscalationTimes();
     $oldperiod->EscalationTimeID = $this->EscalationTimeID;
     $oldperiod->GetEscalationTime();
     $sql = "UPDATE fac_EscalationTimes SET TimePeriod=\"{$this->TimePeriod}\" WHERE \n\t\t\tEscalationTimeID={$this->EscalationTimeID};";
     class_exists('LogActions') ? LogActions::LogThis($this, $oldperiod) : '';
     return $this->query($sql);
 }
Exemplo n.º 11
0
                        $process_assignment = $this_upload->upload_add_assignment($add_arguments);
                        /**
                         * 3- Hide for everyone if checked
                         */
                        if (!empty($file['hideall'])) {
                            $this_file = new FilesActions();
                            $hide_file = $this_file->hide_for_everyone($this_file_id);
                        }
                        /**
                         * 4- Add the notifications to the database
                         */
                        if ($send_notifications == true) {
                            $process_notifications = $this_upload->upload_add_notifications($add_arguments);
                        }
                    }
                    $new_log_action = new LogActions();
                    $log_action_args = array('action' => $action_log_number, 'owner_id' => $global_id, 'owner_user' => $global_user, 'affected_file' => $process_file['new_file_id'], 'affected_file_name' => $file['name']);
                    $new_record_action = $new_log_action->log_action_save($log_action_args);
                    $msg = __('The file has been edited succesfuly.', 'cftp_admin');
                    echo system_message('ok', $msg);
                    include ROOT_DIR . '/upload-send-notifications.php';
                }
            }
        }
    }
    /** Validations OK, show the editor */
    ?>
			<form action="edit-file.php?file_id=<?php 
    echo $this_file_id;
    ?>
" method="post" name="edit_file" id="edit_file">
Exemplo n.º 12
0
 function Search($num_rec_per_page = 0, $page = 1)
 {
     $this->MakeSafe();
     // This will store all our extended sql
     $sqlextend = "";
     function findit($prop, $val, &$sql)
     {
         if ($sql) {
             $sql .= " AND {$prop}=\"{$val}\"";
         } else {
             $sql .= " WHERE {$prop} LIKE \"%{$val}%\"";
         }
     }
     foreach ($this as $prop => $val) {
         if ($val && $val != "1969-12-31") {
             findit($prop, $val, $sqlextend);
         }
     }
     $sqlextend .= " ORDER BY Time DESC";
     // Make sure someone didn't do something crazy with the input
     $page = intval($page);
     $num_rec_per_page = intval($num_rec_per_page);
     if ($page && $num_rec_per_page) {
         $start_from = ($page - 1) * $num_rec_per_page;
         $sqlextend .= " LIMIT {$start_from}, {$num_rec_per_page}";
     }
     $sql = "SELECT * FROM fac_GenericLog{$sqlextend};";
     $events = array();
     foreach ($this->query($sql) as $dbRow) {
         $events[] = LogActions::RowToObject($dbRow);
     }
     return $events;
 }
Exemplo n.º 13
0
 function checkAccess()
 {
     global $db, $survey;
     switch ($survey->getAccessType()) {
         case LOGIN_ANONYMOUS:
             return true;
             break;
         case LOGIN_DIRECT:
             return true;
             break;
         case LOGIN_LOGINCODE:
             $logincode = loadvarSurvey('primkey');
             $result = $db->selectQuery('select count(*), primkey from ' . Config::dbSurvey() . '_respondents where aes_decrypt(logincode, \'' . Config::loginCodeKey() . '\') = \'' . prepareDatabaseString($logincode) . '\'');
             //echo 'select count(*), primkey from ' . Config::dbSurvey() . '_respondents where aes_decrypt(logincode, "' . Config::loginCodeKey() . '") = "' . prepareDatabaseString($logincode) . '"';
             $row = $db->getRow($result);
             if ($row[0] == 1) {
                 $_SESSION['PRIMKEY'] = $row['primkey'];
                 return true;
             } else {
                 $logactions = new LogActions();
                 $logactions->addAction('', '', "loginwrong", USCIC_SURVEY);
             }
             break;
     }
     return false;
 }
Exemplo n.º 14
0
 function removePort()
 {
     /*	Remove a single port from a template */
     global $dbh;
     if (!$this->getport()) {
         return false;
     }
     $sql = "DELETE FROM fac_TemplatePowerPorts WHERE TemplateID={$this->TemplateID} AND PortNumber={$this->PortNumber};";
     if (!$dbh->query($sql)) {
         //delete failed, wtf
         return false;
     } else {
         class_exists('LogActions') ? LogActions::LogThis($this) : '';
         return true;
     }
 }
Exemplo n.º 15
0
 function surveyEntry()
 {
     global $engine;
     if ($this->checkDateTime() == false) {
         /* get whatever the language is (either post or default) and use it */
         $l = getSurveyLanguage();
         if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
             require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
             // language
         } else {
             require_once 'language_en.php';
             // fall back on english language file
         }
         $login = new Login(session_id());
         return $login->getClosedScreen();
     }
     $logactions = new LogActions();
     $nosessionactions = $logactions->getNumberOfSurveyActionsBySession($this->phpid, USCIC_SURVEY);
     /* no entry yet, then ask for prim_key in login screen */
     if ($nosessionactions == 0 || loadvarSurvey(POST_PARAM_NEW_PRIMKEY) == '1') {
         //no entry yet: ask for prim_key!
         if (loadvarSurvey(POST_PARAM_NEW_PRIMKEY) == '1') {
             $logactions->deleteLoggedInSurveySession($this->phpid);
         }
         /* get whatever the language is (either post or default) and use it */
         $l = getSurveyLanguage();
         if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
             require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
             // language
         } else {
             require_once 'language_en.php';
             // fall back on english language file
         }
         $logactions->addAction('', '', "loginstart", USCIC_SURVEY, 1);
         $login = new Login($this->phpid);
         return $login->getLoginScreen();
     } else {
         //entry: is this person logged in?
         $loggedin = $logactions->getLoggedInSurveySession($this->phpid);
         // gets the last logged in action
         /* no prim_key assigned to this sessionid. Assign if given (and check for pwd etc??)! */
         if ($loggedin["count"] == 0) {
             /* we don't have active session, so take the template we can get */
             global $survey;
             require_once "display/templates/displayquestion_" . getSurveyTemplate() . ".php";
             // we don't have an active session, so fall back to whatever was passed along as language in post OR is the default language
             $l = getSurveyLanguage();
             if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
                 //echo 'well done';
                 require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
                 // language
             } else {
                 require_once 'language_en.php';
                 // fall back on english language file
             }
             $primkey = loadvarSurvey(POST_PARAM_PRIMKEY);
             $_SESSION['PRIMKEY'] = $primkey;
             if ($primkey != '' && strlen($primkey) < 20) {
                 // make sure primkey is not encrypted!
                 //check!!!!!!
                 $login = new Login($this->phpid);
                 if ($login->checkAccess()) {
                     $primkey = $_SESSION['PRIMKEY'];
                     $logactions->addAction($primkey, '', "loggedin", USCIC_SURVEY, 1);
                     // pass along primkey to load correct engine!
                     $engine = loadEngine(getSurvey(), $primkey, $this->phpid, getSurveyVersion(), getSurveySection(getSurvey(), $primkey));
                     $engine->setFirstForm(true);
                     return $engine->getNextQuestion();
                 } else {
                     // incorrect login..start new session
                     endSession();
                     session_start();
                     session_regenerate_id(true);
                     $logactions->addAction('', '', "loginempty", USCIC_SURVEY, 1);
                     $login = new Login(session_id());
                     global $survey;
                     return $login->getLoginScreen($survey->getLoginError());
                 }
             } else {
                 $logactions->addAction('', '', "loginempty", USCIC_SURVEY, 1);
                 $login = new Login($this->phpid);
                 global $survey;
                 if ($survey->getAccessType() == LOGIN_ANONYMOUS) {
                     return $login->getLoginScreen(Language::messageEnterPrimKey());
                 } else {
                     if ($survey->getAccessType() == LOGIN_LOGINCODE) {
                         return $login->getLoginScreen($survey->getLoginError());
                     } else {
                         return $login->getLoginScreen(Language::messageEnterPrimKeyDirectAccess());
                     }
                 }
             }
         } else {
             //continue interview! EXTRA CHECK!!!
             /* update survey info with what we know from the last session action */
             setSurvey($loggedin["suid"]);
             /* include survey template now that we know which survey we are in */
             global $survey;
             require_once "display/templates/displayquestion_" . getSurveyTemplate() . ".php";
             /* update interview mode with what we know from the last session action
              * IF we are not changing the interview mode right now
              */
             if (isset($_POST['navigation']) && $_POST['navigation'] != NAVIGATION_MODE_CHANGE && $survey->getReentryMode() == MODE_REENTRY_YES) {
                 setSurveyMode($loggedin["mode"]);
             }
             /* update language with what we know from the last session action 
              * IF we are not changing the language right now
              */
             if (isset($_POST['navigation']) && $_POST['navigation'] != NAVIGATION_LANGUAGE_CHANGE && $survey->getReentryLanguage(getSurveyMode()) == LANGUAGE_REENTRY_YES) {
                 setSurveyLanguage($loggedin["language"]);
             }
             /* update version with what we know from the last session action */
             setSurveyVersion($loggedin["version"]);
             // include language file
             $l = getSurveyLanguage();
             //echo 'NOW: ' . $l;
             if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
                 //echo 'well done';
                 require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
                 // language
             } else {
                 require_once 'language_en.php';
                 // fall back on english language file
             }
             // pass along primkey to load correct engine!
             $engine = loadEngine(getSurvey(), $loggedin["primkey"], $this->phpid, getSurveyVersion(), getSurveySection(getSurvey(), $loggedin["primkey"]));
             /* handle button click */
             return $engine->getNextQuestion();
         }
     }
 }
Exemplo n.º 16
0
 /**
  * Receives the data from any of the 2 clear assignments functions
  */
 private function delete_assignments($arguments)
 {
     $this->clients = $arguments['clients'];
     $this->groups = $arguments['groups'];
     $this->owner_id = $arguments['owner_id'];
     /**
      * Get a list of clients names for the log
      */
     if (!empty($this->clients)) {
         $this->delete_clients = implode(',', array_unique($this->clients));
         $this->statement = $this->dbh->prepare("SELECT id, name FROM " . TABLE_USERS . " WHERE FIND_IN_SET(id, :clients)");
         $this->statement->bindParam(':clients', $this->delete_clients);
         $this->statement->execute();
         $this->statement->setFetchMode(PDO::FETCH_ASSOC);
         while ($this->row = $this->statement->fetch()) {
             $this->clients_names[$this->row['id']] = $this->row['name'];
         }
         /** Remove existing assignments of this file/clients */
         $this->statement = $this->dbh->prepare("DELETE FROM " . TABLE_FILES_RELATIONS . " WHERE file_id = :file_id AND FIND_IN_SET(client_id, :clients)");
         $this->statement->bindParam(':file_id', $this->file_id, PDO::PARAM_INT);
         $this->statement->bindParam(':clients', $this->delete_clients);
         $this->statement->execute();
         /** Record the action log */
         foreach ($this->clients as $this->deleted_client) {
             $new_log_action = new LogActions();
             $log_action_args = array('action' => 10, 'owner_id' => $this->owner_id, 'affected_file' => $this->file_id, 'affected_file_name' => $this->file_name, 'affected_account' => $this->deleted_client, 'affected_account_name' => $this->clients_names[$this->deleted_client]);
             $new_record_action = $new_log_action->log_action_save($log_action_args);
         }
     }
     /**
      * Get a list of groups names for the log
      */
     if (!empty($this->groups)) {
         $this->delete_groups = implode(',', array_unique($this->groups));
         $this->statement = $this->dbh->prepare("SELECT id, name FROM " . TABLE_GROUPS . " WHERE FIND_IN_SET(id, :groups)");
         $this->statement->bindParam(':groups', $this->delete_groups);
         $this->statement->execute();
         $this->statement->setFetchMode(PDO::FETCH_ASSOC);
         while ($this->row = $this->statement->fetch()) {
             $this->groups_names[$this->row['id']] = $this->row['name'];
         }
         /** Remove existing assignments of this file/groups */
         $this->statement = $this->dbh->prepare("DELETE FROM " . TABLE_FILES_RELATIONS . " WHERE file_id = :file_id AND FIND_IN_SET(group_id, :groups)");
         $this->statement->bindParam(':file_id', $this->file_id, PDO::PARAM_INT);
         $this->statement->bindParam(':groups', $this->delete_groups);
         $this->statement->execute();
         /** Record the action log */
         foreach ($this->groups as $this->deleted_group) {
             $new_log_action = new LogActions();
             $log_action_args = array('action' => 11, 'owner_id' => $this->owner_id, 'affected_file' => $this->file_id, 'affected_file_name' => $this->file_name, 'affected_account' => $this->deleted_group, 'affected_account_name' => $this->groups_names[$this->deleted_group]);
             $new_record_action = $new_log_action->log_action_save($log_action_args);
         }
     }
 }
 function UpdateUser()
 {
     global $dbh;
     $this->MakeSafe();
     $olduser = new User();
     $olduser->UserID = $this->UserID;
     $olduser->GetUserRights();
     /* Update a user record based upon the current object attribute values, with UserID as key. */
     $sql = "UPDATE fac_User SET Name=\"{$this->Name}\", ReadAccess={$this->ReadAccess}, \n\t\t\tAdminOwnDevices={$this->AdminOwnDevices}, WriteAccess={$this->WriteAccess}, \n\t\t\tDeleteAccess={$this->DeleteAccess}, ContactAdmin={$this->ContactAdmin}, \n\t\t\tRackRequest={$this->RackRequest}, RackAdmin={$this->RackAdmin}, \n\t\t\tSiteAdmin={$this->SiteAdmin}, Disabled={$this->Disabled} \n\t\t\tWHERE UserID=\"{$this->UserID}\";";
     $this->MakeDisplay();
     class_exists('LogActions') ? LogActions::LogThis($this, $olduser) : '';
     return $dbh->exec($sql);
 }
Exemplo n.º 18
0
 /**
  * Receives the data from any of the 2 clear assignments functions
  */
 private function delete_assignments($arguments)
 {
     global $database;
     $this->clients = $arguments['clients'];
     $this->groups = $arguments['groups'];
     $this->owner_id = $arguments['owner_id'];
     /**
      * Get a list of clients names for the log
      */
     if (!empty($this->clients)) {
         $this->delete_clients = implode(',', array_unique($this->clients));
         $this->clients_names_query = "SELECT id, name FROM tbl_users WHERE id IN ({$this->delete_clients})";
         $this->clients_names_sql = $database->query($this->clients_names_query);
         while ($this->crow = mysql_fetch_array($this->clients_names_sql)) {
             $this->clients_names[$this->crow['id']] = $this->crow['name'];
         }
         $this->clean_query = "DELETE FROM tbl_files_relations WHERE file_id = '{$this->file_id}' AND client_id IN ({$this->delete_clients})";
         $this->clean_sql = $database->query($this->clean_query);
         /** Record the action log */
         foreach ($this->clients as $this->deleted_client) {
             $new_log_action = new LogActions();
             $log_action_args = array('action' => 10, 'owner_id' => $this->owner_id, 'affected_file' => $this->file_id, 'affected_file_name' => $this->file_name, 'affected_account' => $this->deleted_client, 'affected_account_name' => $this->clients_names[$this->deleted_client]);
             $new_record_action = $new_log_action->log_action_save($log_action_args);
         }
     }
     /**
      * Get a list of groups names for the log
      */
     if (!empty($this->groups)) {
         $this->delete_groups = implode(',', array_unique($this->groups));
         $this->groups_names_query = "SELECT id, name FROM tbl_groups WHERE id IN ({$this->delete_groups})";
         $this->groups_names_sql = $database->query($this->groups_names_query);
         while ($this->grow = mysql_fetch_array($this->groups_names_sql)) {
             $this->groups_names[$this->grow['id']] = $this->grow['name'];
         }
         $this->clean_query = "DELETE FROM tbl_files_relations WHERE file_id = '{$this->file_id}' AND group_id IN ({$this->delete_groups})";
         $this->clean_sql = $database->query($this->clean_query);
         /** Record the action log */
         foreach ($this->groups as $this->deleted_group) {
             $new_log_action = new LogActions();
             $log_action_args = array('action' => 11, 'owner_id' => $this->owner_id, 'affected_file' => $this->file_id, 'affected_file_name' => $this->file_name, 'affected_account' => $this->deleted_group, 'affected_account_name' => $this->groups_names[$this->deleted_group]);
             $new_record_action = $new_log_action->log_action_save($log_action_args);
         }
     }
 }
Exemplo n.º 19
0
 function Search($num_rec_per_page = 0, $page = 1)
 {
     $this->MakeSafe();
     // This will store all our extended sql
     $sqlextend = "";
     foreach ($this as $prop => $val) {
         if ($val && $val != date("Y-m-d", strtotime(0))) {
             extendsql($prop, $val, $sqlextend, true);
         }
     }
     $sqlextend .= " ORDER BY Time DESC";
     // Make sure someone didn't do something crazy with the input
     $page = intval($page);
     $num_rec_per_page = intval($num_rec_per_page);
     if ($page && $num_rec_per_page) {
         $start_from = ($page - 1) * $num_rec_per_page;
         $sqlextend .= " LIMIT {$start_from}, {$num_rec_per_page}";
     }
     $sql = "SELECT * FROM fac_GenericLog{$sqlextend};";
     $events = array();
     foreach ($this->query($sql) as $dbRow) {
         $events[] = LogActions::RowToObject($dbRow);
     }
     return $events;
 }