function get_project_index($project) { $projects = load_projects(); for ($i = 0; $i < count($projects); $i++) { if ($projects[$i] == $project) { return $i; } } return -1; }
<?php $categories = load_categories(); $projects = load_projects(); if (isset($_POST['method'])) { if ($_POST['method'] == 1 && isset($_POST['title']) && isset($_POST['description']) && isset($_POST['keywords']) && isset($_POST['author'])) { $settings = merge($settings, 'settings', array('metaTitle' => htmlspecialchars($_POST['title']), 'metaDescription' => htmlspecialchars($_POST['description']), 'metaKeywords' => htmlspecialchars($_POST['keywords']), 'metaAuthor' => htmlspecialchars($_POST['author']), 'metaLanguage' => htmlspecialchars($_POST['language'])), PP_MESSAGE_METACHANGED); } else { if ($_POST['method'] == 2) { $settings = merge($settings, 'settings', isset($_POST['enable']) ? array('adflyUse' => true, 'adflyId' => htmlspecialchars($_POST['id'])) : array('adflyUse' => false), PP_MESSAGE_ADFLYCHANGED); } else { if ($_POST['method'] == 3) { $categories = merge($categories, 'categories', array(htmlspecialchars($_POST['name'])), PP_MESSAGE_CATEGORYADDED); } else { if ($_POST['method'] == 4) { if (count($categories) == 1) { echo message(PP_MESSAGE_CANNOTREMOVE, 'alert-danger'); } else { $categories = remove($categories, 'categories', $_POST['category'], PP_MESSAGE_CATEGORYREMOVED); $projects_changed = false; for ($i = 0; $i < count($projects); $i++) { if ($projects[$i]['category'] != $_POST['category']) { continue; } $projects = remove($projects, null, $i, null, false); $projects_changed = true; } if ($projects_changed) { finish($projects, 'projects', null); } }
function increment_field($project_index, $field) { $projects = load_projects(); $projects[$project_index][$field] = isset($projects[$project_index][$field]) ? $projects[$project_index][$field] + 1 : 1; file_put_contents('json/projects.json', json_encode($projects)); }
CONTACT LIST </section> <section class="content"> <div class="box box-primary"> <div class="box-header with-boarder"> <h2 class="box-title"> PROJECTS LIST </h2> </div> <table class="table table-hover"> <tr> <th>PROJECT-ID</th> <th>PROJECT-NAME</th> <th>CUSTOMER-NAME</th> <th>EXPIRY-DATE</th> <th>ACTIONS</th> </tr> <?php load_projects(); ?> </table> </div> </section> <?php // closing the page include '..\\includes\\admin_frame_close.php';
echo "There was a hole."; } } } } } } } } } return; } //===== //===== GET -------------------------------------------------------------------- //===== if ($_SERVER['REQUEST_METHOD'] == "GET") { $function = $_GET['function']; if ($function == 'load-projects') { load_projects($_GET['username'], $_GET['amount'], $_GET['start']); } else { if ($function == 'load-project') { load_project($_GET['username'], $_GET['projectname']); } else { if ($function == 'load-project-counts') { load_project_counts($_GET['project_id']); } else { echo "There was a hole."; } } } }