Exemple #1
0
 public function isPosted()
 {
     if (isset($_POST[self::$postAdd])) {
         self::$saveArtistField = $_POST[self::$artist];
         self::$saveSongField = $_POST[self::$song];
         self::$saveChordsField = $_POST[self::$chords];
         if (empty($_POST[self::$artist])) {
             $this->setErrorMessage("You have to write something in the artist field.");
             return false;
         } else {
             if ($_POST[self::$artist] != strip_tags($_POST[self::$artist])) {
                 $this->setErrorMessage("The artist you've entered contains forbidden characters.");
                 return false;
             } else {
                 if (empty($_POST[self::$song])) {
                     $this->setErrorMessage("You have to write something in the song field.");
                     return false;
                 } else {
                     if ($_POST[self::$song] != strip_tags($_POST[self::$song])) {
                         $this->setErrorMessage("The song you've entered contains forbidden characters.");
                         return false;
                     } else {
                         if (empty($_POST[self::$chords])) {
                             $this->setErrorMessage("You have to write something in the chords field.");
                             return false;
                         } else {
                             if ($_POST[self::$chords] != strip_tags($_POST[self::$chords])) {
                                 $this->setErrorMessage("The chords you've entered contains forbidden characters.");
                                 return false;
                             } else {
                                 return true;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
    $authManager = new AuthManager();
    switch ($page_action) {
        case 'update_by_id':
            //$db_update_success = $userManager->updateRecord ($id, $user_type, $username, $password);
            $db_update_success = $authManager->updateRecord($id, $user_type, $username, $new_password);
            break;
        case "add_user":
            //$userManager->addRecord($user_type, $username, $password);
            $db_add_success = $authManager->addUser($user_type, $username, $password);
            break;
        case "delete_by_id":
            //$userManager->deleteRecord ($id);
            $db_delete_success = $authManager->deleteUser($id);
            break;
    }
    $users_data = $userManager->getAllRecords();
    $page_title = 'Manage users';
    $alt_menu = '<a href="#" class="add">Add</a>';
    $addView = new AddView('Add', 'add_user');
    $addView->addOptionBox('user_type', 'User type', $usertype_options);
    $addView->addRow('username', 'Username', null, 'eg. Neil');
    $addView->addRow('password', 'Password', null, 'eg. Sm4rtH0uSe');
    $tableView = new TableView(array('View', ''));
    while (($users_row = mysql_fetch_array($users_data)) != null) {
        $tableView->addRow(array(TableView::createCell('user_type', $users_row['user_type']), TableView::createCell('username', $users_row['username']), TableView::createEdit($users_row['USER_ID'])));
    }
    $views_to_load = array();
    $views_to_load[] = '../../views/_add.php';
    $views_to_load[] = '../../views/_table.php';
    include '../../views/_generic.php';
}
    switch ($page_action) {
        case 'update_by_id':
            $db_update_success = PasswordManager::updateRecord($PASSMAN_ID, $USER_ID, $site, $url, $username, $password);
            break;
        case 'add_password':
            $db_add_success = PasswordManager::addRecord($USER_ID, $site, $url, $username, $password);
            break;
        case 'delete_by_id':
            $db_delete_success = PasswordManager::deleteRecord($PASSMAN_ID, $USER_ID);
            break;
    }
    $passman_records = PasswordManager::getAllRecords($USER_ID);
    $page_title = 'PassMan';
    $alt_menu = getAddButton();
    // build add view
    $addView = new AddView('Add', 'add_password');
    $addView->addRow('site', 'Site');
    $addView->addRow('url', 'URL');
    $addView->addRow('username', 'Username');
    $addView->addRow('password', 'Password');
    // build table view
    $tableView = new TableView(array('Site', 'Username', 'Password', ''));
    foreach ($passman_records as $record) {
        $tableView->addRow(array(TableView::createCell('site', '<a href="' . $record->getUrl() . '" target="_blank">' . $record->getSite() . '</a>'), TableView::createCell('username', $record->getUsername()), TableView::createCell('password', '<span class="mask">************</span><span class="password-actual">' . $record->getPassword() . '</span>'), TableView::createEdit($record->getPassmanId())));
    }
    // load views to be used in front end
    $views_to_load = array();
    $views_to_load[] = '../../views/_add.php';
    $views_to_load[] = '../../views/_table.php';
    include '../../views/_generic.php';
}
    $id = request_isset('id');
    $key = request_isset('key');
    $value = request_isset('value');
    $settingsManager = new SettingsManager();
    switch ($page_action) {
        case 'add_setting':
            $settingsManager->addRecord($key, $value);
            break;
        case 'delete_by_id':
            $settingsManager->deleteRecord($id);
            break;
        case 'update_by_id':
            $settingsManager->updateRecord($id, $key, $value);
            break;
    }
    $settings_data = $settingsManager->getAllRecords();
    $page_title = 'Settings';
    $alt_menu = '<a href="#" class="add">Add</a>';
    $addView = new AddView('Add', 'add_setting');
    $addView->addRow('key', 'Key');
    $addView->addRow('value', 'Value');
    $tableView = new TableView(array('Key', 'Value', ''));
    while (($settings_row = mysql_fetch_array($settings_data)) != null) {
        $tableView->addRow(array(TableView::createCell('key', $settings_row['key']), TableView::createCell('value', $settings_row['value']), TableView::createEdit($settings_row['SETTING_ID'])));
    }
    $views_to_load = array();
    $views_to_load[] = '../../views/_add.php';
    $views_to_load[] = '_warning.php';
    $views_to_load[] = '../../views/_table.php';
    include '../../views/_generic.php';
}
             break;
         case 'delete_by_id':
             $db_delete_success = $stockManager->deleteRecord($STOCK_ID, $USER_ID);
             break;
     }
 }
 $stock_records = $stockManager->getAllRecords();
 // build header view
 $headerView = new HeaderView(($sessionManager->getUserType() == 'ADMIN' ? 'Indexer | ' : '') . 'Stocks');
 $headerView->setLink('<link rel="stylesheet" type="text/css" href="css/styles.css" />');
 if ($sessionManager->getUserType() == 'ADMIN') {
     $headerView->setMeta('<meta http-equiv="refresh" content="1800;url=#" />');
 } else {
     $headerView->setAltMenu('<a class="add" href="#">Add</a>');
     // build add view
     $addView = new AddView('Add', 'add_stock');
     $addView->addRow('ticker', 'Ticker');
 }
 // build table view
 if ($sessionManager->getUserType() == 'ADMIN') {
     $tableView = new TableView(array('Stock', 'Price', 'Change'));
 } else {
     $tableView = new TableView(array('Stock', 'Price', 'Change', ''));
 }
 foreach ($stock_records as $record) {
     if ($sessionManager->getUserType() == 'ADMIN') {
         $tableView->addRow(array(TableView::createCell('stock', $record->getStock()), TableView::createCell('price', $record->getPrice(true)), TableView::createCell('change', $record->getChangePoints(true) . ' (' . $record->getChangePercent(true) . ')')));
         StockManager::updateHistory($record->getStock(), $record->getTicker(), $record->getPrice(), $record->getChangePoints(), $record->getChangePercent(), $record->getUpdateTime());
     } else {
         $tableView->addRow(array(TableView::createCell('stock', $record->getStock()), TableView::createCell('price', $record->getPrice(true)), TableView::createCell('change ' . ($record->getChangePoints() < 0 ? 'negitive' : 'positive'), $record->getChangePoints(true) . ' (' . $record->getChangePercent(true) . ')'), TableView::createEdit($record->getTicker())));
     }
    $passphrase = request_isset('passphrase');
    switch ($page_action) {
        case 'update_by_id':
            $db_update_success = KeyManager::updateRecord($KEYSTORE_ID, $USER_ID, $name, $private_key, $public_key, $passphrase);
            break;
        case 'add_key':
            $db_add_success = KeyManager::addRecord($KEYSTORE_ID, $USER_ID, $name, $private_key, $public_key, $passphrase);
            break;
        case 'delete_by_id':
            $db_delete_success = KeyManager::deleteRecord($KEYSTORE_ID, $USER_ID);
            break;
    }
    $keyman_records = KeyManager::getAllRecords($USER_ID);
    $alt_menu = getAddButton();
    // build add view
    $addView = new AddView('Add', 'add_key');
    $addView->addRow('name', 'Name');
    $addView->addRow('private_key', 'Private key');
    $addView->addRow('public_key', 'Public key');
    $addView->addRow('passphrase', 'Passphrase');
    // build table view
    $tableView = new TableView(array('Name', 'Public key', 'Private key', 'Passphrase', ''));
    foreach ($keyman_records as $record) {
        $tableView->addRow(array(TableView::createCell('name', $record->getName()), TableView::createCell('public_key', $record->getPublicKey()), TableView::createCell('private_key', $record->getPrivateKey()), TableView::createCell('passphrase', '<span class="mask">************</span><span class="password-actual">' . $record->getPassphrase() . '</span>'), TableView::createEdit($record->getKeystoreId())));
    }
    // load views to be used in front end
    $views_to_load = array();
    $views_to_load[] = '../../views/_add.php';
    $views_to_load[] = '../../views/_table.php';
    include '../../views/_generic.php';
}