Esempio n. 1
0
 /**
  * Modifica la informacion de un cliente
  */
 public function updateConfig($id_conf, $data = null, $data_ext = null)
 {
     $msg = 4;
     if ($data == null) {
         $path_img = '';
         //valida la imagen
         $upload_res = UploadFiles::uploadImgLogo();
         if (is_array($upload_res)) {
             if ($upload_res[0] == false) {
                 return array(false, $upload_res[1]);
             }
             $path_img = 'application/images/logos/' . $upload_res[1]['file_name'];
         }
         $data = array('nombre' => $this->input->post('dnombre'), 'razon_social' => $this->input->post('drazon_social'), 'rfc' => $this->input->post('drfc'), 'calle' => $this->input->post('dcalle'), 'num_ext' => $this->input->post('dno_exterior'), 'num_int' => $this->input->post('dno_interior'), 'colonia' => $this->input->post('dcolonia'), 'municipio' => $this->input->post('dmunicipio'), 'estado' => $this->input->post('destado'), 'cp' => $this->input->post('dcp'), 'telefono' => $this->input->post('dtelefono'), 'url_logop' => $this->input->post('durl_logop') == 'true' ? 'true' : 'false', 'email' => $this->input->post('demail'), 'pag_web' => $this->input->post('dpag_web'), 'footer' => $this->input->post('dfooter'), 'color_1' => $this->input->post('dcolor_1'), 'color_2' => $this->input->post('dcolor_2'), 'fuente_pv' => $this->input->post('dfuente_pv'));
         $dataEmpresas = array('nombre_fiscal' => $this->input->post('drazon_social'), 'rfc' => $this->input->post('drfc'), 'calle' => $this->input->post('dcalle'), 'no_exterior' => $this->input->post('dno_exterior'), 'no_interior' => $this->input->post('dno_interior'), 'colonia' => $this->input->post('dcolonia'), 'localidad' => $this->input->post('dmunicipio'), 'municipio' => $this->input->post('dmunicipio'), 'estado' => $this->input->post('destado'), 'cp' => $this->input->post('dcp'), 'telefono' => $this->input->post('dtelefono'), 'email' => $this->input->post('demail'), 'pass' => $this->input->post('dpass'), 'pag_web' => $this->input->post('dpag_web'));
         if ($path_img != '') {
             $data['url_logo'] = $path_img;
             $dataEmpresas['logo'] = $path_img;
         }
     }
     $this->db->update('config', $data, "id = '" . $id_conf . "'");
     $select = $this->db->query("select * from empresas limit 1");
     $info['info'] = $select->row();
     //certificado
     $dcer_org = isset($info['info']->cer_org) ? $info['info']->cer_org : '';
     $dcer = isset($info['info']->cer) ? $info['info']->cer : '';
     $cer_caduca = isset($info['info']->cer_caduca) ? $info['info']->cer_caduca : '';
     $upload_res = UploadFiles::uploadFile('dcer_org');
     if ($upload_res !== false && $upload_res !== 'ok') {
         if ($dcer_org != '' && strpos($dcer_org, $upload_res) === false) {
             UploadFiles::deleteFile($dcer_org);
             UploadFiles::deleteFile($dcer);
         }
         $upload_res = json_decode(file_get_contents(base_url("openssl/bin/cer.php?file={$upload_res}&path=" . APPPATH . "CFDI/certificados/")));
         if ($upload_res[0] == '' || $upload_res[1] == '') {
             return array(false, '', 2);
         }
         $dcer_org = $upload_res[0];
         $dcer = $upload_res[1];
         //se obtiene la fecha que caduca el certificado
         $this->load->library('cfdi');
         $cer_caduca = $this->cfdi->obtenFechaCertificado($dcer_org);
     }
     //llave
     $new_pass = $this->pass_finkok;
     $dkey_path = isset($info['info']->key_path) ? $info['info']->key_path : '';
     $upload_res = UploadFiles::uploadFile('dkey_path');
     if ($upload_res !== false && $upload_res !== 'ok') {
         if ($dkey_path != '' && strpos($dkey_path, $upload_res) === false) {
             UploadFiles::deleteFile($dkey_path);
         }
         $upload_res = json_decode(file_get_contents(base_url("openssl/bin/key.php?newpass={$new_pass}&pass={$this->input->post('dpass')}&file={$upload_res}&path=" . APPPATH . "CFDI/certificados/")));
         print_r($upload_res);
         if ($upload_res[0] == 's' || $upload_res[0] == '') {
             return array(false, '', 2);
         }
         $dkey_path = $upload_res[0];
         $_POST['dpass'] = $new_pass;
     }
     print_r($dkey_path);
     $_POST['dpass'] = $new_pass;
     $dataEmpresas['cer_org'] = $dcer_org;
     $dataEmpresas['cer'] = $dcer;
     $dataEmpresas['key_path'] = $dkey_path;
     $dataEmpresas['pass'] = $_POST['dpass'];
     $this->db->update('empresas', $dataEmpresas);
     return array(true, '', $msg);
 }
Esempio n. 2
0
function pageform()
{
    global $session;
    $process = new ProcessForm();
    $validate = $process::validate();
    $postdata = new Page("pages");
    $user = new User("users");
    $uid = $user::findRow("Id={$session->userid}");
    //change this to login session id when login is activated
    $id = $postdata::$id = isset($GLOBALS["id"]) ? "Id=" . $GLOBALS["id"] : null;
    //id recieved form querystring
    if ($GLOBALS["action"] == "editpage") {
        $edit = $postdata::findRow($id);
        //
        $title = $edit->Title;
        $category = $edit->Position;
        $source = $edit->Source;
        $pgcontent = $edit->Content;
        $published = $edit->Published;
        $featured = $edit->Featured;
        $authorid = $uid->Id;
        //image to upload
        $pgimage = "";
        $imgcaption = "";
    } else {
        $title = "";
        $category = "";
        $source = "";
        $pgcontent = "";
        $published = "";
        $featured = "";
        $authorid = $uid->Id;
        //image to upload
        $pgimage = "";
        $imgcaption = "";
        //debug($authorid);
    }
    //Process Page Form
    //Process Image Uploads here
    $upload_path = "../";
    $upload = new UploadFiles($upload_path . PAGEIMG_DIR, $upload_path . TEMP_DIR);
    if ($process->submitForm()) {
        /*@setting validation rules*/
        $upload->Mimetype = array('image/pjpeg' => "jpeg", 'image/jpeg' => "jpeg", 'image/png' => "png", 'image/gif' => "gif");
        $required = array("title", "page_content", "source");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_requiredFields($required));
        $check_invalidchars = array("title", "source");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_invalidChars($check_invalidchars));
        $requiredlen = array("title" => 100);
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_FieldLength($requiredlen));
        $selectedindex = array("category" => "--Select Category--");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_selectField($selectedindex));
        if ($id == null) {
            $getrow = $postdata::fieldExists("Title={$_POST["title"]}");
            if ($getrow) {
                $process->errorinfo["title"] = $_POST["title"] . " already exist";
            }
        }
        /* upload info on validation ,//Sucess*/
        $massage = $process->message("Page has been successfully submmited.");
        if ($process->successflag) {
            //put database table here
            $postdata::$tablefields = array("Title" => $_POST["title"], "Content" => $_POST["page_content"], "Source" => $_POST["source"], "Postedby" => $_POST["authorid"], "Position" => $_POST["category"], "Published" => $_POST["publish"], "Featured" => $_POST["feature"]);
            /*saved to database*/
            $postdata->save();
            //echo "new recored was added with id=".$postdata->lastInsertedId();
            //echo "<br> success happened and all fields are sent to database, Thank you ! :)";
            /*uploads info*/
            $upload->uploadFile("uploadimg");
            //upolads an image
            if ($upload->Upload_status == true) {
                $postimg = new Image("pageimgs");
                $pageid = $id != null ? $id : $postdata->lastInsertedId();
                $postimg::$tablefields = array("Imgname" => $upload->Newfilename, "Width" => $upload->Width, "Height" => $upload->Height, "Imgcaption" => $_POST["imgcaption"], "Mimetype" => $upload->Filetype, "Extention" => $upload->File_ext, "Pageid" => $pageid);
                //check and delete old image record in pageimg table
                $pid = $postimg->findRow("Pageid=" . $pageid);
                if ($pid != null) {
                    //if(file_exists($upload_path.PAGEIMG_DIR.$pid->Imgname.".".$pid->Extention)){
                    $upload->deleteFile($upload_path . PAGEIMG_DIR . $pid->Imgname . "." . $pid->Extention);
                    $upload->deleteFile($upload_path . PAGEIMG_DIR . "thumbnails/" . $pid->Imgname . "." . $pid->Extention);
                }
                // }
                $postimg->save();
            }
        }
        //upload image
    }
    $form = new Form("Pageform", filter_var($_SERVER['PHP_SELF']) . "?" . filter_var($_SERVER['QUERY_STRING']), "post", "enctype=\"multipart/form-data\"\n");
    //Company;
    $form->startForm();
    $form->setFormField("", $form->addFormInfo("<h2>Use this form add new Page..</h2><p>Required Fields are labelled with asterics (*)</p><hr/>"));
    //Page Title
    $form->setFormField($form->inputLabel("title", "*Title"), $form->inputField("text", "title", $process->post("title", $title)), $validate->displayErrorField($process->errorinfo, "title"));
    //Category
    $pgcategory = function () {
        $category = new GetTableRecord("pagecategory");
        $category_options = $category::findAllRecords();
        $options[] = "--Select Category--";
        foreach ($category_options as $opt) {
            $options[$opt->Position] = $opt->Category;
        }
        return $options;
    };
    $form->setFormField($form->inputLabel("category", "*Category"), $form->selectOptions("category", $pgcategory(), $process->post("category", $category)), $validate->displayErrorField($process->errorinfo, "category"));
    //Page Source
    $form->setFormField($form->inputLabel("source", "*Source"), $form->inputField("text", "source", $process->post("source", $source)), $validate->displayErrorField($process->errorinfo, "source"));
    // Page Content
    $form->setFormField($form->inputLabel("page_content", "*Content"), $form->textAreaField("page_content", $process->post("page_content", $pgcontent), "10", "50", "class=\"ckeditor\""), $validate->displayErrorField($process->errorinfo, "page_content"));
    //Upload Image
    $form->setFormField($form->inputLabel("uploadimg", "Upload Image"), $form->uploadField("uploadimg[]", "uploadimg") . "<br>" . $form->textAreaField("imgcaption", $process->post("imgcaption", $imgcaption), "1", "45", 'placeholder="Image Caption"') . $form->inputField("hidden", "MAX_FILE_SIZE", "40000000"), $validate->displayErrorField($process->errorinfo, "uploadimg"));
    //Radio for Visible/
    $form->setFormField($form->inputLabel("publish", "Publish"), $form->radioButton("Yes", "publish", "Y", $process->post("publish", $published) == "Y" ? true : false) . $form->radioButton("No", "publish", "N", $process->post("publish", $published) == "N" ? true : false));
    //Featured Page
    $form->setFormField($form->inputLabel("feature", "Feature"), $form->radioButton("Yes", "feature", "Y", $process->post("feature", $featured) == "Y" ? true : false) . $form->radioButton("No", "feature", "N", $process->post("feature", $featured) == "N" ? true : false));
    //Submit Form
    $form->setFormField(null, $form->inputField("hidden", "authorid", $process->post("authorid", $authorid)) . $form->inputField("submit", "send", "Save"));
    $form->endForm();
    return $form->DisplayFields($GLOBALS["form_labling"], $process->message);
}