function wp_cache_get_ob(&$buffer)
{
    global $cache_path, $cache_filename, $meta_file, $wp_start_time, $supercachedir;
    global $new_cache, $wp_cache_meta, $file_expired, $blog_id, $cache_compression;
    global $wp_cache_gzip_encoding, $super_cache_enabled, $cached_direct_pages;
    global $wp_cache_404, $gzsize, $supercacheonly, $wp_cache_gzip_first, $wp_cache_gmt_offset;
    global $blog_cache_dir;
    $new_cache = true;
    $wp_cache_meta = '';
    /* Mode paranoic, check for closing tags 
     * we avoid caching incomplete files */
    if ($wp_cache_404) {
        $new_cache = false;
        $buffer .= "\n<!-- Page not cached by WP Super Cache. 404. -->\n";
    }
    if (!preg_match('/(<\\/html>|<\\/rss>|<\\/feed>)/i', $buffer)) {
        $new_cache = false;
        if (false === strpos($_SERVER['REQUEST_URI'], 'robots.txt')) {
            $buffer .= "\n<!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->\n";
        }
    }
    if (!$new_cache) {
        return $buffer;
    }
    $duration = wp_cache_microtime_diff($wp_start_time, microtime());
    $duration = sprintf("%0.3f", $duration);
    $buffer .= "\n<!-- Dynamic page generated in {$duration} seconds. -->\n";
    if (!wp_cache_writers_entry()) {
        $buffer .= "\n<!-- Page not cached by WP Super Cache. Could not get mutex lock. -->\n";
        return $buffer;
    }
    $mtime = @filemtime($blog_cache_dir . $cache_filename);
    /* Return if:
    		the file didn't exist before but it does exist now (another connection created)
    		OR
    		the file was expired and its mtime is less than 5 seconds
    	*/
    if (!(!$file_expired && $mtime || $mtime && $file_expired && time() - $mtime < 5)) {
        $dir = get_current_url_supercache_dir();
        $supercachedir = $cache_path . 'supercache/' . preg_replace('/:.*$/', '', $_SERVER["HTTP_HOST"]);
        if (!empty($_GET) || is_feed() || $super_cache_enabled == true && is_dir(substr($supercachedir, 0, -1) . '.disabled')) {
            $super_cache_enabled = false;
        }
        $tmp_wpcache_filename = $cache_path . uniqid(mt_rand(), true) . '.tmp';
        // Don't create wp-cache files for anon users
        $supercacheonly = false;
        if ($super_cache_enabled && wp_cache_get_cookies_values() == '') {
            $supercacheonly = true;
        }
        if (!$supercacheonly) {
            $fr = @fopen($tmp_wpcache_filename, 'w');
            if (!$fr) {
                $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $cache_path) . $cache_filename . " -->\n";
                return $buffer;
            }
        }
        if ($super_cache_enabled) {
            $user_info = wp_cache_get_cookies_values();
            $do_cache = apply_filters('do_createsupercache', $user_info);
            if ($user_info == '' || $do_cache === true) {
                if (@is_dir($dir) == false) {
                    @wp_mkdir_p($dir);
                }
                $cache_fname = "{$dir}index.html";
                $tmp_cache_filename = $dir . uniqid(mt_rand(), true) . '.tmp';
                $fr2 = @fopen($tmp_cache_filename, 'w');
                if (!$fr2) {
                    $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $tmp_cache_filename) . " -->\n";
                    @fclose($fr);
                    @nlink($tmp_wpcache_filename);
                    return $buffer;
                }
                if ($cache_compression) {
                    $gz = @fopen($tmp_cache_filename . ".gz", 'w');
                    if (!$gz) {
                        $buffer .= "<!-- File not cached! Super Cache Couldn't write to: " . str_replace(ABSPATH, '', $tmp_cache_filename) . ".gz -->\n";
                        @close($fr);
                        @nlink($tmp_wpcache_filename);
                        @close($fr2);
                        @nlink($tmp_cache_filename);
                        return $buffer;
                    }
                }
            }
        }
        if (preg_match('/<!--mclude|<!--mfunc/', $buffer)) {
            //Dynamic content
            $store = preg_replace('|<!--mclude (.*?)-->(.*?)<!--/mclude-->|is', "<!--mclude-->\n<?php include_once('" . ABSPATH . "\$1'); ?>\n<!--/mclude-->", $buffer);
            $store = preg_replace('|<!--mfunc (.*?)-->(.*?)<!--/mfunc-->|is', "<!--mfunc-->\n<?php \$1 ;?>\n<!--/mfunc-->", $store);
            $store = apply_filters('wpsupercache_buffer', $store);
            $wp_cache_meta['dynamic'] = true;
            /* Clean function calls in tag */
            $buffer = preg_replace('|<!--mclude (.*?)-->|is', '<!--mclude-->', $buffer);
            $buffer = preg_replace('|<!--mfunc (.*?)-->|is', '<!--mfunc-->', $buffer);
            if ($fr) {
                fputs($fr, $store);
            }
            if ($fr2) {
                fputs($fr2, $store . '<!-- super cache -->');
            }
            if ($gz) {
                fputs($gz, gzencode($store . '<!-- super cache gz -->', 1, FORCE_GZIP));
            }
        } else {
            $buffer = apply_filters('wpsupercache_buffer', $buffer);
            $buffer .= "<!-- Cached page generated by WP-Super-Cache on " . gmdate('Y-m-d H:i:s', time() + $wp_cache_gmt_offset * 3600) . " -->\n";
            if ($gz || $wp_cache_gzip_encoding) {
                $gzdata = gzencode($buffer . "<!-- Compression = gzip -->", 3, FORCE_GZIP);
                $gzsize = strlen($gzdata);
            }
            if ($wp_cache_gzip_encoding) {
                $wp_cache_meta['headers']['Content-Encoding'] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
                $wp_cache_meta['headers']['Vary'] = 'Vary: Accept-Encoding, Cookie';
                // Return uncompressed data & store compressed for later use
                if ($fr) {
                    fputs($fr, $gzdata);
                }
            } else {
                // no compression
                $wp_cache_meta['headers']['Vary'] = 'Vary: Cookie';
                if ($fr) {
                    fputs($fr, $buffer);
                }
            }
            if ($fr2) {
                fputs($fr2, $buffer . '<!-- super cache -->');
            }
            if ($gz) {
                fwrite($gz, $gzdata);
            }
            $buffer .= $log;
        }
        $new_cache = true;
        if ($fr) {
            $supercacheonly = false;
            fclose($fr);
            if (!rename($tmp_wpcache_filename, $blog_cache_dir . $cache_filename)) {
                unlink($blog_cache_dir . $cache_filename);
                rename($tmp_wpcache_filename, $blog_cache_dir . $cache_filename);
            }
        }
        if ($fr2) {
            fclose($fr2);
            if (!@rename($tmp_cache_filename, $cache_fname)) {
                @unlink($cache_fname);
                @rename($tmp_cache_filename, $cache_fname);
            }
        }
        if ($gz) {
            fclose($gz);
            if (!@rename($tmp_cache_filename . '.gz', $cache_fname . '.gz')) {
                @unlink($cache_fname . '.gz');
                @rename($tmp_cache_filename . '.gz', $cache_fname . '.gz');
            }
        }
    }
    wp_cache_writers_exit();
    if (!headers_sent() && isset($wp_cache_gzip_first) && 1 == $wp_cache_gzip_first && $wp_cache_gzip_encoding && $gzdata) {
        header('Content-Encoding: ' . $wp_cache_gzip_encoding);
        header('Vary: Accept-Encoding, Cookie');
        header('Content-Length: ' . $gzsize);
        return $gzdata;
    } else {
        return $buffer;
    }
}
Example #2
0
function upload_items($dir)
{
    if (!permissions_grant($dir, NULL, "create")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Execute
    if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
        $cnt = count($GLOBALS['__FILES']['userfile']['name']);
        $err = false;
        $err_avaliable = isset($GLOBALS['__FILES']['userfile']['error']);
        // upload files & check for errors
        for ($i = 0; $i < $cnt; $i++) {
            $errors[$i] = NULL;
            $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i];
            $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]);
            if ($err_avaliable) {
                $up_err = $GLOBALS['__FILES']['userfile']['error'][$i];
            } else {
                $up_err = file_exists($tmp) ? 0 : 4;
            }
            $abs = get_abs_item($dir, $items[$i]);
            if ($items[$i] == "" || $up_err == 4) {
                continue;
            }
            if ($up_err == 1 || $up_err == 2) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilesize"];
                $err = true;
                continue;
            }
            if ($up_err == 3) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilepart"];
                $err = true;
                continue;
            }
            if (!is_uploaded_file($tmp)) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
            if (file_exists($abs) && empty($_REQUEST['overwrite_files'])) {
                $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"];
                $err = true;
                continue;
            }
            // Upload
            if (function_exists("move_uploaded_file")) {
                $ok = @move_uploaded_file($tmp, $abs);
            } else {
                $ok = @copy($tmp, $abs);
                @nlink($tmp);
                // try to delete...
            }
            if ($ok === false) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
        }
        if ($err) {
            // there were errors
            $err_msg = "";
            for ($i = 0; $i < $cnt; $i++) {
                if ($errors[$i] == NULL) {
                    continue;
                }
                $err_msg .= $items[$i] . " : " . $errors[$i] . "<BR>\n";
            }
            show_error($err_msg);
        }
        miwoftp_redirect(make_link("list", $dir, NULL));
        return;
    }
    show_header($GLOBALS["messages"]["actupload"]);
    // List
    echo "<br />";
    echo "<form enctype=\"multipart/form-data\" action=\"" . make_link("upload", $dir, NULL) . "\" method=\"post\">";
    echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"\" method=\"post\">";
    echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"" . get_max_file_size() . "\">";
    echo "<input type=\"hidden\" name=\"confirm\" value=\"true\">";
    echo "<table>";
    $filecount = 10;
    for ($ii = 0; $ii < $filecount; $ii++) {
        echo "<tr>";
        echo "<td nowrap align=\"center\">";
        echo "<input name=\"userfile[]\" type=\"file\" size=\"40\">";
        echo "</td>";
        echo "</tr>";
    }
    echo "</table>";
    echo "<br />";
    echo "<table>";
    echo "<tr>";
    echo "<td colspan=\"2\">";
    echo "<input type=\"checkbox\" checked=\"checked\" value=\"1\" name=\"overwrite_files\" id=\"overwrite_files\" /><label for=\"overwrite_files\">" . $GLOBALS["messages"]["overwrite_files"] . "</label>";
    echo "<br />";
    echo "<br />";
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>";
    echo "<input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnupload"] . "\">";
    echo "</td>";
    echo "<td>";
    echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"] . "\" onClick=\"javascript:location='" . make_link("list", $dir, NULL) . "';\">";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    echo "<input type=\"hidden\" name=\"option\" value=\"com_miwoftp\">";
    echo "</form>";
    echo "<br />";
    return;
}
Example #3
0
function upload_items($dir)
{
    if (!permissions_grant($dir, NULL, "create")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Execute
    if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
        $cnt = count($GLOBALS['__FILES']['userfile']['name']);
        $err = false;
        $err_avaliable = isset($GLOBALS['__FILES']['userfile']['error']);
        // upload files & check for errors
        for ($i = 0; $i < $cnt; $i++) {
            $errors[$i] = NULL;
            $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i];
            $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]);
            if ($err_avaliable) {
                $up_err = $GLOBALS['__FILES']['userfile']['error'][$i];
            } else {
                $up_err = file_exists($tmp) ? 0 : 4;
            }
            $abs = get_abs_item($dir, $items[$i]);
            if ($items[$i] == "" || $up_err == 4) {
                continue;
            }
            if ($up_err == 1 || $up_err == 2) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilesize"];
                $err = true;
                continue;
            }
            if ($up_err == 3) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilepart"];
                $err = true;
                continue;
            }
            if (!@is_uploaded_file($tmp)) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
            if (@file_exists($abs)) {
                $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"];
                $err = true;
                continue;
            }
            // Upload
            if (function_exists("move_uploaded_file")) {
                $ok = @move_uploaded_file($tmp, $abs);
            } else {
                $ok = @copy($tmp, $abs);
                @nlink($tmp);
                // try to delete...
            }
            if ($ok === false) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
        }
        if ($err) {
            // there were errors
            $err_msg = "";
            for ($i = 0; $i < $cnt; $i++) {
                if ($errors[$i] == NULL) {
                    continue;
                }
                $err_msg .= $items[$i] . " : " . $errors[$i] . "<BR>\n";
            }
            show_error($err_msg);
        }
        header("Location: " . make_link("list", $dir, NULL));
        return;
    }
    show_header($GLOBALS["messages"]["actupload"]);
    // List
    echo "<BR><FORM enctype=\"multipart/form-data\" action=\"" . make_link("upload", $dir, NULL);
    echo "\" method=\"post\">\n<INPUT type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"";
    echo get_max_file_size() . "\"><INPUT type=\"hidden\" name=\"confirm\" value=\"true\"><TABLE>\n";
    $filecount = 10;
    for ($ii = 0; $ii < $filecount; $ii++) {
        echo "<TR><TD nowrap align=\"center\">";
        echo "<INPUT name=\"userfile[]\" type=\"file\" size=\"40\"></TD></TR>\n";
    }
    echo "</TABLE>\n<BR><TABLE><TR><TD><INPUT type=\"submit\" value=\"" . $GLOBALS["messages"]["btnupload"];
    echo "\"></TD>\n<TD><input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"];
    echo "\" onClick=\"javascript:location='" . make_link("list", $dir, NULL) . "';\">\n</TD></TR></FORM></TABLE><BR>\n";
    return;
}
function upload_items($dir)
{
    if (!permissions_grant($dir, NULL, "create")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Execute
    if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
        $cnt = count($GLOBALS['__FILES']['userfile']['name']);
        $err = false;
        $err_avaliable = isset($GLOBALS['__FILES']['userfile']['error']);
        // upload files & check for errors
        for ($i = 0; $i < $cnt; $i++) {
            $errors[$i] = NULL;
            $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i];
            $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]);
            if ($err_avaliable) {
                $up_err = $GLOBALS['__FILES']['userfile']['error'][$i];
            } else {
                $up_err = file_exists($tmp) ? 0 : 4;
            }
            $abs = get_abs_item($dir, $items[$i]);
            if ($items[$i] == "" || $up_err == 4) {
                continue;
            }
            if ($up_err == 1 || $up_err == 2) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilesize"];
                $err = true;
                continue;
            }
            if ($up_err == 3) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilepart"];
                $err = true;
                continue;
            }
            if (!@is_uploaded_file($tmp)) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
            if (@file_exists($abs)) {
                $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"];
                $err = true;
                continue;
            }
            // Upload
            if (function_exists("move_uploaded_file")) {
                $ok = @move_uploaded_file($tmp, $abs);
            } else {
                $ok = @copy($tmp, $abs);
                @nlink($tmp);
                // try to delete...
            }
            if ($ok === false) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
        }
        if ($err) {
            // there were errors
            $err_msg = "";
            for ($i = 0; $i < $cnt; $i++) {
                if ($errors[$i] == NULL) {
                    continue;
                }
                $err_msg .= $items[$i] . " : " . $errors[$i] . "<BR>\n";
            }
            show_error($err_msg);
        }
        miwoftp_redirect(make_link("list", $dir, NULL));
        return;
    }
    show_header($GLOBALS["messages"]["actupload"]);
    ?>

<script type="text/javascript"> 
$(document).ready(function() {
  $('#file_upload').uploadify({
    'uploader'  : '/apps/uploadify/uploadify.swf',
'script'    : '/apps/uploadify/uploadify.php',
'cancelImg' : '/apps/uploadify/cancel.png',
'folder'    : '<?php 
    echo $GLOBALS["home_dir"] . $GLOBALS["dir"];
    ?>
',
'auto'      : true,
'multi'     : true,
'removeCompleted' : true,
'auto' : false
  });
});
</script> 
<?php 
    // List
    echo "<BR><FORM enctype=\"multipart/form-data\" action=\"" . make_link("upload", $dir, NULL);
    echo "\" method=\"post\">\n<INPUT type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"";
    echo get_max_file_size() . "\"><INPUT type=\"hidden\" name=\"confirm\" value=\"true\"><TABLE>\n";
    for ($i = 0; $i < 0; $i++) {
        echo "<TR><TD nowrap align=\"center\">";
        echo "<INPUT name=\"userfile[]\" id=\"file_upload\" type=\"file\" size=\"40\"></TD></TR>\n";
    }
    echo "<input id=\"file_upload\" name=\"file_upload\" type=\"file\" />\n";
    echo "</TABLE>\n<BR><TABLE><TR><TD><INPUT type=\"button\" onClick=\"javascript:\$('#file_upload').uploadifyUpload()\" value=\"" . $GLOBALS["messages"]["btnupload"];
    echo "\"></TD>\n<TD><INPUT type=\"button\" onClick=\"javascript:\$('#file_upload').uploadifyClearQueue()\" value=\"Limpiar\"";
    echo "\"></TD>\n<TD><INPUT type=\"submit\" value=\"Listo\"";
    echo "\"></TD></TR></FORM></TABLE><BR>\n";
    //	echo "\"></TD>\n<TD><input type=\"button\" value=\"".$GLOBALS["messages"]["btncancel"];
    //	echo "\" onClick=\"javascript:location='".make_link("list",$dir,NULL)."';\">\n</TD></TR></FORM></TABLE><BR>\n";
    return;
}
 public function upload_file()
 {
     $data = array('header' => 'Generate Text File', 'status' => '', 'pesan' => '', 'list_file' => array());
     if ($this->session->userdata('username') === '' || array_key_exists('username', $this->session->all_userdata()) === false) {
         $this->load->view('errors/html/custom_error_401');
     } else {
         date_default_timezone_set("Asia/Jakarta");
         $this->load->model('upload_models');
         $pilihan_bank = $this->input->post('pilihan_bank');
         $back_code = '';
         $config['upload_path'] = '';
         $config['allowed_types'] = 'csv';
         if ($pilihan_bank == 'MDR') {
             $config['upload_path'] = getcwd() . '/uploads/virtual/mandiri';
             $config['file_name'] = 'MANDIRI_' . date("Ymdhis");
             $back_code = 'MANDR';
         } elseif ($pilihan_bank == 'BRI') {
             $config['upload_path'] = getcwd() . '/uploads/virtual/bri';
             $config['file_name'] = 'BRIVA_' . date("Ymdhis");
             $back_code = 'BRIVA';
         }
         $this->load->library('upload', $config);
         if (!$this->upload->do_upload()) {
             $data['status'] = 'Error';
             $data['pesan'] = $this->upload->display_errors();
             $this->load->view('virtual/generate_file', $data);
         } else {
             $upload = array('upload_data' => $this->upload->data());
             $insert_result = $this->upload_models->upload_file($upload['upload_data'], $this->session->userdata('username'), $pilihan_bank);
             if ($insert_result[0]['Status'] !== 'Failed') {
                 $this->load->model('virtualaccount_models');
                 $record = array();
                 $path_file = $upload['upload_data']['full_path'];
                 $file_name = $upload['upload_data']['file_name'];
                 $file = fopen($path_file, 'r');
                 while (!feof($file)) {
                     if ($pilihan_bank == 'BRI') {
                         array_push($record, fgetcsv($file, null, ';'));
                     } elseif ($pilihan_bank == 'MDR') {
                         array_push($record, fgetcsv($file, null, ','));
                     }
                 }
                 fclose($file);
                 $insert_record = $this->virtualaccount_models->insert_virtualaccount($record, $back_code, $this->session->userdata('username'), $file_name);
                 if ($insert_record['Status'] !== 'Failed') {
                     $data['list_file'] = $this->upload_models->get_upload_file('', 'VIRTUAL');
                     $this->load->view('virtual/generate_file', $data);
                 } else {
                     nlink($upload['upload_data']['full_path']);
                     $data['status'] = $insert_result[0]['Status'];
                     $data['pesan'] = $insert_result[0]['Pesan'];
                     $this->load->view('virtual/generate_file', $data);
                 }
             } else {
                 unlink($upload['upload_data']['full_path']);
                 $data['status'] = $insert_result[0]['Status'];
                 $data['pesan'] = $insert_result[0]['Pesan'];
                 $this->load->view('virtual/generate_file', $data);
             }
         }
     }
 }
Example #6
0
            /* optional database name */
            $DatabaseName = $OptVal;
            break;
        case 'f':
            /* schema file */
            $SchemaFilePath = $OptVal;
            break;
        case 'h':
            /* help */
            $showUsage = true;
            break;
        default:
            echo "Invalid Option \"{$Option}\".\n";
            $showUsage = true;
    }
}
if ($showUsage) {
    global $argv;
    $usage = "Usage: " . basename($argv[0]) . " [options]\n  Update FOSSology database.  Options are:\n  -d  {database name} default is 'fossology'\n  -f  {output file} \n  -h  this help usage";
    print "{$usage}\n";
} else {
    if (file_exists($SchemaFilePath) && !@nlink($SchemaFilePath)) {
        $FailMsg = "Existing schema data file ({$SchemaFilePath}) could not be removed.";
    } else {
        $FailMsg = ExportSchema($SchemaFilePath);
    }
    if ($FailMsg !== false) {
        print "ERROR: {$FailMsg} \n";
        exit(1);
    }
}
function upload_items($dir)
{
    if (!permissions_grant($dir, NULL, "create")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Execute
    if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
        $cnt = count($GLOBALS['__FILES']['userfile']['name']);
        $err = false;
        $err_avaliable = isset($GLOBALS['__FILES']['userfile']['error']);
        // upload files & check for errors
        for ($i = 0; $i < $cnt; $i++) {
            $errors[$i] = NULL;
            $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i];
            $items[$i] = $GLOBALS['__FILES']['userfile']['name'][$i];
            if ($err_avaliable) {
                $up_err = $GLOBALS['__FILES']['userfile']['error'][$i];
            } else {
                $up_err = file_exists($tmp) ? 0 : 4;
            }
            $abs = get_abs_item($dir, $items[$i]);
            if ($items[$i] == "" || $up_err == 4) {
                continue;
            }
            if ($up_err == 1 || $up_err == 2) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilesize"];
                $err = true;
                continue;
            }
            if ($up_err == 3) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilepart"];
                $err = true;
                continue;
            }
            if (!@is_uploaded_file($tmp)) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
            if (@file_exists($abs)) {
                $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"];
                $err = true;
                continue;
            }
            // Upload
            if (function_exists("move_uploaded_file")) {
                $ok = @move_uploaded_file($tmp, $abs);
            } else {
                $ok = @copy($tmp, $abs);
                @nlink($tmp);
                // try to delete...
            }
            if ($ok === false) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
        }
        if ($err) {
            // there were errors
            $err_msg = "";
            for ($i = 0; $i < $cnt; $i++) {
                if ($errors[$i] == NULL) {
                    continue;
                }
                $err_msg .= $items[$i] . " : " . $errors[$i] . "<BR>\n";
            }
            show_error($err_msg);
        }
        header("Location: " . make_link("list", $dir, NULL));
        return;
    }
    show_header($GLOBALS["messages"]["actupload"]);
    ?>

<script type="text/javascript"> 

// Convert divs to queue widgets when the DOM is ready
$(function() {
	$("#uploader").pluploadQueue({
		// General settings
		runtimes : 'gears,flash,silverlight,browserplus,html5',
		url : '<?php 
    echo make_link("upload", $dir, NULL);
    ?>
',
		max_file_size : '<?php 
    echo get_max_file_size();
    ?>
',
		chunk_size : '1mb',
		unique_names : true,

		// Resize images on clientside if we can
		resize : {width : 320, height : 240, quality : 90},

		// Specify what files to browse for
		filters : [
			{title : "Image files", extensions : "jpg,gif,png"},
			{title : "Zip files", extensions : "zip"}
		],

		// Flash settings
		flash_swf_url : '/apps/plupload/js/plupload.flash.swf',

		// Silverlight settings
		silverlight_xap_url : '/apps/plupload/js/plupload.silverlight.xap'
	});

	// Client side form validation
	$('form').submit(function(e) {
		var uploader = $('#uploader').pluploadQueue();

		// Validate number of uploaded files
		if (uploader.total.uploaded == 0) {
			// Files in queue upload them first
			if (uploader.files.length > 0) {
				// When all files are uploaded submit form
				uploader.bind('UploadProgress', function() {
					if (uploader.total.uploaded == uploader.files.length)
						$('form').submit();
				});

				uploader.start();
			} else
				alert('You must at least upload one file.');

			e.preventDefault();
		}
	});
});
</script> 

<?php 
    // List
    echo "<BR><FORM enctype=\"multipart/form-data\" action=\"" . make_link("upload", $dir, NULL);
    echo "\" method=\"post\">\n";
    echo "<TR><TD nowrap align=\"center\">\n";
    echo "<div id=\"uploader\" style=\"height: 330px;\">\n";
    echo "\t<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>\n";
    echo "</div>\n";
    echo "</TD></TR>\n";
    //echo "<input id=\"file_upload\" name=\"file_upload\" type=\"file\" />\n";
    echo "</TABLE>\n<BR><TABLE><TR><TD><INPUT type=\"submit\" value=\"Listo\"";
    echo "\"></TD></TR></FORM></TABLE><BR>\n";
    //	echo "\"></TD>\n<TD><input type=\"button\" value=\"".$GLOBALS["messages"]["btncancel"];
    //	echo "\" onClick=\"javascript:location='".make_link("list",$dir,NULL)."';\">\n</TD></TR></FORM></TABLE><BR>\n";
    return;
}
Example #8
0
function upload_items($dir)
{
    if (!permissions_grant($dir, NULL, "create")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Execute
    if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
        $cnt = count($GLOBALS['__FILES']['userfile']['name']);
        $err = false;
        $err_avaliable = isset($GLOBALS['__FILES']['userfile']['error']);
        // upload files & check for errors
        for ($i = 0; $i < $cnt; $i++) {
            $errors[$i] = NULL;
            $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i];
            $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]);
            if ($err_avaliable) {
                $up_err = $GLOBALS['__FILES']['userfile']['error'][$i];
            } else {
                $up_err = file_exists($tmp) ? 0 : 4;
            }
            $abs = get_abs_item($dir, $items[$i]);
            if ($items[$i] == "" || $up_err == 4) {
                continue;
            }
            if ($up_err == 1 || $up_err == 2) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilesize"];
                $err = true;
                continue;
            }
            if ($up_err == 3) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilepart"];
                $err = true;
                continue;
            }
            if (!is_uploaded_file($tmp)) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
            if (file_exists($abs) && empty($_REQUEST['overwrite_files'])) {
                $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"];
                $err = true;
                continue;
            }
            // Upload
            if (function_exists("move_uploaded_file")) {
                $ok = @move_uploaded_file($tmp, $abs);
            } else {
                $ok = @copy($tmp, $abs);
                @nlink($tmp);
                // try to delete...
            }
            if ($ok === false) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
        }
        if ($err) {
            // there were errors
            $err_msg = "";
            for ($i = 0; $i < $cnt; $i++) {
                if ($errors[$i] == NULL) {
                    continue;
                }
                $err_msg .= $items[$i] . " : " . $errors[$i] . "<BR>\n";
            }
            show_error($err_msg);
        }
        miwoftp_redirect(make_link("list", $dir, NULL));
        return;
    }
    //show_header($GLOBALS["messages"]["actupload"]);
    echo "Nahrať súbor/súbory";
    // List
    echo "<br />";
    echo "<form enctype=\"multipart/form-data\" action=\"" . make_link("upload", $dir, NULL) . "\" method=\"post\">";
    echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"\" method=\"post\">";
    echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"" . get_max_file_size() . "\">";
    echo "<input type=\"hidden\" name=\"confirm\" value=\"true\">";
    echo "<table>";
    $filecount = 10;
    for ($ii = 0; $ii < $filecount; $ii++) {
        echo "<tr>";
        echo "<td nowrap align=\"center\">";
        echo "<input name=\"userfile[]\" type=\"file\" size=\"40\">";
        echo "</td>";
        echo "</tr>";
    }
    echo "</table>";
    echo "<br />";
    echo "<table>";
    echo "<tr>";
    echo "<td colspan=\"2\">";
    echo "<input type=\"checkbox\" checked=\"checked\" value=\"1\" name=\"overwrite_files\" id=\"overwrite_files\" /><label for=\"overwrite_files\">Prepísať existujúci súbor/súbory?</label>";
    echo "<br />";
    echo "<br />";
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>";
    echo "<input type=\"submit\" value=\"Nahrať súbor/súbory\" style=\"color:#fff;background:#337ab7;display:inline-block;padding:6px 12px;font-size:16px;text-decoration:none;font-weight:400;line-height:1.4;text-align:center;white-space:nowrap;vertical-align:middle;border:1px solid #2e6da4;border-radius:4px;\">";
    echo "</td>";
    echo "<td>";
    echo "<input type=\"button\" value=\"Zrušiť\" onClick=\"javascript:location='" . make_link("list", $dir, NULL) . "';\" style=\"color:#333;background:#fff;display:inline-block;padding:6px 12px;font-size:16px;text-decoration:none;font-weight:400;line-height:1.4;text-align:center;white-space:nowrap;vertical-align:middle;border:1px solid #ccc;border-radius:4px;\">";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    echo "<input type=\"hidden\" name=\"option\" value=\"com_miwoftp\">";
    echo "</form>";
    echo "<br />";
    return;
}
Example #9
0
?>
<div id=navbar> 
	<?php 
//simbol de menú (3 barres horitzontals)
echo "&#9776; ";
nlink("/mbr/index.php", "HOME");
nlink("/mbr/devices.php", "Devices");
nlink("/mbr/readings.php", "Readings");
nlink("/mbr/calculations.php", "Calculations");
nlink("/mbr/offline.php", "Offline");
nlink("/mbr/setpoints.php", "Setpoints");
nlink("/mbr/export.php", "Export");
//nlink("/mbr/rules/rules.php"  ,"Rules");
nlink("/mbr/problems.php", "Problems");
nlink("/mbr/sql.php", "SQL (advanced)");
nlink("/mbr/about.php", "About");
?>
</div>

<style>
	#navbar {
		border-bottom:1px solid #ccc;
		padding:0;
		margin:0;
		font-size:18px;
		background:white;
	}
	#navbar a {
		display:inline-block;
		border-right:1px solid #ccc;
		padding:0.5em 0.3em;