Script

Filter
2007-05-08

Kolla inställningarna

Php
Visa några serverinställningar i php.ini på en webbsida
<html>
<head>
<title>php.ini</title>
<body>
<? 
echo 'get_magic_quotes_gpc = ' , get_magic_quotes_gpc() , "<br>\n";
echo 'display_errors = ' , ini_get('display_errors') , "<br>\n";
echo 'register_globals = ' , (int)ini_get('register_globals') , "<br>\n";
echo 'post_max_size = ' , ini_get('post_max_size');
?>
</body>
</html> 
2007-05-08

Beräkna bildernas storlek

Php
Hämta bildernas storlek och generera HTML-attribut automatiskt
foreach (scandir("img") as $value) {
    if (substr($value, -4) == ".png") {
        $a = getimagesize("img/$value");
        echo "<img src=\"img/$value\" {$a[3]} alt=\"\" /><br />";
    }
}

/* Alla egenskaper (även mime mm)...
foreach (scandir("img") as $value) {
    if ($value != "." && $value != "..") {
        $a = getimagesize("img/$value");
        foreach ($a as $key => $value) {
            echo "$key = $value<br />";
        }
        echo "<hr />";
    }
}
*/ 
2007-04-24

Hängslen och livrem

Javascript
Dubbla confirmrutor på en länk
<a href="" onclick="if(confirm('Sure?')){return confirm('ABSOLUTELY SURE?');}else{return false;}">Delete</a> 
2007-04-19

Renare webbsida i windows

Javascript
Litet script som tar bort den streckade rutan runt objekt som har fokus
function blured() {
    for (a in document.links) document.links[a].onfocus = document.links[a].blur;
}
if (document.all) {
    document.onmousedown = blured;
} 
2007-04-19

Räknare

Asp
Enkel räknare i asp som skriver till en fil
<%
dim fs, ts, path, number

if not session("counted") then
    'Get current filename and path
    path=Request.ServerVariables("PATH_TRANSLATED") 
    
    'Calculate filename
    path = Left(path, instrRev(path, "\")) & "count.dat"
    
    set fs = Server.CreateObject("Scripting.FileSystemObject")
    
    'Open file for reading
    Set ts = fs.OpenTextFile(path, 1, True, -2)
    
    number = -1
    if not ts.AtEndOfStream then number=int (ts.ReadLine) + 1
    ts.Close
    
    'If reading succeded
    'Open file for writing
    Set ts = fs.OpenTextFile(path, 2, False, -2)
    
    if number < 1 then number = 1
    
    ts.WriteLine number
    ts.close
        
    session("counted")=true
    session("visitor")=number
    
    set ts = nothing
    set fs = nothing
end if
%>
🙂