Delphi 推出社群版本(Community Edition)


Delphi推出了全新的社群版本(Community Edition),不像先前的starter版本。而是專業版加上iOS/Android功能。如果寫開放源始碼/免費軟體都可以,商業版的話限制為
1年收入不超過5000美金(約15萬台幣)
2成員不超過5人

 

延伸閱讀:

Learn to Program with Community Edition

Introducing Delphi and C++Builder Community Edition

C# AES加解密

最近常遇到需要使用AES加解密的需求,無論是網路傳輸/API相關的部份。
分享一下
Github原始碼下載
https://github.com/superlevin/CSharpAES

using System.Security.Cryptography;
public static string SHAEncrypt(string str)
{
var crypt = new System.Security.Cryptography.SHA256Managed();
var hash = new System.Text.StringBuilder();
byte[] crypto = crypt.ComputeHash(Encoding.UTF8.GetBytes(str));
foreach (byte theByte in crypto)
{
hash.Append(theByte.ToString("x2"));
// x小寫 X 大寫 x2 補0
}
return hash.ToString();
}
public static string AESEncrypt(string str, string strkey, string strivKey, bool isVasEncrypt = false)
{

var aesCipher = new AesManaged
{
KeySize = 128,
BlockSize = 128,
Mode = CipherMode.CBC,
Padding = PaddingMode.PKCS7
};

var keyStr = KeyGenerator(strkey);
var key = Convert.FromBase64String(keyStr);
var ivKey = Encoding.UTF8.GetBytes(strivKey);
var input = str;
var ivStr = Convert.ToBase64String(ivKey);

aesCipher.Key = key;
aesCipher.IV = ivKey;
byte[] b = System.Text.Encoding.UTF8.GetBytes(str); // plain text to be encrypted
ICryptoTransform encryptTransform = aesCipher.CreateEncryptor();
byte[] cipherText = encryptTransform.TransformFinalBlock(b, 0, b.Length);
return Convert.ToBase64String(cipherText);
}
public static string AESDecrypt(string encstring, string strkey, string strivKey)
{
var aesCipher = new AesManaged
{
KeySize = 128,
BlockSize = 128,
Mode = CipherMode.CBC,
Padding = PaddingMode.PKCS7
};
var keyStr = KeyGenerator(strkey);
var key = Convert.FromBase64String(keyStr);
aesCipher.Key = key;
aesCipher.IV = Encoding.UTF8.GetBytes(strivKey);

var encryptBytes = Convert.FromBase64String(encstring);
ICryptoTransform decryptTransform = aesCipher.CreateDecryptor();
byte[] plainText = decryptTransform.TransformFinalBlock(encryptBytes, 0, encryptBytes.Length);

return System.Text.Encoding.UTF8.GetString(plainText);
}

終於完成了Delphi XE 10.2.3的升級 感謝embarcadero及台灣QCom


今年3月份embarcadero發佈10.2.3升級後,卻發生一直無法正常解除10.2.2的問題,後來求助台灣QCom捷康的幫忙後也無法解決,台灣捷康幫忙與總部聯繫。在連假第三天終於解決了!感謝台灣捷康Eddie Chang以及embarcadero support。

相關資源:
https://community.embarcadero.com/
www.qcomgroup.com.tw
https://community.embarcadero.com/article/articles-support/174-rad-studio/installation-registration/16501-manual-uninstall-of-rad-studio-delphi-c-builder-10-2

PHP管制檔案下載的方式

在許多時候,我們會不希望網友知道網址空間直接下載檔案,或是透過帳號密碼的管控才能下載時,該如何用程式做過濾及管制呢?

header("Content-type:application");
header("Content-Disposition: attachment; filename=file_name");
//file_name是預設下載時的檔名,可使用變數。
readfile("file");
//file是實際存放在你硬碟中要被下載的檔案,可使用變數。
exit(0);

header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="downloaded.pdf"');
readfile('original.pdf');
//限制下載速度,使用 while 迴圈加上 sleep。

while (!feof($handle)) {
echo fread($handle, 8192);
sleep(1);
}

$content = "";
$fp = fopen("http://file-to-download.com/a-file.zip", "rb");

if (!$fp)
die("Error opening file.");
while (!feof($fp))
$content .= fread($fp, 2048);
fclose($fp);

$fp=fopen("local-file-name.zip", "w");
fwrite($fp, $content);
fclose($fp);

$OrgFileName = mb_convert_encoding($OrgFileName, 'BIG-5','UTF-8');

$real_path = dirname(__FILE__).'/upload/'.$FileName;

header('Pragma: public');

header('Expires: 0');

header('Cache-Control: must-revalidate, post-check=0, pre-check=0');

header('Cache-Control: public', false);

header('Content-Description: File Transfer');

header('Accept-Ranges: bytes');

// application/force-download 為通用類型,亦可判斷檔案格式做改變

header('Content-Type: application/force-download');

header('Content-Length: '.filesize($real_path));

header('Content-Transfer-Encoding: binary');

// 注意「"」不可省略,否則FireFox會無法正確讀取

header('Content-Disposition:attachment;filename="'.$OrgFileName.'"');

// 讀取來源檔案資料

if ($stream = fopen($real_path, 'rb')){

while(!feof($stream) && connection_status() == 0){

echo(fread($stream,1024*8));

flush();

}

fclose($stream);

}

header('Content-type:application/force-download'); //告訴瀏覽器 為下載
header('Content-Transfer-Encoding: Binary'); //編碼方式
header('Content-Disposition:attachment;filename='.$filename); //檔名
@readfile($filename);

Windows Server 2016 安裝 PHP Laravel

一、開啟CGI功能
控制台→程式與功能→開啟或關閉Windows功能
開啟CGI

二、下載安裝PHP
http://windows.php.net/download/
三、修改php.ini
fastcgi.impersonate = 1
fastcgi.logging = 0
cgi.fix_pathinfo=1
cgi.force_redirect = 0
date.timezone = “Asia/Taipei”
extension_dir = “C:\PHP\ext”
四、安裝Visual C++ 可轉散發套件
五、IIS設定處理常式對應
六、IIS設定預設文件index.php
七、安裝URL Rewrite
https://www.iis.net/downloads/microsoft/url-rewrite

RAD Studio 10.2.1 Release 1出爐了!

父親節Embarcadero捎來了一份禮物,在官方部落格上宣布RAD Studio 10.2.1 Release1可以下載了(RAD Studio 10.2.1 Released Today),主要當然是一些bug fix外,也多了一些功能。

    • Delphi Linux server performance enhancements for both RAD Server and DataSnap.

    1. Delphi and C++ compiler and linker updates that resolve issues loading packages, especially when debugging, on Windows 10 Creators Update.

    1. Support for latest versions of iOS and Xcode (iOS 10.3 and XCode 8.3.2) when targeting the iOS App Store.

    1. FireDAC support for MSSQL 2012, 2014, 2016, and ODBC Driver 13.

    1. Significant C++ linker improvements pertaining to linking larger projects.

    1. Fixes and enhancements to the Runtime Library and VCL.

    1. Additional Android enhancements around control rendering and performance, and fixes for TEdit issues with Android N.

    1. FireDAC Support for InterBase 2017 Exclusive Isolation Level and Transaction Wait Time.

    1. Changes in DataSize for fields of type ftInteger and ftLongWord to avoid using the platform-dependent LongInt and LongWord type (the change affects only 64-bit Linux and 64-bit iOs platforms), and related changes for SetFieldData and GetFieldData

    Fixes for over 140 issues reported by customers in Quality Portal.