Example #1
0
 public function import()
 {
     $this->application->setDevMode(true);
     ignore_user_abort(true);
     ini_set('memory_limit', '512M');
     set_time_limit(0);
     if ($this->request->get('password') != $this->config->get('CLONE_STORE_API_KEY')) {
         return new RawResponse('Wrong password');
     }
     ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=0;');
     ActiveRecord::getLogger()->setLogFileName(null);
     $dir = $this->getFileDir();
     //if (ob_get_length())
     //{
     ob_flush();
     ob_end_clean();
     //}
     //echo str_repeat('FLUSH ', 10000);
     foreach (scandir($dir) as $file) {
         if (strlen($file) < 3) {
             continue;
         }
         $path = $dir . $file;
         if (substr($file, -4) == '.sql') {
             $f = fopen($path, 'r');
             $prev = '';
             while (!feof($f)) {
                 $s = $prev . fread($f, 1024 * 1024);
                 if (!feof($f)) {
                     $pos = strrpos($s, ";\n");
                     $prev = substr($s, $pos + 1);
                     $s = substr($s, 0, $pos);
                 }
                 Installer::loadDatabaseDump($s, true);
             }
         } else {
             $this->untar($path, ClassLoader::getRealPath('public.upload.'));
         }
         unlink($path);
     }
     $this->user->allowBackendAccess();
     $c = new ProductImageController($this->application);
     $c->resizeImages();
     Category::reindex();
     Category::recalculateProductsCount();
 }
Example #2
0
<?php

require_once "phpuploader/include_phpuploader.php";
?>
    
<?php 
$uploader = new PhpUploader();
$mvcfile = $uploader->GetValidatingFile();
if ($mvcfile->FileName == "accord.bmp") {
    $uploader->WriteValidationError("My custom error : Invalid file name. ");
    exit(200);
}
//USER CODE:
$productId = $_REQUEST["proId"];
$imageType = $_REQUEST["imgType"];
$savefilepath = "data/" . $productId . "_" . $imageType . "." . substr(strrchr($mvcfile->FileName, '.'), 1);
$targetfilepath = "../../" . $savefilepath;
if (is_file($targetfilepath)) {
    unlink($targetfilepath);
}
$mvcfile->MoveTo($targetfilepath);
$uploader->WriteValidationOK();
require_once "../../controller/ProductImageController.php";
ProductImageController::Update($productId, $imageType, $savefilepath);
?>
   
</script>
        </head>
        <body class="body" >
 <?php 
include_once 'header.php';
?>
                <div id="contain" class="contain contain box-transparent">
       	<?php 
if (isset($_REQUEST['productid']) && $_REQUEST['productid'] != null) {
    include_once $contextPath . "controller/ProductController.php";
    include_once $contextPath . "controller/CommentController.php";
    include_once $contextPath . "controller/ProductImageController.php";
    include_once $contextPath . "controller/UserController.php";
    $productid = $_REQUEST['productid'];
    $product_detail = ProductController::GetProductByID($_REQUEST['productid']);
    $productImage = ProductImageController::GetImageOfProductFromProductID($productid);
    $productComment = CommentController::GetCommentFromProductID($productid);
    $_SESSION["addCart"] = "true";
} else {
    Utils::redirect("product-list.php");
}
?>
  
	<?php 
require_once 'left-menu.php';
?>
                  
<div >
	<div class="product-detail-picture">
		<div id="image_wrap" >
			<div href='<?php 
		$("#msgResult").fadeOut(300);
		$("#dvImgResult").fadeOut(300);
	}

	function show_image(src) {
		$("#imgResult").attr('src',src);
		$("#dvImgResult").fadeIn(300);
	}
</script>
<div id="wrapper">
<div id="content">
<div id="box">
		<h3 id="adduser">PRODUCT</h3>
		<!--<form id="form" action="" method="post">-->
		<?php 
$image = ProductImageController::GetImageOfProductFromProductID($_REQUEST['proId']);
?>
			<fieldset id="personal">
				<legend>
					EDIT IMAGE TO PRODUCT
				</legend
				<label >Cover_Img : </label>
				<a href="#" onclick="show_image('<?php 
echo "../../" . $image['Cover_Img'];
?>
');"><?php 
echo $image['Cover_Img'];
?>
 </a>
				<img src="img/icons/user_delete.png"	style="cursor:pointer;"	onclick="deleteImg('Cover_Img',<?php 
echo $_REQUEST["proId"];
Example #5
0
            }
        }
    }
    //echo "<br>count session cart2=".count($_SESSION["cart"]);
}
//end check
if (count($_SESSION["cart"]) > 0) {
    include_once $contextPath . "controller/ProductController.php";
    include_once $contextPath . "controller/ProductImageController.php";
    include_once $contextPath . "controller/CartController.php";
    include_once $contextPath . "utility/Utils.php";
    $totalmoney = 0;
    echo "<form action='" . $contextPath . "controller/AddCartProcessor.php' method='post' id='frmCheckOut' name='frmCheckOut'>";
    for ($i = 0; $i < count($_SESSION["cart"]); $i++) {
        $product_detail = ProductController::GetProductByID($_SESSION["cart"][$i]);
        $productImage = ProductImageController::GetImageOfProductFromProductID($_SESSION["cart"][$i]);
        $totalmoney += $product_detail[4];
        if ($i % 2 == 0) {
            echo "<tr style='background-color: rgb(239, 239, 239);'>";
        } else {
            echo "<tr style='background-color: rgb(255, 255, 255);'>";
        }
        //Image
        echo "<td style='border-right:solid 1px #D3D3D3; padding:4px;' width='35px' align='center'><a href='' ><img  src='" . $contextPath . $productImage[1] . "'width='80px'/></a></td>";
        //productID
        echo "<td  align='center' style='border-right:solid 1px #D3D3D3; padding:4px;' width='20px'>\r\n\t\t\t\t\t\t\t  <a href='product-detail.php?productid=" . $product_detail[0] . "&type=" . $product_detail[2] . "'><b style='color:blue;'>" . $product_detail[0] . "</b></a></td>";
        //product Name
        echo "<td style='border-right:solid 1px #D3D3D3; padding:4px;'>" . $product_detail[1] . "</td>";
        //Quantity
        if (isset($_SESSION["curUser"]) && $_SESSION["curUser"][0] > 0) {
            $quantityofUser = CartController::GetCartByUserIDAndProductId($_SESSION["curUser"][0], $product_detail[0]);
            require_once "../utils/product_util.php";
            $id = $_REQUEST["id"];
            $result = ProductController::Delete($id);
            if ($result) {
                echo ProductUtil::createMessageBox("DELETE PRODUCT", "Delete completed!");
            } else {
                echo ProductUtil::createMessageBox("DELETE PRODUCT", "Delete does not complete!");
            }
        } else {
            if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "deleteImage") {
                include_once "../../../controller/ProductImageController.php";
                require_once "../utils/product_util.php";
                $id = $_REQUEST["proId"];
                $imgType = $_REQUEST["imgType"];
                $img = ProductImageController::GetImageOfProductFromProductID($id);
                $result = ProductImageController::Update($id, $imgType, "");
                $result = true;
                if ($result) {
                    if (unlink("../../../" . $img[$imgType])) {
                        echo ProductUtil::createMessageBox("DELETE IMAGE", "Delete completed!");
                        return;
                    }
                }
                echo ProductUtil::createMessageBox("DELETE IMAGE", "Delete does not complete!");
            }
        }
    }
}
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "search") {
    $name = $_REQUEST["name"];
    $type = $_REQUEST["type"];