Пример #1
0
 function index()
 {
     $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS;
     $files = \GCore\Libs\Folder::getFiles($path, true);
     $strings = array();
     //function to prepare strings
     $prepare = function ($str) {
         /*$path = \GCore\C::get('GCORE_FRONT_PATH');
         		if(strpos($str, $path) !== false AND strpos($str, $path) == 0){
         			return '//'.str_replace($path, '', $str);
         		}*/
         $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : '';
         return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";';
     };
     foreach ($files as $file) {
         if (substr($file, -4, 4) == '.php') {
             // AND strpos($file, DS.'extensions'.DS) === TRUE){
             //$strings[] = $file;
             $file_code = file_get_contents($file);
             preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs);
             if (!empty($langs[2])) {
                 $strings = array_merge($strings, $langs[2]);
             }
         }
     }
     $strings = array_unique($strings);
     $strings = array_map($prepare, $strings);
     echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>';
 }
Пример #2
0
 public static function on_finalize($controller)
 {
     $config = new \GCore\Libs\Parameter($controller->connection['Connection']['extras']['plugins']['download']);
     $path_field = $config->get('path_field');
     $download_action = $config->get('download_action');
     if (!empty($path_field) and !empty($download_action)) {
         if ($controller->action == $download_action) {
             if (!empty($controller->data['gcb'])) {
                 $path_pcs = explode('.', $path_field);
                 $field = array_pop($path_pcs);
                 $model = array_pop($path_pcs);
                 $row = $controller->connection_models[$model]->load($controller->data['gcb']);
                 if (!empty($row)) {
                     $file_path = \GCore\Libs\Arr::getVal($row, explode('.', $path_field));
                     if ($config->get('download_path')) {
                         $file_path = rtrim($config->get('download_path'), DS) . DS . $file_path;
                     }
                     if (is_dir($file_path)) {
                         //this is a folder
                         $files = @\GCore\Libs\Folder::getFiles($file_path, false);
                         foreach ($files as $file) {
                             $found[$file] = filemtime($file);
                         }
                         if (empty($found)) {
                             return false;
                         }
                         arsort($found);
                         $files = array_keys($found);
                         sort($files);
                         $file = array_pop($files);
                         \GCore\Libs\Download::send($file, 'D');
                     } else {
                         //this is a file
                         $file = $file_path;
                         \GCore\Libs\Download::send($file, 'D');
                     }
                 }
             }
         }
     }
 }
 function delete_cache()
 {
     $path = \GCore\C::get('GCORE_FRONT_PATH') . 'cache' . DS;
     $files = \GCore\Libs\Folder::getFiles($path);
     $count = 0;
     foreach ($files as $k => $file) {
         if (basename($file) != 'index.html' and basename($file) != 'demos.cf5bak') {
             $result = \GCore\Libs\File::delete($file);
             if ($result) {
                 $count++;
             }
         }
     }
     $session = \GCore\Libs\Base::getSession();
     $session->setFlash('info', $count . ' ' . l_('CACHE_FILES_DELETED'));
     $this->redirect(r_('index.php?ext=chronoforms'));
 }
Пример #4
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $this->config = $config = new \GCore\Libs\Parameter($config);
     if ((bool) $config->get('enabled', 0) === false) {
         return;
     }
     $upload_path = $config->get('upload_path', '');
     if (!empty($upload_path)) {
         $upload_path = str_replace(array("/", "\\"), DS, $upload_path);
         if (substr($upload_path, -1) == DS) {
             $upload_path = substr_replace($upload_path, '', -1);
         }
         $upload_path = $upload_path . DS;
         $config->set('upload_path', $upload_path);
     } else {
         $upload_path = \GCore\C::ext_path('chronoforms', 'front') . 'uploads' . DS . $form->form['Form']['title'] . DS;
     }
     $this->upload_path = $upload_path;
     //check path is correct
     if (!is_dir($this->upload_path) or !is_writable(realpath($this->upload_path))) {
         //$form->errors[] = "Unable to write to upload directory.";
         //$this->events['fail'] = 1;
         //return;
     }
     if (!file_exists($this->upload_path . DS . 'index.html')) {
         if (!\GCore\Libs\Folder::create($this->upload_path)) {
             $form->errors[] = "Couldn't create upload directory: " . $this->upload_path;
             $this->events['fail'] = 1;
             return;
         }
         $dummy_c = '<html><body bgcolor="#ffffff"></body></html>';
         if (!\GCore\Libs\File::write($this->upload_path . DS . 'index.html', $dummy_c)) {
             $form->errors[] = "Couldn't create upload directory index file.";
             $this->events['fail'] = 1;
             return;
         }
     }
     $files_array = explode("\n", trim($config->get('files', '')));
     //get array fields
     $array_fields = array();
     if (trim($config->get('array_fields', ''))) {
         $array_fields = explode(',', trim($config->get('array_fields', '')));
     }
     foreach ($files_array as $file_string) {
         if (strpos($file_string, ':') !== false) {
             $file_data = explode(':', trim($file_string));
             $file_extensions = explode($config->get('extensions_separator', '-'), $file_data[1]);
             //convert all extensions to lower case
             foreach ($file_extensions as $k => $file_extension) {
                 $file_extensions[$k] = strtolower($file_extension);
             }
             //get the posted file details
             $field_name = $file_data[0];
             if (empty($_FILES[$field_name])) {
                 continue;
             }
             $file_post = $_FILES[$field_name];
             if (in_array($field_name, $array_fields) and !empty($file_post['name']) and $file_post['name'] === array_values($file_post['name'])) {
                 foreach ($file_post['name'] as $k => $v) {
                     $uploaded_file_data = $this->processUpload($form, array('name' => $file_post['name'][$k], 'tmp_name' => $file_post['tmp_name'][$k], 'error' => $file_post['error'][$k], 'size' => $file_post['size'][$k]), $file_data[0], $file_extensions);
                     if (is_array($uploaded_file_data)) {
                         $form->files[$field_name][] = $uploaded_file_data;
                         $form->data[$field_name][] = $uploaded_file_data['name'];
                     } elseif ($uploaded_file_data === false) {
                         return false;
                     }
                 }
             } else {
                 $uploaded_file_data = $this->processUpload($form, $file_post, $field_name, $file_extensions);
                 if (is_array($uploaded_file_data)) {
                     $form->files[$field_name] = $uploaded_file_data;
                     $form->data[$field_name] = $uploaded_file_data['name'];
                 } elseif ($uploaded_file_data === false) {
                     return false;
                 }
             }
         }
     }
 }
Пример #5
0
    public function on_list($fld, $ttl, &$data_columns)
    {
        $config = new \GCore\Libs\Parameter($this->connection['Connection']['extras']['plugins']['download']);
        if ($config->get('path_field') and $config->get('download_action')) {
            $path = $config->get('path_field');
            $action = $config->get('download_action');
            if ($fld == '_DOWNLOAD_.link') {
                $link = r_('index.php?ext=chronoconnectivity&cont=lists&act=' . $action . '&ccname=' . $this->connection['Connection']['title'] . '&gcb={' . $this->model->alias . '.' . $this->model->pkey . '}');
                $text = $ttl;
                if ($config->get('display_icon', 1)) {
                    $text = '<i class="fa fa-download fa-fw"></i> ' . $text;
                }
                $data_columns[$fld]['html'] = '<a class="' . $config->get('download_link_class', 'btn btn-success btn-xs') . '" href="' . $link . '">' . $text . '</a>';
            }
            $file_info = array();
            $file_info['filesize'] = '';
            $file_info['filetime'] = '';
            $file_info['filename'] = '';
            $get_file_info = function ($cell, $row, $column) use($path, $file_info, $config) {
                $file_path = \GCore\Libs\Arr::getVal($row, explode('.', $path));
                if ($config->get('download_path')) {
                    $file_path = rtrim($config->get('download_path'), DS) . DS . $file_path;
                }
                //$file_info = array();
                if (file_exists($file_path)) {
                    if (is_dir($file_path)) {
                        //this is a folder
                        $files = @\GCore\Libs\Folder::getFiles($file_path, false);
                        foreach ($files as $file) {
                            $found[$file] = filemtime($file);
                        }
                        if (empty($found)) {
                            return false;
                        }
                        arsort($found);
                        $files = array_keys($found);
                        sort($files);
                        $file = array_pop($files);
                        $file_info['filesize'] = \GCore\Libs\File::humanSize(filesize($file));
                        $file_info['filetime'] = date($config->get('filetime_format', 'd-m-Y H:i'), filemtime($file));
                        $file_info['filename'] = basename($file);
                    } else {
                        //this is a file
                        $file = $file_path;
                        $file_info['filesize'] = \GCore\Libs\File::humanSize(filesize($file));
                        $file_info['filetime'] = date($config->get('filetime_format', 'd-m-Y H:i'), filemtime($file));
                        $file_info['filename'] = basename($file);
                    }
                }
                foreach ($file_info as $k => $info) {
                    if ($column == '_DOWNLOAD_.' . $k) {
                        return $file_info[$k];
                    }
                }
                return '';
                //$file_info;
            };
            foreach ($file_info as $k => $info) {
                if ($fld == '_DOWNLOAD_.' . $k) {
                    $data_columns[$fld]['function'] = $get_file_info;
                }
            }
            if ($fld == '_HkkITS_.hot') {
                $data_columns[$fld]['function'] = create_function('$value,$row', '
					if(\\GCore\\Libs\\Arr::getVal($row, explode(".", "' . $download . '"), 0) >= (int)' . $config->get('hot_limit', '1000') . '){
						return 1;
					}else{
						return 0;
					}
				');
                $data_columns[$fld]['html'] = array(0 => '', 1 => '<span class="label label-danger">' . $config->get('hot_text', 'Hot') . '</span>');
            }
        }
    }
Пример #6
0
	function execute(&$form, $action_id){
		$config =  $form->actions_config[$action_id];
		$config = new \GCore\Libs\Parameter($config);
		
		$content = $config->get('content', "");
		ob_start();
		eval('?>'.$content);
		$output = ob_get_clean();
		//if the content box was empty, display the form output
		if(empty($output)){
			$output = $form->form_output;
		}
		$output = \GCore\Libs\Str::replacer($output, $form->data);
		//begin tcpdf code
		require_once('tcpdf/config/lang/eng.php');
		require_once('tcpdf/tcpdf.php');
						
		// create new PDF document
		$pdf = new \TCPDF($config->get('pdf_page_orientation', 'P'), PDF_UNIT, $config->get('pdf_page_format', 'A4'), true, 'UTF-8', false);
		
		//set protection if enabled
		if((bool)$config->get('enable_protection', 0) === true){
			$owner_pass = ($config->get('owner_pass', "") ? $config->get('owner_pass', "") : null);
			$perms = (strlen($config->get('permissions', "")) > 0) ? explode(",", $config->get('permissions', "")) : array();
			$pdf->SetProtection($perms, $config->get('user_pass', ""), $owner_pass, $config->get('sec_mode', ""), $pubkeys=null);
		}

		// set document information
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetAuthor($config->get('pdf_author', 'PDF Author.'));
		$pdf->SetTitle($config->get('pdf_title', 'PDF Title Goes Here.'));
		$pdf->SetSubject($config->get('pdf_subject', 'Powered by Chronoforms + TCPDF'));
		$pdf->SetKeywords($config->get('pdf_keywords', 'Chronoforms, PDF Plugin, TCPDF, PDF, '.$form->form['Form']['title']));
	
		// Willian	
		// set header data, font and margins
		if((bool)$config->get((bool)$config->get('pdf_header_show', 1))){
			if(strlen($config->get('pdf_title')) OR strlen($config->get('pdf_header'))){
                        	$pdf->SetHeaderData(false, 0, $config->get('pdf_title', 'PDF Title Goes Here.'), $config->get('pdf_header', 'Powered by Chronoforms + TCPDF'));
                	}
			$pdf->setHeaderFont(Array($config->get('pdf_header_font', 'helvetica'), '', (int)$config->get('pdf_header_font_size', 10)));
			$pdf->SetHeaderMargin($config->get('pdf_margin_header', 5));
			$pdf->setPrintHeader(true);
		} else {
			$pdf->setPrintHeader(false);
		}
		
		// set footer font and margins
		if((bool)$config->get((bool)$config->get('pdf_footer_show', 1))){
			$pdf->setFooterFont(Array($config->get('pdf_footer_font', 'helvetica'), '', (int)$config->get('pdf_footer_font_size', 8)));
			$pdf->SetFooterMargin($config->get('pdf_margin_footer', 10));
			$pdf->setPrintFooter(true);
		} else {
			$pdf->setPrintFooter(false);
		}

		// set default monospaced font
		$pdf->SetDefaultMonospacedFont($config->get('pdf_monospaced_font', 'courier'));

		//set margins
		$pdf->SetMargins($config->get('pdf_margin_left', 15), $config->get('pdf_margin_top', 27), $config->get('pdf_margin_right', 15));

		//set auto page breaks
		$pdf->SetAutoPageBreak(TRUE, $config->get('pdf_margin_bottom', 25));

		//set image scale factor
		$pdf->setImageScale($config->get('pdf_image_scale_ratio', 1.25));

		//set some language-dependent strings
		$pdf->setLanguageArray($l);

		// Willian
                // Mostrar/Esconder Cabeçalho
                $pdf->setPrintHeader((bool)$config->get('pdf_header_show', 1));
                // Mostrar/Esconder Rodapé
                $pdf->setPrintHeader((bool)$config->get('pdf_footer_show', 1));
		
		// ---------------------------------------------------------

		// set font
		$pdf->SetFont($config->get('pdf_body_font', 'courier'), '', (int)$config->get('pdf_body_font_size', 14));

		// add a page
		$pdf->AddPage();
		// create some HTML content
		$css = "";
		
		$output = $css.$output;
		$html = $output;
		// output the HTML content
		$pdf->writeHTML($html, true, false, true, false, '');
		// reset pointer to the last page
		$pdf->lastPage();
		//Close and output PDF document
		if(isset($form->data['pdf_file_name']) && !empty($form->data['pdf_file_name'])){
			$PDF_file_name = $form->data['pdf_file_name'];
		}else{
			if(strlen(trim($config->get('pdf_file_name', ''))) > 0){
				$PDF_file_name = trim($config->get('pdf_file_name', ''))."_".date('YmdHis');
			}else{
				$PDF_file_name = $form->form['Form']['title']."_".date('YmdHis');
			}
		}
		$PDF_view = $config->get('pdf_view', 'I');
		if(($PDF_view == 'F') || ($PDF_view == 'FI') || ($PDF_view == 'FD')){
			jimport('joomla.utilities.error');
			jimport('joomla.filesystem.file');
			jimport('joomla.filesystem.folder');
			$upload_path = $config->get('pdf_save_path');
			if(!empty($upload_path)){
				$upload_path = str_replace(array("/", "\\"), DS, $upload_path);
				if(substr($upload_path, -1) == DS){
					$upload_path = substr_replace($upload_path, '', -1);
				}
				$upload_path = $upload_path.DS;
				$config->set('pdf_save_path', $upload_path);
			}else{
				$upload_path = \GCore\C::ext_path('chronoforms', 'front').'pdfs'.DS.$form->form['Form']['title'].DS;
			}
			//check the save files path is ok
			if(!file_exists($upload_path.DS.'index.html')){
				if(!\GCore\Libs\Folder::create($upload_path)){
					$form->errors[] = "Couldn't create upload directory: ".$upload_path;
					$this->events['fail'] = 1;
					return;
				}
				$dummy_c = '<html><body bgcolor="#ffffff"></body></html>';
				if(!\GCore\Libs\File::write($upload_path.DS.'index.html', $dummy_c)){
					$form->errors[] = "Couldn't create upload directory index file.";
					$this->events['fail'] = 1;
					return;
				}
			}
			
			$PDF_file_path = $upload_path.$PDF_file_name.".pdf";
			$pdf->Output($PDF_file_path, $PDF_view);
			
			//Try to generate an auto file link
			$site_link = \GCore\C::get('GCORE_FRONT_URL');
			if(substr($site_link, -1) == "/"){
				$site_link = substr_replace($site_link, '', -1);
			}
			
			if(strlen(trim($config->get('pdf_post_name', ''))) > 0){
				$form->files[trim($config->get('pdf_post_name', ''))] = array('name' => $PDF_file_name.".pdf", 'path' => $PDF_file_path, 'size' => 0);
				$form->files[trim($config->get('pdf_post_name', ''))]['link'] = str_replace(array(\GCore\C::get('GCORE_FRONT_PATH'), DS), array($site_link, "/"), $upload_path.$PDF_file_name.".pdf");
				$form->data[trim($config->get('pdf_post_name', ''))] = $PDF_file_name.".pdf";
				$form->debug[$action_id][self::$title][] = $PDF_file_path.' has been saved correctly.';
			}
		}else{
			$pdf->Output($PDF_file_name.".pdf", $PDF_view);
		}
		if($PDF_view != 'F'){
			@flush();
			@ob_flush();
			exit;
		}
	}