Inheritance: extends Illuminate\Database\Migrations\Migration
Example #1
0
 public static function file($file)
 {
     if ($file["error"] == UPLOAD_ERR_OK) {
         $dir = $_SERVER['DOCUMENT_ROOT'] . '/';
         $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
         $name = Rename::translitIt($file['name']);
         $img = $dir . $name;
         /***проверяем есть ли файл в папке, если есть удаляем*****/
         $isset_file = DB::select("settings");
         $file_dir = $_SERVER['DOCUMENT_ROOT'] . '/' . $isset_file[0]['file'];
         //unlink($file_dir);
         if (file_exists($file_dir)) {
             unlink($file_dir);
         }
         /******помещаем новый загружаемый файл в папку****/
         move_uploaded_file($file['tmp_name'], $img);
         $arr_prov = array("file" => $name);
         DB::update(DB::updateSql("settings", $arr_prov), $arr_prov, 1);
         //$img = str_replace('../', '', $img);
         return $img;
     } else {
         return false;
     }
 }
Example #2
0
 public static function update($sql, $arr, $id)
 {
     $update = parent::$DBH->prepare($sql);
     $update->bindParam(':id', $id);
     foreach ($arr as $k => $v) {
         $update->bindParam(':' . $k, Rename::trimStr($v));
     }
     $result = $update->execute();
     return $result;
 }
 /**
  * Rename Folder
  *
  * @param name - required -
  *            The new name of the folder.
  * @param folderId - required -
  *            The id of the folder.
  * @return The Rename object which contains the status of the operation.
  */
 public function renameFolder($name, $folderId)
 {
     $parameters = array('name' => $name);
     $urld = 'dpi/v1/folder/' . $folderId . '/rename';
     $this->response = $this->restTransportInstance->sendRequest($urld, $parameters, self::HTTP_PUT, $this->authToken);
     $responseBody = simplexml_load_string($this->response);
     $returnObject = new Rename();
     if ($responseBody === false) {
         $errorCode = 'N/A';
         $errorMessage = 'The server has encountered an error, please try again.';
         $errorObject = new ErrorStatus($errorCode, $errorMessage);
         $returnObject->setErrorStatus($errorObject);
     } else {
         $errorStatus = $responseBody->errorStatus;
         if (empty($errorStatus)) {
             $returnObject->setStatus((string) $responseBody->status);
         } else {
             $errorCode = (string) $responseBody->errorStatus->code;
             $errorMessage = (string) $responseBody->errorStatus->message;
             $errorObject = new ErrorStatus($errorCode, $errorMessage);
             $returnObject->setErrorStatus($errorObject);
         }
     }
     return $returnObject;
 }
Example #4
0
<?php

include "controller/function.php";
$table = "catalog";
$title = "Каталог продукции";
$records = false;
if (isset($_POST["go"])) {
    if ($_POST["name_en"]) {
        $url = Rename::replace($_POST["name_en"]);
    } else {
        $url = Rename::replace($_POST["name_ru"]);
    }
    $save = array("parent" => $_POST["section"], "name_ru" => $_POST["name_ru"], "name_en" => $url, "title" => $_POST['title'], "desc" => $_POST['desc'], "keywords" => $_POST['keywords']);
    if ($_POST["go"] == "save") {
        $save += array("nn" => DB::selectAI($table));
        DB::insert(DB::insertSql($table, $save), $save);
        header("Location: " . $_SERVER['REQUEST_URI']);
    } else {
        DB::update(DB::updateSql($table, $save), $save, $_POST['go']);
        header("Location: " . $_SERVER['REQUEST_URI']);
    }
}
if (isset($_GET["delete"])) {
    DB::del($_GET["title"], $_GET["delete"]);
    if (isset($_GET["act"]) and $_GET["act"]) {
        header("Location: production.php?id=" . $_GET["act"] . "&table=catalog");
    } else {
        header("Location: production.php");
    }
}
if (isset($_GET["id"])) {
Example #5
0
 public function excute()
 {
     // Init Data
     $data['category'] = $this->that->mcategory->findAll();
     $data['error'] = '';
     // Config path image
     $old_path_name = APPPATH . '../assets/uploads/';
     // Submit was click
     if ($this->that->input->post('name')) {
         // Init image process
         $imageProcess = new ImageProcess($this->that);
         // Init image Config
         $myConfig = new MyConfig();
         // Get data product
         $data['product'] = $this->getDataProduct();
         $imageProcess->setConfig($myConfig->getConfigUpload());
         if (!$imageProcess->getUpload()->upload(new uploadUserLib())) {
             $data['error'] = $imageProcess->getUpload()->getError();
         } else {
             // Get image that uploaded
             $image_data = $imageProcess->getUpload()->getImage();
             // Resize image
             $imageProcess->setConfig($myConfig->getConfigResize());
             $imageProcess->getResize()->resize(new resizeUserLib());
             // Rename image
             $rename = new Rename($image_data, $old_path_name, new getNameByTime());
             $rename->excute();
             // Add link image to upload
             $data['product']['image'] = 'assets/uploads/' . $rename->getNewName()->getName();
             echo $data['product']['image'];
         }
         $this->that->mproduct->insert($data['product']);
         redirect('cproduct');
     } else {
         $this->that->load->view('product/insert', $data);
     }
 }
Example #6
0
}
if (isset($_GET['down'])) {
    $id = $_GET['id'];
    $sql_count = "SELECT count(nn)as amount FROM price WHERE section={$id}";
    $count = DB::selectSql($sql_count);
    $id_prod = $_GET['down'];
    $sql = "UPDATE price SET nn =" . $count[0]['amount'] . " WHERE id = {$id_prod}";
    DB::updatePM($sql);
}
if (isset($_POST["go"])) {
    $table = $_POST["table"];
    if ($table == "catalog") {
        if (!$_POST["name_en"]) {
            $_POST["name_en"] = Rename::replace($_POST["name_ru"]);
        } else {
            $_POST["name_en"] = Rename::replace($_POST["name_en"]);
        }
        $array = array("name_ru" => $_POST['name_ru'], "name_en" => $_POST['name_en'], "parent" => $_POST['parent'], "title" => $_POST['title'], "desc" => $_POST['desc'], "keywords" => $_POST['keywords']);
    } else {
        $array = array("name_ru" => $_POST['name_ru'], "title" => $_POST['title'], "text" => $_POST['text'], "parent" => 0);
        $src = DB::filesUpload($_FILES['photo'], $_POST["table"]);
        if ($src != false) {
            $array += array("src" => $src);
        }
    }
    if ($_POST["go"] == "save") {
        $array += array("nn" => DB::selectAI($table));
        DB::insert(DB::insertSql($table, $array), $array);
    } else {
        $id = $_POST["go"];
        DB::update(DB::updateSql($table, $array), $array, $id);
Example #7
0
<? include "controller/function.php";
$table = "catalog";
$title = "Каталог продукции";
$records = false;

if (isset($_POST["go"])) {
    if ($_POST["name_en"]) { $url = Rename::replace($_POST["name_en"]); } else { $url = Rename::replace($_POST["name_ru"]); }
    $save = array(
        "parent"=>$_POST["section"],
        "name_ru"=>$_POST["name_ru"],
        "name_en"=>$url,
        "title"=>$_POST['title'],
        "desc"=>$_POST['desc'],
        "keywords"=>$_POST['keywords']
    );
	if ($_POST["go"] == "save") {
        $save += array("nn"=>DB::selectAI($table));
		DB::insert(DB::insertSql($table,$save),$save);
		header("Location: ".$_SERVER['REQUEST_URI']);
	} else {
		DB::update(DB::updateSql($table,$save),$save,$_POST['go']);
		header("Location: ".$_SERVER['REQUEST_URI']);
	}
}

if (isset($_GET["delete"])) {
    DB::del($_GET["title"],$_GET["delete"]);
	if (isset($_GET["act"]) and $_GET["act"]) {
		header("Location: production.php?id=".$_GET["act"]."&table=catalog");
	} else {
		header("Location: production.php");