function install_tor()
{
    # TODO: probably a better way to update, install, and check installed
    # TODO: force installed to external SD card?
    # Check to see if tor is installed first (don't waste our time otherwise)
    if (is_tor_installed()) {
        echo 'Tor is already installed!';
        return false;
    }
    # Check to see if we are online to update and download tor
    if (online()) {
        exec('opkg update') && exec('opkg install tor');
        exec('cp /etc/tor/torrc /etc/tor/torrc.bak_' . time());
        exec('cp ' . $directory . '/torrc.pineapple /etc/tor/torrc');
        exec('/etc/init.d/tor stop');
        echo 'Tor has been installed';
        return true;
    } else {
        echo "You must be online to install tor";
        return false;
    }
}
<?php

include_once '/pineapple/includes/api/tile_functions.php';
include_once "{$directory}/functions.php";
if (!is_tor_installed()) {
    echo "<h3>Tor is not installed!<br/>Use this tile to install it first.</h3>";
    die;
}
?>
<script src=/components/infusions/torgateway/includes/js/infusion.js></script>
<script>
// To fix setting multiple intervals
if (typeof SFintervalID == 'undefined'){
	SFintervalID = setInterval(getTorSmallFrame,3000);
}
</script>


<span class="smallFrameUpdate"><?php 
include_once '/pineapple/components/infusions/torgateway/includes/small_frame.php';
?>
</span>

<fieldset>
<pre class="mini_tor_result"></pre></fieldset>