<?php

if (!empty($_POST['sql_host']) && !empty($_POST['sql_user']) && isset($_POST['sql_pass']) && !empty($_POST['sql_db'])) {
    try {
        if ($_POST['use_ftp']) {
            $writer = new writer_ftp($_POST['ftp_host'], $_POST['ftp_user'], $_POST['ftp_pass'], $_POST['ftp_dir']);
        } else {
            $writer = new writer_fs();
        }
        // Test connections
        $db = new mysql_connection($_POST['sql_host'], $_POST['sql_user'], $_POST['sql_pass'], $_POST['sql_db']);
        // Install basic database
        initDb($db);
        // Write Config files
        if ($_POST['use_ftp']) {
            $writer->put('inc/ftp.config.php', sprintf("<?php\n\n\$ftp_host = '%s';\n\$ftp_user = '******';\n\$ftp_pass = '******';\n\$ftp_dir = '%s';\n", $_POST['ftp_host'], $_POST['ftp_user'], $_POST['ftp_pass'], $_POST['ftp_dir']));
        }
        $writer->put('inc/database.config.php', sprintf("<?php\n\n\$db = new mysql_connection( '%s', '%s', '%s', '%s');\n\$db->set_charset('utf8');\n", $_POST['sql_host'], $_POST['sql_user'], $_POST['sql_pass'], $_POST['sql_db']));
        $db->update_server->insert($server);
        // Redirect
        header('LOCATION: ' . IV_SELF);
        exit;
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
}
Example #2
0
 public function index()
 {
     global $conf;
     $categoryId = intval($_GET['category']);
     $self = MODUL_SELF . '&category=' . $categoryId;
     // upload files
     if (isset($_FILES['file']) && isset($_POST['category'])) {
         $file = $_FILES['file'];
         $category = intval($_POST['category']);
         if (!$file['name'] && !$file['tmp_name']) {
             $this->view->error('Es muss eine Datei für den Upload ausgewählt werden!');
         } elseif (!$category) {
             $this->view->error('Es muss eine Kategorie für den Upload ausgewählt werden!');
         } else {
             // May be restricted by modul rights later
             $types = array('png', 'jpg', 'jpeg', 'gif');
             $fileClass = new upload_attachment($file);
             $fileClass->restrictFileSize(1024 * 1024 * 2)->restrictType($types);
             $fileClass->attach('media', $category);
             $fileClass->save(self::UPLOAD_DIR . 'upload_' . uniqid());
             $this->view->success('Upload erfolgreich!');
         }
     }
     // move files
     if (isset($_GET['move']) && $categoryId) {
         upload_list::move($_GET['move'], $categoryId);
         throw new redirect($self);
     }
     // delete file hook
     if (isset($_GET['deleteImg'])) {
         $img = db()->t('content_upload')->row((int) $_GET['deleteImg'])->assoc();
         upload_list::delete($img['id']);
         $writer = new writer_fs();
         $writer->delete($img['path']);
         $this->view->success('Datei erfolgreich gelöscht!');
     }
     // category data controller
     $rc = new data_controller('content_upload_category', $self);
     $rc->add('id', 'ID', 1, 0, 0, 0);
     $rc->add('name', 'Name');
     // edit category form
     if ($_GET['edit']) {
         $this->view->content($rc->get_edit($_GET['edit']));
         $this->view->format = 'plain';
         return;
     }
     // delete hook
     if (isset($_GET['delete'])) {
         $list = new upload_list('media');
         if ($list->get($_GET['delete'])->num_rows()) {
             $this->view->error('Die Kategorie kann nicht gelöscht werden, da sie noch Dateien enthält!');
             $run = false;
         } else {
             $run = true;
         }
     } else {
         $run = true;
     }
     // run category actions
     if ($run && $rc->run()) {
         throw new redirect($self);
     }
     // upload form
     $uploadForm = new form_renderer($self, 'Hochladen');
     $uploadForm->select('category', 'Kategorie', array(0 => "Bitte Wählen") + db()->t('content_upload_category')->get(1)->relate(), $categoryId);
     $uploadForm->upload('file', 'Datei');
     $error = false;
     $data = array();
     // filter files by category
     if ($_GET['category'] > 0) {
         $list = new upload_list('media');
         $data = $list->get($categoryId);
         if (!$data->num_rows()) {
             $error = 'Keine Ergebnisse!';
         }
     } else {
         $error = "Keine Ergebnisse!";
     }
     // render the page
     $this->view->content(template('iv.media')->render(array('categories' => db()->t('content_upload_category')->all(), 'modul_self' => MODUL_SELF, 'current' => $categoryId, 'images' => $data, 'url' => trim($conf->page->url, '/'), 'error' => $error, 'category' => $categoryId, 'uploadForm' => $uploadForm, 'createForm' => $rc->get_create())));
 }
Example #3
0
<?php

if (file_exists('inc/ftp.config.php')) {
    require_once 'inc/ftp.config.php';
    $writer = new writer_ftp($ftp_host, $ftp_user, $ftp_pass, $ftp_dir);
} else {
    $writer = new writer_fs();
}
if (!empty($_POST)) {
    // Name Validation
    if (empty($_POST['register_name'])) {
        $error = 'Bitte Namen angeben';
    }
    if (preg_match('/[^\\w\\d]/', $_POST['register_name'], $m)) {
        $error = 'Der Name enthält ungültige Zeichen: ' . htmlspecialchars($m[0]);
    } elseif (empty($_POST['register_mail'])) {
        $error = 'Bitte E-Mail angeben';
    } elseif (!($mail = filter_var($_POST['register_mail'], FILTER_VALIDATE_EMAIL))) {
        $error = 'Die angegebene E-Mail ist ungültig';
    } elseif (empty($_POST['register_pass'])) {
        $error = 'Bitte Passwort wählen';
    } elseif ($_POST['register_pass'] != $_POST['register_repetition']) {
        $error = 'Passwort und Wiederholung stimmen nicht überein';
    } else {
        $db->insert('user_data', array('name' => $_POST['register_name'], 'email' => $_POST['register_mail'], 'pass_salt' => $salt = uniqid(), 'pass_hash' => md5($salt . md5($_POST['register_pass'] . $salt)), 'type' => 7));
        $writer->delete('install.php');
        header('Location: admin.php');
        exit;
    }
}
<?php

try {
    if ($_POST['use_ftp']) {
        $writer = new writer_ftp($_POST['ftp_host'], $_POST['ftp_user'], $_POST['ftp_pass'], $_POST['ftp_dir']);
    } else {
        $writer = new writer_fs();
    }
    // Test connections
    $writer->dir('db/');
    if (!($db = new sqlite_connection('db/system.sqlite'))) {
        throw new Exception('Database connection failed!');
    }
    // Install basic database
    $db->query("CREATE TABLE IF NOT EXISTS `update_server` (\n\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t`name` varchar(100) NOT NULL,\n\t\t`url` text NOT NULL,\n\t\t`update_date` int(10) unsigned NOT NULL,\n\t\t`update_by` int(10) unsigned NOT NULL,\n\t\t`create_date` int(10) unsigned NOT NULL,\n\t\t`create_by` int(10) unsigned NOT NULL,\n\t\tPRIMARY KEY (`id`)\n\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8;");
    $db->query("CREATE TABLE IF NOT EXISTS `update_package` (\n\t\t`id` varchar(200) NOT NULL,\n\t\t`source` int(10) unsigned DEFAULT NULL,\n\t\t`version` int(10) unsigned NOT NULL,\n\t\t`update_date` int(10) unsigned NOT NULL,\n\t\t`update_by` int(10) unsigned NOT NULL,\n\t\t`create_date` int(10) unsigned NOT NULL,\n\t\t`create_by` int(10) unsigned NOT NULL,\n\t\tPRIMARY KEY (`id`)\n\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
    $db->query("CREATE TABLE IF NOT EXISTS `update_file` (\n\t\t`path` varchar(255) NOT NULL,\n\t\t`package` varchar(200) NOT NULL,\n\t\t`version` int(10) unsigned NOT NULL,\n\t\t`hash` varchar(32) NULL,\n\t\t`content` LONGBLOB NULL,\n\t\tPRIMARY KEY (`path`)\n\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
    $db->query("CREATE TABLE IF NOT EXISTS `update_migration` (\n\t\t`id` varchar(250) NOT NULL,\n\t\t`create_date` int(10) unsigned NOT NULL,\n\t\t`create_by` int(10) unsigned NOT NULL,\n\t\tPRIMARY KEY (`id`)\n\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
    $db->query("CREATE TABLE IF NOT EXISTS `update_dependency` (\n\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t`package` varchar(200) NOT NULL,\n\t\t`required` varchar(200) NOT NULL,\n\t\t`version` int(10) unsigned NOT NULL,\n\t\tPRIMARY KEY (`id`)\n\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
    $db->query("CREATE TABLE IF NOT EXISTS `update_share` (\n\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t`package` varchar(200) NOT NULL,\n\t\t`comment` varchar(200) NOT NULL,\n\t\t`pattern` varchar(200) NOT NULL,\n\t\tPRIMARY KEY (`id`)\n\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8;");
    // Write Config files
    if ($_POST['use_ftp']) {
        $writer->put('inc/ftp.config.php', sprintf("<?php\n\n\$ftp_host = '%s';\n\$ftp_user = '******';\n\$ftp_pass = '******';\n\$ftp_dir = '%s';\n", $_POST['ftp_host'], $_POST['ftp_user'], $_POST['ftp_pass'], $_POST['ftp_dir']));
    }
    $writer->put('inc/database.config.php', "<?php\n\n\$db = new sqlite_connection( 'db/system.sqlite' );\n\n");
    $db->update_server->insert($server);
    // Redirect
    header('LOCATION: ' . IV_SELF);
    exit;
} catch (sqlite_exception $e) {
    $error = $e->getError() . $e->getSql();