Пример #1
0
 function execute()
 {
     global $osC_Cache;
     if (isset($this->cache_key)) {
         if ($osC_Cache->read($this->cache_key, $this->cache_expire)) {
             $this->cache_data = $osC_Cache->cached_data;
             $this->cache_read = true;
         }
     }
     if ($this->cache_read === false) {
         if ($this->logging === true) {
             $this->logging_action = substr($this->sql_query, 0, strpos($this->sql_query, ' '));
             if ($this->logging_action == 'update') {
                 $db = split(' ', $this->sql_query, 3);
                 $this->logging_database = $db[1];
                 $test = $this->db_class->simpleQuery('select ' . implode(', ', array_keys($this->logging_fields)) . ' from ' . $this->logging_database . substr($this->sql_query, osc_strrpos_string($this->sql_query, ' where ')));
                 while ($result = $this->db_class->next($test)) {
                     foreach ($this->logging_fields as $key => $value) {
                         if ($result[$key] != $value) {
                             $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => $result[$key], 'new' => $value);
                         }
                     }
                 }
             } elseif ($this->logging_action == 'insert') {
                 $db = split(' ', $this->sql_query, 4);
                 $this->logging_database = $db[2];
                 foreach ($this->logging_fields as $key => $value) {
                     $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => '', 'new' => $value);
                 }
             } elseif ($this->logging_action == 'delete') {
                 $db = split(' ', $this->sql_query, 4);
                 $this->logging_database = $db[2];
                 $del = $this->db_class->simpleQuery('select * from ' . $this->logging_database . ' ' . $db[3]);
                 while ($result = $this->db_class->next($del)) {
                     foreach ($result as $key => $value) {
                         $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => $value, 'new' => '');
                     }
                 }
             }
         }
         $this->query_handler = $this->db_class->simpleQuery($this->sql_query, $this->debug);
         if ($this->logging === true) {
             if ($this->db_class->logging_transaction_action === false) {
                 $this->db_class->logging_transaction_action = $this->logging_action;
             }
             if ($this->affectedRows($this->query_handler) > 0) {
                 if (!empty($this->logging_changed)) {
                     if ($this->logging_action == 'insert' && !is_numeric($this->logging_module_id)) {
                         $this->logging_module_id = $this->db_class->nextID();
                         $this->setNextID($this->logging_module_id);
                     }
                     if (class_exists('osC_AdministratorsLog')) {
                         osC_AdministratorsLog::insert($this->logging_module, $this->db_class->logging_transaction_action, $this->logging_module_id, $this->logging_action, $this->logging_changed, $this->db_class->logging_transaction);
                     }
                 }
             }
         }
         if ($this->batch_query === true) {
             $this->batch_size = $this->db_class->getBatchSize($this->sql_query, $this->batch_select_field);
             $this->batch_to = $this->batch_rows * $this->batch_number;
             if ($this->batch_to > $this->batch_size) {
                 $this->batch_to = $this->batch_size;
             }
             $this->batch_from = $this->batch_rows * ($this->batch_number - 1);
             if ($this->batch_to == 0) {
                 $this->batch_from = 0;
             } else {
                 $this->batch_from++;
             }
         }
         return $this->query_handler;
     }
 }
 function deleteAdministratorsLogs()
 {
     global $toC_Json, $osC_Language;
     $error = false;
     $batch = explode(',', $_REQUEST['batch']);
     foreach ($batch as $id) {
         if (!osC_AdministratorsLog::delete($id)) {
             $error = true;
             break;
         }
     }
     if ($error === false) {
         $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
     } else {
         $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed'));
     }
     echo $toC_Json->encode($response);
 }