<?php ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// require_once "inc/setup.php"; ////////////////////////////////////////////////////////////////////////////// // Make a backup if ($_POST['backup']) { $backup_file = 'inc/backups/' . date("Y-m-d_H-i-s_") . str_replace(" ", "-", strtolower($cms_user['first_name'] . '-' . $cms_user['last_name'])) . '.sql'; $output = system("mysqldump -h{$db_server} -u{$db_username} -p{$db_password} {$db_database} > {$backup_file}"); if ($output !== false) { echo 'success'; $filesize = filesize($backup_file); if (insert_activity($table = $backup_file, $row = $filesize, $type = 'backed up', $sql = '')) { $_SESSION['alert'] = "backup"; } } else { echo 'backup_error'; } die; } ////////////////////////////////////////////////////////////////////////////// // Get activity item's main description function get_item_description($activity) { global $dbh; global $settings; if ($activity['type'] == 'backed up') { ?> <a href="<?php echo $activity['table']; ?>
} } ////////////////////////////////////////////////////////////////////////////// // Update status for each item // Reminder: Compare against existing tables foreach ($status_ids as $id) { $sth = $dbh->prepare("UPDATE `{$table}` SET `active` = :active WHERE `id` = :id AND `active` != :active "); $sth->bindParam(':active', $status); $sth->bindParam(':id', $id); if ($sth->execute()) { // If the item was actually changed if ($sth->rowCount() > 0) { $success_count++; $id_safe = intval($id); // Save status change to revisions insert_activity($table = $table, $row = $id, $type = $action, $sql = "UPDATE `{$table}` SET `active` = '{$status}' WHERE `id` = '{$id_safe}' "); } } else { $error_count++; } } ////////////////////////////////////////////////////////////////////////////// // Alert user of how many items were changed if ($success_count > 0) { $_SESSION['alert'] = "item_{$action}" . "_{$success_count}"; } // Alert user of how many items had errors if ($error_count > 0) { $plural = $error_count == 1 ? '' : 's'; echo "Error: {$error_count}/{$total_count} item{$plural} not {$action}"; }
} elseif ($alert == 'error_cleaning_settings') { $alert_message['error'][] = 'Error cleaning up settings'; } elseif ($alert == 'error_resetting_settings') { $alert_message['error'][] = 'Error cleaning up settings table'; // Default and custom messages } elseif ($alert_type == 'txt') { $alert_message['error'][] = stripslashes(nl2br($alert)); } else { $alert_message['error'][] = stripslashes($alert); } // Log all errors if ($alert_type == 'error') { $last_page = $_SESSION['cms_last_page'] ? $_SESSION['cms_last_page'] : 'None'; $error_info = $_SERVER['REMOTE_ADDR'] . ', '; $alert_detail = $alert_detail ? "\n" . $alert_detail : ''; echo '<!-- ' . insert_activity($table = $last_page, $row = $error_info, $type = 'error', $sql = $alert_message . $alert_detail, $active = 0) . ' -->'; } } ////////////////////////////////////////////////////////////////////////////// // If there are errors, display $alert_types = array_unique(array_keys($alert_message)); foreach ($alert_types as $alert_type) { if (count($alert_message[$alert_type]) > 0) { ?> <div class="alert_box<?php echo $persistent ? ' persistent' : ''; ?> " style="display:none;"> <div class="alert_box_message <?php echo $alert_type; ?>
if ($_POST["id"] != 'create') { $sth->bindParam(':id', $_POST["id"]); } if ($sth->execute()) { // Remove or upload the user avatar if ($_POST["remove_avatar"] == '1') { unlink(BASE_PATH . "media/users/" . $_POST["id"] . ".jpg"); } elseif ($_FILES['avatar']['tmp_name']) { $extension = strtolower(end(explode('.', $_FILES['avatar']['name']))); $extension = $extension == "jpeg" ? "jpg" : $extension; $_POST["id"] = !is_numeric($_POST["id"]) ? $dbh->lastInsertId() : $_POST["id"]; make_thumb("media/users/" . $_POST["id"] . ".jpg", false, $_FILES["avatar"]['tmp_name'], $extension, 50, 50, true); } // Save as a revision if new user if ($_POST["id"] == 'create') { insert_activity($table = 'directus_users', $row = $dbh->lastInsertId(), $type = 'added', $sql = $_POST["first_name"] . ' ' . $_POST["last_name"]); } $_SESSION['alert'] = $_POST["id"] != 'create' ? "saved" : "added"; header("Location: " . CMS_INSTALL_PATH . "users.php"); die; } else { $alert[] = "user_save_error"; } } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Try to get user info if ($_GET['u']) { $sth = $dbh->prepare("SELECT * FROM `directus_users` WHERE id = :id LIMIT 1 "); $sth->bindParam(':id', $_GET['u']); $sth->execute();
$sth = $dbh->query("SELECT max(sort) AS max_sort FROM `{$table}` "); $next_sort = ($sort = $sth->fetch()) ? $sort["max_sort"] + 1 : 1; $save_array[] = "`sort` = '{$next_sort}'"; } elseif ($table_rows['sort'] == '1' && $has_id) { $save_array[] = "`sort` = '" . $_POST['sort'] . "'"; } $query_save .= implode(", ", $save_array); $query_save .= $has_id && $_POST['save_and'] != 'duplicate' ? " WHERE `id` = '{$id}' " : ""; //die($query_save); if ($dbh->query($query_save)) { // Save in revisions $id = $has_id ? $id : $dbh->lastInsertId(); $type = $has_id ? 'edited' : 'added'; $query_save .= !$has_id ? " WHERE `id` = '{$id}' " : ""; $revision_sql = preg_replace('/INSERT INTO /', 'UPDATE ', $query_save, 1); insert_activity($table = $table, $row = $id, $type = $type, $sql = $revision_sql); // Saved if (!isset($_GET['modal'])) { $_SESSION['alert'] = "saved"; if ($_POST['save_and'] == 'stay') { header("Location: " . CMS_INSTALL_PATH . "edit.php?table={$table}&item={$id}"); } elseif ($_POST['save_and'] == 'add') { header("Location: " . CMS_INSTALL_PATH . "edit.php?table={$table}"); } elseif (in_array($table, $settings['table_single'])) { header("Location: " . CMS_INSTALL_PATH . "tables.php"); } else { header("Location: " . CMS_INSTALL_PATH . "browse.php?table={$table}"); } die; } }
* * I'm sorry. */ $i = $_POST['editBusinessActivities']; $result = update_activity($name, $_POST['old_activity' . $i], $_POST['old_scheduledTime' . $i], $_POST['activity' . $i], $_POST['scheduledTime' . $i], $_POST['discount' . $i], $_POST['interestType' . $i]); /* Commit to save changes... */ OCICommit($db_conn); } else { if (array_key_exists('deleteBusinessActivities', $_POST)) { $i = $_POST['deleteBusinessActivities']; $result = delete_activity($name, $_POST['old_activity' . $i], $_POST['old_scheduledTime' . $i]); /* Commit to save changes... */ OCICommit($db_conn); } else { if (array_key_exists('newBusinessActivity', $_POST)) { insert_activity($name, $_POST['activity'], $_POST['scheduledTime'], $_POST['discount'], $_POST['interestType']); /* Commit to save changes... */ OCICommit($db_conn); } } } } else { /* if ($db_conn) */ echo "cannot connect"; $e = OCI_Error(); // For OCILogon errors pass no handle echo htmlentities($e['message']); } ?> <html>
} */ } elseif ($file_info['extension'] == 'vimeo') { /* foreach($settings['image_autothumb'] as $autothumb){ $thumb_dimensions = explode(",", $autothumb); $error[] = make_thumb($settings['cms']['media_path'], $file_info['id'], "../media/cms_thumbs/vimeo_" . $file_info['source'] . ".jpg", 'jpg', $thumb_dimensions[0], $thumb_dimensions[1], $thumb_dimensions[2]); } */ } ////////////////////////////////////////////////////////////////////////////// // Add to revisions $revision_method = isset($_GET['batch']) ? 'batch' : ''; // Types batch, URL, computer $revision_type = $_POST['replace_id'] ? 'swapped' : 'uploaded'; insert_activity($table = 'directus_media', $file_info['id'], $revision_type, $revision_method); } else { $_SESSION['alert'] = $_POST['replace_id'] ? 'error_swapping_media' : 'error_adding_media'; $error_each[] = "Media not added to database!"; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } // End extension check // Pass on and clear this items errors and continue to next $error = array_merge($error, $error_each); unset($error_each); // Create an array of all files uploaded $files_added[] = $file_info; } // End uploaded file(s) loop