public function set($cat_id = null, $action = null)
 {
     $this->load->model('categories_model');
     if (isset($cat_id)) {
         //attempt to get cat
         $this->data['category'] = $this->categories_model->get_category($cat_id);
         if (!$this->data['category']) {
             show_404();
         }
         $title = 'Edit Category';
     } else {
         $title = 'Add category';
     }
     $this->data['title'] = $title;
     //did we want to delete the user?
     $this->data['action_confirm'] = $action;
     if ($action == 'delete' && @$this->input->post('action-confirm') == 'delete') {
         $result = $this->categories_model->delete_category($cat_id);
         if (@$result) {
             $this->flash->set('action', 'Category was deleted.', TRUE);
             return redirect(site_url() . 'admin/categories');
         } else {
             $this->flash->set('action', 'Error occured when deleting the category.', TRUE);
             return redirect(site_url() . 'admin/categories');
         }
     }
     if ($this->input->post()) {
         // load form validation library
         $this->load->library(array('form_validation'));
         $this->load->helper('url');
         // set rules
         $this->form_validation->set_rules('cat_name', '', 'required|strip_tags')->set_rules('cat_slug', '', 'required|strip_tags|callback__cds_check_duplicate');
         $this->form_validation->set_message('_cds_check_duplicate', 'Short Name should be unique');
         // if form validates
         if ($this->form_validation->run() == true) {
             //if image uploaded
             if (@$_FILES['cat_image']['name']) {
                 $this->load->helper('image_upload_helper');
                 $img_config = array('width' => 142, 'height' => 142);
                 $img_data = image_upload($cat_id, 'cat_image', @$this->data['category']['cat_image'], 'categories', $img_config);
                 if (@$img_data['result'] === true) {
                     $result = $this->categories_model->update_img($cat_id, $img_data['file_name']);
                 } else {
                     $this->flash->set('error', 'Image was not uploaded.', TRUE);
                 }
                 if (!$result) {
                     $this->flash->set('error', 'Image was not updated.', TRUE);
                 }
             }
             //update category details
             $result = $this->categories_model->update_category($cat_id);
             if (@$result) {
                 $this->flash->set('action', 'Category added/updated.', TRUE);
                 return redirect(site_url() . 'admin/categories');
             } else {
                 $this->flash->set('error', 'Category not added/updated.', TRUE);
                 return redirect(current_url());
             }
         } else {
             $this->flash->set('error', 'Please correct the missing or wrong information.' . validation_errors(), TRUE);
         }
     }
     //if we want to make kittens, we need some cats
     if ($this->input->post()) {
         foreach ($this->input->post() as $key => $value) {
             $this->data['category'][$key] = $value;
         }
     }
     $this->data['categories'] = $this->categories_model->get_categories();
     $this->layout->set_title('Manage Categories')->set_breadcrumb('Manage Categories', 'admin/categories');
     $this->layout->set_title($title)->set_breadcrumb($title);
     $this->layout->set_js(array('views/admin/categories/set', 'plugins/jquery.validate'));
     $this->load->vars($this->data);
     $this->view = 'admin/categories/set';
 }
Esempio n. 2
0
<?php 
$id = $_GET['id'];
if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $parmalink = $_POST['parmalink'];
    $desc = stripcslashes(mysql_real_escape_string($_POST['desc']));
    $shortdesc = $_POST['shortdesc'];
    $category = $_POST['category'];
    $tags = $_POST['tags'];
    $status = $_POST['status'];
    //Adding General information
    $form_data = array('name' => mysql_real_escape_string($name), 'parmalink' => mysql_real_escape_string($parmalink), 'description' => mysql_real_escape_string($desc), 'short_description' => mysql_real_escape_string($shortdesc), 'tags' => mysql_real_escape_string($tags), 'last_update' => date("Y-m-d H:i:s"), 'status' => $status);
    UpdateData(POST, $form_data, "WHERE slno = " . $id . "");
    //Adding Featured Image
    if ($_FILES["postimage"]["name"] != "") {
        $newname = image_upload($_FILES["postimage"]["tmp_name"], $_FILES["postimage"]["name"], uniqid(), "../images/featured_image/");
        $form_data = array('image' => $newname);
        UpdateData(POST, $form_data, "WHERE slno = " . $id . "");
    }
    //Adding Category
    $array1 = $category;
    $array2 = get_cat_arr_id($id);
    $result = array_intersect($array1, $array2);
    if (count($array1) == count($array2) && count($array1) == count($result)) {
        $flag = FALSE;
    } else {
        $flag = TRUE;
    }
    if ($flag) {
        mysql_query("DELETE FROM `" . POST_CATEGORY . "` WHERE `post_id`='{$id}'");
        foreach ($category as $cat) {
 public function set($p_id = null, $action = null)
 {
     $this->load->model('products_model');
     $this->load->helper('dates_helper');
     if (@$p_id) {
         //attempt to get cat
         $this->data['product'] = $this->products_model->get_product_full($p_id);
         if (!$this->data['product']) {
             show_404();
         }
         $title = 'Edit Product';
     } else {
         $title = 'Add Product';
     }
     $this->data['title'] = $title;
     //did we want to delete?
     $this->data['action_confirm'] = $action;
     if ($action == 'delete' && @$this->input->post('action-confirm') == 'delete') {
         $result = $this->products_model->delete_product($p_id);
         if (@$result) {
             $this->flash->set('action', 'Product was removed.', TRUE);
             return redirect(site_url() . '/admin/products');
         } else {
             $this->flash->set('action', 'Error occured when deleting the product.', TRUE);
             return redirect(site_url() . '/admin/products');
         }
     }
     if ($this->input->post()) {
         // load form validation library
         $this->load->library('form_validation');
         $this->form_validation->set_rules(array(array('field' => 'p_page_order', 'label' => 'Page Order', 'rules' => implode('|', array('integer'))), array('field' => 'p_status', 'label' => 'Status', 'rules' => implode('|', array())), array('field' => 'p_slug', 'label' => 'Slug', 'rules' => implode('|', array('required'))), array('field' => 'p_code', 'label' => 'Code', 'rules' => implode('|', array())), array('field' => 'p_s_id', 'label' => 'Supplier', 'rules' => implode('|', array('required', 'integer'))), array('field' => 'p_name', 'label' => 'Name', 'rules' => implode('|', array('required'))), array('field' => 'p_description', 'label' => 'Description', 'rules' => implode('|', array())), array('field' => 'p_pu_id', 'label' => 'Product Unit', 'rules' => implode('|', array('integer'))), array('field' => 'p_price', 'label' => 'Price', 'rules' => implode('|', array('required'))), array('field' => 'p_cost', 'label' => 'Cost', 'rules' => implode('|', array('required'))), array('field' => 'p_stock_warning', 'label' => 'Stock Warning', 'rules' => implode('|', array('integer')))));
         // if form validates
         if ($this->form_validation->run() == true) {
             //update product
             if (empty($p_id)) {
                 $p_id = $this->products_model->insert_product();
             } else {
                 $p_id = $this->products_model->update_product($p_id);
             }
             if (@$p_id) {
                 //if image uploaded
                 if (@$_FILES['p_image']['name']) {
                     $this->load->helper('image_upload_helper.php');
                     $img_config = array('width' => 195, 'height' => 195);
                     $img_data = image_upload($p_id, 'p_image', @$this->data['product']['p_image'], 'products', $img_config);
                     if (@$img_data['result'] === true) {
                         $result = $this->products_model->update_img($p_id, $img_data['file_name']);
                     }
                 }
                 //if price/cost has changed
                 if (!empty($this->data['product'])) {
                     if ($this->input->post('p_price') != FALSE && $this->input->post('p_price') != $this->data['product']['p_price'] || $this->input->post('p_cost') != FALSE && $this->input->post('p_cost') != $this->data['product']['p_cost']) {
                         //update orders
                         $this->load->model('order_model');
                         $this->order_model->update_product_prices($p_id, $this->input->post('p_price'), $this->input->post('p_cost'));
                     }
                 }
                 $this->flash->set('action', 'Product added/updated.', TRUE);
                 return redirect(site_url() . 'admin/products');
             } else {
                 $this->flash->set('error', 'Product not added/updated.', TRUE);
                 return redirect(current_url());
             }
         } else {
             $this->flash->set('error', 'Please correct the missing or wrong information.' . validation_errors(), TRUE);
         }
     }
     //we need to know the possible field values
     $this->config->load('datasets');
     $this->data['frequencies'] = $this->config->item('commitment_frequencies');
     $this->data['periods'] = $this->config->item('commitment_periods');
     //we need some options from the auxillary tables
     $this->data['units'] = $this->products_model->get_product_units();
     $this->load->model('categories_model');
     $this->data['categories'] = $this->categories_model->get_categories();
     $this->load->model('suppliers_model');
     $this->data['suppliers'] = $this->suppliers_model->get_suppliers();
     $this->load->model('seasons_model');
     $this->data['named_seasons'] = $this->seasons_model->get_named_seasons();
     $this->layout->set_title('Manage Products')->set_breadcrumb('Manage Products', 'admin/products');
     $this->layout->set_title($title)->set_breadcrumb($title);
     $this->layout->set_js(array('views/admin/products/set', 'plugins/jquery.validate'));
     $this->load->vars($this->data);
     $this->view = 'admin/products/set';
 }
Esempio n. 4
0
<?php 
include 'template/header.php';
include 'template/menu.php';
?>


<?php 
if (!empty($_GET['product'])) {
    $product_info = product_info($_GET['product']);
    $product_id = $_GET['product'];
    if (!empty($product_info)) {
        if (!empty($_POST['submit'])) {
            if (!empty($_FILES['product_image']['name'])) {
                $product_image_url = image_upload();
            } else {
                $product_image_url = $product_info['product_image_url'];
            }
            if (isset($product_image_url)) {
                $update_product = update_product($product_id, $_POST['product_name'], $product_image_url, $_POST['category_id'], $_POST['unit_price']);
                if ($update_product == 1) {
                    header('Location:product.php');
                } else {
                    $errormessage = "Something wrong. Please Try Again!!";
                }
            } else {
                $errormessage = "Product Image is invalid. Please Try Again!!";
            }
        }
        $all_category = all_category();
        //for select box
Esempio n. 5
0
function user_edit()
{
    global $html_main_content, $DBH, $title;
    //check access
    if ($_SESSION['rules'] == 'admin') {
        //Update info
        if (isset($_POST['submit'])) {
            $img = image_upload();
            if ($_SESSION['err'] == '') {
                if ($img == '') {
                    $img = $_POST['avatar'];
                }
                $login = $_POST['login'];
                $lastname = $_POST['lastname'];
                $name = $_POST['name'];
                $surname = $_POST['surname'];
                $sql = "UPDATE user SET";
                if ($_POST['password'] !== '') {
                    $password = md5(trim($_POST['password']));
                    $sql .= " password=:password,";
                }
                if ($_POST['email'] !== '') {
                    $sql .= " email=:email,";
                }
                $sql .= " lastname=:lastname, name=:name, surname=:surname,\n        avatar=:avatar, date_reg=:date_reg, date_login=:date_login,\n        rules=:rules WHERE login=:login";
                $STH = $DBH->prepare($sql);
                if ($_POST['password'] !== '') {
                    $STH->bindParam(':password', $password);
                }
                if ($_POST['email'] !== '') {
                    $STH->bindParam(':email', $_POST['email']);
                }
                $STH->bindParam(':lastname', $lastname);
                $STH->bindParam(':name', $name);
                $STH->bindParam(':surname', $surname);
                $STH->bindParam(':avatar', $img);
                $STH->bindParam(':date_reg', $_POST['date_reg']);
                $STH->bindParam(':date_login', $_POST['date_login']);
                $STH->bindParam(':rules', $_POST['rules']);
                $STH->bindParam(':login', $login);
                $STH->execute();
                $_SESSION['err'] = print_lg('Your information update sucsesful', $_SESSION['lang']) . '<br>';
            }
            $_FILES['file']['error'] = '';
            show_err();
        }
        // Show html.
        $STH = $DBH->prepare("Select * FROM user WHERE login = :login");
        $data = array('login' => $_GET['id']);
        $STH->execute($data);
        $row = $STH->fetch(PDO::FETCH_ASSOC);
        $html_main_content .= '<div class="post"><h2 class="title">' . $title . '</h2><form method="post" enctype="multipart/form-data">
    <table><tr><td><b>' . print_lg('Avatar', $_SESSION['lang']) . '
    : </b></td><td><img src="/news/images/';
        if ($row['avatar'] == '') {
            $html_main_content .= 'noimage.jpeg';
        } else {
            $html_main_content .= $row['avatar'];
        }
        $html_main_content .= '"width="150px" height="150px"></td></tr><tr><td><b>' . print_lg('Login', $_SESSION['lang']) . ': </b></td><td>
      <input type="text" name="login" disabled="true" value="' . $row['login'] . '">
      </td></tr><tr><td><b>' . print_lg('Email', $_SESSION['lang']) . ': </b>
      </td><td><input type=text name="email" value=""></td>
      </tr><tr><td><b>' . print_lg('Surname', $_SESSION['lang']) . ': </b></td>
      <td><input type=text name="surname" value="' . $row['surname'] . '"></td>
      </tr><tr><td><b>' . print_lg('Name', $_SESSION['lang']) . ': </b></td><td>
      <input type=text name="name" value="' . $row['name'] . '"></td></tr><tr>
      <td><b>' . print_lg('Lastname', $_SESSION['lang']) . ': </b></td><td>
      <input type=text name="lastname"value="' . $row['lastname'] . '"></td>
      </tr><tr><td><b>' . print_lg('Registration date', $_SESSION['lang']) . ': </b></td><td><input type=text name="date_reg"value="' . $row['date_reg'] . '"></td></tr><tr><td><b>' . print_lg('Last login', $_SESSION['lang']) . ': </b></td><td>
        <input type=text name="date_login" value="' . $row['date_login'] . '"></td></tr><tr><td><b>' . print_lg('Rules', $_SESSION['lang']) . ': </b></td><td>
      <select name="rules"><option ';
        if ($row['rules'] == 'user') {
            $html_main_content .= 'selected ';
        }
        $html_main_content .= 'value="user">user</option><option ';
        if ($row['rules'] == 'editor') {
            $html_main_content .= 'selected ';
        }
        $html_main_content .= 'value="editor">editor</option><option ';
        if ($row['rules'] == 'baned') {
            $html_main_content .= 'selected ';
        }
        $html_main_content .= 'value="baned">baned</option><option ';
        if ($row['rules'] == 'admin') {
            $html_main_content .= 'selected ';
        }
        $html_main_content .= 'value="admin">admin</option>';
        $html_main_content .= '  </select></td></tr><tr><td><b>' . print_lg('Password', $_SESSION['lang']) . ': </b></td>
      <td><input type="Password" name="password" ></td>
      </tr><tr><td><b>' . print_lg('Retry password', $_SESSION['lang']) . ': </b></td><td>
      <input type="Password" name="rpassword"></td>
      </tr><tr><td><b>' . print_lg('Edit avatar', $_SESSION['lang']) . ': </b></td><td>
      <input type="file" name="file" size="26" /></td></tr>
      <input type="hidden" name="avatar" value="' . $row['avatar'] . '"></td>
      </tr><tr><td colspan="2"><b><input type="submit" value="ok" name="submit"
       onclick="return validateUserEdit();">
      </td></tr></table></form>&nbsp;</div>';
    }
}
Esempio n. 6
0
    }
}
//Edit an item
if (isset($_POST['edit_item'])) {
    if (empty($_POST['description'])) {
        $_POST['description'] = $_POST['item_name'];
    }
    //Upload image file
    // but if the image is NOT updated it needs to be ignored
    $item_image = "images/items/";
    $imgsql = "";
    if (isset($_POST['imagedefault']) && $_POST['imagedefault'] == "1") {
        $item_image .= "item.png";
        $imgsql = ", image='" . $item_image . "'";
    }
    if (isset($_FILES['item_image']['name']) && image_upload($_FILES['item_image'], $item_image)) {
        $item_image .= $_FILES['item_image']['name'];
        $imgsql = ", image='" . $item_image . "'";
    }
    $_POST = db_clean($_POST, $db);
    //Save values
    $sql = "update items set \r\nitem_name = '" . $_POST['item_name'] . "',\r\nitem_number = '" . $_POST['item_number'] . "',\r\ndescription = '" . $_POST['description'] . "',\r\nbrand_id = " . $_POST['brand_id'] . ",\r\ncategory_id = " . $_POST['category_id'] . ",\r\nsupplier_id = " . $_POST['supplier_id'] . ",\r\ntrade_price = '" . $_POST['trade_price'] . "',\r\n    wholesale = '" . $_POST['wholesale_price'] . "',\r\nunit_price = '" . $_POST['unit_price'] . "',\r\nsupplier_item_number = '" . $_POST['supplier_item_number'] . "',\r\ntax_percent = '" . $_POST['tax_percent'] . "',\r\ntotal_cost = '" . $_POST['total_cost'] . "',\r\nquantity = " . $_POST['quantity'] . ",\r\nreorder_level = " . $_POST['reorder_level'] . $imgsql . " where id=" . $_POST['item_id'];
    $db->query($sql);
}
//Delete item
if (isset($_GET['delete'])) {
    $sql = "delete from items where id=" . $_GET['delete'];
    $db->query($sql);
}
?>
<div class="admin_content">
Esempio n. 7
0
<?php 
include 'template/header.php';
include 'template/menu.php';
?>

<?php 
$all_product_name = all_product_name();
//for select box;s
$all_bundle_list = all_bundle_list();
//for all list show
/*******************************create bundle****************************************/
if (!empty($_POST['create'])) {
    $bundle_image_url = image_upload();
    if (!empty($bundle_image_url)) {
        $product_counter = $_POST['product_counter'];
        $product_array = array();
        for ($i = 1; $i <= $product_counter; $i++) {
            $product_field = 'product_' . $i;
            $product_unit = 'product_unit_' . $i;
            $product_array[] = ['product_id' => $_POST[$product_field], 'product_unit' => $_POST[$product_unit]];
        }
        $create_bundle = create_bundle($_POST['bundle_name'], $_POST['bundle_price'], $product_array, $bundle_image_url, $product_counter);
        if ($create_bundle == 1) {
            //$message = "Bundle has been created successfully.";
            header('Location:bundle.php');
        } else {
            $errormessage = "Something wrong. Please try again!!.";
        }
    } else {
        $errormessage = "Bundle Image is invalid. Please Try Again!!";
Esempio n. 8
0
        $output = "<br>That category is already loaded.";
    }
}
//Edit category
if (isset($_POST['submiteditcategory'])) {
    //Upload image file
    foreach ($_POST as $key => $val) {
        $_POST[$key] = $db->clean($_POST[$key]);
    }
    $category_image = "images/categories/";
    $imgsql = "";
    if (isset($_POST['imagedefault']) && $_POST['imagedefault'] == "1") {
        $category_image .= "category.png";
        $imgsql = ", image='" . $category_image . "'";
    }
    if (isset($_FILES['category_image']['name']) && image_upload($_FILES['category_image'], $category_image)) {
        $category_image .= $_FILES['category_image']['name'];
        $imgsql = ", image='" . $category_image . "'";
    } else {
        $category_image .= "category.png";
    }
    $sql = "update categories set category='" . $_POST['category'] . "' {$imgsql} where id=" . $_POST['category_id'];
    $db->query($sql);
}
//Delete category
if (isset($_GET['delete'])) {
    $sql = "delete from categories where id=" . $_GET['delete'];
    $db->query($sql);
}
?>
<div class="admin_content">
Esempio n. 9
0
<?php

include "config/config.php";
include "include/function.php";
include "include/logincheck.php";
if (isset($_POST['uploadfile'])) {
    $newname = image_upload($_FILES["sliderfile1"]["tmp_name"], $_FILES["sliderfile1"]["name"], uniqid(), "../uploads/");
    if ($newname) {
        $ext = pathinfo($newname, PATHINFO_EXTENSION);
        mysql_query("INSERT INTO `" . FILE_2_URL . "`(`file`,`userid`,`type`) VALUES ('{$newname}','{$_SESSION['auserid']}','{$ext}')");
        header("location:file-tourl.php");
    }
}
?>
<!DOCTYPE html>


<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->

<head>
<meta charset="utf-8"/>
<title><?php 
echo the_option("website_title");
?>
 | File To url</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Esempio n. 10
0
include "config/config.php";
include "admin/include/function.php";
include "include/common-scripts.php";
include "include/logincheck.php";
if (isset($_POST['submit1'])) {
    $form_data = array('userid' => $_SESSION['userid'], 'type' => "share:update", 'name' => "", 'parmalink' => "", 'description' => mysql_real_escape_string(stripcslashes($_POST["description"])), 'short_description' => "", 'tags' => "", 'image' => "", 'create_date' => date("Y-m-d H:i:s"), 'last_update' => date("Y-m-d H:i:s"), 'verified' => "yes", 'status' => "publish");
    InsertData(POST, $form_data);
    $id = mysql_insert_id();
    update_post_meta($id, "share_with", $_POST["share_with"]);
    header("location:profile.php?success");
}
if (isset($_POST['submit2'])) {
    //Adding Featured Image
    if ($_FILES["minpstimg"]["name"] != "") {
        $newname = image_upload($_FILES["minpstimg"]["tmp_name"], $_FILES["minpstimg"]["name"], uniqid(), "images/featured_image/");
    } else {
        $newname = "null.jpg";
    }
    $form_data = array('userid' => $_SESSION['userid'], 'type' => "share:image", 'name' => "", 'parmalink' => "", 'description' => mysql_real_escape_string(stripcslashes($_POST["description"])), 'short_description' => "", 'tags' => "", 'image' => $newname, 'create_date' => date("Y-m-d H:i:s"), 'last_update' => date("Y-m-d H:i:s"), 'verified' => "yes", 'status' => "publish");
    InsertData(POST, $form_data);
    $id = mysql_insert_id();
    update_post_meta($id, "share_with", $_POST["share_with"]);
    header("location:profile.php?success");
}
if (isset($_POST['submit3'])) {
    $form_data = array('userid' => $_SESSION['userid'], 'type' => "share:link", 'name' => "", 'parmalink' => "", 'description' => mysql_real_escape_string(stripcslashes($_POST["description"])), 'short_description' => "", 'tags' => "", 'image' => "", 'create_date' => date("Y-m-d H:i:s"), 'last_update' => date("Y-m-d H:i:s"), 'verified' => "yes", 'status' => "publish");
    InsertData(POST, $form_data);
    $id = mysql_insert_id();
    update_post_meta($id, "share_with", $_POST["share_with"]);
    update_post_meta($id, "url", $_POST["url"]);
 public function set($s_id = null)
 {
     if (!$this->auth->is_allowed_to('manage_suppliers', 'all') && !$this->auth->is_allowed_to('manage_suppliers', 's', $s_id)) {
         show_error('You do not have permission to manage this producer.');
     }
     $this->load->model('suppliers_model');
     if (@$s_id) {
         //attempt to get cat
         $this->data['supplier'] = $this->suppliers_model->get_supplier($s_id);
         if (!$this->data['supplier']) {
             show_404();
         }
         $title = 'Edit Producer';
     } else {
         $title = 'Add Producer';
     }
     if ($this->input->post()) {
         // load form validation library
         $this->load->library('form_validation');
         // set rules
         $this->form_validation->set_rules('s_name', '', 'required|strip_tags')->set_rules('s_description', '', 'required|strip_tags');
         // if form validates
         if ($this->form_validation->run() == true) {
             //update supplier
             $s_id = $this->suppliers_model->update_supplier($s_id);
             if (@$s_id) {
                 //if image uploaded
                 if (@$_FILES['s_image']['name']) {
                     $this->load->helper('image_upload_helper.php');
                     $img_config = array('width' => 142, 'height' => 142);
                     $img_data = image_upload($s_id, 's_image', @$this->data['supplier']['s_image'], 'suppliers', $img_config);
                     if (@$img_data['result'] === true) {
                         $result = $this->suppliers_model->update_img($s_id, $img_data['file_name']);
                     } else {
                         $this->flash->set('error', 'Image was not uploaded.', TRUE);
                     }
                     if (!$result) {
                         $this->flash->set('error', 'Image was not updated.', TRUE);
                     }
                 }
                 $this->flash->set('action', 'Producer added/updated.', TRUE);
                 return redirect(site_url() . 'admin/suppliers');
             } else {
                 $this->flash->set('error', 'Producer not added/updated.', TRUE);
                 return redirect(current_url());
             }
         } else {
             $this->flash->set('error', 'Please correct the missing or wrong information.' . validation_errors(), TRUE);
         }
     }
     $this->layout->set_title('Manage Producers')->set_breadcrumb('Manage Producers', 'admin/suppliers');
     $this->layout->set_title($title)->set_breadcrumb($title);
     $this->layout->set_js(array('views/admin/suppliers/set', 'plugins/jquery.validate'));
     $this->load->vars($this->data);
     $this->view = 'admin/suppliers/set';
 }
include "config/config.php";
include "include/function.php";
include "include/logincheck.php";
if (isset($_POST['submit'])) {
    if ($_POST['parent'] == "0") {
        $label = '0';
    } else {
        $cat_arr = get_the_category($_POST['parent']);
        $label = intval($cat_arr['label']) + 1;
    }
    $form_data = array('name' => $_POST['name'], 'desc' => mysql_real_escape_string(stripslashes($_POST['desc'])), 'parent' => $_POST['parent'], 'sort_order' => '0', 'label' => $label, 'image' => "null.jpg");
    InsertData(CATEGORY, $form_data);
    $id = mysql_insert_id();
    if ($_FILES["pic"]["name"] != "") {
        $s = image_upload($_FILES["pic"]["tmp_name"], $_FILES["pic"]["name"], 'logo_' . $id, '../images/category_image/');
        mysql_query("UPDATE `" . CATEGORY . "` SET  `image`='{$s}'  WHERE `slno`='{$id}'");
    }
    add_log_admin("Post Category {$_POST['name']}{{" . $id . "}} is added");
    header("location:post-category.php?addsuccess");
}
?>


<!DOCTYPE html>


<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
Esempio n. 13
0
 public function edit_banner()
 {
     chk_login();
     $this->data = '';
     //<!------------code------------------->
     $banner_id = $this->uri->segment(3, 0);
     $page = $this->uri->segment(4, 0);
     $this->data['controller'] = "banner";
     $this->data['return_link'] = BACKEND_URL . $this->data['controller'] . "/index/" . $page;
     $this->data['lastOrderLimit'] = $this->model_banner->lastOrderLimit();
     if ($this->input->get_post('action') == 'Process') {
         $this->form_validation->set_rules('banner_title', 'Alt Tag', 'trim|required|callback_is_name_exists');
         if ($this->form_validation->run() == FALSE) {
         } else {
             //if(file_exists($_FILES['banner_image']['tmp_name']))
             //{
             //       $imageDim = getimagesize($_FILES['banner_image']['tmp_name']);
             //       if(($imageDim[0]<1680)||($imageDim[1]<773))
             //       {
             //
             //		$this->nsession->set_userdata('errmsg', "Image dimensions do not match please upload image with dimentions 1680x773.");
             //		redirect(base_url()."banner/index/".$page."/");
             //       }
             //}
             $banner_image = '';
             if ($_FILES['banner_image']['name'] != "") {
                 $upload_config['field_name'] = 'banner_image';
                 $upload_config['file_upload_path'] = 'banner/';
                 $upload_config['max_size'] = '';
                 $upload_config['max_width'] = '1920';
                 $upload_config['max_height'] = '580';
                 $upload_config['allowed_types'] = '*';
                 $thumb_config['thumb_create'] = true;
                 $thumb_config['thumb_file_upload_path'] = 'thumb/';
                 $thumb_config['thumb_width'] = '';
                 $thumb_config['thumb_height'] = '';
                 $isUploaded = image_upload($upload_config, $thumb_config);
                 $banner_image = $isUploaded;
                 $currentFile = $this->input->post('currentFile');
                 $arr_banner_image_old = $this->model_banner->get_single($banner_id);
                 $banner_image_old = $arr_banner_image_old[0]['banner_image'];
                 if ($isUploaded == '') {
                     $this->nsession->set_userdata('errmsg', $this->nsession->userdata('upload_err'));
                     $this->nsession->set_userdata('upload_err', '');
                     redirect(base_url() . "banner/");
                     return false;
                 } else {
                     if (file_exists(FILE_UPLOAD_ABSOLUTE_PATH . 'banner/' . stripslashes($banner_image_old)) && stripslashes($banner_image_old) != "") {
                         unlink(FILE_UPLOAD_ABSOLUTE_PATH . 'banner/' . stripslashes($banner_image_old));
                         unlink(FILE_UPLOAD_ABSOLUTE_PATH . 'banner/thumb/' . stripslashes($banner_image_old));
                     }
                     $banner_title = addslashes($this->input->post('banner_title'));
                     $banner_image = !$isUploaded ? $currentFile : $banner_image;
                     $banner_order = addslashes($this->input->post('banner_order'));
                     $banner_status = addslashes($this->input->post('banner_status'));
                     $banner_updated_on = date('Y-m-d H:i:s');
                     $insertArr = array('banner_title' => $banner_title, 'banner_image' => $banner_image, 'banner_order' => !$banner_order ? '-999' : $banner_order, 'banner_status' => $banner_status, 'banner_updated_on' => $banner_updated_on);
                     $idArr = array('banner_id' => $banner_id);
                     $ret = $this->model_basic->updateIntoTable(BANNER_MASTER, $idArr, $insertArr);
                     if ($ret) {
                         $this->nsession->set_userdata('succmsg', "Banner updated successfully.");
                     } else {
                         $this->nsession->set_userdata('errmsg', "Unable to update. Please try again later.");
                     }
                     redirect(BACKEND_URL . "banner/index/" . $page . "/");
                     return true;
                 }
             } else {
                 $banner_title = addslashes($this->input->post('banner_title'));
                 $banner_order = addslashes($this->input->post('banner_order'));
                 $banner_status = addslashes($this->input->post('banner_status'));
                 $banner_updated_on = date('Y-m-d H:i:s');
                 $insertArr = array('banner_title' => $banner_title, 'banner_order' => !$banner_order ? '-999' : $banner_order, 'banner_status' => $banner_status, 'banner_updated_on' => $banner_updated_on);
                 $idArr = array('banner_id' => $banner_id);
                 $ret = $this->model_basic->updateIntoTable(BANNER_MASTER, $idArr, $insertArr);
                 if ($ret) {
                     $this->nsession->set_userdata('succmsg', "Banner updated successfully.");
                 } else {
                     $this->nsession->set_userdata('errmsg', "Unable to update. Please try again later.");
                 }
                 redirect(BACKEND_URL . "banner/index/" . $page . "/");
                 return true;
             }
         }
     }
     $row = array();
     // Prepare Data
     $Condition = " banner_id = '" . $banner_id . "'";
     $rs = $this->model_basic->getValues_conditions(BANNER_MASTER, '', '', $Condition);
     $row = $rs[0];
     if ($row) {
         $this->data['arr_banner'] = $row;
     } else {
         $this->nsession->set_userdata('errmsg', "Record does not exist.");
         redirect(BACKEND_URL . $this->data['controller'] . "/edit_banner/" . $page . "/");
         return false;
     }
     //For breadcrump..........
     $this->data['brdLink'][0]['logo'] = 'fa fa-file';
     $this->data['brdLink'][0]['name'] = 'CMS';
     $this->data['brdLink'][0]['link'] = 'javascript:void(0)';
     $this->data['brdLink'][1]['logo'] = 'fa fa-picture-o';
     $this->data['brdLink'][1]['name'] = 'Banner Listing';
     $this->data['brdLink'][1]['link'] = BACKEND_URL . "banner/index";
     $this->data['brdLink'][2]['logo'] = '';
     $this->data['brdLink'][2]['name'] = 'Edit Banner';
     $this->data['brdLink'][2]['link'] = 'javascript:void(0)';
     //........................
     //<!------------code------------------->
     //$this->data['brdLink']='';
     $this->data['base_url'] = BACKEND_URL . $this->data['controller'] . "/index/0/1/";
     $this->data['edit_url'] = BACKEND_URL . $this->data['controller'] . "/edit_banner/" . $banner_id . "/" . $page . "/";
     $this->data['succmsg'] = $this->nsession->userdata('succmsg');
     $this->data['errmsg'] = $this->nsession->userdata('errmsg');
     $this->nsession->set_userdata('succmsg', "");
     $this->nsession->set_userdata('errmsg', "");
     $this->templatelayout->get_topbar();
     $this->templatelayout->get_leftmenu();
     $this->templatelayout->get_footer();
     $this->elements['middle'] = 'banner/edit';
     $this->elements_data['middle'] = $this->data;
     $this->layout->setLayout('layout');
     $this->layout->multiple_view($this->elements, $this->elements_data);
 }
<?php

include "config/config.php";
include "admin/include/function.php";
if (!empty($_FILES)) {
    echo $newname = image_upload($_FILES["file"]["tmp_name"], $_FILES["file"]["name"], uniqid() . rand(0, 999999), "images/gallery_post/");
}
?>
  
Esempio n. 15
0
    update_user_option($id, "link_in", mysql_real_escape_string(stripcslashes($_POST['link_in'])));
    if ($error == "") {
        $form_data = array('username' => mysql_real_escape_string(stripcslashes($_POST['username'])), 'email' => mysql_real_escape_string(stripcslashes($_POST['email'])), 'fname' => mysql_real_escape_string(stripcslashes($_POST['fname'])), 'lname' => mysql_real_escape_string(stripcslashes($_POST['lname'])), 'phone' => mysql_real_escape_string(stripcslashes($_POST['phone'])), 'occupation' => mysql_real_escape_string(stripcslashes($_POST['occupation'])), 'updated' => date("Y-m-d H:i:s"));
        UpdateData(USER, $form_data, "WHERE slno = " . $id . "");
        log_edit_user($id);
        echo "1";
        sleep(1);
    } else {
        echo trim($error, "<br>");
    }
    exit;
}
if (isset($_POST["form_2"])) {
    $id = $_SESSION["userid"];
    //Adding Profile Image
    $newname = image_upload($_FILES["thumb"]["tmp_name"], $_FILES["thumb"]["name"], uniqid(), "images/profile_image/");
    $form_data = array('thumb' => mysql_real_escape_string($newname), 'updated' => date("Y-m-d H:i:s"));
    UpdateData(USER, $form_data, "WHERE slno = " . $id . "");
    log_edit_user($id);
    add_user_option($id, "profile_img", $newname);
    sleep(1);
    exit;
}
if (isset($_POST["form_3"])) {
    $id = $_SESSION["userid"];
    $userarr = get_the_user($_SESSION["userid"]);
    if ($userarr["password"] == $_POST["current_password"]) {
        $form_data = array('password' => mysql_real_escape_string(stripcslashes($_POST["new_password"])), 'updated' => date("Y-m-d H:i:s"));
        UpdateData(USER, $form_data, "WHERE slno = " . $id . "");
        log_edit_user($id);
        echo "1";
Esempio n. 16
0
 public function index()
 {
     chk_login();
     $this->data = '';
     $profile_type = $this->uri->segment(3);
     //$page_type	= $this->uri->segment(3, 0);
     //$this->data['result']=$page_type;
     $logged_id = $this->nsession->userdata('admin_id');
     $type = $this->nsession->userdata('role');
     if ($this->input->get_post('profile') == 'editprofile') {
         $this->form_validation->set_rules('first_name', 'First Name', 'trim|required');
         $this->form_validation->set_rules('last_name', 'Last Name', 'trim|required|callback_is_name_pair_exists');
         if ($this->form_validation->run() == FALSE) {
         } else {
             $user_image = '';
             if ($_FILES['user_image']['name'] != "") {
                 $upload_config['field_name'] = 'user_image';
                 $upload_config['file_upload_path'] = 'admin/';
                 $upload_config['max_size'] = '';
                 $upload_config['max_width'] = '1200';
                 $upload_config['max_height'] = '800';
                 $upload_config['allowed_types'] = 'jpg|jpeg|gif|png';
                 $thumb_config['thumb_create'] = true;
                 $thumb_config['thumb_file_upload_path'] = 'thumb/';
                 $thumb_config['thumb_width'] = '';
                 $thumb_config['thumb_height'] = '';
                 $user_image = '';
                 $sUploaded = image_upload($upload_config, $thumb_config);
                 $user_image = $sUploaded;
                 $arr_user_image_old = $this->model_adminuser->get_single($logged_id);
                 $user_image_old = $arr_user_image_old[0]['image'];
                 if ($sUploaded == '') {
                     $this->nsession->set_userdata('errmsg', $this->nsession->userdata('upload_err'));
                     $this->nsession->set_userdata('upload_err', '');
                     redirect(base_url() . "profile/index");
                     return false;
                 } else {
                     if (file_exists(FILE_UPLOAD_ABSOLUTE_PATH . 'admin/' . stripslashes($user_image_old)) && stripslashes($user_image_old) != "") {
                         unlink(FILE_UPLOAD_ABSOLUTE_PATH . 'admin/' . stripslashes($user_image_old));
                         unlink(FILE_UPLOAD_ABSOLUTE_PATH . 'admin/thumb/' . stripslashes($user_image_old));
                     }
                     $this->user_model->updateAdminUsersProfile($logged_id, $user_image, $type);
                     $this->nsession->set_userdata('succmsg', "Admin user profile details updated successfully.");
                     redirect(base_url() . "profile/index/");
                     return true;
                 }
             } else {
                 $this->user_model->updateAdminUsersProfile($logged_id, '', $type);
                 $this->nsession->set_userdata('succmsg', "Admin user profile details updated successfully.");
                 redirect(base_url() . "profile/index");
                 return true;
             }
         }
     }
     if ($this->input->get_post('account') == 'editaccount') {
         $this->form_validation->set_rules('email_address', 'Email Address', 'trim|required|valid_email|callback_is_email_exists');
         $this->form_validation->set_rules('password', 'Password', 'trim|required');
         $this->form_validation->set_rules('conf_password', 'Confirm Password', 'trim|required|matches[password]');
         if ($this->form_validation->run() == FALSE) {
         } else {
             $this->user_model->updateAdminUsersAccount($logged_id, $type);
             $this->nsession->set_userdata('succmsg', "Admin user account details updated successfully.");
             redirect(base_url() . "profile/index/account");
             return true;
         }
     }
     if ($this->input->get_post('contact') == 'editcontact') {
         $this->user_model->updateAdminUsersContact($logged_id, $type);
         $this->nsession->set_userdata('succmsg', "Admin user contact details updated successfully.");
         redirect(base_url() . "profile/index/contact");
         return true;
     }
     $this->data['base_url'] = BACKEND_URL . "dashboard";
     $this->data['profile_url'] = BACKEND_URL . "profile/index";
     $this->data['user_info'] = $this->model_adminuser->get_single($logged_id);
     //$this->data['logged_info'] = $this->model_adminuser->get_single($logged_id);
     //For breadcrump..........
     $this->data['brdLink'][0]['logo'] = 'fa fa-user';
     $this->data['brdLink'][0]['name'] = 'User Profile';
     $this->data['brdLink'][0]['link'] = 'javascript:void(0)';
     //........................
     $this->data['succmsg'] = $this->nsession->userdata('succmsg');
     $this->data['errmsg'] = $this->nsession->userdata('errmsg');
     $this->nsession->set_userdata('succmsg', "");
     $this->nsession->set_userdata('errmsg', "");
     $this->templatelayout->get_topbar();
     $this->templatelayout->get_leftmenu();
     $this->templatelayout->get_footer();
     $this->elements['middle'] = 'users/profile';
     $this->elements_data['middle'] = $this->data;
     $this->layout->setLayout('layout');
     $this->layout->multiple_view($this->elements, $this->elements_data);
 }