Esempio n. 1
0
function parseOneItem($item)
{
    global $enableForceDeletion;
    eLog('*** Parse item ' . $item);
    $lines = file($item, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    $cnt = count($lines);
    if ($cnt > 3) {
        $dirs = array();
        $force_delete = intval($lines[$cnt - 1]) == 2 && $enableForceDeletion;
        $is_multi = intval($lines[$cnt - 2]);
        $base_path = $lines[$cnt - 3];
        unset($lines[$cnt - 3]);
        unset($lines[$cnt - 2]);
        unset($lines[$cnt - 1]);
        if (!$force_delete || !$is_multi) {
            foreach ($lines as $file) {
                if (@unlink($file)) {
                    eLog('Successfully delete file ' . $file);
                } else {
                    eLog('FAIL Delete file ' . $file);
                }
                if ($is_multi) {
                    $dir = $base_path;
                    $file = substr($file, strlen($base_path) + 1);
                    $pieces = explode('/', $file);
                    for ($i = 0; $i < count($pieces) - 1; $i++) {
                        $dir .= '/';
                        $dir .= $pieces[$i];
                        $dirs[] = $dir;
                    }
                }
            }
        }
        if ($is_multi) {
            if ($force_delete) {
                if (@deleteDir($base_path)) {
                    eLog('Successfully forced delete dir ' . $base_path);
                } else {
                    eLog('FAIL force delete dir ' . $base_path);
                }
            } else {
                $dirs = array_unique($dirs);
                usort($dirs, create_function('$a,$b', 'return strrpos($b,"/")-strrpos($a,"/");'));
                foreach ($dirs as $dir) {
                    if (@rmdir($dir)) {
                        eLog('Successfully delete dir ' . $dir);
                    } else {
                        eLog('FAIL delete dir ' . $dir);
                    }
                }
                if (@rmdir($base_path)) {
                    eLog('Successfully delete dir ' . $base_path);
                } else {
                    eLog('FAIL delete dir ' . $base_path);
                }
            }
        }
    }
}
Esempio n. 2
0
 function start()
 {
     global $db;
     $bot = $db->selectObject('bots', 'name="' . $this->name() . '"');
     while ($bot->state > 0) {
         eLog(time() . " - Bots Rock!", '', '', 1);
         $bot = $db->selectObject('bots', 'name="' . $this->name() . '"');
         sleep(1);
     }
 }
Esempio n. 3
0
 public function fire()
 {
     $convo = $this->method . " " . $this->url . "&ajax_action=1 HTTP/1.1\r\n";
     if ($this->method == 'POST') {
         $convo .= "Content-Type: multipart/form-data";
     }
     $convo .= "Host: " . HOSTNAME . "\r\n";
     $convo .= "User-Agent:  ExponentCMS/" . EXPONENT_VERSION_MAJOR . "." . EXPONENT_VERSION_MINOR . "." . EXPONENT_VERSION_REVISION . "  Build/" . EXPONENT_VERSION_ITERATION . " PHP/" . phpversion() . "\r\n";
     $convo .= "Connection: Close\r\n\r\n";
     try {
         $theSpawn = fsockopen(HOSTNAME, 80);
         try {
             fwrite($theSpawn, $convo);
             sleep(1);
             fclose($theSpawn);
         } catch (Exception $error) {
             eLog("Error writing to socket: <br />", '', '', 1);
             eLog($error->getMessage(), '', '', 1);
         }
     } catch (Exception $error) {
         eLog("Error opening socket: <br />", '', '', 1);
         eLog($error->getMessage(), '', '', 1);
     }
 }
Esempio n. 4
0
                    $valid_entry = 0;
                    $commit = "rollback";
                }
                $sql = "DELETE FROM `articles-languages` WHERE A_ID = '" . $item[$i] . "'";
                $query = mysql_query($sql);
                if (!$query) {
                    $valid_entry = 0;
                    $commit = "rollback";
                }
                $sql = "DELETE FROM `articles-galleries` WHERE A_ID = '" . $item[$i] . "'";
                $query = mysql_query($sql);
                if (!$query) {
                    $valid_entry = 0;
                    $commit = "rollback";
                }
            }
            //START: REPORT ACTION TO THE LOG FILE
            $elog_action = "Διαγραφή Άρθρων από τη Διαχείριση Ανάκτησης";
            include "functions.php";
            eLog($elog_action);
            //END: REPORT ACTION TO THE LOG FILE
            break;
        default:
            $valid_entry = 0;
    }
    //End Transaction - Commit or Rollback
    mysql_query($commit);
    require "db_disconnect.php";
}
//Redirection
header('Location: ../?action=restore_manager&validation=' . $valid_entry . '&' . $tab_select);
Esempio n. 5
0
    exit('');
}
if (expPermissions::check('extensions', expCore::makeLocation('administrationmodule'))) {
    // turn on the bot
    $bot = $db->selectObject('bots', 'id=' . $_REQUEST['id']);
    $bot->state = 1;
    $db->updateObject($bot, 'bots');
    // start the bot
    $convo = "GET " . PATH_RELATIVE . "index.php?module=bots&action=run_bot&id=" . $_REQUEST['id'] . "&ajax_action=1 HTTP/1.1\r\n";
    $convo .= "Host: " . HOSTNAME . "\r\n";
    $convo .= "User-Agent:  ExponentCMS/" . EXPONENT_VERSION_MAJOR . "." . EXPONENT_VERSION_MINOR . "." . EXPONENT_VERSION_REVISION . "  Build/" . EXPONENT_VERSION_ITERATION . " PHP/" . phpversion() . "\r\n";
    $convo .= "Connection: Close\r\n\r\n";
    try {
        $theSpawn = fsockopen(HOSTNAME, 80);
        try {
            fwrite($theSpawn, $convo);
            sleep(1);
            fclose($theSpawn);
        } catch (Exception $error) {
            eLog("Error writing to socket: <br />", '', '', 1);
            eLog($error->getMessage(), '', '', 1);
        }
    } catch (Exception $error) {
        eLog("Error opening socket: <br />", '', '', 1);
        eLog($error->getMessage(), '', '', 1);
    }
    // go back to the manager
    expHistory::back();
} else {
    echo SITE_403_HTML;
}
Esempio n. 6
0
 function createTable($tablename, $datadef, $info)
 {
     $sql = "CREATE TABLE \"" . $this->prefix . "{$tablename}\" (";
     $alter_sql = array();
     foreach ($datadef as $name => $def) {
         $sql .= $this->fieldSQL($name, $def) . ",";
         // PostGres is stupid, you cant specify NOT NULL in the Create Table
         if (!isset($def[DB_INCREMENT]) || !$def[DB_INCREMENT]) {
             $alter_sql[] = 'ALTER TABLE "' . $this->prefix . $tablename . '" ALTER COLUMN "' . $name . '" SET NOT NULL';
             $default = null;
             if (isset($def[DB_DEFAULT])) {
                 $default = $def[DB_DEFAULT];
             }
             if (isset($def[DB_PRIMARY]) && $def[DB_PRIMARY] == true) {
                 $primary[] = $name;
             }
             if (isset($def[DB_INDEX]) && $def[DB_INDEX] > 0) {
                 if ($def[DB_FIELD_TYPE] == DB_DEF_STRING) {
                     $index[$name] = $def[DB_INDEX];
                 } else {
                     $index[$name] = 0;
                 }
             }
             if (isset($def[DB_UNIQUE])) {
                 if (!isset($unique[$def[DB_UNIQUE]])) {
                     $unique[$def[DB_UNIQUE]] = array();
                 }
                 $unique[$def[DB_UNIQUE]][] = $name;
             } else {
                 switch ($def[DB_FIELD_TYPE]) {
                     case DB_DEF_ID:
                     case DB_DEF_INTEGER:
                     case DB_DEF_TIMESTAMP:
                     case DB_DEF_DECIMAL:
                     case DB_DEF_BOOLEAN:
                         $default = 0;
                         break;
                     default:
                         $default = '';
                         break;
                 }
             }
             $alter_sql[] = 'ALTER TABLE "' . $this->prefix . $tablename . '" ALTER COLUMN "' . $name . '" SET DEFAULT ' . "'" . $default . "'";
         }
     }
     $sql = substr($sql, 0, -1);
     if (count($primary)) {
         $sql .= ", PRIMARY KEY(" . implode(",", $primary) . ")";
     }
     foreach ($unique as $key => $value) {
         $sql .= ", UNIQUE " . $key . " ( " . implode(",", $value) . ")";
     }
     $sql .= ")";
     pg_query($this->connection, $sql);
     foreach ($alter_sql as $sql) {
         #echo '//'.$sql.'<br />';
         pg_query($this->connection, $sql);
     }
     foreach ($index as $key => $value) {
         $indexes_sql = "CREATE INDEX " . $key . "_idx ON " . $this->prefix . "{$tablename} (" . $key . ");";
         eLog($indexes_sql);
         pg_query($indexes_sql);
     }
 }