// Start session pj_session_start(); // Are we logged in? pj_isLoggedIn(true); // The settings file is in parent folder $ccount_settings['db_file'] = '../' . $ccount_settings['db_file']; // Pre-set values $error_buffer = array(); $warn_new_link = false; // Get links database $data = explode('//', file_get_contents($ccount_settings['db_file']), 2); // Convert contents into an array $ccount_database = isset($data[1]) ? unserialize($data[1]) : array(); unset($data); // Link ID $id_old = preg_replace('/[^0-9a-zA-Z_\\-\\.]/', '', pj_REQUEST('id')); // Link ID exists? if (strlen($id_old) < 1 || !isset($ccount_database[$id_old])) { $_SESSION['PJ_MESSAGES']['ERROR'] = 'Invalid link ID'; header('Location: admin.php'); exit; } $id_new = $id_old; // Add a new link? if (pj_POST('action') == 'save' && pj_token_check()) { // Check demo mode pj_demo('edit_link.php?id=' . $id_old); // Link URL $ccount_database[$id_old]['L'] = pj_validateURL(pj_POST('url')) or $error_buffer['url'] = 'Enter a valid URL address.'; // Link title $ccount_database[$id_old]['T'] = stripslashes(pj_input(pj_POST('title'))) or $title = '';
function pj_token_check() { // Verify token or throw an error if (isset($_SESSION['token']) && pj_REQUEST('token') == $_SESSION['token']) { return true; } else { return false; } }