Exemplo n.º 1
0
 public function __construct()
 {
     // echo "ta aqui.".UserClient::getTypeId();exit();
     if (!UserClient::isAlive() || UserClient::getTypeId() != Config::ADMIN_USER_TYPE_ID && UserClient::getTypeId() != Config::DEVELOPER_USER_TYPE_ID) {
         $urlTo = Navigation::getURI(Config::$URL_ROOT_APPLICATION);
         Navigation::redirect("backend/login/to/" . implode("/", $urlTo));
     }
 }
Exemplo n.º 2
0
 /**
  * envie por post uma array de ids de files, só os ids
  * file/get_ziped_files
  */
 public function getZipedFiles()
 {
     if (!UserClient::getId() > 0) {
         //nao tem permissao
         Navigation::redirect("405");
         exit;
     }
     $array_file_ids = DataHandler::getValueByArrayIndex($_POST, "file_id");
     //Debug::print_r($_REQUEST);
     $array_file_vo = array();
     if (is_array($array_file_ids)) {
         foreach ($array_file_ids as $id) {
             $FileVO = new FileVO();
             $Result = $FileVO->setId($id, TRUE);
             if ($Result->success == TRUE) {
                 $array_file_vo[] = $FileVO;
             }
         }
     } else {
         //erro, não é uma array, verifica se pelo menos é 1 único id
         $id = DataHandler::forceInt($array_file_ids);
         if ($id > 0) {
             //é um id único
             $FileVO = new FileVO();
             $Result = $FileVO->setId($id, TRUE);
             if ($Result->success == TRUE) {
                 $array_file_vo[] = $FileVO;
             }
         } else {
             //erro mesmo, esse dado é zoado, estoura excessão
             throw new Exception("No ids sended", 404);
             exit;
         }
     }
     //a pasta zip precisa existir
     DataHandler::createFolderIfNotExist("upload/zip/");
     //verifica o nome do arquivo baseado nos ids enviados conforme regra inventada agora
     $zip_name = "upload/zip/" . md5(implode("|", $array_file_ids));
     DataHandler::createFolderIfNotExist($zip_name);
     $zip_name = $zip_name . "/teto.zip";
     if (!file_exists($zip_name)) {
         //echo Debug::li($zip_name);exit();
         $Zip = new ZipArchive();
         $Zip->open($zip_name, ZipArchive::CREATE);
         foreach ($array_file_vo as $FileVO) {
             $url = $FileVO->getUrl();
             $array = explode("/", $url);
             $file = $array[count($array) - 1];
             $Zip->addFile($url, $file);
         }
         $Zip->close();
     }
     header("Location: " . Config::getRootPath($zip_name));
     exit;
 }
 public function __construct($arrayRestFolder = NULL)
 {
     //verifica se o sujeito está logado e se é admin
     if (!UserClient::isAlive()) {
         Navigation::redirect("admin/login");
     } else {
         if (UserClient::getTypeId() != Config::ADMIN_USER_TYPE_ID && UserClient::getTypeId() != Config::DEVELOPER_USER_TYPE_ID) {
             //o sujeito ou não está logado ou ele não é admin
             Navigation::redirect("admin/login");
         }
     }
     if ($arrayRestFolder != NULL) {
         $this->arrayVariable = Navigation::getVariableArraySlug($arrayRestFolder);
         $this->arrayRestFolder = $arrayRestFolder;
     }
 }
Exemplo n.º 4
0
 public function __construct($arrayRestFolder = NULL)
 {
     if (!UserClient::isAlive()) {
         Navigation::redirect("client/login");
         exit;
     }
     $id_user = UserClient::getId();
     $PartnerDAO = PartnerDAO::getInstance();
     $ReturnPartnerDAO = $PartnerDAO->selectById($id_user);
     if ($ReturnPartnerDAO->success && count($ReturnPartnerDAO->result) > 0) {
         $_SESSION["is_partner"] = 1;
     }
     if ($arrayRestFolder != NULL) {
         $this->arrayRestFolder = $arrayRestFolder;
         $this->arrayVariable = Navigation::getVariableArraySlug($this->arrayRestFolder);
     }
     $this->DAO = PurchaseOrderDAO::getInstance();
 }
Exemplo n.º 5
0
function go($url = false)
{
    Navigation::redirect($url);
}
Exemplo n.º 6
0
 public function delete()
 {
     $ReturnResult = parent::delete();
     Navigation::redirect("backend/client/show/");
 }
Exemplo n.º 7
0
 /**
  * baixar o zip do mal
  * ?products={product_id:N,gallery:true,dimensions:true,files:[]}|{product_id:N,gallery:true,dimensions:true,files:[]}
  */
 public function getZip()
 {
     if (!UserClient::getId() > 0) {
         //nao tem permissao
         Navigation::redirect("405");
         exit;
     }
     set_time_limit(0);
     //tratando variaveis enviadas
     $files_id = DataHandler::getValueByArrayIndex($_POST, "file_id");
     $imagens = DataHandler::getValueByArrayIndex($_POST, "imagens");
     $pdf = DataHandler::getValueByArrayIndex($_POST, "pdf");
     //precisa saber quais sao os produtos envolvidos
     $array_products_id = array();
     $array_files = array();
     if ($files_id) {
         foreach ($files_id as $file_id) {
             $temp_array = explode("_", $file_id);
             $product_id = $temp_array[0];
             if (!in_array($product_id, $array_products_id)) {
                 $array_products_id[] = $product_id;
                 $array_files[] = $product_id;
             }
         }
     }
     if ($imagens) {
         foreach ($imagens as $product_id) {
             if (!in_array($product_id, $array_products_id)) {
                 $array_products_id[] = $product_id;
             }
         }
     }
     if ($pdf) {
         foreach ($pdf as $product_id) {
             if (!in_array($product_id, $array_products_id)) {
                 $array_products_id[] = $product_id;
             }
         }
     }
     $ReturnResultVO = new ReturnResultVO();
     $ProductVO = new ContentSiteVO();
     $FileVO = new FileVO();
     //se tiver produtos para tratar
     if (count($array_products_id) > 0) {
         //a pasta zip precisa existir
         $zip_path = "upload/zip/";
         DataHandler::createFolderIfNotExist($zip_path);
         $array_products_to_zip = array();
         $unique_str = "";
         //nome final do zip que vai baixar, adiciona alguns parametros indicadores
         $zip_name = "teto";
         if (count($array_products_id) > 0) {
             //sao varios produtos
             $zip_name = $zip_name . "_produtos";
         }
         //cada indice dessa array, tem que ser array, terá um json com as info:
         foreach ($array_products_id as $product_id) {
             $resultProduto = $ProductVO->setId($product_id, TRUE);
             if ($resultProduto->success) {
                 $stdProduct = $ProductVO->toStdClass();
                 $array_products_to_zip[] = $stdProduct;
                 $array_images = array();
                 if ($imagens) {
                     if (in_array($product_id, $imagens)) {
                         $array_gallery = $ProductVO->getImages(NULL, "gallery", true);
                         foreach ($array_gallery as $imageVO) {
                             $array_images[] = $imageVO->getURL();
                             $unique_str .= "|" . $imageVO->getId();
                             //add a imagem na pasta
                         }
                         //
                         $array_dimensions = $ProductVO->getImages(NULL, "dimensions", true);
                         foreach ($array_dimensions as $imageVO) {
                             $array_images[] = $imageVO->getURL();
                             //add a imagem na pasta
                             $unique_str .= "|" . $imageVO->getId();
                         }
                     }
                 }
                 $stdProduct->images = $array_images;
                 $array_file_vo = array();
                 //cria a pasta do produto no zip
                 $product_folder_name = DataHandler::strToURL($stdProduct->title);
                 if (count($array_files) > 0) {
                     if (in_array($product_id, $array_files)) {
                         //esse produto pediu algum file
                         $temp_array_files = $ProductVO->getFiles();
                         foreach ($temp_array_files as $FileVO) {
                             if (in_array($FileVO->id, $files_id)) {
                                 $array_file_vo[] = $FileVO;
                                 $unique_str .= "|f." . $file_id;
                                 //add a url do arquivo no zip na pasta
                             }
                         }
                     }
                 }
                 $stdProduct->files = $array_file_vo;
                 $stdProduct->pdf = null;
                 //verificar se quer o pdf
                 if (count($pdf) > 0) {
                     $unique_str .= "|pdf!|";
                     //quero pdf
                     //ver com onde foi salvo
                     if (in_array($product_id, $pdf)) {
                         //ele quer esse pdf, provavelmente se chegou aqui é porque ele realmente exite
                         //mas vou conferir de novo
                         $pdf_url = "upload/pdf/{$product_id}/" . $ProductVO->slug . ".pdf";
                         if (file_exists($pdf_url)) {
                             $stdProduct->pdf = $pdf_url;
                         }
                     }
                 }
             }
             //end if produto sucess
         }
         $folder_name = md5($unique_str);
         DataHandler::createFolderIfNotExist($zip_path . $folder_name . "/");
         $zip_name = $zip_path . $folder_name . "/" . $zip_name . ".zip";
         //echo $zip_name;exit();
         if (!file_exists($zip_name)) {
             //echo Debug::li($zip_name);exit();
             $Zip = new ZipArchive();
             $Zip->open($zip_name, ZipArchive::CREATE);
             //adicionando os arquivos escolhidos
             foreach ($array_products_to_zip as $ProductStd) {
                 $product_slug_folder = $ProductStd->id . "_" . DataHandler::strToURL($ProductStd->title);
                 foreach ($ProductStd->files as $FileVO) {
                     $url = $FileVO->getUrl();
                     $array = explode("/", $url);
                     $file = $array[count($array) - 1];
                     $Zip->addFile($url, $product_slug_folder . "/arquivos/" . $file);
                 }
                 foreach ($ProductStd->images as $url) {
                     //$url 	= $ImageVO->getUrl();
                     $array = explode("/", $url);
                     $file = $array[count($array) - 1];
                     $file = str_replace("original_", "", $file);
                     $Zip->addFile($url, $product_slug_folder . "/imagens/" . $file);
                 }
                 if ($ProductStd->pdf) {
                     $url = $ProductStd->pdf;
                     $array = explode("/", $url);
                     $file = $array[count($array) - 1];
                     $Zip->addFile($url, $product_slug_folder . "/ficha_tecnica.pdf");
                 }
             }
             $Zip->close();
         }
         header("Location: " . Config::getRootPath($zip_name));
         exit;
     }
     exit;
 }
Exemplo n.º 8
0
 public function delete()
 {
     parent::delete();
     Navigation::redirect("admin/contact");
     exit;
 }
Exemplo n.º 9
0
 private static function login()
 {
     global $Conf, $Now, $email_class, $password_class;
     $external_login = $Conf->external_login();
     // In all cases, we need to look up the account information
     // to determine if the user is registered
     if (!isset($_REQUEST["email"]) || ($_REQUEST["email"] = trim($_REQUEST["email"])) == "") {
         $email_class = " error";
         if ($Conf->opt("ldapLogin")) {
             return Conf::msg_error("Enter your LDAP username.");
         } else {
             return Conf::msg_error("Enter your email address.");
         }
     }
     // Check for the cookie
     if (isset($_SESSION["testsession"])) {
         /* Session cookie set */
     } else {
         if (!isset($_REQUEST["testsession"])) {
             // set a cookie to test that their browser supports cookies
             $_SESSION["testsession"] = true;
             $url = "testsession=1";
             foreach (array("email", "password", "action", "go", "signin") as $a) {
                 if (isset($_REQUEST[$a])) {
                     $url .= "&{$a}=" . urlencode($_REQUEST[$a]);
                 }
             }
             Navigation::redirect("?" . $url);
         } else {
             return Conf::msg_error("You appear to have disabled cookies in your browser, but this site needs to set cookies to function.  Google has <a href='http://www.google.com/cookies.html'>an informative article on how to enable them</a>.");
         }
     }
     // do LDAP login before validation, since we might create an account
     if ($Conf->opt("ldapLogin")) {
         $_REQUEST["action"] = "login";
         if (!self::ldap_login()) {
             return null;
         }
     }
     // look up user in our database
     if (strpos($_REQUEST["email"], "@") === false) {
         self::unquote_double_quoted_request();
     }
     $user = $Conf->user_by_whatever($_REQUEST["email"]);
     // look up or create user in contact database
     $cdb_user = null;
     if (opt("contactdb_dsn")) {
         if ($user) {
             $cdb_user = $user->contactdb_user();
         } else {
             $cdb_user = Contact::contactdb_find_by_email($_REQUEST["email"]);
         }
     }
     // create account if requested
     if ($_REQUEST["action"] == "new") {
         if (!($user = self::create_account($user, $cdb_user))) {
             return null;
         }
         $_REQUEST["password"] = $user->password_plaintext;
     }
     // auto-create account if external login
     if (!$user && $external_login) {
         $reg = Contact::safe_registration($_REQUEST);
         $reg->no_validate_email = true;
         if (!($user = Contact::create($Conf, $reg))) {
             return Conf::msg_error($Conf->db_error_html(true, "while adding your account"));
         }
         if ($Conf->setting("setupPhase", false)) {
             return self::first_user($user, $msg);
         }
     }
     // if no user found, then fail
     if (!$user && (!$cdb_user || !$cdb_user->allow_contactdb_password())) {
         $email_class = " error";
         return Conf::msg_error("No account for " . htmlspecialchars($_REQUEST["email"]) . ". Did you enter the correct email address?");
     }
     // if user disabled, then fail
     if ($user && $user->disabled) {
         return Conf::msg_error("Your account is disabled. Contact the site administrator for more information.");
     }
     // maybe reset password
     $xuser = $user ?: $cdb_user;
     if ($_REQUEST["action"] == "forgot") {
         $worked = $xuser->sendAccountInfo("forgot", true);
         if ($worked == "@resetpassword") {
             $Conf->confirmMsg("A password reset link has been emailed to " . htmlspecialchars($_REQUEST["email"]) . ". When you receive that email, follow its instructions to create a new password.");
         } else {
             if ($worked) {
                 $Conf->confirmMsg("Your password has been emailed to " . htmlspecialchars($_REQUEST["email"]) . ".  When you receive that email, return here to sign in.");
                 $Conf->log("Sent password", $xuser);
             }
         }
         return null;
     }
     // check password
     if (!$external_login) {
         if (($password = trim(req_s("password"))) === "") {
             $password_class = " error";
             return Conf::msg_error("Enter your password. If you’ve forgotten it, enter your email address and use the “I forgot my password” option.");
         }
         if (!$xuser->check_password($password)) {
             $password_class = " error";
             return Conf::msg_error("That password doesn’t match. If you’ve forgotten your password, enter your email address and use the “I forgot my password” option.");
         }
     }
     // mark activity
     $xuser->mark_login();
     // activate and redirect
     $user = $xuser->activate();
     unset($_SESSION["testsession"]);
     $_SESSION["trueuser"] = (object) array("email" => $user->email);
     $Conf->save_session("freshlogin", true);
     $Conf->save_session("password_reset", null);
     if (isset($_REQUEST["go"])) {
         $where = $_REQUEST["go"];
     } else {
         if (isset($_SESSION["login_bounce"]) && $_SESSION["login_bounce"][0] == $Conf->dsn) {
             $where = $_SESSION["login_bounce"][1];
         } else {
             $where = hoturl("index");
         }
     }
     go($where);
     exit;
 }
Exemplo n.º 10
0
 public function logout()
 {
     UserClient::kill();
     Navigation::redirect("");
 }
Exemplo n.º 11
0
 public function delete()
 {
     parent::delete();
     Navigation::redirect($this->my_redirect);
     exit;
 }
Exemplo n.º 12
0
 public function updateAddress()
 {
     $returnResult = new HttpResult();
     $retornoDaPaginaHTML = new HttpAdminGenericResult();
     $ReturnResultVO = new ReturnResultVO();
     $retornoDaPaginaHTML->return_result_vo = $ReturnResultVO;
     if (DataHandler::getValueByArrayIndex($this->arrayVariable, "address_id") != NULL && DataHandler::getValueByArrayIndex($this->arrayVariable, "user_id") != NULL) {
         $user_id = DataHandler::getValueByArrayIndex($this->arrayVariable, "user_id");
         $address_id = DataHandler::getValueByArrayIndex($this->arrayVariable, "address_id");
         $AddressVO = new AddressVO($_POST);
         $UserDetailVO = new UserDetailVO();
         //			print_r($AddressVO);exit();
         if ($_POST) {
             $AddressVO->setId($address_id);
             $ReturnResultVO = $AddressVO->commit(TRUE);
             if ($ReturnResultVO->success) {
                 //					Debug::print_r($ReturnResultVO);
                 if (DataHandler::getValueByArrayIndex($_POST, "principal") == '1') {
                     $UserDetailVO->setId($user_id, TRUE);
                     $UserDetailVO->setAddressId($address_id);
                     //						Debug::print_r($UserDetailVO);
                     $ReturnResultVO = $UserDetailVO->commit();
                     //						Debug::print_r($ReturnResultVO);
                 }
             }
             if ($ReturnResultVO->success) {
                 Navigation::redirect("admin/user/update/id." . $user_id);
                 exit;
             }
         } else {
             $AddressVO->setId($address_id, TRUE);
             $UserDetailVO->setId($user_id, TRUE);
         }
         $retornoDaPaginaHTML->return_result_vo = $ReturnResultVO;
         $retornoDaPaginaHTML->user_id = $user_id;
         $retornoDaPaginaHTML->user_address_vo = $AddressVO;
         $retornoDaPaginaHTML->user_detail_vo = $UserDetailVO;
     } else {
         Navigation::redirect("admin/user");
         exit;
     }
     //iniciando o retorno padrao em http result
     $returnResult->setHttpContentResult($retornoDaPaginaHTML);
     return $returnResult;
 }
Exemplo n.º 13
0
 public function delete()
 {
     parent::delete();
     Navigation::redirect("admin/home/banner");
     exit;
 }
Exemplo n.º 14
0
 public function delete()
 {
     $ReturnResult = parent::delete();
     Navigation::redirect("backend/product/family/show/");
 }
Exemplo n.º 15
0
 public function update()
 {
     $ReturnResultVO = new ReturnResultVO();
     $retornoDaPaginaHTML = new HttpAdminGenericResult();
     //iniciando o retorno padrao
     $returnResult = new HttpResult();
     $id = 0;
     if (DataHandler::getValueByArrayIndex($this->arrayVariable, "id")) {
         $id = DataHandler::getValueByArrayIndex($this->arrayVariable, "id");
     }
     $VO = $this->DAO->getVO();
     $VO->setId($id, TRUE);
     if ($_POST) {
         $VO->setFetchArray($_POST);
         $VO->setId($id);
         $ReturnResultVO = $VO->commit(TRUE);
         //			Debug::print_r($ReturnResultVO);exit();
         if ($ReturnResultVO->success) {
             Navigation::redirect("admin/attribute/module." . $this->module);
             exit;
         }
     }
     $retornoDaPaginaHTML->return_result_vo = $ReturnResultVO;
     $retornoDaPaginaHTML->attribute_vo = $VO;
     $retornoDaPaginaHTML->module = $this->module;
     //iniciando o retorno padrao em http result
     $returnResult->setHttpContentResult($retornoDaPaginaHTML);
     return $returnResult;
 }
Exemplo n.º 16
0
 public function delete()
 {
     $DAO = CategoryDAO::getInstance();
     if (FALSE) {
         $DAO = new CategoryDAO();
     }
     $DAO->delete(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     Navigation::redirect("admin/category/select");
 }
Exemplo n.º 17
0
 /**
  * para detalhe de um produto
  */
 public function init()
 {
     //Debug::print_r($this->arrayVariable);
     //filtro vindo por parametro é o addres que ele tem que enviar de volta como busca
     //rel ids de produtos relacionados
     //exit();
     //echo 12;
     $id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     if ($id > 0) {
         $ContentSiteVO = new ContentSiteVO();
         $ReturnResult_vo = $ContentSiteVO->setId($id, TRUE);
         if ($ReturnResult_vo->success) {
             $stdProduct = $ContentSiteVO->toStdClass();
             $stdProduct->array_gallery = $ContentSiteVO->getImages(NULL, "gallery", true);
             $stdProduct->array_dimensions = $ContentSiteVO->getImages(NULL, "dimensions", true);
             $stdProduct->array_video = $ContentSiteVO->getImages(NULL, "video", true);
             $stdProduct->array_360 = $ContentSiteVO->getImages(NULL, "360", true);
             $stdProduct->array_tagged = $ContentSiteVO->getImages(NULL, "tagged", true);
             $LinkDAO = LinkDAO::getInstance();
             //passo 1, descobrir a qual família esse protudo pertence
             //passo 2, pegar todos os produtos pertencente a mesma família
             //passo 3, tirar o próprio produto da listagem de produtos da mesma família
             $array_links = array();
             $resultLinks = $LinkDAO->select(DbInterface::RETURN_STD_OBJECT, "content", $table_id = null, $linked_table = 'content', $linked_table_id = $id, $active = 1, $quant_started = NULL, $quant_limit = NULL, $order_by = "order", $order_type = " ASC ");
             if ($resultLinks->success && $resultLinks->count_total > 0) {
                 foreach ($resultLinks->result as $familia) {
                     $link = $familia;
                     //$resultLinks->result[0];
                     $ContentFamiliaVO = new ContentSiteVO();
                     $ContentFamiliaVO->setId($link->table_id, TRUE);
                     Debug::print_r($ContentFamiliaVO);
                     exit;
                     if ($ContentFamiliaVO->active > 0) {
                         $arrayResult_links = $ContentFamiliaVO->getLinks("content");
                         foreach ($arrayResult_links as $link) {
                             if ($link->linked_table_id != $id) {
                                 $ResultTempLink = $link->getLinkedVO();
                                 if ($ResultTempLink->success) {
                                     $produtoVO = $ResultTempLink->result;
                                     if ($produtoVO->active > 0) {
                                         $stdProduto = $produtoVO->toStdClass();
                                         $stdProduto->array_tagged = $produtoVO->getImages(NULL, "tagged", NULL);
                                         $array_links[] = $stdProduto;
                                     }
                                     //Debug::print_r($stdProduto);exit();
                                 }
                             }
                             //end if
                         }
                         //end foerach
                     }
                 }
             }
             //verifica a qual familia esse produto pertence
             $stdProduct->array_produtos_vinculados = $array_links;
             //Debug::print_r($array_links);
             //exit();
             //pegando array de vinculados enviados como id
             $str_ids_send = DataHandler::getValueByArrayIndex($this->arrayVariable, "rel");
             $array_ids_send = explode("|", $str_ids_send);
             $array_filtro = array();
             foreach ($array_ids_send as $id) {
                 $ContentSiteVO = new ContentSiteVO();
                 $tempResult = $ContentSiteVO->setId($id, TRUE);
                 if ($tempResult->success) {
                     $stdProduto = $ContentSiteVO->toStdClass();
                     $stdProduto->array_tagged = $ContentSiteVO->getImages(NULL, "tagged", NULL);
                     $array_filtro[] = $stdProduto;
                 }
             }
             $stdProduct->array_filtro = $array_filtro;
             //Debug::print_r($array_links);
             $returnResult = new HttpResult();
             //exit();
             //iniciando o resultado para o html
             $retornoDaPaginaHTML = new HttpRoot();
             $retornoDaPaginaHTML->vo = $stdProduct;
             $retornoDaPaginaHTML->addressToReturn = str_replace("|", "/", DataHandler::getValueByArrayIndex($this->arrayVariable, "filtro"));
             $strToResend = implode("/", $this->arrayRestFolder);
             $strToResend = explode("/:/", $strToResend);
             if (is_array($strToResend) && count($strToResend) > 1) {
                 $strToResend = $strToResend[1];
             } else {
                 $strToResend = "";
             }
             $retornoDaPaginaHTML->addressToResend = $strToResend;
             $returnResult->setHttpContentResult($retornoDaPaginaHTML);
             return $returnResult;
         } else {
             Navigation::redirect("");
         }
     } else {
         //não mandou o id, vai pra listagem
         Navigation::redirect("produtos");
     }
 }
Exemplo n.º 18
0
 public function delete()
 {
     $ReturnResult = parent::delete();
     Navigation::redirect("backend/info_segmento/show/");
 }
Exemplo n.º 19
0
 public function getFile()
 {
     //pega o id da imagem enviada na url - esse é a preferencia
     $file_id = DataHandler::forceInt($this->infoPost->request_file_id);
     //    	print_r($file_id);exit();
     $url = "";
     //    	echo Debug::li("1");
     if (!$file_id > 0) {
         //    		echo Debug::li("2");
         //só considera a url se não tem id
         $url = $this->infoPost->request_file_url;
     }
     $urlFile = $url;
     //    	echo $url;
     //    	echo Debug::li("3");
     if ($urlFile == "") {
         //			echo Debug::li("4");
         $FileVO = new FileVO();
         $ReturnResultVO = $FileVO->setId($file_id, TRUE);
         //			print_r($FileVO);
         if ($ReturnResultVO->success) {
             //				echo Debug::li("5  : ".$FileVO->getURL());
             $urlFile = DataHandler::removeDobleBars($FileVO->getURL());
         }
     } else {
         //			echo Debug::li("6");
         //			echo $urlFile."cacacaac";
         $urlFile = DataHandler::removeDobleBars(str_replace(array("..", ""), "", $urlFile));
     }
     //		echo $urlFile;
     //		exit();
     //		echo Debug::li("7");
     if ($urlFile == "" || !file_exists($urlFile)) {
         //			echo Debug::li("8 : ".$urlFile."  nao existe, entao:".$this->defaultFile404);
         //			exit();
         //não encontrou a filem, seta a url com a url da filem padrão
         $urlFile = $this->defaultFile404;
     }
     //		echo $urlFile;
     //		exit();
     Navigation::redirect($urlFile);
     exit;
 }
Exemplo n.º 20
0
 /**
  * 
  * Para acessar isso aqui seria a url: pdf_download/produto/id.N/
  */
 public function cliente($id = false)
 {
     if ($id == FALSE) {
         $id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     }
     if ($id > 0) {
         $ContentSiteVO = new ContentSiteVO();
         $ReturnResult_vo = $ContentSiteVO->setId($id, TRUE);
         if ($ReturnResult_vo->success) {
             $stdProduct = $ContentSiteVO->toStdClass();
             $stdProduct->array_gallery = $ContentSiteVO->getImages(NULL, "gallery", true);
             $stdProduct->array_tagged = $ContentSiteVO->getImages(NULL, "tagged", true);
             $html_start = "<html><body>";
             $html_end = "</body></html>";
             $detail_page = file_get_contents(Config::getFolderView("/PdfDownload/detail.tpl"));
             $image_page = file_get_contents(Config::getFolderView("/PdfDownload/image.tpl"));
             $dimension_page = file_get_contents(Config::getFolderView("/PdfDownload/dimension.tpl"));
             $tpl_img_path = "view/site/";
             //Config::getAsset() ;
             $recover_logo = $stdProduct->hat == 1 ? '<img style=" margin-top: 4px; margin-left: 5px; " src="' . $tpl_img_path . '/PdfDownload/recover_logo.png" />' : "";
             $stdProduct->description = utf8_decode($stdProduct->description);
             $stdProduct->title = utf8_decode($stdProduct->title);
             $stdProduct->content = utf8_decode($stdProduct->content);
             $common_tpl_data = array("###IMG_TPL_PATH###", "###content###", "###title###", "###PRODUCT_URI###", "###recover_logo###");
             $common_data = array($tpl_img_path, $stdProduct->content, $stdProduct->title, Config::getRootPath('produto/id.' . $stdProduct->id . '/' . $stdProduct->slug), $recover_logo);
             $detail_page = str_replace($common_tpl_data, $common_data, $detail_page);
             $image_page = str_replace($common_tpl_data, $common_data, $image_page);
             $dimension_page = str_replace($common_tpl_data, $common_data, $dimension_page);
             $detail_page = str_replace("###description###", $stdProduct->description, $detail_page);
             $html = $html_start . $detail_page;
             foreach ($stdProduct->array_gallery as $image) {
                 $w = 600;
                 $h = 550;
                 $img_url = "image/get_image/image_id." . $image->id . "/max_width.{$w}/max_height.{$h}/";
                 // Debug::print_r( $img_url ) ;
                 // $tmp = file_get_contents( $img_url ) ;
                 // unset( $tmp ) ;
                 // $new_page = str_replace( "###IMAGE_SRC###" , Config::getRootPath( "image/get_image/image_id." .  $image->id . "/max_width.600/max_height.525/" )  , $image_page ) ;
                 // $new_page = str_replace( "###IMAGE_SRC###" , $image->url  , $image_page ) ;
                 $img_name = preg_replace("/\\.jpg\$/", "", $image->url);
                 // $sys_img = $img_name . "_w{$w}_h{$h}_m_no_crop.jpg"  ;
                 $sys_img = $img_name . "_w{$w}_h{$h}_m_cache_crop.jpg";
                 // Debug::print_r($sys_img ) ;
                 // var_dump( file_exists($sys_img) ) ;
                 // die;
                 $new_page = str_replace("###IMAGE_SRC###", $sys_img, $image_page);
                 // Debug::print_r( $image ) ; die;
                 $html .= $new_page;
                 // break;
             }
             $html .= $html_end;
             // echo $html ; die;
             $dompdf = new DOMPDF();
             $dompdf->load_html($html);
             $dompdf->render();
             //$dompdf->stream( "upload/pdf/" . $stdProduct->id . "/" . $stdProduct->slug . ".pdf") ;
             $file = $stdProduct->slug . ".pdf";
             $path = "upload/pdf/" . $stdProduct->id . "/";
             if (!dir($path)) {
                 mkdir($path, 0777, true);
             }
             $html_file = "print.html";
             $html = str_replace("src=\"", "src=\"" . Config::getRootPath(), $html);
             $fp = fopen($path . $html_file, "w");
             fwrite($fp, $html);
             fclose($fp);
             $pdfoutput = $dompdf->output();
             // $filename = $output;
             $fp = fopen($path . $file, "w");
             fwrite($fp, $pdfoutput);
             fclose($fp);
             return true;
         } else {
             //não achou um produto com esse id
             return false;
             Navigation::redirect("");
         }
     } else {
         return false;
         //não mandou o id, vai pra listagem ((!?) TODO: ver se é isso mesmo)
         Navigation::redirect("clientes");
     }
 }
Exemplo n.º 21
0
 public function delete()
 {
     parent::delete();
     Navigation::redirect("admin/menu_top");
     exit;
 }
Exemplo n.º 22
0
 /**
  * Da redirect
  * Envie redirect_with_id para o seu redirect_to ir com o parametro id no final
  * @return void
  */
 public function commit($redirect_page = TRUE, $link_table = "image")
 {
     $contentVO = new ContentSiteVO();
     if (isset($_POST["id"])) {
         $contentVO->setId($_POST["id"], TRUE);
     }
     $contentVO->setFetchArray($_POST);
     //antes de tudo, faz a validação
     $ValidationReturnResultVO = new ReturnResultVO();
     $ValidationReturnResultVO->success = TRUE;
     if (DataHandler::getValueByArrayIndex($_POST, "array_validation")) {
         $array_validation = DataHandler::getValueByArrayIndex($_POST, "array_validation");
         //array de fields que deveriam ser validados e estão errados
         $array_fields_errors = array();
         if (is_array($array_validation)) {
             //se for array, valida a array
             //varre a validação
             foreach ($array_validation as $field_name) {
                 $temp_ReturnResultVO = $this->validateContentFields($field_name, $contentVO);
                 if (!$temp_ReturnResultVO->success) {
                     //echo Debug::li("Content.php erro na validacao : $field_name ");
                     //da o push na array_fields error
                     $array_fields_errors[] = $field_name;
                     //já muda o success do result para false para saber que não precisa mais commitar
                     $ValidationReturnResultVO->success = FALSE;
                 }
             }
         } else {
             if (is_string($array_validation)) {
                 //se for só uma string valida só 1 deles
                 $temp_ReturnResultVO = $this->validateContentFields($field_name, $contentVO);
                 if (!$temp_ReturnResultVO->success) {
                     //da o push na array_fields error
                     $array_fields_errors[] = $field_name;
                     //já muda o success do result para false para saber que não precisa mais commitar
                     $ValidationReturnResultVO->success = FALSE;
                 }
             }
         }
     }
     if (!$ValidationReturnResultVO->success) {
         //coloco na result a array de fields com error
         $ValidationReturnResultVO->result = $array_fields_errors;
         //retorna para o edit de quem extends essa classe
         return $this->{$my_edit_method}($ValidationReturnResultVO);
         //daqui nao passa
         exit;
     }
     //vai criar as key_words do content
     $key_words = "";
     $key_words .= " " . DataHandler::removeAccent($contentVO->getAuthor());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getContent());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getDescription());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getHat());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getName());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getSlug());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getTitle());
     $contentVO->setKeyWords($key_words);
     $returnResultVO = $contentVO->commit();
     $content_id = $contentVO->getId();
     //adicionando link com categoria(s) enviada(s)
     //pega a instancia
     $LinkDAO = LinkDAO::getInstance();
     if (FALSE) {
         $LinkDAO = new LinkDAO();
     }
     //deleta vinculos com categoria
     $LinkDAO->deleteAllFromLinkedTableByTableAndTableId('content', $content_id, 'category');
     $have_category_to_commit = FALSE;
     if (!is_array($_POST["category"])) {
         $_POST["category"] = array($_POST["category"]);
     }
     $arrayCategory = $_POST["category"];
     //Debug::print_r($arrayCategory);exit();
     $order = 10;
     if (!is_array($_POST["order"])) {
         $order = $_POST["order"];
     }
     foreach ($arrayCategory as $category_id) {
         ///print_r($category_id);
         //echo Debug::li("categoria id:".$category_id);
         //cada categoria enviada é mais um link com categoria que deve ser adicionado
         //echo $order;exit();
         $LinkDAO->insert('category', $category_id, 'content', $contentVO->getId(), 1, $order);
         // $contentVO->addLink("category", $category_id);
         $have_category_to_commit = TRUE;
     }
     //exit();
     //caso tenha o que adicionar como link em categoria, commita
     if ($have_category_to_commit) {
         $contentVO->commit();
     }
     //fim da adição do content em categoria
     //-----------------------------==================================== [[[  add imagens ]]]
     $array_image_file = DataHandler::getValueByArrayIndex($_FILES, "image");
     include_once "library/facil3/core/controller/image/FacilImage.php";
     $FacilImage = new FacilImage();
     //echo Debug::li(":link_table   [".$link_table."]");exit();
     $FacilImage->moduleName = $link_table;
     $FacilImage->defaultFolderForNewImages = "upload/image/";
     for ($i = 0; $i < count($array_image_file["name"]); $i++) {
         //Debug::print_r($array_image_file);
         $file_image = array();
         $file_image["name"] = $array_image_file["name"][$i];
         $file_image["type"] = $array_image_file["type"][$i];
         $file_image["tmp_name"] = $array_image_file["tmp_name"][$i];
         $file_image["error"] = $array_image_file["error"][$i];
         $file_image["size"] = $array_image_file["size"][$i];
         //adicionar cada image utilizando o módulo de imagem
         $array_config_info_post = array();
         $image_id = NULL;
         if (DataHandler::getValueByArrayIndex($_POST, "image_info_id")) {
             if (DataHandler::getValueByArrayIndex($_POST["image_info_id"], $i)) {
                 $image_id = $_POST["image_info_id"][$i];
             }
         }
         $array_config_info_post["image_info_id"] = $image_id;
         $array_config_info_post["image_info_name"] = isset($_POST["image_info_name"]) ? $_POST["image_info_name"][$i] : "";
         $array_config_info_post["image_info_description"] = isset($_POST["image_info_description"]) ? $_POST["image_info_description"][$i] : "";
         $array_config_info_post["image_info_order"] = isset($_POST["image_info_order"]) ? $_POST["image_info_order"][$i] : "";
         $array_config_info_post["image_info_locale"] = NULL;
         //$_POST["image_info_locale"][$i];
         $array_config_info_post["image_info_author"] = isset($_POST["image_info_author"][$i]) ? $_POST["image_info_author"][$i] : "";
         $array_config_info_post["table"] = "content";
         $array_config_info_post["table_id"] = $content_id;
         $array_config_info_post["Filedata"] = $file_image;
         $ImageInfoPostVO = new ImageInfoPostVO($array_config_info_post);
         //agora inicia o módulo passando esse info post configurado
         $FacilImage->resetInfoPost($ImageInfoPostVO);
         $ReturnResultVO = $FacilImage->insert();
     }
     //-----------------------------==================================== [[[  add file ]]]
     $array_image_file = DataHandler::getValueByArrayIndex($_FILES, "file");
     include_once "library/facil3/core/controller/file/FacilFile.php";
     $FacilFile = new FacilFile();
     //nome do módulo no sistema
     $FacilFile->moduleName = "file";
     $FacilFile->defaultFolderForNewFiles = "upload/file/";
     for ($i = 0; $i < count($array_image_file["name"]); $i++) {
         $file_image = array();
         $file_image["name"] = $array_image_file["name"][$i];
         $file_image["type"] = $array_image_file["type"][$i];
         $file_image["tmp_name"] = $array_image_file["tmp_name"][$i];
         $file_image["error"] = $array_image_file["error"][$i];
         $file_image["size"] = $array_image_file["size"][$i];
         //adicionar cada image utilizando o módulo de imagem
         $array_config_info_post = array();
         $array_config_info_post["file_info_id"] = isset($_POST["file_info_id"]) ? $_POST["file_info_id"][$i] : "";
         //$_POST["file_info_id"][$i];
         $array_config_info_post["file_info_name"] = isset($_POST["file_info_name"]) ? $_POST["file_info_name"][$i] : "";
         //$_POST["file_info_name"][$i];
         $array_config_info_post["file_info_description"] = isset($_POST["file_info_description"]) ? $_POST["file_info_description"][$i] : "";
         //$_POST["file_info_description"][$i];
         $array_config_info_post["file_info_order"] = isset($_POST["file_info_order"]) ? $_POST["file_info_order"][$i] : "";
         //$_POST["file_info_order"][$i];
         $array_config_info_post["file_info_locale"] = NULL;
         //$_POST["file_info_locale"][$i];
         $array_config_info_post["file_info_author"] = isset($_POST["file_info_author"]) ? $_POST["file_info_author"][$i] : "";
         //$_POST["file_info_author"][$i];
         $array_config_info_post["table"] = "content";
         $array_config_info_post["table_id"] = $content_id;
         $array_config_info_post["Filedata"] = $file_image;
         $FileInfoPostVO = new FileInfoPostVO($array_config_info_post);
         //agora inicia o módulo passando esse info post configurado
         $FacilFile->resetInfoPost($FileInfoPostVO);
         $FacilFile->insert();
     }
     //falta terminar
     //Navigation::redirect("admin/content/");
     $redirect_to = $this->my_redirect;
     if (DataHandler::getValueByArrayIndex($_POST, "redirect_to")) {
         $redirect_to = DataHandler::getValueByArrayIndex($_POST, "redirect_to");
     }
     if ($this->redirect_with_id) {
         $redirect_to .= "/id." . $content_id;
     }
     if ($redirect_page) {
         Navigation::redirect($redirect_to);
         exit;
     } else {
         return $contentVO;
     }
 }