Пример #1
0
/**
 * Cron job
 *
 */
function garbagecollector_cron($hook, $entity_type, $returnvalue, $params)
{
    global $CONFIG;
    echo elgg_echo('garbagecollector');
    // Garbage collect metastrings
    echo elgg_echo('garbagecollector:gc:metastrings');
    if (delete_orphaned_metastrings() !== false) {
        echo elgg_echo('garbagecollector:ok');
    } else {
        echo elgg_echo('garbagecollector:error');
    }
    echo "\n";
    // Now, because we are nice, trigger a plugin hook to let other plugins do some GC
    $rv = true;
    $period = get_plugin_setting('period', 'garbagecollector');
    trigger_plugin_hook('gc', 'system', array('period' => $period));
    // Now we optimize all tables
    $tables = get_db_tables();
    foreach ($tables as $table) {
        echo sprintf(elgg_echo('garbagecollector:optimize'), $table);
        if (optimize_table($table) !== false) {
            echo elgg_echo('garbagecollector:ok');
        } else {
            echo elgg_echo('garbagecollector:error');
        }
        echo "\n";
    }
    echo elgg_echo('garbagecollector:done');
}
function Remove_files_when_user_isDel($hook, $entity_type, $returnvalue, $params)
{
    global $CONFIG;
    delete_orphaned_metastrings();
    $tables = get_db_tables();
    foreach ($tables as $table) {
        echo sprintf(elgg_echo('garbagecollector:optimize'), $table);
        if (optimize_table($table) !== false) {
            echo elgg_echo('garbagecollector:ok');
        } else {
            echo elgg_echo('garbagecollector:error');
        }
        echo "\n";
    }
}
Пример #3
0
<?php

// Create a new table that will hold geometry data for entities
$prefix = elgg_get_config('dbprefix');
$tables = get_db_tables();
if (!in_array("{$prefix}entity_geometry", $tables)) {
    set_time_limit(0);
    run_sql_script(__DIR__ . '/sql/create_table.sql');
    elgg_add_admin_notice("geo:create_table", "MySQL table for storing entity geometry with the name '{$prefix}entity_geometry' has been created");
    // Populate geometry table with know information about entities
    $batch = new ElggBatch('elgg_get_entities_from_metadata', array('metadata_name_value_pairs' => array(array('name' => 'geo:lat', 'value' => null, 'operand' => 'NOT NULL'), array('name' => 'geo:lat', 'value' => '0', 'operand' => '!='), array('name' => 'geo:long', 'value' => null, 'operand' => 'NOT NULL'), array('name' => 'geo:long', 'value' => '0', 'operand' => '!=')), 'order_by' => 'e.guid ASC', 'limit' => 0));
    $i = $k = 0;
    foreach ($batch as $b) {
        if (elgg_instanceof($b)) {
            $lat = $b->getLatitude();
            $long = $b->getLongitude();
            if ($lat && $long) {
                $query = "INSERT INTO {$prefix}entity_geometry (entity_guid, geometry)\r\n\t\t\t\t\t\t\tVALUES ({$b->guid}, GeomFromText('POINT({$lat} {$long})'))\r\n\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE geometry=GeomFromText('POINT({$lat} {$long})')";
                if (insert_data($query)) {
                    $i++;
                }
            } else {
                $k++;
            }
        }
    }
    elgg_add_admin_notice("geo:import", "'{$prefix}entity_geometry' has been populated with information about the location of {$i} entities; geographic coordinates for {$k} entities were incorrect");
}
Пример #4
0
function print_header()
{
    global $err_msg, $VERSION, $DB, $CRYPTDB, $dbh, $self, $is_sht, $xurl, $SHOW_T;
    $dbn = $DB['db'];
    ?>

<!-- HTML BODY -->


<!DOCTYPE html>
<html>
<head><title>CryptDB</title>
<link href="/menu_assets/styles.css" rel="stylesheet" type="text/css">

<style>
body
{
background-color:#E0E0E0;
}
</style>
<h1 align="center" style="color:#990000;">CryptDB</h1>
<meta charset="utf-8">

<script type="text/javascript">
var LSK='pma_',LSKX=LSK+'max',LSKM=LSK+'min',qcur=0,LSMAX=32;

function $(i){return document.getElementById(i)}
function frefresh(){
    var F=document.DF;
    F.method='get';
    F.refresh.value="1";
    F.submit();
}
function go(p,sql){
    var F=document.DF;
    F.p.value=p;
    if(sql)F.q.value=sql;
    F.submit();
}
function ays(){
    return confirm('Are you sure to continue?');
}
function chksql(){
    var F=document.DF,v=F.q.value;
    if(/^\s*(?:delete|drop|truncate|alter)/.test(v)) if(!ays())return false;
    if(lschk(1)){
        var lsm=lsmax()+1,ls=localStorage;
        ls[LSK+lsm]=v;
        ls[LSKX]=lsm;
        //keep just last LSMAX queries in log
        if(!ls[LSKM])ls[LSKM]=1;
        var lsmin=parseInt(ls[LSKM]);
        if((lsm-lsmin+1)>LSMAX){
            lsclean(lsmin,lsm-LSMAX);
        }
    }
    return true;
}
function tmv(tr){
    tr.sc=tr.className;
    tr.className='h';
}
function tmo(tr){
    tr.className=tr.sc;
}
function tc(tr){
    tr.className='s';
    tr.sc='s';
}
function lschk(skip){
    if (!localStorage || !skip && !localStorage[LSKX]) return false;
    return true;
}
function lsmax(){
    var ls=localStorage;
    if(!lschk() || !ls[LSKX])return 0;
    return parseInt(ls[LSKX]);
}
function lsclean(from,to){
    ls=localStorage;
    for(var i=from;i<=to;i++){
        delete ls[LSK+i];ls[LSKM]=i+1;
    }
}
function after_load(){
    qcur=lsmax();
}
function logoff(){
    if(lschk()){
        var ls=localStorage;
        var from=parseInt(ls[LSKM]),to=parseInt(ls[LSKX]);
        for(var i=from;i<=to;i++){
            delete ls[LSK+i];
        }
        delete ls[LSKM];delete ls[LSKX];
    }
}

<?php 
    if ($is_sht) {
        ?>
function chkall(cab){
    var e=document.DF.elements;
    if (e!=null){
        var cl=e.length;
        for (i=0;i<cl;i++){
            var m=e[i];if(m.checked!=null && m.type=="checkbox"){
                m.checked=cab.checked
            }
        }
    }
}
function sht(f){
    document.DF.dosht.value=f;
}


<?php 
    }
    ?>
</script>

</head>

<?php 
    /*
     * Footer tags
     */
    function print_footer()
    {
        ?>
</form>
</body></html>
<?php 
    }
    ?>

<body onload="after_load()">
<form method="post" name="DF" action="<?php 
    echo $self;
    ?>
" enctype="multipart/form-data">
<input type="hidden" name="XSS" value="<?php 
    echo $_SESSION['XSS'];
    ?>
">
<input type="hidden" name="refresh" value="">
<input type="hidden" name="p" value="">


<!-- HEADER MENU -->
<div class="inv">
<?php 
    if (isset($_SESSION['is_logged']) && $dbh) {
        ?>
Databases:
<select name="db" onChange="frefresh()">
<?php 
        echo get_db_select($dbn);
        ?>
</select>
Tables:
<form action="'<?php 
        echo $self;
        ?>
'" method="post" >
<select name="cryptdb_describe_table" onChange="this.form.submit()">
<?php 
        $a = 0;
        if (isset($_REQUEST['refresh'])) {
            ?>
    <option selected value="">---</option>
<?php 
        }
        $array = get_db_tables($dbn);
        foreach ($array as $key => $value) {
            $accesskey = "Tables_in_" . $dbn;
            ?>

<?php 
            if (isset($_POST['cryptdb_describe_table']) && $_POST['cryptdb_describe_table'] == $value[$accesskey]) {
                ?>
<option selected value="<?php 
                echo $value[$accesskey];
                ?>
"><?php 
                echo $value[$accesskey];
                ?>
</option>
<?php 
            } else {
                ?>
<option value="<?php 
                echo $value[$accesskey];
                ?>
"><?php 
                echo $value[$accesskey];
                ?>
</option>
<?php 
            }
            ?>


<?php 
        }
        ?>
</select>
</form>

<?php 
        if ($dbn) {
            $z = " &#183; <a href='{$self}?{$xurl}&db={$dbn}";
            if (isset($_POST['cryptdb_describe_table']) && $dbn) {
                $z . '&q=' . urlencode($var);
            }
            ?>

<?php 
        }
    }
    ?>




<?php 
    if (isset($GLOBALS['ACCESS_PWD'])) {
        ?>
 | <a href="?<?php 
        echo $xurl;
        ?>
&logoff=1" onclick="logoff()">Logoff</a> <?php 
    }
    ?>
</div>
<div class="err"><?php 
    echo $err_msg;
    ?>
</div>

<?php 
}