Tag Archives: php

KFile, a simple download-link generator for WordPress

After finally finding a nice CMS to use for my homepage, I was searching for a simple plugin that lets me

  • upload files manually using scp or other means from the command line
  • display a nice link to the file, stating name, size etc. after adding a text like [file=foo.tar.bz2]

All I found were quite large plugins using databases, using quite elaborate administration front ends. So I started writing one myself.

Usage

  • Install and activate the plugin.
  • Create a directory wordpressurl/download (alternatively, change the constant in kfile.php)
  • Upload files there
Posted in Internet | Tagged , | 2 Comments

Deleting multiple tables with a common prefix

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
//Connect to the database server and select our database
$link = mysql_connect('rdbms.strato.de', 'UXXXX', 'epsilon eridani') 
	or die('Could not connect: ' . mysql_error());
mysql_select_db('DBXXXX') or die('Could not select database');
 
//get table list
$result = mysql_query("SHOW TABLES") or die(mysql_error());
 
//kill tables
$tokillprefix = "jos_";
while($row=mysql_fetch_array($result)){
 	if(substr($row[0],0,strlen($tokillprefix)) == $tokillprefix){
	 	echo "killing $row[0] <br>\n";
		mysql_query("DROP TABLE $row[0]") or die(mysql_error());
	}
}
 
?>done
Posted in Computers | Tagged , , | Leave a comment