Example #1
0
function set_location($name, $location)
{
    $locations = load_locations();
    if ($locations === False) {
        return False;
    }
    $name = strtolower(trim($name));
    $location = trim($location);
    $locations[$name] = $location;
    return save_locations($locations);
}
    }
}
$rules_id = request_var('rules_id', '');
$uid = $bitfield = $options = '';
$allow_bbcode = $allow_smilies = $allow_urls = true;
$sql_ary = array('SELECT' => 'r.rules_id, r.rules_title, r.rules_text, r.display_rules, r.must_agree, r.display_as_link', 'FROM' => array(CLASSIFIEDS_RULES_TABLE => 'r'), 'WHERE' => 'r.rules_id = ' . $rules_id, 'ORDER_BY' => 'r.rules_id ASC');
if (!is_numeric($rules_id) || $rules_id > 3 || $rules_id < 1) {
    $sql_ary['WHERE'] = '';
}
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
    generate_text_for_storage($row['rules_text'], $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
    $row['rules_text'] = generate_text_for_display($row['rules_text'], $uid, $bitfield, $options);
    $template->assign_block_vars('rules', array('S_RULES_DISPLAY' => $row['display_rules'] && !empty($row['rules_text']) ? true : false, 'S_RULES_TITLE' => $row['rules_title'], 'S_RULES_TEXT' => $row['rules_text']));
}
$db->sql_freeresult($result);
if ($config['allow_classifieds_feeds']) {
    $feeds_mode = 'active';
    $template->assign_vars(array('L_CL_CLASSIFIEDS_RSS' => $user->lang('CL_CLASSIFIEDS_RSS', !empty($cat) ? $user->lang['CL_FOR_CAT'] . get_ad_category($cat) : $user->lang['CL_FOR_ALL_ACTIVE_ADS'])));
    $allow_feeds = true;
}
load_prefixes();
load_locations();
user_total_ads($user->data['user_id'], 'left_bar');
$template->assign_block_vars('navlinks', array('FORUM_NAME' => $user->lang['CL_CLASSIFIEDS'], 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}" . CL_DIRECTORY . "/index.{$phpEx}")));
$template->assign_block_vars('navlinks', array('FORUM_NAME' => empty($row['rules_title']) ? $user->lang['CL_RULES'] : $row['rules_title'], 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}" . CL_DIRECTORY . "/rules.{$phpEx}", "rules_id={$rules_id}")));
$template->assign_vars(array('S_IN_CLASSIFIEDS_RULES' => true, 'CATEGORIES' => build_categories(), 'U_VIEW_REPORTED_LINK' => $auth->acl_get('a_') || $auth->acl_get('m_report_classifieds') ? append_sid("{$phpbb_root_path}" . CL_DIRECTORY . "/index.{$phpEx}", 'mode=reported') : '', 'U_SEARCH_ADS' => append_sid("{$phpbb_root_path}" . CL_DIRECTORY . "/index.{$phpEx}", 'mode=search'), 'U_CLASSIFIEDS_RSS' => $allow_feeds ? append_sid("{$phpbb_root_path}" . CL_DIRECTORY . "/feeds.{$phpEx}", "mode={$feeds_mode}") : ''));
page_header($user->lang('CL_RULES'));
$template->set_filenames(array('body' => 'classifieds_rules_body.html'));
page_footer();
// load rules
$rules_must_agree = load_rules(3);
/* show custom bbcode, smilies, categories, prefixes, locations, curency
*  request and generate temporary advertisement id for images
*  set some template variables
*/
if ($mode == 'create_ad' || $mode == 'edit_ad') {
    if (!function_exists('display_custom_bbcodes')) {
        include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
    }
    display_custom_bbcodes();
    generate_smilies('inline', 0);
    list_categories();
    load_currency();
    $prefix_exist = load_prefixes();
    $location_exist = load_locations();
    $template->assign_vars(array('S_BBCODE_ALLOWED' => true, 'S_BBCODE_IMG' => true, 'S_LINKS_ALLOWED' => true, 'S_SMILIES_ALLOWED' => true, 'S_BBCODE_QUOTE' => true, 'S_SHOW_SMILEY_LINK' => true, 'S_MAX_IMG_SIZE' => $config['max_img_size'] / 1024, 'S_COMMENTS_ENABLED' => $config['allow_comments'], 'S_MANDATORY_PHONE' => $config['mandatory_phone'], 'S_MANDATORY_AD_PREFIX' => $config['mandatory_ad_prefix'], 'S_MANDATORY_AD_LOCATION' => $config['mandatory_ad_location'], 'S_DEFAULT_CURRENCY' => $config['default_currency'], 'S_ALLOW_UPLOAD' => $config['allow_upload'], 'U_MORE_SMILIES' => append_sid("{$phpbb_root_path}posting.{$phpEx}", 'mode=smilies'), 'T_CL_IMAGES_PATH' => generate_board_url() . '/' . CL_DIRECTORY . '/images/', 'T_THUMB_PATH' => generate_board_url() . '/' . CL_DIRECTORY . '/images/thumb/'));
}
switch ($mode) {
    case 'create_ad':
        // if dont have permissions to create ad
        if (!$auth->acl_get('u_post_classifieds')) {
            trigger_error('NOT_AUTHORISED');
        }
        // if location necessary
        if ($config['fill_location_to_trade'] && !$user->data['user_from']) {
            trigger_error('CL_NOT_FILLED_LOCATION');
        }
        // if not enough posts
        if ($user->data['user_posts'] < $config['required_posts_to_create']) {
            trigger_error('CL_NOT_ENOUGH_POSTS_TO_CREATE');