// 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 = ''; // Link ID $id_new = pj_input(pj_POST('newid')); // Check ID syntax if (preg_match('/[^0-9a-zA-Z_\\-\\.]/', $id_new)) { $error_buffer['id'] = 'Invalid link ID. Leave it empty or use only these chars: a-z A-Z 0-9 _ - .'; } elseif (strlen($id_new) > 0 && $id_new != $id_old) { // A duplicate ID? if (isset($ccount_database[$id_new])) { $error_buffer['id'] = 'Link with this ID already exists! Each link requires a unique ID (leave empty to use current one).';
// 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']; // Get links if (file_exists($ccount_settings['db_file'])) { // 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); // Any special actions? $action = pj_GET('action'); if ($action && pj_token_check()) { // Check demo mode pj_demo(); // Link ID $modified_id = preg_replace('/[^0-9a-zA-Z_\\-\\.]/', '', pj_GET('id')); // Link ID exists? if ($action != 'reset_all' && (strlen($modified_id) < 1 || !isset($ccount_database[$modified_id]))) { $_SESSION['PJ_MESSAGES']['ERROR'] = 'Invalid link ID'; header('Location: admin.php'); exit; } // Do the action if ($action == 'reset') { $ccount_database[$modified_id]['C'] = 0; $ccount_database[$modified_id]['U'] = 0; $success_message = 'Link with ID ' . $modified_id . ' has been reset';
// Load functions require '../inc/common.inc.php'; // 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 $url = ''; $title = ''; $id = ''; $count = 0; $error_buffer = array(); // Add a new link? if (pj_POST('action') == 'add' && pj_token_check()) { // Check demo mode pj_demo('new_link.php'); // Link URL $url = pj_validateURL(pj_POST('url')) or $error_buffer['url'] = 'Enter a valid URL address.'; // Link title $title = stripslashes(pj_input(pj_POST('title'))) or $title = ''; // Link ID $id = pj_input(pj_POST('id')) or $id = ''; // Check ID if (preg_match('/[^0-9a-zA-Z_\\-\\.]/', $id)) { $error_buffer['id'] = 'Invalid link ID. Leave it empty or use only these chars: a-z A-Z 0-9 _ - .'; } // Count $count = intval(pj_POST('count', 0)); // If no errors, check for duplicates/generate a new ID
$_SESSION['PJ_MESSAGES']['SUCCESS'] = 'Backup file has been restored'; } } if ($restore_existing) { // Update database file if (@file_put_contents($ccount_settings['db_file'], $existing, LOCK_EX) === false) { $_SESSION['PJ_MESSAGES']['ERROR'] = 'Could not restore: Error writing to database file, please try again later.'; } } unset($existing); unset($data); } } // END restore backup // Import legacy backup? if (pj_POST('legacy') && pj_token_check()) { // Check demo mode pj_demo('backups.php'); // File uploaded? if (empty($_FILES['backupfile']['name'])) { $_SESSION['PJ_MESSAGES']['ERROR'] = 'No legacy backup file uploaded.'; } else { $restore_existing = false; // Save current contents just in case $existing = file_get_contents($ccount_settings['db_file']); // Replace existing with new file if (!move_uploaded_file($_FILES['backupfile']['tmp_name'], dirname(dirname(__FILE__)) . '/' . substr($ccount_settings['db_file'], 3))) { $_SESSION['PJ_MESSAGES']['ERROR'] = 'Could not copy uploaded backup file over the existing one.'; } else { $data = array(); // Verify backup file
* Removing any of the copyright notices without purchasing a license * is expressly forbidden. To remove copyright notice you must purchase * a license for this script. For more information on how to obtain * a license please visit the page below: * http://www.phpjunkyard.com/buy.php *******************************************************************************/ define('IN_SCRIPT', 1); define('THIS_PAGE', 'INDEX'); // Require the settings file require '../ccount_settings.php'; // Load functions require '../inc/common.inc.php'; // Start session pj_session_start(); // Is this a LOGOUT request? if (pj_GET('logout', false) !== false && pj_token_check()) { // Expire session variable $_SESSION['LOGGED_IN'] = false; // Delete cookie setcookie('ccount_hash', ''); // Stop session pj_session_stop(); // Define a success message $_SESSION['PJ_MESSAGES']['SUCCESS'] = 'You have logged out successfuly.'; } elseif (pj_isLoggedIn()) { header('Location: admin.php'); die; } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { // Check password etc if (stripslashes(pj_input(pj_POST('pass', false))) == $ccount_settings['admin_pass']) { // Set session variable