Example #1
0
 function thumb($url = '', $source = '', $name = '', $type = -1, $width = 0, $height = 0)
 {
     //如何生成不成功,则返回原url
     global $cms_abs, $cmsurl, $ftp_url, $atm_smallsite;
     if (!$url || !$source || !$name || !$width || !$height) {
         return $url;
     }
     include_once M_ROOT . "./include/upload.cls.php";
     if ($ftp_url && preg_match(u_regcode($ftp_url), $url)) {
         //ftp上的文件
         include_once M_ROOT . "./include/http.cls.php";
         include_once M_ROOT . "./include/ftp.fun.php";
         //下载原图
         $tempfile = M_ROOT . './dynamic/imcache/' . basename($url);
         mmkdir($tempfile, 0, 1);
         $m_http = new http();
         $m_http->savetofile($url, $tempfile);
         unset($m_http);
         //生成缩略图
         $m_upload = new cls_upload();
         $m_upload->image_resize($tempfile, $width, $height, $tempfile . '.s.jpg');
         @unlink($tempfile);
         unset($m_upload);
         //上传缩略图
         $ftpfile = preg_replace(u_regcode($ftp_url), '', $url) . 's/' . $width . '_' . $height . '.jpg';
         //根据url得到缩略上传到的位置
         $tempfile .= '.s.jpg';
         if (ftp_upload($tempfile, $ftpfile)) {
             $this->refresh_record($source, $name, $type, $width, $height);
             //将缩略图规格写入数据库
             return $url . 's/' . $width . '_' . $height . '.jpg';
         } else {
             return $url;
         }
         @unlink($tempfile);
     } else {
         //本地服务器上的文件
         $m_upload = new cls_upload();
         $localfile = local_atm($url);
         $m_upload->image_resize($localfile, $width, $height, $localfile . 's/' . $width . '_' . $height . '.jpg');
         unset($m_upload);
         return $url . 's/' . $width . '_' . $height . '.jpg';
     }
 }
            array_push($file_content, "    max-limit=0 name=" . $addr_list_in . " packet-mark=" . $addr_list_in . " parent=global-in priority=1 \\\n");
            array_push($file_content, "    queue=" . $queue_type_in . " \n");
            array_push($file_content, "add burst-limit=0 burst-threshold=0 burst-time=0s comment=\"" . $comment . "\" disabled=no limit-at=0 \\\n");
            array_push($file_content, "    max-limit=0 name=" . $addr_list_out . " packet-mark=" . $addr_list_out . " parent=global-out priority=1 \\\n");
            array_push($file_content, "    queue=" . $queue_type_out . " \n");
        }
    }
    $file_name = "./pcq_mikrotik.rsc";
    if (!is_writable($file_name)) {
        $fp = fopen($file_name, "w+");
        fclose($fp);
    }
    file_put_contents($file_name, $file_content);
    $nas_ip = $value['nasname'];
    $nas_login = $value['naslogin'];
    $nas_pass = $value['naspass'];
    $file_in = $file_name;
    $file_out = 'pcq_mikrotik.rsc';
    $file_exec = $file_out;
    ftp_upload($nas_ip, $nas_login, $nas_pass, $file_in, $file_out);
    $command = 'import ' . $file_exec;
    $ssh = $system_options['ssh_path'] . ' ' . $nas_login . '@' . $nas_ip;
    $mik_ssh = $system_options['sudo'] . ' ' . $ssh . ' ';
    exec($mik_ssh . "{$command}" . " &>/dev/null 2>&1");
}
mysql_close($LINK);
# На всякий случай
# Комманда на микротике удалить все созданые правила MikBIll
# /ip firewall mangle remove [find comment="mikbill_auto"]
# /queue simple remove [find comment="mikbill_auto"]
# /queue type remove [find name~"mikbill."]
Example #3
0
 function zip_upload($localname, $type = 'image')
 {
     global $curuser, $memberid, $_FILES, $localfiles, $dir_userfile, $db, $tblprefix, $timestamp, $ftp_enabled;
     include_once 'include/zip.cls.php';
     $uploadfile = $result = array();
     $file_saved = false;
     $localfile = $localfiles[$type];
     foreach ($localfile as $k => $v) {
         if (empty($v['islocal'])) {
             unset($localfile[$k]);
         }
     }
     if (!$_FILES[$localname] || !mis_uploaded_file($_FILES[$localname]['tmp_name']) || !$_FILES[$localname]['tmp_name'] || !$_FILES[$localname]['name'] || $_FILES[$localname]['tmp_name'] == 'none') {
         $result['error'] = 1;
         //'不存在的上传文件!'
         return $result;
     }
     $uploadfile = $_FILES[$localname];
     $localfilename = addslashes($uploadfile['name']);
     $uploadfile['mid'] = $curuser->info['mid'];
     $uploadfile['mname'] = $curuser->info['mname'];
     $uploadpath = $this->upload_path($type);
     $fuploadpath = M_ROOT . $uploadpath;
     if (empty($localfile)) {
         //本地上传方案为空
         @unlink($uploadfile['tmp_name']);
         $result['error'] = 1;
         return $result;
     }
     if ($this->capacity != -1 && $uploadfile['size'] > 1024 * $this->capacity) {
         //超过空间
         @unlink($uploadfile['tmp_name']);
         $result['error'] = 1;
         return $result;
     }
     $zip = new PHPZip($uploadfile['tmp_name']);
     $lst = $zip->filelist();
     $result['count'] = count($lst);
     $ret = array();
     $capacity = 1024 * $this->capacity;
     $size = 0;
     foreach ($lst as $z) {
         if ($z['folder']) {
             $result['count']--;
             continue;
         }
         $extension = strtolower(mextension($z['name']));
         if (!in_array($extension, array_keys($localfile))) {
             //文件类型不在本地上传方案中
             continue;
         }
         if (!empty($localfile[$extension]['minisize']) && $z['size'] < 1024 * $localfile[$extension]['minisize']) {
             //'超出该文件类型大小限制!'
             continue;
         }
         if (!empty($localfile[$extension]['maxsize']) && $z['size'] > 1024 * $localfile[$extension]['maxsize']) {
             //'超出该文件类型大小限制!'
             continue;
         }
         $size += $z['size'];
         if ($this->capacity != -1 && $size > $capacity) {
             break;
         }
         $ret[] = $z['index'];
     }
     if (empty($ret)) {
         $result['error'] = -2;
         return $result;
     }
     $tzip = "{$fuploadpath}{$memberid}_" . random(6) . '/';
     $lst = $zip->Extract($tzip, $ret);
     @unlink($uploadfile['tmp_name']);
     $ret = array();
     foreach ($lst as $k => $v) {
         if (substr($k, -1) == '/') {
             continue;
         }
         $uploadfile['filename'] = preg_replace("/(php|phtml|php3|php4|jsp|exe|dll|asp|cer|asa|shtml|shtm|aspx|asax|cgi|fcgi|pl)(\\.|\$)/i", "_\\1\\2", date('dHis') . substr(md5($k . microtime()), 5, 10) . random(4, 1) . '.' . $extension);
         $uploadfile['url'] = $uploadpath . $uploadfile['filename'];
         $target = $fuploadpath . $uploadfile['filename'];
         if (!rename($tzip . $k, $target)) {
             continue;
         }
         $uploadfile['thumbed'] = 0;
         if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'swf', 'bmp'))) {
             if (!($infos = @getimagesize($target))) {
                 @unlink($target);
                 continue;
             }
             if (in_array($extension, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) {
                 /*					if(isset($infos[0]) && isset($infos[1])){
                 						$result['width'] = $infos[0];
                 						$result['height'] = $infos[1];
                 					}*/
                 if ($this->image_thumb($target)) {
                     $uploadfile['thumbed'] = 1;
                 }
                 if ($this->image_watermark($target)) {
                     $uploadfile['size'] = filesize($target);
                 }
             }
         }
         if ($ftp_enabled) {
             include_once M_ROOT . "./include/ftp.fun.php";
             ftp_upload($target, $uploadfile);
         }
         $this->upload_size += ceil($uploadfile['size'] / 1024);
         if ($this->capacity != -1) {
             $this->capacity -= ceil($uploadfile['size'] / 1024);
             $this->capacity = max(0, $this->capacity);
         }
         $db->query("INSERT INTO {$tblprefix}userfiles SET\n\t\t\t\t\tfilename='{$uploadfile['filename']}',\n\t\t\t\t\turl='{$uploadfile['url']}',\n\t\t\t\t\ttype='{$type}',\n\t\t\t\t\tcreatedate='{$timestamp}',\n\t\t\t\t\tmid='{$uploadfile['mid']}',\n\t\t\t\t\tmname='{$uploadfile['mname']}',\n\t\t\t\t\tsize='{$uploadfile['size']}',\n\t\t\t\t\tthumbed='{$uploadfile['thumbed']}'");
         if ($ufid = $db->insert_id()) {
             $this->ufids[] = $ufid;
         }
         $ret[] = $uploadfile['url'];
     }
     unset($uploadfile);
     clear_dir($tzip, 1);
     $result['remote'] = $ret;
     return $result;
 }
Example #4
0
                }
                // if ($db_backup_tar)
            }
            // if (!$success = mysql_select_db($db_name, $GLOBALS["db_connect"]))
        }
        //if (!$db_connect = mysql_pconnect(DB_HOST, DB_USER, DB_PASS))
        log_msg(date("H:i:s") . ": Backup for database {$db_name} completed with {$db_error_count} errors.\n");
        $total_error_count = $total_error_count + $db_error_count;
        log_msg($sep);
    }
    // if ($cfg['db'][$db_i]['db_name'] != '';)
}
// foreach ($cfg['db'] as $db_i)
// Upload archive file to remote server by FTP
if ($ftp_upload == "yes" && $archive_tar) {
    ftp_upload();
}
// if($use_ftp == "yes")
log_msg(date("H:i:s") . ": Diskspace used by MySQL database backup files: ");
log_msg(format_size(dirsize(DB_BACKUP_PATH)));
log_msg("\n");
log_msg($sep);
log_msg(date("H:i:s") . ": Backup completed with {$total_error_count} errors.\n          Have a nice day!\n");
// Mail the contents of the output buffer
if ($email_report or $email_archive) {
    $success = mail_report($log);
    log_msg(date("H:i:s") . ": {$success}");
    log_msg("\n");
}
log_msg($sep);
// No HTML Output when running from command-line