public function test_check_folder()
 {
     check_folder("santo/santo2/santo3");
     $this->assertTrue(is_dir(FCPATH . "santo/santo2/santo3"));
     rmdir(FCPATH . "santo/santo2/santo3");
     rmdir(FCPATH . "santo/santo2");
     rmdir(FCPATH . "santo");
 }
 public function haveIcon()
 {
     if (file_exists(CACHE_DIR . '/image/application/' . $this->getAttribute('id') . '.png')) {
         return true;
     }
     if (!check_folder(CACHE_DIR . '/image') || !check_folder(CACHE_DIR . '/image/application')) {
         return false;
     }
     return true;
 }
Пример #3
0
 public function getIconPathRW()
 {
     if (!check_folder(CACHE_DIR . '/image') || !check_folder(CACHE_DIR . '/image/application')) {
         return NULL;
     }
     if ($this->hasAttribute('id')) {
         return CACHE_DIR . '/image/application/' . $this->getAttribute('id') . '.png';
     }
     return NULL;
 }
Пример #4
0
 public function __construct($server_)
 {
     // 		Logger::debug('main', 'Starting Server_Logs::__construct for \''.$server_->fqdn.'\'');
     if (!check_folder(SESSIONMANAGER_SPOOL . '/cache/logs')) {
         Logger::error('main', 'Server_Logs::__construct Unable to create global logs cache folder');
         die_error(SESSIONMANAGER_SPOOL . '/cache/logs does not exist and cannot be created!', __FILE__, __LINE__);
     }
     $this->server = $server_;
     $this->logsdir = SESSIONMANAGER_SPOOL . '/cache/logs/' . $this->server->fqdn;
     if (!check_folder($this->logsdir)) {
         Logger::error('main', 'Server_Logs::__construct Unable to create logs cache folder for server \'' . $this->server->fqdn . '\'');
         die_error($this->logsdir . ' does not exist and cannot be created!', __FILE__, __LINE__);
     }
     $this->since = @file_get_contents($this->logsdir . '/since');
     if (!$this->since) {
         $this->since = 0;
     }
     $this->last = @file_get_contents($this->logsdir . '/last');
     if (!$this->last) {
         $this->last = 0;
     }
 }
Пример #5
0
 public function __construct()
 {
     parent::__construct();
     $this->load->library('image_lib');
     // ============ ============  ============  ============
     // Kiểm tra folder
     //
     $folders = [FCPATH . "asset/images/", FCPATH . "asset/images/idear/", FCPATH . "asset/images/idear/thumb/"];
     foreach ($folders as $key => $value) {
         // Fucntion in common_helper
         check_folder($value);
     }
     //
     // ============ ============  ============  ============
     // ============ ============  ============  ============
     // Khởi tạo DB
     //
     if (!$this->db->table_exists("idear")) {
         $this->db->query("CREATE TABLE 'idear' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 'idear_title' TEXT, 'idear_content' TEXT, 'idear_img' TEXT, 'idear_create' TEXT);");
     }
     //
     //  ============ ============  ============  ============
 }
Пример #6
0
 public function sent_log()
 {
     if (ALLOW_SENT_MAIL) {
         $this->load->library('HZip');
         $file_name = "BK_log_" . date("Ymd_his") . ".zip";
         $config['upload_path'] = check_folder(FCPATH . 'asset/file_upload/custom_banner_' . $position . '/');
         HZip::zipDir(FCPATH . "application/logs", FCPATH . "asset/tmp/" . $file_name);
         $this->load->library('email', $this->config_email_custom);
         $this->email->from(FROM_EMAIL, 'Family');
         $this->email->to('*****@*****.**');
         $this->email->cc('*****@*****.**');
         $this->email->subject("Backup log " . date("Y-m-d h:i:s"));
         $this->email->message(date("Y-m-d h:i:s"));
         $this->email->attach(FCPATH . "asset/tmp/" . $file_name);
         if ($this->email->send()) {
             echo "<h1>Send mail [" . __FUNCTION__ . "]</h1>";
         } else {
             throw new Exception("Can't backup db", 1);
             echo "<h1>Can't sent mail [" . __FUNCTION__ . "]</h1>";
         }
     }
 }
Пример #7
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
//if (stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml'))
//	header('Content-Type: application/xhtml+xml; charset=utf-8');
//else
header('Content-Type: text/html; charset=utf-8');
require_once dirname(__FILE__) . '/core-minimal.inc.php';
$folders = array('reporting', 'tmp', 'cache');
foreach ($folders as $folder) {
    $buf = strtoupper($folder) . '_DIR';
    define($buf, SESSIONMANAGER_SPOOL . '/' . $folder);
    if (!check_folder(constant($buf))) {
        Logger::critical('main', constant($buf) . ' does not exist and cannot be created!');
        die_error(constant($buf) . ' does not exist and cannot be created!', __FILE__, __LINE__);
    }
}
$prefs = Preferences::getInstance();
if (is_object($prefs)) {
    define('HAS_PREFERENCES', true);
    $sql_conf = $prefs->get('general', 'sql');
    if (is_array($sql_conf)) {
        define('SERVERS_HISTORY_TABLE', $sql_conf['prefix'] . 'servers_history');
        define('SESSIONS_HISTORY_TABLE', $sql_conf['prefix'] . 'sessions_history');
        SQL::newInstance($sql_conf);
    }
}
Пример #8
0
<?php

/**
 *	Checking Permissions
 *
 *	This file would be used to create the framework Check Permissions
 *
 *	@package				gContacts
 *	@file					check_per.php
 *	@copyright				Cee Emm Infotech, 2013-2014
 *	@author					Vineet Gupta <*****@*****.**>
 *	@since					1.0.0
 *
 **/
require_once 'gContacts.php';
if (check_folder()) {
    header("Location:/dbconfig.php");
    exit;
}
Пример #9
0
 function do_upload()
 {
     $uploadPath = "docs/calendar/";
     check_folder($uploadPath);
     $config['upload_path'] = $uploadPath;
     $config['allowed_types'] = "xls|xlsx";
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload()) {
         print $this->upload->display_errors();
     } else {
         $tmpName = basename($_FILES["userfile"]["tmp_name"]);
         $data = $this->upload->data();
         $data["file_temp"] = $tmpName;
         $this->conn->StartTrans();
         $this->upload_progress();
         $ok = $this->conn->CompleteTrans();
     }
     $this->msg_ok = "Data upload successfully";
     $this->msg_fail = "Unable to upload data";
     $this->_proses_message($ok, $this->module . "upload", $this->module . "upload");
 }
Пример #10
0
 function _doc_upload()
 {
     //cek token is valid
     print "test";
     print $this->input->get_post("token");
     $is_valid = validate_key($this->input->get_post("token"));
     print $is_valid;
     if (!$is_valid) {
         if ($this->agent->is_referral()) {
             //echo $this->agent->referrer();
             set_message("error", "Your form has expired, reload page and then submit again");
             redirect($this->module . "add");
         } else {
             redirect($this->module . "add");
         }
         exit;
     }
     //$category=$this->input->post("category")?$this->input->post("category"):"0";
     $uploadPath = "docs/wa_doc/raw/";
     check_folder($uploadPath);
     $config['upload_path'] = $uploadPath;
     $config['allowed_types'] = "docx|doc|jpg|jpeg|png|bmp|xls|xlsx|pdf";
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload()) {
         $error = $this->upload->display_errors();
         print $error;
         set_message("error", $error);
         if ($this->agent->is_referral) {
             redirect($this->agent->referrer());
         }
         exit;
     } else {
         $tmpName = basename($_FILES["userfile"]["tmp_name"]);
         $data = $this->upload->data();
         $data["file_temp"] = $tmpName;
         return $data;
     }
     return FALSE;
 }
Пример #11
0
 public function getApplicationIcon($id_)
 {
     $ret = query_url($this->getBaseURL() . '/aps/application/icon/' . $id_);
     if (!$ret) {
         return false;
     }
     if (!check_folder(CACHE_DIR . '/image') || !check_folder(CACHE_DIR . '/image/application')) {
         return false;
     }
     $imgfile = tempnam(NULL, 'ico');
     @file_put_contents($imgfile, $ret);
     try {
         if (class_exists('Imagick')) {
             $imagick = new Imagick();
             $imagick->readImage($imgfile);
         } else {
             if (file_exists($imgfile)) {
                 @unlink($imgfile);
             }
             Logger::error('main', 'Imagick support is not available, fetching applications icons may not work properly');
             return false;
         }
     } catch (Exception $e) {
         if (file_exists($imgfile)) {
             @unlink($imgfile);
         }
         Logger::error('main', 'Server::getApplicationIcon(' . $id_ . ') - Content received is not an image');
         Logger::debug('main', 'Server::getApplicationIcon(' . $id_ . ') - Content received : ' . $ret);
         return false;
     }
     if (file_exists($imgfile)) {
         @unlink($imgfile);
     }
     @file_put_contents(CACHE_DIR . '/image/application/' . $id_ . '.png', $ret);
     return true;
 }
Пример #12
0
 function add($id)
 {
     if ($this->encrypt_status == TRUE) {
         $id_enc = $id;
         $id = decrypt($id);
     }
     $this->msg_ok = "Data created successfully";
     $this->msg_fail = "Unable to add new comment";
     $act = $this->input->post("act") ? $this->input->post("act") : "";
     if ($act == "create") {
         // debug();
         $data = get_post();
         $data['id_wa'] = $data['id_wa'];
         $data = $this->_add_creator($data);
         if (!empty($_FILES['dok_name']['name'])) {
             $fix_name = time() . substr($_FILES['dok_name']['name'], strrpos($_FILES['dok_name']['name'], "."));
             $uploadPath = "docs/wa_doc/keberatan/";
             check_folder($uploadPath);
             $config['upload_path'] = $uploadPath;
             $config['allowed_types'] = 'doc|docx|xls|xlsx|pdf|rar|zip';
             $config['max_size'] = '10000000';
             $config['file_name'] = $fix_name;
             $this->load->library('upload', $config);
             $field = "dok_name";
             // $headline_img=$fix_name;
             if ($fix_name) {
                 $data["dok_name"] = $fix_name;
             }
             if ($this->upload->do_upload($field)) {
                 $data_up = $this->upload->data();
                 $this->conn->StartTrans();
                 $this->model_wa_keberatan->InsertData($data);
                 $ok = $this->conn->CompleteTrans();
                 // redirect("keberatan/keberatan/view/$id_enc");
                 $this->_proses_message($ok, $this->module . "view/{$id_enc}", $this->module . "view/{$id_enc}");
             } else {
                 // redirect("keberatan/keberatan/view/$id_enc");
                 $this->_proses_message($ok, $this->module . "view/{$id_enc}", $this->module . "view/{$id_enc}");
             }
         }
     }
 }
Пример #13
0
 public function save_img_box()
 {
     // ============ ============  ============  ============
     // Upload img
     //
     $config['upload_path'] = check_folder(FCPATH . 'asset/file_upload/media/' . date("Y") . "/" . date("m") . "/" . date("d"));
     $config['allowed_types'] = 'gif|jpg|png';
     $config['max_size'] = '1000000';
     $config['max_width'] = '10240';
     $config['max_height'] = '76800';
     $config['xss_clean'] = true;
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload("file_x")) {
         $error = array('error' => $this->upload->display_errors());
         echo json_encode(["status" => "Error", "content" => $error]);
     } else {
         //============ ============ ============  ============  ============  ============
         // Resize image after upload
         //
         $data = $this->upload->data();
         $path_file_name = $data["file_path"] . $data["file_name"];
         $thumbWidth = MAX_SIZE_IMG;
         $thumbHeight = MAX_SIZE_IMG;
         list($width, $height) = getimagesize($path_file_name);
         if ($thumbWidth < $width || $thumbHeight < $height) {
             $config['source_image'] = $path_file_name;
             $config['width'] = $thumbWidth;
             $config['height'] = $thumbHeight;
             $this->load->library('image_lib', $config);
             $this->image_lib->resize();
             if (@$this->image_lib->display_errors()) {
                 echo json_encode(["status" => "Error", "content" => $this->image_lib->display_errors()]);
                 return false;
             }
         }
         //
         //============ ============ ============  ============  ============  ============
         //============ ============ ============  ============  ============  ============
         // Insert to db
         //
         $file_path = preg_replace("/^(.+)\\/asset\\//", "/asset/", $data["file_path"]);
         if (!$file_path) {
             $file_path = $data["file_path"];
         }
         $object = ["files_name" => $data["file_name"], "files_path" => $file_path, "files_size" => $data["file_size"], "files_type" => $data["file_type"]];
         if (!$this->db->insert('media', $object)) {
             echo json_encode(["status" => "error"]);
             return false;
         }
         //
         //============ ============ ============  ============  ============  ============
     }
 }
Пример #14
0
 function peta()
 {
     $uploadPath = "docs/brwa/peta";
     check_folder($uploadPath);
     $config['upload_path'] = $uploadPath;
     $config['allowed_types'] = "*";
     $this->load->library('upload', $config);
     $this->upload_peta_action();
 }