Пример #1
0
function _moduleContent(&$smarty, $module_name)
{
    global $arrConf;
    //folder path for custom templates
    $local_templates_dir = getWebDirModule($module_name);
    //conexion resource
    $dsn = generarDSNSistema('asteriskuser', 'asteriskcdrdb');
    $pDB = new paloDB($dsn);
    //user credentials
    global $arrCredentials;
    $action = getAction();
    $content = "";
    switch ($action) {
        case 'delete':
            $content = deleteRecord($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials);
            break;
        case 'download':
            $content = downloadFile($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials);
            break;
        case "display_record":
            $content = display_record($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials);
            break;
        default:
            $content = reportMonitoring($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentials);
            break;
    }
    return $content;
}
Пример #2
0
function dwFile($filename, $query, $type)
{
    if ($_SERVER['SERVER_NAME'] == 'download.osmand.net') {
        header('HTTP/1.1 302 Found');
        $var = rand(0, 99);
        $simple = false;
        if ($type == "road" or $type == "" or $type == "wiki") {
            $simple = true;
        }
        $helpServers = array();
        $mainServers = array("dl2.osmand.net", "dl3.osmand.net");
        $mainServersLoad = 100;
        $helpServersCount = count($helpServers);
        $mainServersCount = count($mainServers);
        if ($type == "osmc") {
            downloadFile($filename);
        } else {
            if ($helpServersCount > 0 and $simple and $var < 100 - $mainServersLoad) {
                $url = $helpServers[$var % $helpServersCount];
                header('Location: http://' . $url . '/download.php?' . $query);
            } else {
                if ($mainServersCount > 0) {
                    $url = $mainServers[$var % $mainServersCount];
                    header('Location: http://' . $url . '/download.php?' . $query);
                } else {
                    downloadFile($filename);
                }
            }
        }
    } else {
        downloadFile($filename);
    }
}
Пример #3
0
function saveAndDownload()
{
    global $objPHPExcel;
    $objPHPExcel->setActiveSheetIndex(0);
    $filepath = saveXlsxFileToServer();
    downloadFile($filepath);
}
Пример #4
0
 /**
  * This is the main task switch where we decide what to do.
  */
 function mainSwitch()
 {
     switch (rsgInstance::getVar('rsgOption', '')) {
         case 'rsgComments':
             require_once JPATH_RSGALLERY2_SITE . '/lib/rsgcomments/rsgcomments.php';
             break;
         case 'rsgVoting':
             require_once JPATH_RSGALLERY2_SITE . '/lib/rsgvoting/rsgvoting.php';
             break;
         case 'myGalleries':
             require_once JPATH_RSGALLERY2_SITE . '/lib/mygalleries/mygalleries.php';
             break;
         case 'search':
             require_once JPATH_RSGALLERY2_SITE . '/lib/rsgsearch/search.php';
             break;
         default:
             switch (rsgInstance::getVar('task', '')) {
                 case 'xml':
                     xmlFile();
                     break;
                 case "downloadfile":
                     downloadFile();
                     break;
                 default:
                     // require the base class rsgDisplay
                     require_once JPATH_RSGALLERY2_SITE . '/templates/meta/display.class.php';
                     // show the template
                     template();
             }
     }
 }
function downloadPhoto($photoId, $photoFolder, $appContentFolder)
{
    $filename = $photoId . '.jpg';
    $url = 'http://www.sutromedia.com/published/iphone-sized-photos/' . $filename;
    $archivedFile = $photoFolder . $filename;
    $appInstallFile = $appContentFolder . $filename;
    return downloadFile($url, $appInstallFile, $archivedFile);
}
Пример #6
0
function CreateFolder($programID, $url)
{
    if (!file_exists($GLOBALS['IMG_PATH'] . $programID)) {
        mkdir($GLOBALS['IMG_PATH'] . $programID, 0755, true);
    }
    if (!empty($url)) {
        downloadFile($url, $GLOBALS['IMG_PATH'] . $programID . "\\" . basename($url));
    }
}
Пример #7
0
 private function _get_image_of_word($word)
 {
     $string = file_get_contents("https://www.google.com/search?q=" . $word . "&es_sm=122&source=lnms&tbm=isch&sa=X&ved=0CAcQ_AUoAWoVChMIgNmD7KKMyQIVweOmCh1CKwHX&biw=1851&bih=952#q=" . $word . "&tbm=isch&tbs=itp:clipart&imgrc=dSVdnddBAfH_CM%3A");
     preg_match_all("/[\"\\']((https\\:\\/\\/encrypted-tbn).+?)[\"\\']/", $string, $return);
     foreach ($return[1] as $key => $value) {
         if (downloadFile($value, APPPATH . "../asset/images/" . strtolower($word) . "_" . $key . ".jpg")) {
             $return_m["path"][] = APPPATH . "../asset/images/" . strtolower($word) . "_" . $key . ".jpg";
             $return_m["name_file"][] = "" . strtolower($word) . "_" . $key . ".jpg";
         }
     }
     return $return_m;
 }
Пример #8
0
function downloadPhoto($photoId, $photoFolder, $appContentFolder)
{
    $filename = $photoId . '.jpg';
    $url = 'http://sutromedia.com/published/480-sized-photos/' . $filename;
    $archivedFile = $photoFolder . $filename;
    $appInstallFile = $appContentFolder . $filename;
    if (file_exists($archivedFile) && jpeg_file_is_corrupted($archivedFile)) {
        unlink($archivedFile);
    }
    // if identification fails
    downloadFile($url, $appInstallFile, $archivedFile);
    return jpeg_file_is_corrupted($archivedFile);
}
 function autoupdate()
 {
     $update = $this->parseXMLFile();
     $config =& JFactory::getConfig();
     $tmp_dest = $config->getValue('config.tmp_path');
     if (!is_object($update)) {
         // parseXMLFile will have set a message hopefully
         //$this->setState('message', 'XML Parse failed');
         return false;
     } else {
         $destination = $tmp_dest . DS . 'com_jupdateman_auto.tgz';
         $download = downloadFile($update->updaterurl, $destination);
         if ($download !== true) {
             $this->setState('message', $download->error_message);
             return false;
         } else {
             $package = JInstallerHelper::unpack($destination);
             if (!$package) {
                 $this->setState('message', 'Unable to find install package');
                 return false;
             }
             $installer =& JInstaller::getInstance();
             // Install the package
             if (!$installer->install($package['dir'])) {
                 // There was an error installing the package
                 $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error'));
                 $result = false;
             } else {
                 // Package installed sucessfully
                 $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
                 $result = true;
             }
             // Grab the application
             $mainframe =& JFactory::getApplication();
             // Set some model state values
             $mainframe->enqueueMessage($msg);
             $this->setState('name', $installer->get('name'));
             $this->setState('result', $result);
             $this->setState('message', $installer->message);
             $this->setState('extension.message', $installer->get('extension.message'));
             // Cleanup the install files
             if (!is_file($package['packagefile'])) {
                 $config =& JFactory::getConfig();
                 $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
             }
             JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
             return $result;
         }
     }
 }
Пример #10
0
function _moduleContent(&$smarty, $module_name)
{
    global $arrConf;
    //folder path for custom templates
    $local_templates_dir = getWebDirModule($module_name);
    //conexion resource
    $pDB = new paloDB($arrConf['elastix_dsn']["elastix"]);
    //user credentials
    global $arrCredentials;
    $dsn_agi_manager = getDNSAGIManager();
    $action = getAction();
    $content = "";
    switch ($action) {
        case "add":
            $content = form_Recordings($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrCredentials);
            break;
        case "record":
            $content = record($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $dsn_agi_manager, $arrCredentials);
            break;
        case "hangup":
            $content = hangup($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $dsn_agi_manager, $arrCredentials);
            break;
        case "save":
            $content = save_recording($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrCredentials);
            break;
        case "remove":
            $content = remove_recording($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrCredentials);
            break;
        case "check_call_status":
            $content = checkCallStatus("call_status", $smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $dsn_agi_manager, $arrCredentials);
            break;
        case "checkName":
            $content = check_name($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $dsn_agi_manager, $arrCredentials);
            break;
        case "download":
            $content = downloadFile($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $dsn_agi_manager, $arrCredentials);
            break;
        default:
            $content = reportRecording($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrCredentials);
            break;
    }
    return $content;
}
Пример #11
0
// if uploading a tsv indicated by the POST['type']
if ($_POST['type'] == 'tsv' or $_POST['type'] == 'csv' or $_POST['type'] == 'txt') {
    // get clustering parameters
    $method = $_POST['method'];
    $metric = $_POST['metric'];
    $output = 'phyloxml';
    //create an xml file
    $title = $_POST['title'];
    $type = $_POST['type'];
    $p = $_POST['p'];
    # $addLabels = $addLabels;
    # $labelFile = $labelFile;
    // build the argument string for Rscript
    // flags do nothing,
    // future: make flags work, right now, R script assumes current order
    $rArgs = "-f {$infile} -m {$method} -d {$metric} -o {$output} -t \"{$title}\" \n\t-p {$p} -s {$type} -l {$labelFile}";
    // the file name is the expected output of clustr.r
    $stdout = callR("clustr.r", "{$rArgs}");
    $stdout = explode(",<r>,", $stdout);
    $file = $stdout[0];
    $rowlabels = $stdout[1];
    $out = openfile($file, "b");
    //give the file to the user to download
    // $name = $_FILES['file']['name'];
    $name = $title;
    require "download.php";
    // download script
    downloadFile($file, "{$name}.xml");
    // and exit so nothing else is sent back to the browser
    exit;
}
Пример #12
0
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
//
//     This program is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     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, see <http://www.gnu.org/licenses/>.
// /download.php
// downloads a zip of all of the user's texts and chunksets
// RETURN
//  - nothing
// DOWNLOAD
//  - zip of all of user's texts and chunksets in user.texts.zip
$HOME = ".";
require_once "{$HOME}/includes/nav.php";
require_once $MODLOGIN;
require_once $MODDOWNLOAD;
session_start();
login();
$FILE = "texts.zip";
$NEWDIR = "user.texts";
`mkdir {$NEWDIR}`;
`mv * {$NEWDIR}`;
`zip -r {$FILE} {$NEWDIR}`;
`mv {$NEWDIR}/* .`;
downloadFile("{$FILE}");
`rm -r {$NEWDIR} {$FILE}`;
Пример #13
0
    $nodeID = getPassword();
    registerNode($nodeID, $cfg_file);
}
// Set default command, then loop to process
$chCommand = "RUN";
while ($chCommand != "STOP" && $chCommand != "DIE") {
    echo "Asking for tasking...\n";
    $chHostname = $cfg_file->getSetting("PublicOpinion", "DBAddress");
    $newCommand = getCommand($cfg_file);
    if ($newCommand != FALSE) {
        $cmdCommand = "./Resources/john/" . $newCommand[0] . " --pot=/tmp/" . $nodeID . ".pot " . "--wordlist=/tmp/wordlist.txt " . "/tmp/targets.txt";
        $cmdWords = "http://" . $chHostname . "/" . $newCommand[1];
        $cmdTargets = "http://" . $chHostname . "/" . $newCommand[2];
        $jobID = $newCommand[3];
        downloadFile($cmdWords, "/tmp/wordlist.txt");
        downloadFile($cmdTargets, "/tmp/targets.txt");
        echo "Processing Job ID: " . $jobID . "\n";
        $jRes = exec($cmdCommand);
        if (substr($jRes, 0, 35) == "No password hashes loaded (see FAQ)") {
            echo "Bad format match.\n";
            die;
        }
        echo "COMPLETE.\n";
        $results = readPotFile($nodeID);
        if (strlen($results) > 0) {
            echo "Found matches!  Uploading!\n";
            courthouseWebConnect($chHostname, "SubmitResult", $nodeID, '0', $ownIPAddress, $jobID, $results, "POST");
        } else {
            echo "No matches... getting another job.\n";
            $results = "CLCSUNDEFINED";
            courthouseWebConnect($chHostname, "SubmitResult", $nodeID, '0', $ownIPAddress, $jobID, $results, "POST");
Пример #14
0
    $_SESSION['CRON'] = $array;
    // get DOM from URL or file
    $html = file_get_html($URL . $FILE);
    $_SESSION['PASS'][] = $FILE;
    $FILE = $html->newFileName('a', $FILE);
    $html->readFilesUrl($FILE);
    //Take a memory
    $_SESSION['FILE'] = $FILE;
    $_SESSION['CRON'] = array_unique(array_merge($_SESSION['CRON'], array_diff($html->Document['a'][0], $_SESSION['PASS'])));
    $_SESSION[$FILE] = $html->Document;
    foreach ($DOWNLOAD as $e) {
        $TOTALFILE += count($_SESSION[$FILE][$e][0]);
    }
    echo $TOTALFILE . ':' . $FILE . ':' . count($_SESSION['PASS']) . ':' . count($_SESSION['CRON']);
} else {
    $i = $_POST['id'];
    $fileUrl = $_SESSION[$_SESSION['FILE']][$DOWNLOAD[$_POST['type']]][0][$i];
    $newName = isset($_SESSION[$_SESSION['FILE']][$DOWNLOAD[$_POST['type']] . '_url'][0][$i]) ? $_SESSION[$_SESSION['FILE']][$DOWNLOAD[$_POST['type']] . '_url'][0][$i] : '';
    $i++;
    if ($i > count($_SESSION[$_SESSION['FILE']][$DOWNLOAD[$_POST['type']]][0]) - 1) {
        $_POST['type']++;
        $i = 0;
        if (!isset($_SESSION[$_SESSION['FILE']][$DOWNLOAD[$_POST['type']]])) {
            exit(die);
        }
        exit($_POST['type'] . ':' . $i . ':' . '-------------------<b class="yellow">' . $DOWNLOAD[$_POST['type']] . '</b>-------------------<br>');
    }
    $newName = downloadFile($fileUrl, $newName, $ROOT, $URL);
    echo $_POST['type'] . ':' . $i . ': <span class="' . ((file_exists($newName) ? 'yesil' : 'red') . '">' . $newName . '</span>');
}
ob_end_flush();
Пример #15
0
function downloadMapTile($urlPrefix, $zoom, $row, $col, $allMapTilesFolder)
{
    $filename = tile2path($col, $row, $zoom);
    $url = 'http://' . $urlPrefix . $filename;
    $archivedFile = $allMapTilesFolder . $filename;
    if (!file_exists(dirname($archivedFile))) {
        mkdir(dirname($archivedFile), 0777, true);
    }
    // 12/16/2011 kevin removing for png map tiles => if(file_exists($archivedFile) && jpeg_file_is_corrupted($archivedFile)) unlink($archivedFile); // if identification fails
    downloadFile($url, null, $archivedFile);
    return $archivedFile;
}
Пример #16
0
            respond("BADFILENAME", '', true);
        }
        if (preg_match("/[^0-9]/", $iid)) {
            respond("BADIID", '', true);
        }
        if (!preg_match("/\\d{4}-\\d{2}-\\d{2}/", $date)) {
            respond("BADDATE", '', true);
        }
        if (preg_match("/[^0-9]/", $sid)) {
            respond("BADSERVICEID", '', true);
        }
        if (preg_match("/[^A-Za-z]/", $service)) {
            respond("BADSERVICE", '', true);
        }
        if (preg_match("/[^0-9A-Za-z\\.]/", $version)) {
            respond("BADVERSION", '', true);
        }
        // PROCESS INPUTS
        $date = split('-', $date);
        $year = $date[0];
        $month = $date[1];
        $day = $date[2];
        $filePath = "/home/data1/isolates/{$year}/{$month}/{$day}/{$iid}/services/" . $service . "_{$sid}/downloads/";
    }
    // TRY TO UPLOAD THE DOWNLOADABLE FILE TO THE USER
    if ($filePath != '' and $filename != '') {
        downloadFile($filePath, $filename);
    }
} else {
    echo "<html><body>Missing input</body></html>";
}
Пример #17
0
 public function indenx()
 {
     //echo "<pre>";
     //print_r($_SERVER['HTTP_HOST']);
     //exit;
     $hostname = '{imap.gmail.com:993/imap/ssl}test';
     $username = '******';
     $password = '******';
     $inbox = imap_open($hostname, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error());
     /* grab emails */
     $emails = imap_search($inbox, 'ALL');
     $overview = imap_fetch_overview($inbox, 1, 0);
     print_r($overview);
     exit;
     /* if emails are returned, cycle through each... */
     if ($emails) {
         /* begin output var */
         $output = '';
         $values = '';
         /* put the newest emails on top */
         rsort($emails);
         /* for every email... */
         foreach ($emails as $email) {
             /* get information specific to this email */
             $overview = imap_fetch_overview($inbox, $email, 0);
             $message = get_part($inbox, $email, "TEXT/HTML");
             $attachments = '';
             //$message = imap_fetchbody($inbox,$email,2);
             //imap_fetchstructure($inbox, $email);
             $struct = imap_fetchstructure($inbox, $email);
             $contentParts = count($struct->parts);
             if ($contentParts >= 2) {
                 for ($i = 2; $i <= $contentParts; $i++) {
                     $att[$i - 2] = imap_bodystruct($inbox, $email, $i);
                 }
                 for ($k = 0; $k < sizeof($att); $k++) {
                     if ($att[$k]->parameters[0]->value == "us-ascii" || $att[$k]->parameters[0]->value == "US-ASCII") {
                         if ($att[$k]->parameters[1]->value != "") {
                             $strFileName = $att[$k]->parameters[1]->value;
                             $strFileType = strrev(substr(strrev($strFileName), 0, 4));
                             $fileContent = imap_fetchbody($inbox, $email, 2);
                             downloadFile($strFileType, $strFileName, $fileContent);
                             $attachments .= $strFileName . ',';
                         }
                     } elseif ($att[$k]->parameters[0]->value != "iso-8859-1" && $att[$k]->parameters[0]->value != "ISO-8859-1") {
                         $strFileName = $att[$k]->parameters[0]->value;
                         $strFileType = strrev(substr(strrev($strFileName), 0, 4));
                         $fileContent = imap_fetchbody($inbox, $email, 2);
                         //downloadFile($strFileType,$strFileName,$fileContent);
                         $attachments .= $strFileName . ',';
                     }
                 }
             }
         }
     }
     //	imap_msgno($inbox,$uid);
     //exit;
     $this->load->view('welcome_message');
 }
Пример #18
0
        $size2 = $size - 1;
        $new_length = $size - $range;
        header("HTTP/1.1 206 Partial Content");
        header("Content-Length: {$new_length}");
        header("Content-Range: bytes {$range}{$size2}/{$size}");
    } else {
        $size2 = $size - 1;
        header("Content-Range: bytes 0-{$size2}/{$size}");
        header("Content-Length: " . $size);
    }
    if ($size == 0) {
        die('Zero byte file! Aborting download');
    }
    if (get_magic_quotes_runtime()) {
        set_magic_quotes_runtime(0);
    }
    $fp = fopen("{$fileLocation}", "rb");
    fseek($fp, $range);
    while (!feof($fp) and connection_status() == 0) {
        set_time_limit(0);
        print fread($fp, 1024 * $maxSpeed);
        flush();
        ob_flush();
        sleep(1);
    }
    fclose($fp);
    return connection_status() == 0 and !connection_aborted();
}
/* Implementation */
downloadFile('file/', 'test.zip', 900, false);
Пример #19
0
<?php 
$pageTitle = "Files";
include './includes/header.php';
checkIfLoggedIn();
$message = "";
if ($_GET && isset($_GET['id'])) {
    $fileName = htmlspecialchars(trim($_GET['id']));
    $fileDir = 'user_files' . DIRECTORY_SEPARATOR . $fileName;
    if (file_exists($fileDir)) {
        downloadFile($fileDir);
    } else {
        $message = "File not Found!";
    }
}
?>
<h1><?php 
echo $pageTitle;
?>
</h1>
<h4 class="text-error"><?php 
echo $message;
?>
</h4>

<div class = "row-fluid">
    <table class = "table table-bordered table-striped">
        <thead>
            <tr>
                <th>File Name</th>
                <th>File Size</th>
Пример #20
0
$http = eZHTTPTool::instance();
$module = $Params['Module'];
$templateFile = 'design:newsletter/mailbox_item_view.tpl';
require_once 'kernel/common/i18n.php';
include_once 'kernel/common/template.php';
$mailboxItemId = (int) $Params['MailboxItemId'];
$mailboxItemObject = CjwNewsletterMailboxItem::fetch($mailboxItemId);
if (!is_object($mailboxItemObject)) {
    return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
if ($http->hasVariable('GetRawMailContent')) {
    header('Content-Type: text/plain');
    echo $mailboxItemObject->getRawMailMessageContent();
    eZExecution::cleanExit();
} elseif ($http->hasVariable('DownloadRawMailContent')) {
    downloadFile($mailboxItemObject->getFilePath());
} else {
    $cjwNewsletterMailParserObject = new CjwNewsletterMailParser($mailboxItemObject);
    if (is_object($cjwNewsletterMailParserObject)) {
        $parseHeaderArray = $cjwNewsletterMailParserObject->parse();
    }
    $tpl = templateInit();
    $tpl->setVariable('mailbox_item', $mailboxItemObject);
    $tpl->setVariable('mailbox_item_raw_content', $mailboxItemObject->getRawMailMessageContent());
    $tpl->setVariable('mailbox_header_hash', $parseHeaderArray);
    $Result = array();
    $Result['content'] = $tpl->fetch($templateFile);
    $Result['path'] = array(array('url' => 'newsletter/mailbox_item_list', 'text' => ezi18n('cjw_newsletter/mailbox_item_view', 'Mailbox item list')), array('url' => false, 'text' => ezi18n('cjw_newsletter/mailbox_item_view', 'Mailbox item view')));
}
// helpfunction
/**
Пример #21
0
    $visitor->setScreenResolution('1024x768');
    // Assemble Session information
    // (could also get unserialized from PHP session)
    $session = new GoogleAnalytics\Session();
    // Assemble Page information
    $page = new GoogleAnalytics\Page('/download.php?' . $file);
    $page->setTitle('Download file ' . $file);
    // Track page view
    $tracker->trackPageview($page, $session, $visitor);
    $event = new GoogleAnalytics\Event($app, 'App', $file, $eventno);
    $tracker->trackEvent($event, $session, $visitor);
}
set_time_limit(0);
$xml = simplexml_load_file("indexes.xml");
$res = $xml->xpath('//region[@name="' . $file . '"]');
if (count($res) > 0) {
    $node = $res[0];
    if (isset($_GET['road'])) {
        downloadFile('road-indexes/' . $file);
    } else {
        if ($node["local"]) {
            downloadFile('indexes/' . $file);
        } else {
            header('HTTP/1.1 302 Found');
            header('Location: http://osmand.googlecode.com/files/' . $file);
        }
    }
} else {
    header('HTTP/1.1 302 Found');
    header('Location: http://osmand.googlecode.com/files/' . $file);
}
Пример #22
0
function downloadFiles()
{
    global $conn_id;
    global $serverTmp;
    global $lang_server_error_down;
    global $downloadFileAr;
    clipboard_files();
    $downloadFileAr = array();
    // Folders
    foreach ($_SESSION["clipboard_folders"] as $folder) {
        $folder = urldecode($folder);
        $folder_name = getFileFromPath($folder);
        $path_parts = pathinfo($folder);
        $dir_source = $path_parts['dirname'];
        downloadFolder($folder_name, $dir_source);
    }
    // Files
    foreach ($_SESSION["clipboard_files"] as $file) {
        $downloadFileAr[] = urldecode($file);
    }
    // Download and zip each file
    if (sizeof($downloadFileAr) > 1) {
        $zip_file_name = "monstaftp_" . date("Y_m_d_H_i_s") . ".zip";
        $zip_file = tempnam($serverTmp, $zip_file_name);
        $zip = new ZipArchive();
        $zip->open($zip_file, ZipArchive::CREATE);
        foreach ($downloadFileAr as $file) {
            $file_name = getFileFromPath($file);
            $fp1 = $serverTmp . "/" . $file_name;
            $fp2 = $file;
            $isError = 0;
            ensureFtpConnActive();
            // Download file to client server
            if (!@ftp_get($conn_id, $fp1, $fp2, FTP_BINARY)) {
                if (checkFirstCharTilde($fp2) == 1) {
                    if (!@ftp_get($conn_id, $fp1, replaceTilde($fp2), FTP_BINARY)) {
                        recordFileError("file", $file_name, $lang_server_error_down);
                        $isError = 1;
                    }
                } else {
                    recordFileError("file", $file_name, $lang_server_error_down);
                    $isError = 1;
                }
            }
            if ($isError == 0) {
                // Remove the current folder path
                $file_path = str_replace($_SESSION["dir_current"] . "/", "", $fp2);
                // Add file to zip
                $zip->addFile($fp1, $file_path);
            }
        }
        $zip->close();
        // Unlink tmp files
        foreach ($downloadFileAr as $file) {
            $file_name = getFileFromPath($file);
            $fp1 = $serverTmp . "/" . $file_name;
            unlink($fp1);
        }
        header("Content-Type: application/octet-stream");
        header("Content-Disposition: attachment; filename=\"" . $zip_file_name . "\"");
        header("Content-Transfer-Encoding: Binary");
        header("Content-Type: application/download");
        header("Content-Description: File Transfer");
        header("Content-Length: " . filesize($zip_file));
        flush();
        $fp = @fopen($zip_file, "r");
        while (!feof($fp)) {
            echo @fread($fp, 65536);
            @flush();
        }
        @fclose($fp);
        // Delete tmp file
        unlink($zip_file);
    }
    // Download just one file
    if (sizeof($downloadFileAr) == 1) {
        $_GET["dl"] = $downloadFileAr[0];
        downloadFile();
    }
    $_SESSION["clipboard_folders"] = array();
    $_SESSION["clipboard_files"] = array();
}
Пример #23
0
$accessToken = $reftoken->access_token;*/
// Exchange authorization code for access token
$accessToken = $client->authenticate($authCode);
$client->setAccessToken($accessToken);
//*************************************************  Select Flow  **************************************************************************
//$query = mysql_query("select * from  files");
//$row = mysql_fetch_array($query);
$flow = 'update';
//$row['flow'];
if ($flow == 'down') {
    //**************************************************  DOWNLOAD  *****************************************************************************
    $fileId = 1;
    //$row['fid'];
    $file = new Google_DriveFile();
    $file = $service->files->get($fileId);
    $data = downloadFile($service, $file);
    $name = $file->getTitle();
    make($data, $name);
    mysql_query("UPDATE files SET fname='" . $name . "' WHERE sr='1'") or die('error updating');
    echo '<script type="text/javascript">';
    echo 'window.location.href = "http://localhost/Dropbox-master/examples/putFile.php";';
    echo '</script>';
} elseif ($flow == 'up') {
    //**************************************************  UPLOAD  ****************************************************************************
    $name = 'WorldCup2014.txt';
    //Insert a file
    $file = new Google_DriveFile();
    $file->setTitle($name);
    //$file->setDescription('A test document');
    //$file->setMimeType('text/plain');
    $data = file_get_contents($name);
Пример #24
0
     //解禁用户账号-----
     var_dump(activeUser("zhangsan"));
     break;
 case 31:
     //强制用户下线
     var_dump(disconnectUser("zhangsan"));
     break;
 case 32:
     //上传图片或文件
     var_dump(uploadFile("./resource/up/pujing.jpg"));
     //var_dump(uploadFile("./resource/up/mangai.mp3"));
     //var_dump(uploadFile("./resource/up/sunny.mp4"));
     break;
 case 33:
     //下载图片或文件
     var_dump(downloadFile('01adb440-7be0-11e5-8b3f-e7e11cda33bb', 'Aa20SnvgEeWul_Mq8KN-Ck-613IMXvJN8i6U9kBKzYo13RL5'));
     break;
 case 34:
     //下载图片缩略图
     var_dump(downloadThumbnail('01adb440-7be0-11e5-8b3f-e7e11cda33bb', 'Aa20SnvgEeWul_Mq8KN-Ck-613IMXvJN8i6U9kBKzYo13RL5'));
     break;
 case 35:
     //发送文本消息
     $from = 'admin';
     $target_type = "users";
     //$target_type="chatgroups";
     $target = array("zhangsan", "lisi", "wangwu");
     //$target=array("122633509780062768");
     $content = "Hello HuanXin!";
     $ext['a'] = "a";
     $ext['b'] = "b";
Пример #25
0
    notFound();
}
$audio = $json['response'][0];
$fileName = $audio["artist"] . " - " . $audio["title"];
$audioUrl = $audio["url"];
$filePath = "dl/" . md5($audioId) . ".mp3";
//caching mp3s, md5 for unique audioIds
if (file_exists($filePath)) {
    if ($isStream) {
        stream($filePath, $fileName);
    } else {
        forceDownload($filePath, $fileName);
    }
    return;
} else {
    if (downloadFile($audioUrl, $filePath)) {
        if ($isStream) {
            stream($filePath, $fileName);
        } else {
            forceDownload($filePath, $fileName);
        }
    }
}
//Functions
/**
 * Download file with given name to given path
 * @param $url url to download
 * @param $path output filepath
 * @return true if success, else you know what
 */
function downloadFile($url, $path)
Пример #26
0
 public static function download($filename, $type)
 {
     $backupDirectory = SG_BACKUP_DIRECTORY . $filename . '/';
     switch ($type) {
         case SG_BACKUP_DOWNLOAD_TYPE_SGBP:
             $filename .= '.sgbp';
             downloadFileSymlink($backupDirectory, $filename);
             break;
         case SG_BACKUP_DOWNLOAD_TYPE_BACKUP_LOG:
             $filename .= '_backup.log';
             downloadFile($backupDirectory . $filename, 'text/plain');
             break;
         case SG_BACKUP_DOWNLOAD_TYPE_RESTORE_LOG:
             $filename .= '_restore.log';
             downloadFile($backupDirectory . $filename, 'text/plain');
             break;
     }
     exit;
 }
Пример #27
0
function download_google_files($service, $filesArray)
{
    $CI =& get_instance();
    $CI->load->library('zip');
    if (!empty($filesArray)) {
        //pr($filesArray);
        if ($filesArray->mimeType != "application/vnd.google-apps.folder") {
            $name = 'Documents/' . $filesArray->title;
            $data = downloadFile($service, $filesArray);
            //pr($data);
            return $CI->zip->add_data($name, $data);
        }
    }
}
function makeArchive($pluginName, $generationBaseDir, $templateBaseDir)
{
    $zip = new ZipArchive();
    $filename = $pluginName . '.zip';
    $filepath = $generationBaseDir . '/' . $filename;
    if (file_exists($filepath)) {
        $flags = ZipArchive::OVERWRITE;
    } else {
        $flags = ZipArchive::CREATE;
    }
    if ($zip->open($filepath, $flags) !== TRUE) {
        exit("Impossible d'ouvrir le fichier <{$filepath}>\n");
    }
    //add generated files
    addToArchive($zip, $generationBaseDir . '/' . $pluginName, '.');
    //add static files
    addToArchive($zip, $templateBaseDir . '/static', '.');
    $zip->close();
    downloadFile($filename, $filepath);
    //delete file
    unlink($filepath);
}
<?php

/*
Copyright (c) 2010-2016 Carlos Omar Villanueva

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
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, see <http://www.gnu.org/licenses/>.
*/
require_once "_lib/php/auth.php";
$gdbo->sql = "SELECT * FROM _fso WHERE fso='" . $_GET["fso"] . "'";
$gdbo->getRec();
$recFSO = $gdbo->getAssociative();
downloadFile($fsorootpath . $recFSO[0]["fso_path"] . $recFSO[0]["fso"], $recFSO[0]["fso_originalname"]);
Пример #30
0
        case 'checkForExistentFile':
            checkForExistentFile();
            break;
        case 'downloadFile':
            downloadFile();
            break;
    }
}
if (isset($_GET['action'])) {
    if (!isUserLogged()) {
        exit;
    }
    $_GET['action'] = sanitizeString($_GET['action']);
    switch ($_GET['action']) {
        case "doUserLogout":
            doUserLogout();
            break;
        case "listFiles":
            if (!isset($_GET['pathDir'])) {
                exit;
            }
            listFiles(sanitizeFilePath($_GET['pathDir']));
            break;
        case "runExecutableFile":
            runExecutableFile();
            break;
        case 'downloadFile':
            downloadFile();
            break;
    }
}