Plugin Directory

Changeset 490454


Ignore:
Timestamp:
01/16/2012 04:48:54 AM (14 years ago)
Author:
Risal Affendie
Message:

Upload new version: 1.3

Location:
wp-risal-download
Files:
5 added
3 edited
8 copied

Legend:

Unmodified
Added
Removed
  • wp-risal-download/trunk/readme.txt

    r489133 r490454  
    55Requires at least: 3.0.0
    66Tested up to: 3.3.0
    7 Stable Tag: 1.2
     7Stable Tag: 1.3
    88
    99risal-download is a simple scripts to avoid download abuse(either by human or robot).
     
    6363* Replace input syntax in Record's Form with "text box" rather than "browse file". More practical for user who remote their server. Sorry, you got to type manually filename and it's path.
    6464
     65= 1.3 =
     66* Add button for file browsing.
     67
  • wp-risal-download/trunk/risal-download.php

    r489133 r490454  
    44Plugin URI: http://linuxuserjp.wordpress.com/
    55Description: Filter direct download of files. Manage how your files from outside ROOT_DIRECTORY will be downloaded. Monitor who download your files.
    6 Version: 1.2
     6Version: 1.3
    77Author: Risal Affendie
    88Author URI: http://linuxuserjp.wordpress.com
     
    5757function risal_config_page() {
    5858    if ( function_exists('add_submenu_page') )
    59     add_submenu_page('plugins.php', __('Risal Configuration'), __('Risal Configuration'), 'manage_options', 'risal', 'risal_conf');
    60 }
    61 
    62 
    63 
     59    add_submenu_page('plugins.php', __('Risal Configuration'), __('Risal Configuration'), 'manage_options', 'risal', 'risal_confx');
     60}
     61
     62function browsefs() {
     63 // Explore the files via a web interface.   
     64  $xcript = basename(__FILE__); // the name of this script
     65    if ( $_GET['path'] == "" || !isset($_GET['path']) )
     66    {
     67    $xath = $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']);
     68    } else {
     69    $xath = $_GET['path'];
     70    }
     71  //$xath = !empty($_REQUEST['path']) ? $_REQUEST['path'] : $_SERVER['DOCUMENT_ROOT'].'/'.dirname($_SERVER['PHP_SELF'])/*dirname(__FILE__)*/; // the path the script should access
     72 
     73  echo "<p>Browsing Location: <input type=text size=70 readonly=readonly value=\"{$xath}\"></p>";
     74
     75  $drtries = array();
     76  $tiles = array();
     77 
     78  // Check we are focused on a dir
     79  if (is_dir($xath)) {
     80    chdir($xath); // Focus on the dir
     81   if ($handle = opendir('.')) {
     82      while (($item = readdir($handle)) !== false) {
     83        // Loop through current directory and divide files and directorys
     84        if(is_dir($item)){
     85          array_push($drtries, realpath($item));
     86        }
     87        else
     88        {
     89          array_push($tiles, ($item));
     90        }
     91   }
     92   closedir($handle); // Close the directory handle
     93   }
     94    else {
     95      echo "<p class=\"error\">Directory handle could not be obtained.</p>";
     96    }
     97  }
     98  else
     99  {
     100    echo "<p class=\"error\">Path is not a directory</p>";
     101  }
     102 
     103  // There are now two arrays that contains the contents of the path.
     104 
     105  // List the directories as browsable navigation
     106   
     107  echo "<table><tr class=d0><td>Name</td><td>Size</td><td>Type</td></tr>";
     108  sort($drtries);
     109  $kira = 0;
     110  foreach( $drtries as $drtry ){
     111    if ( $xath !== $drtry ) {
     112    if ( $kira !== 2 ) { $kira = $kira + 1; } else { $kira = 1; }
     113    echo "<tr class=d".$kira.">";
     114    if ( dirname($xath) == $drtry ) {
     115    echo "<td><a href=\"plugins.php?page=risal&browse=true&path={$drtry}\" icon='sf'> .. </a></td>";
     116    } else {
     117    echo "<td><a href=\"plugins.php?page=risal&browse=true&path={$drtry}\" icon='sf'>".basename($drtry)."</a></td>";
     118    }
     119    echo "<td>".filesize($drtry)."</td><td>".mime_content_type($drtry)."</td></tr>";
     120    }
     121  }
     122  foreach( $tiles as $tile ){
     123    // Comment the next line out if you wish see hidden files while browsing
     124
     125    if(preg_match("/^\./", $tile) || $tile == $xcript): continue; endif; // This line will hide all invisible files.
     126    if ( $kira !== 2 ) { $kira = $kira + 1; } else { $kira = 1; }
     127    echo "<tr class=d".$kira.">";
     128        echo '<td><a href="javascript:void(0)" onClick="refreshParent(\''.$tile.'\',\''.$xath.'\');" icon="f">' . $tile . '</a></td>';
     129    echo "<td>".filesize($xath.'/'.$tile)."</td><td>".mime_content_type($xath.'/'.$tile)."</td></tr>";
     130  }
     131
     132  echo "</table>";
     133
     134}
     135
     136
     137function risal_confx() {
     138echo '<div class="wrap"><div id="icon-plugins" class="icon32"><br /></div>';
     139if ( $_GET['browse'] !== "true" )
     140{
     141echo '<h2>Risal Download Configuration</h2>';
     142risal_conf();
     143} else {
     144echo '<h2>Risal Download Configuration: Browse File</h2>';
     145browsefs();
     146}
     147}
    64148
    65149function risal_conf() {
     
    67151$rissettings = $table_prefix . 'rissettings';
    68152$risfiles = $table_prefix . 'risfiles';
    69 echo '<div class="wrap"><div id="icon-plugins" class="icon32"><br /></div>
    70     <h2>Risal Download Configuration</h2></div>
     153echo '</div>
    71154    <div class="rissdiv">';
    72155///step 1: Create alert
     
    142225///step 3: Create Editor //form to POST (insert/edit) will be here.
    143226    echo '</tbody></table><hr>
    144         <form id="myform" class="cssform" method="post" action="">';
     227        <form id="myform" name=rform class="cssform" method="post" action="">';
    145228    if ( $_POST['submit'] == "edit" && $_POST['myid'] !== "" ) {
    146229        $myid = $_POST['myid'];
     
    151234        }
    152235        $vris = "Update";
     236        $xfile = $myrow->file;
     237        $xpath = $myrow->outsidepath;
    153238        echo '<h2>Modify Record:</h2>';
     239
    154240        if ( $myrow->method == "md5" ) { $fmd5 = "checked"; $fsha1 = "";}
    155241        if ( $myrow->method == "sha1" ) { $fsha1 = "checked"; $fmd5 = ""; }
     
    161247    }
    162248    echo '<p><label for="ID">ID</label><input type=text name="myid" value="'.$tris.'"></p>
    163         <p><label for="File">Server\'s File Name</label><input type=text name="myfile" value="'.$myrow->file.'"></p>
    164         <p><label for="File Path">Server\'s File Path</label><input type=text name="mypath" value="'.$myrow->outsidepath.'"></p>
     249        <p><label for="File">Server\'s File Name</label><input type=text name="myfile" value="'.$xfile.'"></p>
     250        <p><label for="File Path">Server\'s File Path</label><input type=text name="mypath" value="'.$xpath.'"></p>
     251        <p><input type="button" value="BROWSE FILE" onclick="window.open(\'plugins.php?page=risal&browse=true\')" /></p>
    165252        <p><label for="Method">Method</label><input type="radio" name="mymeth" value="md5" '.$fmd5.'> MD5
    166253        <input type="radio" name="mymeth" value="sha1" '.$fsha1.'> SHA1</p>
     
    330417}
    331418
     419function risal_browse() {
     420echo "<script language=\"JavaScript\">
     421function refreshParent(i,j) {
     422window.opener.document.rform.myfile.value = i;
     423window.opener.document.rform.mypath.value = j;
     424window.close();
     425}
     426</script>";
     427}
     428
    332429//inserts java script into head of document
    333430add_action ( 'wp_head', 'risal_popup' );
     
    340437if ( $_GET['page'] == 'risal' ) {
    341438add_action('admin_head', 'css_admin_head');
     439add_action('admin_head', 'risal_browse');
    342440}
    343441?>
  • wp-risal-download/trunk/risal.css

    r488497 r490454  
    1 a {
    2     color: #c75f3e;
     1a[icon ^="sf"] {
     2  padding: 0 2px 1px 20px;
     3  background: transparent url(sf.gif) left center no-repeat;
     4  text-decoration: none;
     5}
     6
     7a[icon ^="f"] {
     8  padding: 0 2px 1px 20px;
     9  background: transparent url(f.gif) left center no-repeat;
     10  color: black;
    311}
    412
     
    104112margin-left: 3px;
    105113}
     114
     115tr.d0 td {
     116    background-color: #C7BBBB; color: black;
     117}
     118
     119tr.d1 td {
     120    background-color: white; color: black;
     121}
     122tr.d2 td {
     123    background-color: #E3D1D1; color: black;
     124}
Note: See TracChangeset for help on using the changeset viewer.