Skip to content

Snippets

Simple directory listing script

<?php

/*
 *   Dili is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   Dili is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Dili; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
********************************************************************************
 *  
 * This is the Dili (DIrectory LIsting) script v0.0.1.
 * Place the index.php in the directory you want listed, simple as that. :)
 *  
 * Jorge Barrera Grandon 
 * Atlantiscrew 
 *
 */

$title = basename(dirname(__FILE__)).'/';

        echo '';
        echo '';
        echo '';
        echo ''.$title.'';
        echo '';
        echo '';
        echo '';
        echo 'Directory listing of '.$title.'';

        $dir = opendir(".");

        while(FALSE !== ($file = readdir($dir))) {
            if($file != "." && $file != ".." && $file != "index.php") {
                $myFiles[] = "$file";
            }
        }

        closedir($dir);
        sort($myFiles);
        reset($myFiles);

        foreach($myFiles as $value) {
            if (is_dir($value)) {
                echo '[d] - '.$value.'/';
        } else {
                echo '[f] - '.$value.'';
            }
        }

        echo '';
        echo '';
            echo '';
                echo '';
            echo '';
            echo '';
                echo '';
            echo '';
        echo '';
        echo '';
        echo '';
?>

Create a DVD with growisofs

#!/bin/sh

# Create an AUDIO_TS subdirectory if it does not exist
[ ! -d AUDIO_TS ] && mkdir AUDIO_TS

chown -R root:root AUDIO_TS VIDEO_TS
chmod 500 AUDIO_TS VIDEO_TS
chmod 400 VIDEO_TS/*

growisofs -dvd-compat -Z /dev/dvd -R -J -dvd-video .

Mount iso

mount -t iso9660 -o ro,loop=/dev/loop0 /var/tmp/some.iso /mnt/cdrom

encrypt

#!/usr/bin/perl

# Shows your encrypted password

print "Enter your password: ";
chomp($password = );
$salt = sprintf("%02x",($$^time^rand)&0xFF);
print "Your encrypted password is: ".crypt($password,$salt)."\n";

xsu

#!/bin/sh

# Program to run X-programs as root
# (when you get the "**WARNING** cannot open display" message)

su - -c "exec env DISPLAY='$DISPLAY'
XAUTHORITY='${XAUTHORITY-$HOME/.Xauthority}'
"'"$SHELL"'" -c '$*'"