Ejemplo n.º 1
0
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_admin'] = '../' . $ccount_settings['db_file'];
$error_buffer = array();
// Save settings?
if (pj_POST('action') == 'save' && pj_token_check()) {
    // Check demo mode
    pj_demo('settings.php');
    // Admin password
    $ccount_settings['admin_pass'] = pj_input(pj_POST('admin_pass')) or $error_buffer['admin_pass'] = '******';
    // click.php URL
    $ccount_settings['click_url'] = pj_validateURL(pj_POST('click_url')) or $error_buffer['click_url'] = 'Enter a valid URL address of the click.php file on your server.';
    // Database file
    $ccount_settings['db_file'] = pj_input(pj_POST('db_file', 'ccount_database.php'));
    // Check database file
    if (preg_match('/[^0-9a-zA-Z_\\-\\.]/', $ccount_settings['db_file'])) {
        $error_buffer['db_file'] = 'Invalid file name. Use only these chars: a-z A-Z 0-9 _ - .';
    }
    // Unique hours
    $ccount_settings['unique_hours'] = intval(pj_POST('unique_hours', 24));
    if ($ccount_settings['unique_hours'] < 0) {
        $ccount_settings['unique_hours'] = 0;
    }
    // Notation
    $ccount_settings['notation'] = pj_input(pj_POST('notation', 'US'));
    if (!in_array($ccount_settings['notation'], array('US', 'UK', 'FR', 'X1', 'X2'))) {
        $ccount_settings['notation'] = 'US';
Ejemplo n.º 2
0
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).';
        } else {
            $warn_new_link = true;
        }
    }
Ejemplo n.º 3
0
// 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
    if (count($error_buffer) == 0) {
        // Get links database
        $data = explode('//', file_get_contents($ccount_settings['db_file']), 2);
        // Convert contents into an array