Script

Filter
2020-06-07

Telefon-länk

Html
Klicka för att ringa!
<a href="tel:1-562-867-5309">Click to Call!</a> 
2019-06-12

Wildcards i DNS

Provider
Inställningar i DNS
2
* = Whatever subdomän
@ = utan www (eller subdomän)
2018-12-03

General Tree Class

Php
A general class for constructing recursive trees (that can include a list of other trees of the same class as the tree itself)
<?php
/**
Copyright Rolf Fredriksson ROSiRO Dec 2018. https://www.webman.se

General class that collects a recursive tree of tree objects from database.
Uses 4 fields: id, parent_id, name and place from a given table stored in
the global variable $db_table. The top parent id is 0 and all other objects
must track up to this.

The class can be changed by altering the sql question, for instance
to display and sort on other fields or by adding a global variable
to keep track on which parts of the Tree that is in use.

Use like this:
// 1. Create top object: id, path to parent, name
$oTree = new Tree(0, array(0), 'top');

// 2. Build a tree of Tree objects: Tree object, path
$oTree->buildTree($oTree, array(0));

// 3. Use the object (as many times you want)
function showTree($oTree) {
    foreach($oTree->getSubtrees() as $o) {
        echo $o->getName(), '<br />';
        // Do something more...
        showTree($o); // Recursive call
    }
}
showTree($oTree);
*/

class Tree {
    
    protected $id;       // int
    protected $aPath;    // array of parent ids, from top level down
    protected $name;     // str
    protected $subtrees; // array of objects
    
    function __construct($id, $aPath, $name) {
        $this->id       = intval($id);
        $this->aPath    = $aPath;
        $this->name     = $name;
        $this->subtrees = array();
    }
    
    function buildTree($oTree, $aPath) {

        global $conn, $db_table;

        // Get last id from path and use it as parent to get the sub-items...
        $sql = "select * from " . $conn->escape($db_table) .
        " where parent_id = " . $aPath[count($aPath) - 1] . " order by place";
        $rs = $conn->getResult($sql);
        
        foreach (new LimitIterator($rs, 0) as $row) {
            
            // Copy the path array and add the new id...
            $path = $aPath; 
            $path[] = $row['id'];
            
            // Create and add a new sub-tree with that id and path...
            $tree = new Tree($row['id'], $path, $row['name']);
            $oTree->subtrees[] = $tree;
            
            // Build the new tree...
            $this->buildTree($tree, $path); // Recursive call
            
        }
        
    }
    
    function getId()       { return $this->id; }
    function getParentId() { return $this->aPath[count($this->aPath) - 2]; }
    function getPath()     { return $this->aPath; }
    function getLevel()    { return count($this->aPath) - 2; }
    function getName()     { return $this->name; }
    function getSubtrees() { return $this->subtrees; }

} ?> 
2018-11-11

Traceroute

Tips & tricks
Trace a web address
In windows cmd:
tracert -d www.mydomain.com
2018-09-28

Avstånd i css3

Css
Räkna ut avstånd med calc i css3
3
#theCalcDiv {
    background:green;
    height: -moz-calc(100% - (20px + 30px));
    height: -webkit-calc(100% - (20px + 30px));
    height: calc(100% - (20px + 30px));
    display:block
}
🙂