public function getFilter($month = "", $year = "") { $date = \DashboardHelpers::filter($month, $year, 1); foreach (\DashboardHelpers::filter($month, $year, 2) as $key => $value) { $postData[] = \DashboardHelpers::getPostCount($value); } $data['dateList'] = json_encode($date); $data['dataPost'] = json_encode($postData); return $data; }
function db_build_insert_records($table = '') { if (empty($table)) { return; } $search = array('\\x00', '\\x0a', '\\x0d', '\\x1a'); $replace = array('\\0', '\\n', '\\r', '\\Z'); $q = $this->query('SELECT * FROM ' . $table); $q->execute(); $output = ''; $output .= '--' . PHP_EOL . '-- Dumping data for table ' . $table . PHP_EOL . '--' . PHP_EOL; $output .= 'INSERT INTO ' . $table . ' VALUES ' . PHP_EOL; $rows_output = ''; while ($row = $q->fetch(PDO::FETCH_ASSOC)) { $num_fields = count($row); $j = 0; $rows_output .= "("; foreach ($row as $field) { // $field = addslashes($field); $field = str_replace("\n", "\\n", $field); $field = str_replace("\r", "\\r", $field); $field = str_replace("'", "''", $field); //$rows_output.="'" . str_replace( $search, $replace, DashboardHelpers::wp_addslashes( $field ) ) . "'"; $rows_output .= $this->quote($field); // $rows_output.= "'".$field."'" ; if ($j < $num_fields - 1) { $rows_output .= ','; } $j++; } $rows_output .= ")," . PHP_EOL; } if (!empty($rows_output)) { $rows_output = stripslashes($rows_output); $output .= DashboardHelpers::str_lreplace(',', ';', $rows_output); $output .= "\n\n\n" . PHP_EOL; return $output; } //$output.= ");\n"; }
/** * Get a list of files. * * @access public * @param int $num : The number of files to list. 0 means all the files. * @param bool $new_list : If the user want to get two lists from the same instance, he can ask to use the list previously generated instead of generating a new list. * @return bool|array : List of files. False on error. * @author Aziz Light */ public function get_files($num = 0, $options = array()) { $order = array_key_exists('order', $options) ? $options['order'] : 'lastmodified'; $new_list = array_key_exists('new_list', $options) ? $options['new_list'] : true; $recursive_size = array_key_exists('recursive_size', $options) ? $options['recursive_size'] : false; // What the f**k does return false mean? // FIXME: throw an exception, or log an error message or something... if (!is_int($num) || !is_bool($new_list)) { return false; } if ($new_list === false && isset($this->files) && count($this->files >= $num)) { return array_slice($this->files, 0, $num); } if ($handle = opendir($this->folder)) { while (($file = readdir($handle)) !== false) { if (!in_array($file, self::$excluded_files)) { // Get the modification time of folders recursively if (is_dir($this->folder . $file) && !DashboardHelpers::is_empty_dir($this->folder . $file)) { $modification_date = DashboardHelpers::get_highest_file_timestamp($this->folder . $file); $modification_date = DashboardHelpers::timespan($modification_date); if ($recursive_size) { $size = DashboardHelpers::recursive_directory_size($this->folder . $file); $size = DashboardHelpers::format_file_size($size); } else { $size = DashboardHelpers::format_file_size(filesize($this->folder . $file)); } } else { $modification_date = DashboardHelpers::timespan(filemtime($this->folder . $file)); $size = DashboardHelpers::format_file_size(filesize($this->folder . $file)); } $this->files[$file] = array('filename' => $file, 'path' => $this->folder . $file, 'folderpath' => $this->folder, 'url' => $this->url . $file, 'folderurl' => $this->url, 'modification_date' => $modification_date, 'size' => $size); } } closedir($handle); } if (!$this->order_files($order)) { // TODO: Do something to notify the user that the sort operation failed. } return array_slice($this->files, 0, $num); }
function backup_all_files() { $view_url = $this->dashboard_model->settings['view_url']; $wp_dir = $this->settings['wp_dir']; $wp_base_name = basename($wp_dir); $sfstore = $this->settings['sfstore']; $date = date('d-m-Y--H-i-s'); $file = $sfstore . 'file_backup/full/filesbackup_' . $date . '.zip'; if (DashboardHelpers::zip_all_data($wp_dir, $file)) { $this->set_message('All site files successfully archived in ' . $file); } $this->redirect('?view=' . $this->current_page); //$this->render( $view_url.'backup_success', $this->data , array($wp_dir.'wp-config.php')); }