示例#1
0
文件: hole.php 项目: Jintha/cama
 /**
  * Delete a hole, removing all files (both from the database and the disk)
  *
  * @static
  * @param int $id ID of the hole to delete
  * @return void
  **/
 function delete($id)
 {
     global $wpdb;
     $hole = DH_Hole::get($id);
     $files = DH_File::get_all($id);
     if (count($files) > 0) {
         foreach ($files as $file) {
             DH_File::delete($file->id);
         }
     }
     $options = get_option('drainhole_options');
     if (isset($options['delete_file']) && $options['delete_file'] && is_writable($hole->directory)) {
         @unlink($hole->directory . '/.htaccess');
         @rmdir($hole->directory);
     }
     $wpdb->query("DELETE FROM {$wpdb->prefix}drainhole_holes WHERE id='{$id}'");
 }
示例#2
0
文件: csv.php 项目: slaFFik/l10n-ru
    header('Content-Disposition: attachment; filename="' . basename($file->file) . '.csv"');
    $stats = DH_Access::get_all($id);
    if (count($stats) > 0) {
        foreach ($stats as $stat) {
            $csv = array();
            $csv[] = $drainhole->csv_escape(date('Y-m-d', $stat->created_at));
            $csv[] = $drainhole->csv_escape(date('H:i', $stat->created_at));
            $csv[] = $drainhole->csv_escape($stat->ip);
            $csv[] = $drainhole->csv_escape($stat->speed);
            $csv[] = $drainhole->csv_escape($stat->time_taken);
            echo implode(',', $csv) . "\r\n";
        }
    }
} else {
    if ($type == 'files') {
        $hole = DH_Hole::get($id);
        header('Content-Disposition: attachment; filename="' . basename($hole->url) . '.csv"');
        $files = DH_File::get_all($id);
        if (count($files) > 0) {
            foreach ($files as $file) {
                $csv = array();
                $csv[] = $drainhole->csv_escape($file->file);
                $csv[] = $drainhole->csv_escape($file->version);
                $csv[] = $drainhole->csv_escape($file->hits);
                $csv[] = $drainhole->csv_escape(date('Y-m-d', $file->updated_at));
                $csv[] = $drainhole->csv_escape(date('H:i', $file->updated_at));
                echo implode(',', $csv) . "\r\n";
            }
        }
    } else {
        if ($type == 'holes') {
示例#3
0
文件: upgrade.php 项目: Jintha/cama
 function upgrade_from_0()
 {
     // Copy old tables
     $old = $wpdb->get_results("SELECT * FROM drainhole_files");
     if (count($old) > 0) {
         DH_Hole::create(array('url' => get_option('drainhole_store'), 'directory' => realpath(ABSPATH) . '/' . get_option('drainhole_store')));
         $hole = DH_Hole::get($wpdb->insert_id);
         foreach ($old as $row) {
             $version = $wpdb->escape($row->version);
             $file = $wpdb->escape($row->file);
             $wpdb->query("INSERT INTO {$wpdb->prefix}drainhole_files (file,hole_id,version,downloads,updated_at) VALUES ('{$file}',{$hole->id},'{$version}','{$row->downloads}',NOW())");
             $file = DH_File::get($wpdb->insert_id);
             $file->sync_modified_time($hole);
         }
     }
     // Delete old tables
     $wpdb->query("DROP TABLE drainhole_files");
     $wpdb->query("DROP TABLE drainhole_access");
 }
示例#4
0
文件: ajax.php 项目: slaFFik/l10n-ru
 function show_version($id)
 {
     $version = DH_Version::get($id);
     $file = DH_File::get($version->file_id);
     $hole = DH_Hole::get($file->hole_id);
     $this->render_admin('versions_item', array('version' => $version, 'hole' => $hole, 'file' => $file));
 }
示例#5
0
 function delete()
 {
     global $wpdb;
     $wpdb->query("DELETE FROM {$wpdb->prefix}drainhole_version WHERE id='{$this->id}'");
     $file = DH_File::get($this->file_id);
     $hole = DH_Hole::get($file->hole_id);
     $file->delete_version($this->id, $hole);
 }
示例#6
0
<?php

if (!defined('ABSPATH')) {
    die('No direct access allowed');
}
?>
<ul>
<?php 
foreach ($files as $file) {
    $hole = DH_Hole::get($file->hole_id);
    ?>
	<li><?php 
    echo $file->url($hole);
    ?>
 (<?php 
    echo $file->hits;
    ?>
)</li>
<?php 
}
?>
</ul>
示例#7
0
 /**
  * Replaces matched regular expressions with appropriate data
  * 
  * @param array $matches An array of matches from preg_replace.  $matches[1]=type, $matches[2]=ID, $matches[3]=command, $matches[4]=arguments
  * @return string New text with replaced tags
  **/
 function tags($matches)
 {
     $type = $matches[1];
     $id = intval($matches[2]);
     $cmd = $matches[3];
     $args = $matches[4];
     $options = $this->get_options();
     if ($type == 'hole') {
         $hole = DH_Hole::get($id);
         if ($hole) {
             if ($cmd == 'hits') {
                 return number_format($hole->hits);
             } else {
                 if ($cmd == 'recent') {
                     if ($args == 0) {
                         $args = 1;
                     }
                     $files = DH_File::get_recent($hole->id, $args);
                     return $this->capture('show_hole', array('files' => $files, 'hole' => $hole));
                 } else {
                     if ($cmd == 'show' && !$this->excerpt) {
                         if ($args == '') {
                             $args = 'show_hole';
                         }
                         $files = DH_File::get_all($hole->id);
                         return $this->capture($args, array('files' => $files, 'hole' => $hole));
                     }
                 }
             }
         }
     } else {
         if ($type == 'file') {
             $file = DH_File::get($id);
             if ($file) {
                 $hole = DH_Hole::get($file->hole_id);
                 if ($cmd == 'show' && !$this->excerpt) {
                     if ($args == '') {
                         $args = 'default_show';
                     }
                     return $this->tags_inline($this->capture($args, array('file' => $file, 'hole' => $hole)), $hole, $file);
                 } else {
                     if ($cmd == 'versions') {
                         $limit = 5;
                         if ($args) {
                             $limit = intval($args);
                         }
                         $versions = DH_Version::get_history($file->id, $file->version_id, $limit);
                         if (count($versions) > 0 && $options['tracker']) {
                             foreach ($versions as $pos => $version) {
                                 $versions[$pos]->reason = preg_replace('@\\#(\\d*)@', '<a href="' . $options['tracker'] . '$1">#$1</a>', $version->reason);
                             }
                         }
                         return $this->capture('versions', array('versions' => $versions, 'file' => $file, 'hole' => $hole));
                     } else {
                         if ($cmd == 'version') {
                             return $file->version;
                         } else {
                             if ($cmd == 'hits') {
                                 return number_format($file->hits);
                             } else {
                                 if ($cmd == 'name') {
                                     return $file->name();
                                 } else {
                                     if ($cmd == 'md5') {
                                         return md5($file->file($hole));
                                     } else {
                                         if ($cmd == 'url') {
                                             return $file->url($hole, $args == '' ? basename($file->file) : $args, $options['google']);
                                         } else {
                                             if ($cmd == 'href') {
                                                 return $file->url_ref($hole);
                                             } else {
                                                 if ($cmd == 'svn') {
                                                     return $file->svn();
                                                 } else {
                                                     if ($cmd == 'updated') {
                                                         return date(get_option('date_format'), $file->updated_at);
                                                     } else {
                                                         if ($cmd == 'size') {
                                                             return $file->bytes($file->filesize($hole));
                                                         } else {
                                                             if ($cmd == 'icon') {
                                                                 return $file->icon($hole, $this->url(), $options['google']);
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#8
0
文件: file.php 项目: Jintha/cama
 function create_new_version($version, $branch, $reason, $dontbranch = false, $svnupdate = false)
 {
     global $wpdb;
     $hole = DH_Hole::get($this->hole_id);
     // Branch our copy
     if ($dontbranch === false && $branch) {
         if ($hole && $this->exists($hole)) {
             $target = $this->file($hole, $this->version_id);
             @wp_mkdir_p(dirname($target));
             @copy($this->file($hole), $target);
         }
     }
     // Sort out any SVN business
     if ($this->svn && $svnupdate) {
         $options = get_option('drainhole_options');
         if ($options && isset($options['svn']) && $options['svn']) {
             include dirname(__FILE__) . '/svn.php';
             $svn = new DH_SVN($this->svn, $options['svn']);
             $svn->update($this->file($hole));
             if ($svn->version()) {
                 $version = $svn->version();
             }
         }
     }
     // Store details in a version branch
     if ($dontbranch === false) {
         $version = DH_Version::create($this, $version, $this->hits - DH_Version::total_hits($this->id), '', $reason);
         // Update our details
         $wpdb->query("UPDATE {$wpdb->prefix}drainhole_files SET updated_at=NOW(), version_id='{$version}' WHERE id={$this->id}");
     } else {
         $wpdb->query("UPDATE {$wpdb->prefix}drainhole_version SET version='{$version}', created_at=NOW() WHERE id={$this->version_id}");
     }
     return true;
 }