Ejemplo n.º 1
0
 static function init()
 {
     self::$text = Text::sharedInstance();
     self::$route = Route::sharedInstance();
     self::$database = Database::sharedInstance();
     self::$view = View::sharedInstance();
 }
Ejemplo n.º 2
0
function run($params)
{
    $id = (int) $params['id'];
    $url = KY::getRoute()->urlForRoute("job.curlbackup", array('id' => $id));
    $cmd = "curl " . $url . " >> backup-in-background.log &";
    system($cmd);
    header("Location: " . KY::getRoute()->urlForRoute('home'));
    die;
}
Ejemplo n.º 3
0
function addShowTables()
{
    $host = $_POST['host'];
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $database = $_POST['database'];
    $prefix = $_POST['prefix'];
    $rows = ModelDb::sharedInstance()->showTables($host, $user, $pass, $database, $prefix);
    $params = array('rows' => $rows);
    KY::getView()->draw('db.add.showtables', $params);
}
Ejemplo n.º 4
0
function addShowFiles()
{
    echo "<script>\n";
    echo "var checkedValue = '';";
    echo "\$('.checkbox').change(function() { if(this.checked) { checkedValue = this.val();} });";
    echo "\$('.ignored').append( checkedValue );";
    echo "</script>\n";
    echo "</head>\n";
    $currentDir = exec('pwd', $return);
    $dir = $_POST['path'];
    $ignored = array_map('trim', explode(",", $_POST['ignored']));
    $res = scandir($dir, 1);
    if (!$res) {
        echo "The path is not correct, please try again. For example, the path of the current file is: {$currentDir}";
    } else {
        $result = array();
        foreach ($res as $key => $value) {
            if ($value === '.' || $value === '..' || in_array($value, $ignored)) {
                continue;
            }
            if (is_dir($dir . '/' . $value)) {
                //code to use if directory
                $result['folders'][] = $value;
            } else {
                $result['files'][] = $value;
            }
        }
        foreach ($result as $k => $r) {
            echo '<h3 style="text-transform:capitalize;">' . $k . ': ' . count($r) . '</h3>';
            echo '<ul>';
            for ($i = 0; $i < count($r); $i++) {
                echo '<li style="list-style-type:none;"><input class="checkbox" type="checkbox" value="' . $r[$i] . '" />' . $r[$i] . '</li>';
            }
            echo '</ul>';
        }
    }
    echo 'Do you wish to exclude other files or folders?';
    echo '<form method="POST" action="' . KY::getRoute()->urlForRoute('path.add.save') . '">';
    echo '<input type="hidden" name="path" value="' . $_POST['path'] . '"/>';
    echo '<input id="ignored" type="input" name="ignored" value="' . $_POST['ignored'] . '"/><br/>';
    echo '<input type="submit" name="submit" value="Save"/>';
    echo '</form>';
}
Ejemplo n.º 5
0
<?php

echo '<form method="POST" action="' . KY::getRoute()->urlForRoute('job.add.save') . '">';
echo '<fielset>';
echo 'Choose a name for this job:<br/>';
echo '<input type="text" name="name" value=""/><br/>';
echo '</fielset>';
echo '<fielset>';
echo 'Choose a database:<br/>';
foreach ($params['db'] as $db) {
    echo '<input type="checkbox" name="dbId" value="' . $db->id . '">' . $db->dbname . '<br/>';
}
echo '</fielset>';
echo '<fielset>';
echo 'Choose a path:<br/>';
foreach ($params['path'] as $path) {
    echo '<input class="checkbox" type="checkbox" name="pathId" value="' . $path->id . '">' . $path->path . '<br/>';
}
echo '</fielset>';
echo '<fielset>';
echo 'Choose a recurrence:<br/>';
echo '<select name="recurrence">';
echo '<option value="never">Never</option>';
echo '<option value="daily">Daily</option>';
echo '<option value="weekly">Weekly</option>';
echo '<option value="weekly">Monthly</option>';
echo '</select>';
echo '</fielset><br/>';
echo '<input type="submit" name="submit" value="Save"/>';
echo '</form>';
Ejemplo n.º 6
0
<?php

$text = KY::getText();
$route = KY::getRoute();
$currentRoute = $route->getCurrentRoute();
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
    <head>
        <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
        <link rel="stylesheet" type="text/css" href="<?php 
echo $route->getBaseUrl();
?>
/static/styles.css">
            <title>KY BACKUP</title>

    </head>
    <body>
        <div id="container">

            <h1><?php 
echo '<a href="' . $route->urlForRoute('home') . '">' . $text->textForKey('title') . '</a></h1>';
?>
                <p class="byline">by <strong><a href="http://www.kalianey.com" target="_blank"/>Kalianey</a></strong></p>
    
<?php 
echo '<div class="main_menu">';
echo '<ul>';
echo '<li><a href="' . $route->urlForRoute('home') . '">' . $text->textForKey('home') . '</a></li>';
echo '<li><a href="' . $route->urlForRoute('job.index') . '">' . $text->textForKey('jobs') . '</a>';
Ejemplo n.º 7
0
<?php

echo '<form method="POST" action="' . KY::getRoute()->urlForRoute('db.add.showtables') . '">';
echo '<table>';
echo '<tr>';
echo '<td>Host:</td>';
echo '<td><input type="text" name="host" value="localhost"/></td>';
echo '</tr>';
echo '<tr>';
echo '<td>User:</td>';
echo '<td><input type="text" name="user" value="kalianey_bandcka"/></td>';
echo '</tr>';
echo '<tr>';
echo '<td>Password:</td>';
echo '<td><input type="password" name="pass" value="Fxvcoar123"/></td>';
echo '</tr>';
echo '<tr>';
echo '<td>Database:</td>';
echo '<td><input type="text" name="database" value="kalianey_bandc1"/></td>';
echo '</tr>';
echo '<tr>';
echo '<td>Prefix <i>(if any)</i>:</td>';
echo '<td><input type="text" name="prefix" value=""/></td>';
echo '</tr>';
echo '</table>';
echo '<td><input type="submit" name="submit" value="Test"/></td>';
echo '</form>';
Ejemplo n.º 8
0
 function deleteAssociatedJob($id, $entityType)
 {
     $sql = "DELETE FROM ky_kybackup_job_configuration WHERE " . $entityType . "Id=" . $id;
     KY::getDB()->query($sql);
 }
Ejemplo n.º 9
0
 function __construct()
 {
     $this->db = KY::getDB();
 }
Ejemplo n.º 10
0
<?php

echo '<table>';
echo '<tr>';
echo '<td style="width: 80px;">Host</td>';
echo '<td style="width: 140px;">Username</td>';
echo '<td style="width: 140px;">DB Name</td>';
echo '<td style="width: 80px;">' . KY::getText()->textForKey('label.prefix') . '</td>';
echo '</tr>';
foreach ($params['rows'] as $row) {
    echo '<tr>';
    echo '<td>' . $row->host . '</td>';
    echo '<td>' . $row->username . '</td>';
    echo '<td>' . $row->dbname . '</td>';
    echo '<td>' . $row->prefix . '</td>';
    echo '<td><a class="button" href="' . KY::getRoute()->urlForRoute('db.delete', array('id' => $row->id)) . '">Delete</a></td>';
    echo '</tr>';
}
echo '</table>';
echo '</form>';
Ejemplo n.º 11
0
<?php

KY::getRoute()->addRoute('/', 'home', 'home', 'index');
KY::getRoute()->addRoute('/job', 'job.index', 'job', 'index');
KY::getRoute()->addRoute('/job/add', 'job.add', 'job', 'add');
KY::getRoute()->addRoute('/job/add/save', 'job.add.save', 'job', 'addSave');
KY::getRoute()->addRoute('/job/delete/:id', 'job.delete', 'job', 'delete');
KY::getRoute()->addRoute('/job/run/:id', 'job.run', 'job', 'run');
KY::getRoute()->addRoute('/job/curl-backup/:id', 'job.curlbackup', 'job', 'curlBackup');
KY::getRoute()->addRoute('/db', 'db.index', 'db', 'index');
KY::getRoute()->addRoute('/db/delete/:id', 'db.delete', 'db', 'delete');
KY::getRoute()->addRoute('/db/add', 'db.add', 'db', 'addForm');
KY::getRoute()->addRoute('/db/add/showtables', 'db.add.showtables', 'db', 'addShowTables');
KY::getRoute()->addRoute('/db/add/save', 'db.add.save', 'db', 'addSave');
KY::getRoute()->addRoute('/path', 'path.index', 'path', 'index');
KY::getRoute()->addRoute('/path/add', 'path.add', 'path', 'addForm');
KY::getRoute()->addRoute('/path/add/showfiles', 'path.add.showfiles', 'path', 'addShowFiles');
KY::getRoute()->addRoute('/path/add/save', 'path.add.save', 'path', 'addSave');
KY::getRoute()->addRoute('/path/delete/:id', 'path.delete', 'path', 'delete');
Ejemplo n.º 12
0
<?php

echo '<form method="POST" action="' . KY::getRoute()->urlForRoute('path.add.showfiles') . '">';
echo '<table>';
echo '<tr>';
echo '<td>Path:</td>';
echo '<td><input type="text" name="path" value="/Applications/XAMPP/xamppfiles/htdocs/backup"/></td>';
echo '</tr>';
echo '<tr>';
echo '<td>Files and folders to ignore (separated by a comma):</td>';
echo '<td><input type="text" name="ignored" value=""/></td>';
echo '</tr>';
echo '</table>';
echo '<td><input type="submit" name="submit" value="Test"/></td>';
echo '</form>';
Ejemplo n.º 13
0
 function getCurrentRoute()
 {
     $urlQuery = isset($_GET[$this->urlVarName]) ? $_GET[$this->urlVarName] : '/';
     $currentRoute = KY::getRoute()->routeByUrl($urlQuery);
     return $currentRoute;
 }
Ejemplo n.º 14
0
 public function backupFiles($path, $ignored)
 {
     $backupdir = './ky_backups/';
     if (!is_dir($backupdir)) {
         mkdir($backupdir, 0777, true);
     }
     $date = date('Y-m-d_His');
     $filename = $backupdir . 'file-backup_' . $date . ".zip";
     $ignoredArray = array_map('trim', explode(",", $ignored));
     $exclude = "-x ky_backups/* ";
     //here need to exclude full folder
     for ($i = 0; $i < count($ignoredArray); $i++) {
         $exclude .= '-x ' . $ignoredArray[$i] . '/* ';
     }
     $logfile = './last_backup_file.log';
     $cmd = "zip -r {$filename} ./ {$exclude}";
     system('echo "[' . $date . '] BACK START --------------------------------------" > ' . $logfile);
     system($cmd . ' >> ' . $logfile);
     system('echo "[' . $date . '] BACK FINISH -------------------------------------" >> ' . $logfile);
     echo 'Done! Files Backup completed: `' . KY::getRoute()->getBaseUrl() . $filename . '`<br/>';
     return KY::getRoute()->getBaseUrl() . $filename;
 }
Ejemplo n.º 15
0
<?php

include 'config.php';
KY::init();
KY::getText()->setLanguage($language);
KY::getDB()->connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db);
KY::getView()->setBasePath($viewPath);
KY::getRoute()->setBaseUrl($baseurl);
KY::getRoute()->setUrlVar($urlVarName);
include 'routes.php';
KY::getView()->draw('header');
$currentRoute = KY::getRoute()->getCurrentRoute();
KY::getRoute()->loadRoute($currentRoute);