Ejemplo n.º 1
0
function generate_slug($length = 4)
{
    global $db;
    $values = serialize($_POST);
    $length = 4;
    $slug = substr(md5($values . time()), 0, $length);
    $exists = $db->value("\n    SELECT COUNT(id)\n    FROM shift\n    WHERE url_slug = '{$slug}'\n  ");
    if ($length == 32) {
        respond(0, "Could not generate URL slug.");
    }
    if ($exists) {
        return generate_slug($length + 1);
    } else {
        return $slug;
    }
}
function get_stationowner_ID($stationowner_uid, $stationowner_name)
{
    global $stationowners;
    if (isset($stationowners[$stationowner_uid])) {
        return $stationowners[$stationowner_uid];
    }
    // Lol
    if (($pos = strpos($stationowner_name, ' IL REGISTRO IMPRESE NON GARANTISCE')) !== false) {
        $stationowner_name = substr($stationowner_name, 0, $pos);
        $stationowner_uid = generate_slug($stationowner_name);
        $stationowner_note = substr($stationowner_name, $pos);
    } else {
        $stationowner_note = null;
    }
    // Another check
    if (isset($stationowners[$stationowner_uid])) {
        return $stationowners[$stationowner_uid];
    }
    insert_row('stationowner', [new DBCol('stationowner_uid', $stationowner_uid, 's'), new DBCol('stationowner_name', $stationowner_name, 's'), new DBCol('stationowner_note', $stationowner_note, 'snull')]);
    $stationowner = query_row(sprintf("SELECT stationowner_ID, stationowner_uid " . "FROM {$GLOBALS[T]('stationowner')} " . "WHERE stationowner_ID = %d", last_inserted_ID()), 'Stationowner');
    return $stationowners[$stationowner->stationowner_uid] = $stationowner->stationowner_ID;
}
        throw new Exception(_("File delle stazioni non trovato"), 2);
    }
    if (!($handle = fopen(FILENAME_STATIONS, 'r'))) {
        throw new Exception(_("Impossibile aprire il file delle stazioni"), 3);
    }
    // Waste first 2 lines
    fgetcsv($handle);
    fgetcsv($handle);
    while ($data = fgetcsv($handle, 512, ';')) {
        get_station_ID((int) $data[0], $data[4], $data[3], $data[5], (double) $data[8], (double) $data[9], get_comune_ID(generate_slug($data[6]), $data[6], $data[7]), get_stationowner_ID(generate_slug($data[1]), $data[1]), get_fuelprovider_ID(generate_slug($data[2]), $data[2]));
    }
    fclose($handle);
    // Prices
    if (!file_exists(FILENAME_PRICES)) {
        throw new Exception(_("File dei prezzi non trovato"), 4);
    }
    if (!($handle = fopen(FILENAME_PRICES, 'r'))) {
        throw new Exception(_("Impossibile aprire il file dei prezzi"), 5);
    }
    // Waste first 2 lines
    fgetcsv($handle);
    fgetcsv($handle);
    while ($data = fgetcsv($handle, 255, ';')) {
        insert_row('price', [new DBCol('price_value', (double) $data[2], 'f'), new DBCol('price_self', (int) $data[3], 'd'), new DBCol('price_date', itdate2datetime($data[4]), 's'), new DBCol('fuel_ID', get_fuel_ID(generate_slug($data[1]), $data[1]), 'd'), new DBCol('station_ID', get_station_ID((int) $data[0]), 'd')]);
    }
    fclose($handle);
} catch (Exception $e) {
    printf(_("Errore: %s."), $e->getMessage());
    echo "\n";
    exit($e->getCode());
}
Ejemplo n.º 4
0
 function edit($id = 0)
 {
     if ($id == NULL) {
         $id = 0;
     }
     // make sure user is an admin
     if (!$this->ion_auth->is_group('editors') and !$this->ion_auth->is_admin()) {
         $this->session->set_flashdata('message', 'You must be an admin to view this page.');
         redirect('auth/login');
     }
     //validate form input
     $this->form_validation->set_rules('title', 'Post  Title', 'required|xss_clean');
     $this->form_validation->set_rules('status', 'Status:', '');
     $this->form_validation->set_rules('comment_status', 'Comments:', '');
     $this->form_validation->set_rules('slug', 'Post URL', 'xss_clean');
     $this->form_validation->set_rules('post_body', 'Post Content', '');
     if ($this->form_validation->run() == TRUE) {
         if ($this->input->post('delete')) {
             // deleting post
             if ($this->Blog_model->delete_post($id)) {
                 $this->session->set_flashdata('alert_string', 'Blog Post deleted successfully.');
             } else {
                 $this->session->set_flashdata('error_string', 'Could not delete blog post. Please contact the site administrator.');
             }
             redirect(base_url() . 'blog/admin');
         } else {
             // saving user
             // if no slug was submitted, generate one from the page title
             if ($this->input->post('slug') == NULL) {
                 $slug = generate_slug($this->input->post('title'));
             } else {
                 $slug = generate_slug($this->input->post('slug'));
             }
             $blog_post = array('title' => $this->input->post('title'), 'slug' => $slug, 'post_body' => $this->input->post('post_body'), 'comment_status' => $this->input->post('comment_status'), 'status' => $this->input->post('status'));
             // set our modify date
             if ($id > 0) {
                 // existing page
             } else {
                 // new page
                 $blog_post['date_posted'] = date('U');
                 $blog_post['author_id'] = $this->user->id;
             }
             if ($this->Blog_model->save_post($id, $blog_post) == TRUE) {
                 $alert_string = 'Blog Post saved successfully. <a href="' . base_url('blog/post/' . $slug) . '" target="0">View Post</a>';
             } else {
                 $error_string = 'Blog post changes did not save. Please contact the site administrator.';
             }
             if (isset($alert_string)) {
                 $this->session->set_flashdata('alert_string', $alert_string);
             }
             if (isset($error_string)) {
                 $this->session->set_flashdata('error_string', $error_string);
             }
             redirect(base_url('blog/admin'));
         }
     }
     // setup form fields
     $this->data['title'] = array('name' => 'title', 'id' => 'title', 'type' => 'text');
     $this->data['slug'] = array('name' => 'slug', 'id' => 'slug', 'type' => 'text');
     $this->data['post_body'] = array('name' => 'post_body', 'id' => 'post_body');
     $this->data['status'] = array('name' => 'status', 'id' => 'status', 'value' => 'publish');
     $this->data['comment_status'] = array('name' => 'comment_status', 'id' => 'comment_status', 'value' => 'open');
     // set field values depending on if we're editing an existing page or creating a new one
     if ($id > 0) {
         // populate from database
         $blog_post = $this->Blog_model->get_post_by_id($id);
         $this->data['title']['value'] = $this->form_validation->set_value('title', $blog_post['title']);
         $this->data['slug']['value'] = $this->form_validation->set_value('slug', $blog_post['slug']);
         $this->data['post_body']['value'] = $this->form_validation->set_value('post_body', $blog_post['post_body']);
         $this->data['status']['value'] = $this->form_validation->set_value('status', $blog_post['status']);
         $this->data['comment_status']['value'] = $this->form_validation->set_value('comment_status', $blog_post['comment_status']);
     } else {
         // blank form
         $blog_post = NULL;
         $this->data['title']['value'] = $this->form_validation->set_value('title', NULL);
         $this->data['slug']['value'] = $this->form_validation->set_value('slug', NULL);
         $this->data['post_body']['value'] = $this->form_validation->set_value('post_body', NULL);
         $this->data['status']['value'] = $this->form_validation->set_value('status', 'publish');
         $this->data['comment_status']['value'] = $this->form_validation->set_value('comment_status', 'open');
     }
     $this->data['blog_post'] = $blog_post;
     $this->data['post_status'] = $this->post_status;
     $this->data['comment_statuses'] = $this->comment_statuses;
     if (isset($error_string)) {
         $this->data['error_string'] = $error_string;
     }
     if (isset($alert_string)) {
         $this->data['alert_string'] = $alert_string;
     }
     if ($this->input->is_ajax_request()) {
         // ajax request, return the form only
         $this->load->view('blog_admin_form', $this->data);
     } else {
         // not ajax, return the whole page
         $this->template->title('Edit Blog Post')->set_partial('extra_head', 'rich_editor_load')->build('blog_admin_form', $this->data);
     }
 }
Ejemplo n.º 5
0
<?php

echo $map['js'];
?>

<div id="dashboard">
    <h1>Map</h1>
    <div id="dashboard-content">
        <div id="dashboard-photo">
            <div id="dashboard-photo-box">
            <?php 
$merchant_slug = generate_slug($company_name);
$merchant_url = base_url() . 'all/merchant_dashboard/' . $merchant_slug . '//' . $merchant_id;
if (IsNullOrEmptyString($image)) {
    ?>
                <img src="<?php 
    echo base_url() . $this->config->item('empty_image');
    ?>
">
                <?php 
} else {
    ?>
                <a href="<?php 
    echo $merchant_url;
    ?>
" ><img src="<?php 
    echo base_url() . $image_path . $image;
    ?>
"></a>
                <?php 
}
Ejemplo n.º 6
0
        }
        ?>
		<?php 
        foreach ($headings as $heading_name => $heading) {
            ?>
		<?php 
            if (isset($parse_styling[$heading_name])) {
                ?>
			<td data-label="<?php 
                echo $headings[$heading_name]['caption'];
                ?>
" class="<?php 
                echo $heading_name;
                ?>
 <?php 
                echo generate_slug($row[$heading_name], NULL, '_');
                ?>
">
		<?php 
            } else {
                ?>
			<td data-label="<?php 
                echo $headings[$heading_name]['caption'];
                ?>
" class="<?php 
                echo $heading_name;
                ?>
">
		<?php 
            }
            ?>
Ejemplo n.º 7
0
)</a></h3>
	
	<table width="100%" class="single_opinion">
	<thead>
		<tr>
			<th>Signal</th>
			<th>Price</th>
			<th>Bias</th>
			<th>Subject</th>
			<th>Owned</th>
		</tr>
	</thead>
	<tbody>
	<tr>
		<td class="<?php 
    echo generate_slug($opinion['OpinionSignal'], NULL, '_');
    ?>
"><?php 
    echo $opinion['OpinionSignal'];
    ?>
</td>
		<td>&#036;<?php 
    echo $opinion['price'];
    ?>
</td>
		<td><?php 
    echo $opinion['bias'];
    ?>
</td>
		<td><?php 
    echo $opinion['subject'];
Ejemplo n.º 8
0
                 // -- OK --
                 $tpl->assign('REDIRECT_LOCATION', './acp.php?c=pages');
                 $syslog->alert_success('{L_ALERT_PAGES_PAGE_ADD_SUCCESS}');
                 die;
             }
         }
     } else {
         $syslog->permissions_error('{L_PERMISSIONS_PAGES_PAGE_ADD}');
         die;
     }
     break;
 case 'edit':
     if (permissions('pages', 'page', 'edit')) {
         // -- slug --
         if (intval($_POST['page_slug_generate']) == 1) {
             $slug = generate_slug($_POST['page']['header']);
         } else {
             $slug = $_POST['page']['slug'];
         }
         $sql = new MySQLObject();
         // -- update the pages table --
         if ($sql->query("\r\nUPDATE " . $sql->table('pages') . "\r\nSET\r\n\t`header` = '" . $sql->escape($_POST['page']['header']) . "',\r\n\t`slug` = '" . $sql->escape($slug) . "',\r\n\t`content` = '" . $sql->escape($_POST['page']['content']) . "',\r\n\t`parent` = " . intval($_POST['page']['parent']) . ",\r\n\t`path` = '" . $mod->modules['pages']->get_path(intval($_POST['page']['parent']), $sql->escape($slug)) . "'\r\nWHERE (`pid` = " . intval($_GET['pid']) . ")")) {
             // -- update the menu table --
             if ($sql->query("\r\nUPDATE " . $sql->table('menu') . "\r\nSET `link` = '" . $mod->modules['pages']->get_path(intval($_POST['page']['parent']), $sql->escape($slug)) . "'\r\nWHERE (`link` = '" . $sql->escape($_POST['page']['path_original']) . "' AND `module` = 'pages')")) {
                 // -- OK --
                 $tpl->assign('REDIRECT_LOCATION', './acp.php?c=pages');
                 $syslog->alert_success('{L_ALERT_PAGES_PAGE_EDIT_SUCCESS}');
                 die;
             } else {
                 $syslog->alert_error('{L_ALERT_PAGES_PAGE_EDIT_ERROR}');
                 die;
Ejemplo n.º 9
0
 function profile()
 {
     if (!check_correct_login_type($this->main_group_id) && !check_correct_login_type($this->group_id_supervisor)) {
         redirect('/', 'refresh');
     }
     $merchant_id = $this->ion_auth->user()->row()->id;
     $is_supervisor = 0;
     $branch = FALSE;
     //for supervisor view merchant profile because supervisor don't have own profile
     if (check_correct_login_type($this->group_id_supervisor)) {
         $merchant_id = $this->ion_auth->user()->row()->su_merchant_id;
         $is_supervisor = 1;
         $supervisor = $this->ion_auth->user()->row();
         $branch = $this->m_custom->get_one_table_record('merchant_branch', 'branch_id', $supervisor->su_branch_id);
     }
     $user = $this->ion_auth->user($merchant_id)->row();
     $this->form_validation->set_rules('postcode', 'Postcode', 'required|numeric');
     //$this->form_validation->set_rules('phone', $this->lang->line('create_merchant_validation_phone_label'), 'required|valid_contact_number');
     $this->form_validation->set_rules('phone', $this->lang->line('create_merchant_validation_phone_label'));
     $this->form_validation->set_rules('description', $this->lang->line('create_merchant_validation_description_label'));
     $this->form_validation->set_rules('website', $this->lang->line('create_merchant_validation_website_label'));
     $this->form_validation->set_rules('facebook_url', $this->lang->line('create_merchant_validation_facebook_url_label'));
     $this->form_validation->set_rules('person_incharge', $this->lang->line('create_merchant_validation_person_incharge_label'));
     //$this->form_validation->set_rules('person_contact', $this->lang->line('create_merchant_validation_person_contact_label'), 'valid_contact_number');
     $this->form_validation->set_rules('person_contact', $this->lang->line('create_merchant_validation_person_contact_label'));
     if (isset($_POST) && !empty($_POST)) {
         $upload_rule = array('upload_path' => $this->album_merchant_profile, 'allowed_types' => $this->config->item('allowed_types_image'), 'max_size' => $this->config->item('max_size'), 'max_width' => $this->config->item('max_width'), 'max_height' => $this->config->item('max_height'));
         $this->load->library('upload', $upload_rule);
         if ($this->input->post('button_action') == "confirm") {
             if ($this->form_validation->run() === TRUE) {
                 $current_profile = $user->profile_image;
                 if (!empty($_FILES['userfile']['name'])) {
                     if (!$this->upload->do_upload()) {
                         $error = array('error' => $this->upload->display_errors());
                         $this->session->set_flashdata('message', $this->upload->display_errors());
                     } else {
                         $current_profile = $this->upload->data('file_name');
                     }
                 }
                 $data = array('address' => $this->input->post('address'), 'postcode' => $this->input->post('postcode'), 'me_state_id' => $this->input->post('me_state_id'), 'country' => $this->input->post('me_country'), 'description' => $this->input->post('description'), 'phone' => $this->input->post('phone'), 'company' => $this->input->post('company'), 'slug' => generate_slug($this->input->post('company')), 'me_sub_category_id' => $this->input->post('me_sub_category_id'), 'me_person_incharge' => $this->input->post('person_incharge'), 'me_person_contact' => $this->input->post('person_contact'), 'me_website_url' => $this->input->post('website'), 'me_facebook_url' => $this->input->post('facebook_url'), 'me_halal_way' => $this->input->post('me_halal_way'), 'profile_image' => $current_profile);
                 // check to see if we are updating the user
                 if ($this->ion_auth->update($user->id, $data)) {
                     // redirect them back to the admin page if admin, or to the base url if non admin
                     $this->session->set_flashdata('message', $this->ion_auth->messages());
                     $user = $this->ion_auth->user($merchant_id)->row();
                     redirect('all/merchant_dashboard/' . $user->slug . '//' . $user->id, 'refresh');
                 } else {
                     // redirect them back to the admin page if admin, or to the base url if non admin
                     $this->session->set_flashdata('message', $this->ion_auth->errors());
                 }
             }
         }
         if ($this->input->post('button_action') == "change_image") {
             if (!$this->upload->do_upload()) {
                 $error = array('error' => $this->upload->display_errors());
                 $this->session->set_flashdata('message', $this->upload->display_errors());
             } else {
                 $image_data = array('upload_data' => $this->upload->data());
                 //$this->ion_auth->set_message('image_upload_successful');
                 $data = array('profile_image' => $this->upload->data('file_name'));
                 if ($this->ion_auth->update($merchant_id, $data)) {
                     $this->session->set_flashdata('message', 'Merchant logo success update.');
                 } else {
                     $this->session->set_flashdata('message', $this->ion_auth->errors());
                 }
             }
             redirect('all/merchant_dashboard/' . $this->session->userdata('company_slug') . '//' . $merchant_id, 'refresh');
         } else {
             if ($this->input->post('button_action') == "view_branch") {
                 redirect('merchant/branch', 'refresh');
             } else {
                 if ($this->input->post('button_action') == "add_branch") {
                     redirect('merchant/branch/add', 'refresh');
                 } else {
                     if ($this->input->post('button_action') == "view_supervisor") {
                         redirect('merchant/supervisor', 'refresh');
                     } else {
                         if ($this->input->post('button_action') == "add_supervisor") {
                             redirect('merchant/supervisor/add', 'refresh');
                         }
                     }
                 }
             }
         }
     }
     $this->data['image_path'] = $this->album_merchant_profile;
     $this->data['image'] = $user->profile_image;
     // display the edit user form
     $this->data['csrf'] = $this->_get_csrf_nonce();
     // set the flash data error message if there is one
     $this->data['message'] = validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'));
     // pass the user to the view
     $this->data['user'] = $user;
     $this->data['is_supervisor'] = $is_supervisor;
     $this->data['company_main'] = array('name' => 'company_main', 'id' => 'company_main', 'type' => 'text', 'readonly' => 'true', 'value' => $this->form_validation->set_value('company_main', $user->company_main));
     $this->data['company'] = array('name' => 'company', 'id' => 'company', 'type' => 'text', 'value' => $this->form_validation->set_value('company', $user->company));
     $promo_code = $this->m_custom->promo_code_get('merchant', $user->id, 1);
     $this->data['promo_code_no'] = array('name' => 'promo_code_no', 'id' => 'promo_code_no', 'type' => 'text', 'readonly' => 'true', 'value' => $promo_code);
     $this->data['promo_code_url'] = $this->m_custom->generate_promo_code_list_link($promo_code, 33);
     $this->data['me_ssm'] = array('name' => 'me_ssm', 'id' => 'me_ssm', 'type' => 'text', 'readonly' => 'true', 'value' => $this->form_validation->set_value('me_ssm', $user->me_ssm));
     //If is not changeable then change to text box read only
     //        $this->data['category_list'] = $this->ion_auth->get_main_category_list();
     //        $this->data['me_category_id'] = array(
     //            'name' => 'me_category_id',
     //            'id' => 'me_category_id',
     //            'value' => $this->form_validation->set_value('me_category_id'),
     //        );
     $this->data['me_category_id'] = array('name' => 'me_category_id', 'id' => 'me_category_id', 'type' => 'text', 'readonly' => 'true', 'value' => $this->m_custom->get_one_table_record('category', 'category_id', $user->me_category_id)->category_label);
     $this->data['sub_category_selected'] = $user->me_sub_category_id;
     $this->data['sub_category_list'] = $this->m_custom->getSubCategoryList(NULL, NULL, $user->me_category_id);
     $this->data['me_sub_category_id'] = array('name' => 'me_sub_category_id', 'id' => 'me_sub_category_id');
     $this->data['address'] = array('name' => 'address', 'id' => 'address', 'readonly' => 'true', 'value' => $this->form_validation->set_value('address', $user->address));
     $this->data['postcode'] = array('name' => 'postcode', 'id' => 'postcode', 'type' => 'text', 'readonly' => 'true', 'value' => $this->form_validation->set_value('postcode', $user->postcode));
     $this->data['state_selected'] = $user->me_state_id;
     $this->data['state_list'] = $this->ion_auth->get_static_option_list('state');
     $this->data['me_state_id'] = array('name' => 'me_state_id', 'id' => 'me_state_id', 'value' => $this->form_validation->set_value('me_state_id'));
     $this->data['country_selected'] = $user->country;
     $this->data['country_list'] = array('Malaysia' => 'Malaysia');
     $this->data['me_country'] = array('name' => 'me_country', 'id' => 'me_country', 'value' => $this->form_validation->set_value('me_country'));
     $default_desc = '<b>Operating Hours : </b>' . PHP_EOL . PHP_EOL . PHP_EOL . '<b>Services : </b>' . PHP_EOL . PHP_EOL . PHP_EOL . '<b>Specialties : </b>' . PHP_EOL . PHP_EOL . PHP_EOL . '<b>Payment : </b>' . PHP_EOL;
     $this->data['description'] = array('name' => 'description', 'id' => 'description', 'value' => empty($user->description) ? $default_desc : $this->form_validation->set_value('description', $user->description));
     $this->data['phone'] = array('name' => 'phone', 'id' => 'phone', 'type' => 'text', 'value' => $this->form_validation->set_value('phone', $user->phone), 'class' => 'phone_blur');
     $this->data['person_incharge'] = array('name' => 'person_incharge', 'id' => 'person_incharge', 'type' => 'text', 'value' => $this->form_validation->set_value('person_incharge', $user->me_person_incharge));
     $this->data['person_contact'] = array('name' => 'person_contact', 'id' => 'person_contact', 'type' => 'text', 'value' => $this->form_validation->set_value('person_contact', $user->me_person_contact), 'class' => 'phone_blur');
     $this->data['website'] = array('name' => 'website', 'id' => 'website', 'type' => 'text', 'value' => $this->form_validation->set_value('website', $user->me_website_url));
     $this->data['facebook_url'] = array('name' => 'facebook_url', 'id' => 'facebook_url', 'type' => 'text', 'value' => $this->form_validation->set_value('facebook_url', $user->me_facebook_url));
     $this->data['branch_name'] = array('name' => 'branch_name', 'id' => 'branch_name', 'readonly' => 'true', 'value' => $branch ? $branch->name : '');
     $this->data['branch_address'] = array('name' => 'branch_address', 'id' => 'branch_address', 'readonly' => 'true', 'value' => $branch ? $branch->address : '');
     $this->data['branch_phone'] = array('name' => 'branch_phone', 'id' => 'branch_phone', 'readonly' => 'true', 'value' => $branch ? $branch->phone : '');
     $this->data['branch_state'] = array('name' => 'branch_state', 'id' => 'branch_state', 'readonly' => 'true', 'value' => $branch ? $this->m_custom->display_static_option($branch->state_id) : '');
     $this->data['supervisor_username'] = array('name' => 'supervisor_username', 'id' => 'supervisor_username', 'readonly' => 'true', 'value' => $is_supervisor == 1 ? $supervisor->username : $user->username);
     $this->data['supervisor_password'] = array('name' => 'supervisor_password', 'id' => 'supervisor_password', 'readonly' => 'true', 'value' => $is_supervisor == 1 ? $supervisor->password_visible : $user->password_visible);
     //        $me_is_halal = $user->me_is_halal;
     //        $this->data['me_is_halal'] = array(
     //            'name' => 'me_is_halal',
     //            'id' => 'me_is_halal',
     //            'checked' => $me_is_halal == "1" ? TRUE : FALSE,
     //            'value' => $user->me_is_halal,
     //        );
     $this->data['halal_way_selected'] = $user->me_halal_way;
     $this->data['halal_way_list'] = $this->ion_auth->get_static_option_list('halal_way');
     $this->data['me_halal_way'] = array('name' => 'me_halal_way', 'id' => 'me_halal_way');
     $this->data['temp_folder'] = $this->temp_folder;
     $this->data['page_path_name'] = 'merchant/profile';
     $this->load->view('template/index', $this->data);
 }
Ejemplo n.º 10
0
                 break;
         }
     }
     break;
 case 'tag':
     if (isset($_GET['mode'])) {
         switch ($_GET['mode']) {
             case 'edit':
                 if (permissions('blog', 'tag', 'edit') && isset($_POST['tag_tag_generate'])) {
                     // -- slug --
                     switch (intval($_POST['tag_tag_generate'])) {
                         case 0:
                             $tag = $_POST['tag']['tag'];
                             break;
                         case 1:
                             $tag = generate_slug($_POST['tag']['header']);
                             break;
                         case 2:
                             $tag = $_POST['tag_tag_original'];
                             break;
                     }
                     $sql = new MySQLObject();
                     if ($sql->query("\r\nUPDATE " . $sql->table('blog_tags') . "\r\nSET\r\n\t`header` = '" . $sql->escape($_POST['tag']['header']) . "',\r\n\t`tag` = '" . $sql->escape($tag) . "'\r\nWHERE (`tag` = '" . $sql->escape($_GET['tag']) . "')")) {
                         // -- OK --
                         $tpl->assign('REDIRECT_LOCATION', './acp.php?c=blog&section=tag');
                         $syslog->alert_success('{L_ALERT_BLOG_TAG_EDIT_SUCCESS}');
                         die;
                     } else {
                         $syslog->alert_error('{L_ALERT_BLOG_TAG_EDIT_ERROR}');
                         die;
                     }
Ejemplo n.º 11
0
 function merchant_edit($edit_id, $low_balance_only = 0)
 {
     if (!$this->m_admin->check_is_any_admin(78)) {
         redirect('/', 'refresh');
     }
     $message_info = '';
     $login_id = $this->login_id;
     $login_type = $this->login_type;
     $result = $this->m_custom->getUser($edit_id, $this->group_id_merchant);
     if (empty($result)) {
         redirect('/', 'refresh');
     }
     if (isset($_POST) && !empty($_POST)) {
         $can_redirect_to = 0;
         $id = $this->input->post('id');
         $username = strtolower($this->input->post('username'));
         $email = strtolower($this->input->post('email'));
         $company_main = $this->input->post('company_main');
         $company = $this->input->post('company');
         $me_person_incharge = $this->input->post('me_person_incharge');
         $me_person_contact = $this->input->post('me_person_contact');
         $me_ssm = $this->input->post('me_ssm');
         $me_category_id = $this->input->post('me_category_id');
         $address = $this->input->post('address');
         $postcode = $this->input->post('postcode');
         $me_state_id = $this->input->post('me_state_id');
         $phone = $this->input->post('phone');
         //$me_is_halal = $this->input->post('me_is_halal') == NULL ? 0 : 1;
         $me_halal_way = $this->input->post('me_halal_way');
         // to generate company slug for check is it unique
         $_POST['slug'] = generate_slug($_POST['company']);
         $slug = $_POST['slug'];
         $tables = $this->config->item('tables', 'ion_auth');
         // validate form input
         $this->form_validation->set_rules('username', $this->lang->line('create_merchant_validation_username_label'), 'trim|required|is_unique_edit[' . $tables['users'] . '.username.' . $edit_id . ']');
         $this->form_validation->set_rules('email', $this->lang->line('create_merchant_validation_email_label'), 'trim|required|valid_email|is_unique_edit[' . $tables['users'] . '.email.' . $edit_id . ']');
         $this->form_validation->set_rules('company_main', $this->lang->line('create_merchant_validation_company_main_label'), "trim|required|min_length[3]");
         $this->form_validation->set_rules('company', $this->lang->line('create_merchant_validation_company_label'), "trim|required|min_length[3]");
         $this->form_validation->set_rules('slug', $this->lang->line('create_merchant_validation_company_label'), 'trim|is_unique_edit[' . $tables['users'] . '.slug.' . $edit_id . ']');
         $this->form_validation->set_rules('me_person_incharge', $this->lang->line('create_merchant_validation_person_incharge_label'));
         //$this->form_validation->set_rules('me_person_contact', $this->lang->line('create_merchant_validation_person_contact_label'), 'required|valid_contact_number');
         $this->form_validation->set_rules('me_person_contact', $this->lang->line('create_merchant_validation_person_contact_label'));
         $this->form_validation->set_rules('me_ssm', $this->lang->line('create_merchant_validation_companyssm_label'), 'required');
         $this->form_validation->set_rules('me_category_id', $this->lang->line('create_merchant_category_label'), 'callback_check_main_category');
         $this->form_validation->set_rules('address', $this->lang->line('create_merchant_validation_address_label'), 'required');
         $this->form_validation->set_rules('postcode', $this->lang->line('create_merchant_validation_postcode_label'), 'required|numeric');
         $this->form_validation->set_rules('me_state_id', $this->lang->line('create_merchant_validation_state_label'), 'callback_check_state_id');
         //$this->form_validation->set_rules('phone', $this->lang->line('create_merchant_validation_phone_label'), 'required|valid_contact_number');
         $this->form_validation->set_rules('phone', $this->lang->line('create_merchant_validation_phone_label'));
         if ($this->input->post('button_action') == "save") {
             if ($this->form_validation->run() === TRUE) {
                 $data = array('username' => $username, 'email' => $email, 'company_main' => $company_main, 'company' => $company, 'slug' => $slug, 'me_person_incharge' => $me_person_incharge, 'me_person_contact' => $me_person_contact, 'me_ssm' => $me_ssm, 'me_category_id' => $me_category_id, 'address' => $address, 'postcode' => $postcode, 'me_state_id' => $me_state_id, 'phone' => $phone, 'me_halal_way' => $me_halal_way);
                 //if ($this->m_admin->check_is_any_admin(87))
                 if (check_correct_login_type($this->group_id_admin)) {
                     $merchant_worker_selected = array();
                     $post_merchant_worker = $this->input->post('merchant_worker');
                     if (!empty($post_merchant_worker)) {
                         foreach ($post_merchant_worker as $key => $value) {
                             $merchant_worker_selected[] = $value;
                         }
                     }
                 }
                 if ($this->ion_auth->update($edit_id, $data)) {
                     $message_info = add_message_info($message_info, $company . ' success update.');
                     $this->m_custom->update_row_log('users', $edit_id, $login_id, $login_type);
                     if (check_correct_login_type($this->group_id_admin)) {
                         $this->m_custom->many_insert_or_remove('merchant_worker', $edit_id, $merchant_worker_selected);
                     }
                     $can_redirect_to = 1;
                 } else {
                     $message_info = add_message_info($message_info, $this->ion_auth->errors());
                     $can_redirect_to = 1;
                 }
             }
         }
         if ($this->input->post('button_action') == "back") {
             $can_redirect_to = 2;
         }
         if ($this->input->post('button_action') == "frozen") {
             $message_info = add_message_info($message_info, $company . ' success remove.');
             $this->m_custom->update_hide_flag(1, 'users', $edit_id);
             $can_redirect_to = 2;
         }
         if ($this->input->post('button_action') == "recover") {
             $message_info = add_message_info($message_info, $company . ' success recover.');
             $this->m_custom->update_hide_flag(0, 'users', $edit_id);
             $can_redirect_to = 2;
         }
         direct_go:
         if ($message_info != NULL) {
             $this->session->set_flashdata('message', $message_info);
         }
         if ($can_redirect_to == 1) {
             redirect(uri_string(), 'refresh');
         } elseif ($can_redirect_to == 2) {
             if ($low_balance_only == 1) {
                 redirect('admin/merchant_management/1', 'refresh');
             } else {
                 redirect('admin/merchant_management', 'refresh');
             }
         }
     }
     // set the flash data error message if there is one
     $this->data['message'] = validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'));
     $this->data['result'] = $result;
     $this->data['title'] = "Merchant Edit";
     $this->data['can_edit'] = 1;
     $this->data['username'] = array('name' => 'username', 'id' => 'username', 'type' => 'text', 'value' => $this->form_validation->set_value('username', $result['username']));
     $this->data['email'] = array('name' => 'email', 'id' => 'email', 'type' => 'text', 'value' => $this->form_validation->set_value('email', $result['email']));
     $this->data['company_main'] = array('name' => 'company_main', 'id' => 'company_main', 'type' => 'text', 'value' => $this->form_validation->set_value('company_main', $result['company_main']));
     $this->data['company'] = array('name' => 'company', 'id' => 'company', 'type' => 'text', 'value' => $this->form_validation->set_value('company', $result['company']));
     $this->data['me_person_incharge'] = array('name' => 'me_person_incharge', 'id' => 'me_person_incharge', 'type' => 'text', 'value' => $this->form_validation->set_value('me_person_incharge', $result['me_person_incharge']));
     $this->data['me_person_contact'] = array('name' => 'me_person_contact', 'id' => 'me_person_contact', 'type' => 'text', 'value' => $this->form_validation->set_value('me_person_contact', $result['me_person_contact']));
     $this->data['me_ssm'] = array('name' => 'me_ssm', 'id' => 'me_ssm', 'type' => 'text', 'value' => $this->form_validation->set_value('me_ssm', $result['me_ssm']));
     $this->data['category_selected'] = $result['me_category_id'];
     //$this->data['category_list'] = $this->ion_auth->get_main_category_list();
     $this->data['category_list'] = $this->m_custom->getCategoryList();
     $this->data['me_category_id'] = array('name' => 'me_category_id', 'id' => 'me_category_id', 'value' => $this->form_validation->set_value('me_category_id'));
     $this->data['address'] = array('name' => 'address', 'id' => 'address', 'value' => $this->form_validation->set_value('address', $result['address']));
     $this->data['postcode'] = array('name' => 'postcode', 'id' => 'postcode', 'type' => 'text', 'value' => $this->form_validation->set_value('postcode', $result['postcode']));
     $this->data['state_selected'] = $result['me_state_id'];
     $this->data['state_list'] = $this->ion_auth->get_static_option_list('state');
     $this->data['me_state_id'] = array('name' => 'me_state_id', 'id' => 'me_state_id', 'value' => $this->form_validation->set_value('me_state_id'));
     $this->data['phone'] = array('name' => 'phone', 'id' => 'phone', 'type' => 'text', 'value' => $this->form_validation->set_value('phone', $result['phone']));
     //        $me_is_halal = $result['me_is_halal'];
     //        $this->data['me_is_halal'] = array(
     //            'name' => 'me_is_halal',
     //            'id' => 'me_is_halal',
     //            'checked' => $me_is_halal == "1" ? TRUE : FALSE,
     //            'value' => $result['me_is_halal'],
     //        );
     $this->data['halal_way_selected'] = $result['me_halal_way'];
     $this->data['halal_way_list'] = $this->ion_auth->get_static_option_list('halal_way');
     $this->data['me_halal_way'] = array('name' => 'me_halal_way', 'id' => 'me_halal_way');
     $this->data['merchant_worker_current'] = empty($result) ? array() : $this->m_custom->many_get_childlist('merchant_worker', $result['id']);
     $this->data['merchant_worker'] = $this->m_admin->getAllWorker();
     $this->data['page_path_name'] = 'admin/merchant_edit';
     $this->load->view('template/index', $this->data);
 }
Ejemplo n.º 12
0
 function edit($id = 0)
 {
     if ($id == NULL) {
         $id = 0;
     }
     // make sure user is an admin
     if (!$this->ion_auth->is_group('editors') and !$this->ion_auth->is_admin()) {
         $this->session->set_flashdata('message', 'You must be an admin to view this page.');
         redirect('auth/login');
     }
     //validate form input
     $this->form_validation->set_rules('title', 'Page Title', 'required|xss_clean');
     $this->form_validation->set_rules('slug', 'Page Identifier', 'xss_clean');
     $this->form_validation->set_rules('body', 'Page Content', '');
     $this->form_validation->set_rules('pageOrder', 'Order', 'is_numeric');
     $this->form_validation->set_rules('active', 'Page Active?', '');
     if ($this->form_validation->run() == TRUE) {
         if ($this->input->post('delete')) {
             // deleting page
             if ($this->Page_model->delete_page($id)) {
                 $this->session->set_flashdata('alert_string', 'Page deleted successfully.');
             } else {
                 $this->session->set_flashdata('error_string', 'Could not delete page. Please contact the site administrator.');
             }
             redirect(base_url() . 'page/admin');
         } else {
             // saving user
             // if no slug was submitted, generate one from the page title
             if ($this->input->post('slug') == NULL) {
                 $slug = generate_slug($this->input->post('title'));
             } else {
                 $slug = generate_slug($this->input->post('slug'));
             }
             $pageOrder = $this->input->post('pageOrder');
             if ($this->input->post('active') == 1) {
                 $active = '1';
             } else {
                 $active = '0';
             }
             $page = array('title' => $this->input->post('title'), 'slug' => $slug, 'page_body' => $this->input->post('page_body'), 'pageOrder' => $pageOrder, 'active' => $active);
             // set our modify date
             if ($id > 0) {
                 // existing page
                 $page['date_modified'] = date('U');
             } else {
                 // new page
                 $page['date_created'] = date('U');
                 $page['date_modified'] = date('U');
             }
             if ($this->Page_model->save_page($id, $page) == TRUE) {
                 $alert_string = 'Page saved successfully.';
             } else {
                 $error_string = 'Page changes did not save. Please contact the site administrator.';
             }
             if (isset($alert_string)) {
                 $this->session->set_flashdata('alert_string', $alert_string);
             }
             if (isset($error_string)) {
                 $this->session->set_flashdata('error_string', $error_string);
             }
             redirect(base_url() . 'page/admin', 'refresh');
         }
     }
     $this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message');
     // setup form fields
     $this->data['title'] = array('name' => 'title', 'id' => 'title', 'type' => 'text');
     $this->data['slug'] = array('name' => 'slug', 'id' => 'slug', 'type' => 'text');
     $this->data['page_body'] = array('name' => 'page_body', 'id' => 'page_body');
     $this->data['pageOrder'] = array('name' => 'pageOrder', 'id' => 'pageOrder');
     $this->data['active'] = array('name' => 'active', 'id' => 'active', 'value' => '1');
     // set field values depending on if we're editing an existing page or creating a new one
     if ($id > 0) {
         // populate from database
         $page = $this->Page_model->get_page_by_id($id);
         $this->data['title']['value'] = $this->form_validation->set_value('title', $page['title']);
         $this->data['slug']['value'] = $this->form_validation->set_value('slug', $page['slug']);
         $this->data['page_body']['value'] = $this->form_validation->set_value('page_body', $page['page_body']);
         $this->data['pageOrder']['value'] = $this->form_validation->set_value('pageOrder', $page['pageOrder']);
         $this->data['active']['checked'] = $this->form_validation->set_value('active', $page['active']);
     } else {
         // blank form
         $page = NULL;
         $this->data['title']['value'] = $this->form_validation->set_value('title', NULL);
         $this->data['slug']['value'] = $this->form_validation->set_value('slug', NULL);
         $this->data['page_body']['value'] = $this->form_validation->set_value('page_body', NULL);
         $this->data['active']['checked'] = $this->form_validation->set_value('active', TRUE);
     }
     $this->data['page'] = $page;
     if (isset($error_string)) {
         $this->data['error_string'] = $error_string;
     }
     if (isset($alert_string)) {
         $this->data['alert_string'] = $alert_string;
     }
     if ($this->input->is_ajax_request()) {
         // ajax request, return the form only
         $this->load->view('page_admin_form', $this->data);
     } else {
         // not ajax, return the whole page
         $this->template->title('Page Editor')->set_partial('extra_head', 'rich_editor_load')->build('page_admin_form', $this->data);
     }
 }
Ejemplo n.º 13
0
'>Logout</a>
                                        </ul>
                                    </li>
                                    <li style="display:none">
                                        <a href='<?php 
            echo base_url('merchant/logout');
            ?>
'>
                                            <i class='fa fa-sign-out header-top-bar-navigation-icon'></i> Logout
                                        </a>
                                    </li>
                                    <?php 
        } else {
            if (check_correct_login_type($this->config->item('group_id_supervisor'))) {
                $the_row = $this->m_custom->get_parent_table_record('users', 'id', $login_user_id, 'su_merchant_id', 'users', 'id');
                $header_merchant_slug = generate_slug($the_row->company);
                $where_read_user = array('id' => $login_user_id);
                $login_main_merchant_id = $this->albert_model->read_user($where_read_user)->row()->su_merchant_id;
                $follower_count = $this->albert_model->follower_count($login_main_merchant_id);
                $merchant_id = $this->ion_auth->user()->row()->su_merchant_id;
                $notification_count = $this->m_custom->notification_count($merchant_id) + $this->m_custom->getAdvertise_expired($merchant_id, 1);
                ?>
                                    <li>
                                        <a>My Account</a>
                                        <ul>
                                            <li><a href='<?php 
                echo base_url("all/merchant_dashboard/{$header_merchant_slug}//{$login_main_merchant_id}");
                ?>
' class='layout-inner-right-menu-bar <?php 
                if ($fetch_method == 'merchant_dashboard' || $fetch_method == 'merchant_outlet' || $fetch_method == 'map') {
                    echo "layout-inner-right-menu-bar-active";
Ejemplo n.º 14
0
            <!--TITLE-->           
            <div id="hot-deal-information-title">
                <a href='<?php 
echo $merchant_dashboard_url;
?>
'> <?php 
echo $merchant_name;
?>
</a>            
            </div>
            <!--SHOW ME ADDRESS-->
            <div id="hot-deal-information-show-me-address">
                <?php 
$merchant_info = $this->m_merchant->getMerchant(0, NULL, $merchant_name);
$merchant_info_id = $merchant_info['id'];
$show_outlet = base_url() . 'all/merchant_outlet/' . generate_slug($merchant_name) . '/' . $merchant_info_id . '#outlet';
?>
                <a href="<?php 
echo $show_outlet;
?>
" target="_blank">
                    <img src="<?php 
echo base_url() . "/image/icon-map.png";
?>
"/>Show me Address
                </a>
            </div>
            <div class="float-fix"></div>
            <?php 
//COUNTDOWN
if ($post_hour != 0) {
 /**
  * Upload the filename to a filepath.
  *
  * @param string $pathname The absolute folder WITHOUT trailing slash
  * @param int $status Exception code
  * @param string $filename File name without extension
  * @param string $ext File extension with dot
  * @param string $mime MIME type
  */
 public function uploadTo($pathname, &$status, &$filename = null, &$ext = null, &$mime = null)
 {
     if (!$this->uploadRequestOK()) {
         $status = UPLOAD_EXTRA_ERR_INVALID_REQUEST;
         return false;
     }
     switch ($_FILES[$this->fileEntry]['error']) {
         case UPLOAD_ERR_NO_FILE:
         case UPLOAD_ERR_INI_SIZE:
         case UPLOAD_ERR_FORM_SIZE:
         case UPLOAD_ERR_PARTIAL:
         case UPLOAD_ERR_NO_TMP_DIR:
         case UPLOAD_ERR_CANT_WRITE:
         case UPLOAD_ERR_EXTENSION:
             // Return the same error
             $status = $_FILES[$this->fileEntry]['error'];
             return false;
         case UPLOAD_ERR_OK:
             // It's OK
             break;
         default:
             DEBUG && error(sprintf(_("FileUploader ha ottenuto un errore sconosciuto: %d."), $_FILES[$this->fileEntry]['error']));
             $status = UPLOAD_EXTRA_ERR_GENERIC_ERROR;
             return false;
     }
     // Check filesize
     if ($this->args['max-filesize'] !== null && $_FILES[$this->fileEntry]['size'] > $this->args['max-filesize']) {
         $status = UPLOAD_EXTRA_ERR_OVERSIZE;
         return false;
     }
     // Check original MIME type
     $mime = get_mimetype($_FILES[$this->fileEntry]['tmp_name']);
     if (!$mime) {
         $status = UPLOAD_EXTRA_ERR_CANT_READ_MIMETYPE;
         return false;
     }
     // Check if MIME type it's allowed
     if (!$GLOBALS['mimeTypes']->isMimetypeInCategory($mime, $this->args['category'])) {
         $status = UPLOAD_EXTRA_ERR_UNALLOWED_MIMETYPE;
         return false;
     }
     // Check original file extension
     $ext = $GLOBALS['mimeTypes']->getFileExtensionFromExpectations($_FILES[$this->fileEntry]['name'], $this->args['category'], $mime);
     if (!$ext) {
         $status = UPLOAD_EXTRA_ERR_UNALLOWED_FILE;
         return false;
     }
     if ($this->args['override-filename'] === null) {
         // Strip original complete file name from extension
         $filename = substr($_FILES[$this->fileEntry]['name'], 0, -(strlen($ext) + 1));
     } else {
         // Override file name
         $filename = $this->args['override-filename'];
     }
     // Append prefix (if any)
     $filename = $this->args['pre-filename'] . $filename;
     if ($this->args['slug']) {
         $filename = generate_slug($filename);
     }
     // Make sure that the destination folder exists
     create_path($pathname);
     // Append a suffix to the filename if it already exists
     $filename = search_free_filename($pathname . _, $filename, $ext, $this->args);
     // File name with extension
     $complete_filename = "{$filename}.{$ext}";
     // File name length
     if (strlen($complete_filename) < $this->args['min-length-filename']) {
         $status = UPLOAD_EXTRA_ERR_FILENAME_TOO_SHORT;
         return false;
     }
     // File name length
     if (strlen($complete_filename) > $this->args['max-length-filename']) {
         $status = UPLOAD_EXTRA_ERR_FILENAME_TOO_LONG;
         return false;
     }
     $moved = move_uploaded_file($_FILES[$this->fileEntry]['tmp_name'], $pathname . _ . $complete_filename);
     if (!$moved) {
         $status = UPLOAD_EXTRA_ERR_CANT_SAVE_FILE;
         return false;
     }
     $status = UPLOAD_ERR_OK;
     return $complete_filename;
 }
Ejemplo n.º 16
0
            <div id='user-review-navigation-separater'>|</div> 
            <div id='user-review-navigation-each'>
                <a href="<?php 
echo $user_review_rating;
?>
" >Rating</a>
            </div>
        </div>
        <?php 
foreach ($review_list as $row) {
    $act_refer_type = $row['act_refer_type'];
    $advertise_id = $row['act_refer_id'];
    $sub_category_id = $row['sub_category_id'];
    $merchant_id = $row['merchant_id'];
    $merchant_name = $this->m_custom->display_users($merchant_id);
    $merchant_dashboard_url = base_url() . "all/merchant-dashboard/" . generate_slug($merchant_name) . '//' . $merchant_id;
    $advertise_detail_url = base_url() . "all/advertise/" . $advertise_id;
    $average_rating = $this->m_custom->activity_rating_average($advertise_id, 'adv');
    $rating_count = $this->m_custom->activity_rating_count($advertise_id, 'adv');
    $user_rating = $this->m_custom->activity_rating_this_user($advertise_id, $act_refer_type);
    ?>
            <div id='advertise-list-box'>
                <?php 
    if ($this->router->fetch_method() != 'merchant_dashboard') {
        ?>
                    <div id="advertise-list-title1">
                        <a href='<?php 
        echo $merchant_dashboard_url;
        ?>
'> <?php 
        echo $merchant_name;
Ejemplo n.º 17
0
 public function test_generate_slug()
 {
     $actual = generate_slug(['title' => 'Hello John']);
     $expected = time() . '-hello-john';
     $this->assertEquals($expected, $actual);
 }
Ejemplo n.º 18
0
 function add_merchant()
 {
     if (!check_correct_login_type($this->main_group_id)) {
         redirect('/', 'refresh');
     }
     $login_id = $this->ion_auth->user()->row()->id;
     $tables = $this->config->item('tables', 'ion_auth');
     if (isset($_POST) && !empty($_POST)) {
         $_POST['slug'] = generate_slug($_POST['company']);
         $slug = $_POST['slug'];
     }
     // validate form input
     if (empty($_FILES['userfile']['name'])) {
         $this->form_validation->set_rules('userfile', 'Merchant Logo', 'required');
     }
     //$this->form_validation->set_rules('company_main', $this->lang->line('create_merchant_validation_company_main_label'), "trim|required|min_length[3]");
     $this->form_validation->set_rules('company', $this->lang->line('create_merchant_validation_company_label'), "trim|required|min_length[3]");
     $this->form_validation->set_rules('slug', $this->lang->line('create_merchant_validation_company_label'), 'trim|is_unique[' . $tables['users'] . '.slug]');
     $this->form_validation->set_rules('address', $this->lang->line('create_merchant_validation_address_label'), 'required');
     //$this->form_validation->set_rules('postcode', $this->lang->line('create_merchant_validation_postcode_label'), 'required|numeric');
     $this->form_validation->set_rules('me_state_id', $this->lang->line('create_merchant_validation_state_label'), 'callback_check_state_id');
     //$this->form_validation->set_rules('me_category_id', $this->lang->line('create_merchant_category_label'), 'callback_check_main_category');
     $this->form_validation->set_rules('me_sub_category_id', $this->lang->line('create_merchant_sub_category_label'), 'callback_check_sub_category');
     if ($this->form_validation->run() == true) {
         $username = generate_random_string($slug);
         $email = generate_random_string($slug, 1);
         $password = $this->config->item('password_example');
         //$company_main = $this->input->post('company_main');
         $company_main = '';
         $company = $this->input->post('company');
         $address = $this->input->post('address');
         //$postcode = $this->input->post('postcode');
         $postcode = '';
         $state = $this->input->post('me_state_id');
         $country = 'Malaysia';
         $profile_image = NULL;
         //$me_is_halal = $this->input->post('me_is_halal') == NULL ? 0 : 1;
         $me_halal_way = $this->input->post('me_halal_way');
         if (!empty($_FILES['userfile']['name'])) {
             $upload_rule = array('upload_path' => $this->album_merchant_profile, 'allowed_types' => $this->config->item('allowed_types_image'), 'max_size' => $this->config->item('max_size'), 'max_width' => $this->config->item('max_width'), 'max_height' => $this->config->item('max_height'));
             $this->load->library('upload', $upload_rule);
             if (!$this->upload->do_upload()) {
                 $this->session->set_flashdata('message', $this->upload->display_errors());
             } else {
                 //$image_data = array('upload_data' => $this->upload->data());
                 $profile_image = $this->upload->data('file_name');
             }
         }
         $additional_data = array('username' => $username, 'company_main' => $company_main, 'company' => $company, 'slug' => $slug, 'address' => $address, 'postcode' => $postcode, 'country' => $country, 'me_state_id' => $state, 'me_category_id' => $this->config->item('food_category_id'), 'me_sub_category_id' => $this->input->post('me_sub_category_id'), 'main_group_id' => $this->config->item('group_id_merchant'), 'password_visible' => $password, 'me_addby_user' => $login_id, 'me_notyet_active' => 1, 'profile_image' => $profile_image, 'me_halal_way' => $me_halal_way);
         $group_ids = array($this->config->item('group_id_merchant'));
         $new_id = $this->ion_auth->register($username, $password, $email, $additional_data, $group_ids);
         if ($new_id) {
             $this->m_user->candie_history_insert(35, $new_id, 'users');
             $this->session->set_flashdata('message', 'Merchant account successfully created, Please add a photo for this merchant. Thank You.');
             redirect("user/upload_for_merchant/" . $new_id, 'refresh');
         } else {
             goto add_merchant_fail;
         }
     } else {
         add_merchant_fail:
         $this->data['message'] = validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'));
         $this->data['company_main'] = array('name' => 'company_main', 'id' => 'company_main', 'type' => 'text', 'value' => $this->form_validation->set_value('company_main'));
         $this->data['company'] = array('name' => 'company', 'id' => 'company', 'type' => 'text', 'value' => $this->form_validation->set_value('company'));
         $this->data['address'] = array('name' => 'address', 'id' => 'address', 'value' => $this->form_validation->set_value('address'));
         $this->data['postcode'] = array('name' => 'postcode', 'id' => 'postcode', 'type' => 'text', 'value' => $this->form_validation->set_value('postcode'));
         $this->data['state_list'] = $this->m_custom->get_static_option_array('state', '0', 'Please Select');
         $this->data['me_state_id'] = array('name' => 'me_state_id', 'id' => 'me_state_id', 'value' => $this->form_validation->set_value('me_state_id'));
         $me_category_id = $this->form_validation->set_value('me_category_id') == '' ? '' : $this->form_validation->set_value('me_category_id');
         $this->data['category_list'] = $this->m_custom->getCategoryList('0', 'Please Select');
         $this->data['me_category_id'] = array('name' => 'me_category_id', 'id' => 'me_category_id', 'value' => $me_category_id, 'onChange' => "get_SubCategory()");
         $this->data['sub_category_list'] = $this->m_custom->getSubCategoryList('0', 'Please Select', 1);
         //$this->data['sub_category_list'] = $this->m_custom->getSubCategoryList(NULL, NULL, $me_category_id);
         $this->data['me_sub_category_id'] = array('name' => 'me_sub_category_id', 'id' => 'me_sub_category_id', 'value' => $this->form_validation->set_value('me_sub_category_id'));
         //            $this->data['me_is_halal'] = array(
         //                'name' => 'me_is_halal',
         //                'id' => 'me_is_halal',
         //                'value' => '1', //Just to have some value, checkbox have to have value
         //            );
         $this->data['halal_way_list'] = $this->ion_auth->get_static_option_list('halal_way');
         $this->data['me_halal_way'] = array('name' => 'me_halal_way', 'id' => 'me_halal_way');
         $this->data['temp_folder'] = $this->temp_folder;
         $this->data['page_path_name'] = 'user/add_merchant';
         $this->load->view('template/layout', $this->data);
     }
 }
Ejemplo n.º 19
0
if (empty($href)) {
    respond(0, "Please specify an 'href' argument.");
} else {
    if (empty($space)) {
        respond(0, "Please specify a 'space' argument.");
    } else {
        if (empty($content)) {
            respond(0, "Please specify a 'content' argument.");
        } else {
            if (empty($summary)) {
                respond(0, "Please specify a 'summary' argument.");
            }
        }
    }
}
// Set some default values, if not specified
if (empty($summary)) {
    $summary = '<i>No summary provided</i>';
}
if (empty($version)) {
    $version = '1.0';
}
// Generate a URL slug and creation time
$created = date('Y-m-d H:i:s');
$modified = $created;
$url_slug = generate_slug();
$domain = calculate_domain($href);
// Save the shift to storage
$db->query("\n  INSERT INTO shift\n  (user_id, space, href, summary, content, domain,\n   url_slug, created, modified, version, status)\n  VALUES ({$user->id}, '{$space}', '{$href}', '{$summary}', '{$content}', '{$domain}',\n          '{$url_slug}', '{$created}', '{$modified}', '{$version}', '{$status}')\n");
// Done
respond(1, array('id' => $url_slug, 'message' => 'Success.'));