#抓取TRC Catalogue,隔週五抓取
15 22 * * 5 [ $(( $(( $(date +\%W ) )) % 2 )) -eq 1 ] && $HOME/perl/web/getInfoFromTRC.pl > /tmp/getInfoFromTRC.log 2>&1
This man is too old to remember everything in his brain. Right now, he needs a place to write down what he has studied.
2016年11月24日 星期四
2016年11月9日 星期三
PHP 和 Javascript (AJAX) 數值傳遞實例
1. 由於不同server,所以PHP需要增加以下紅字部分
<?php
header("Access-Control-Allow-Origin: *");
$v = $_REQUEST;
foreach($v as $i=>$v)
{
#$temp = $temp."$i=$v,";
if ($i == "occ03") {$occ03 = $v;}
if ($i == "occ11") {$occ11 = $v;}
}
$dbconn = oci_connect("xxx","yyy",
"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xxx.xxx)(PORT=1521))(CONNECT_DATA=(SID=xxx)))",
"AL32UTF8");
$sql = "
select count(*)
from occ_file
where occ03 = substr(:occ03,1,2)
and occ11 = :occ11
order by 1
";
$stid = oci_parse($dbconn, $sql);
oci_bind_by_name($stid,":occ03",$occ03);
oci_bind_by_name($stid,":occ11",$occ11);
//echo "2";
oci_execute($stid);
while ($row = oci_fetch_row($stid)) {
echo "$row[0]";
#echo "var occ11_cnt=$row[0];";
}
oci_close($dbconn);
?>
2. 由於是asynch,所以javascript在判斷時要在 onreadystatechange 就改變原本網頁element的值,另外sleep兩秒(因為asynch,太短時間怕抓到為修改以前的值)
3. 也許使用 XmlHttpRequest 的 sync option (底下true的地方) 也可以,但我未測試
function ... (
chkOCC11();
sleep(2000);
var str = document.getElementById("occ11").value;
if (str.match("請重新輸入")) {
//alert("統一編號重複,請確認")
return false;
};
return true;
)
function chkOCC11() {
var occ03 = document.getElementById("occ03").value;
var occ11 = document.getElementById("occ11").value;
var http ;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
http = new XMLHttpRequest();
} else {// code for IE6, IE5
http = new ActiveXObject("Microsoft.XMLHTTP");
}
var url = "http://10.1.100.201/eip/action/SA001/chkOCC11.php";
var params = "occ03=" + occ03.substr(0,2) + "&occ11=" + occ11;
var occ11_cnt;
if ("withCredentials" in http) {
http.open('POST', url + "?" + params, true);
}
else if (typeof XDomainRequest != "undefined") {
http = new XDomainRequest();
http.open('POST', url + "?" + params, true);
}
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
occ11_cnt = http.responseText;
if (occ11_cnt > 0) {
document.getElementById("occ11").value = "請重新輸入";
alert("統一編號重複,請重新輸入");
}
}
}
http.send(null);
}
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
4.2017/05/02 經過測試,使用同步,不使用非同步的方式就可以檢查值的正確性
5313 function chkTC_CTR11() {
5314 var ta_occ09 = document.getElementById("ta_occ09").value;
5315 var occ11 = document.getElementById("occ11").value;
5316
5317 var http ;
5318 if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
5319 http = new XMLHttpRequest();
5320 } else {// code for IE6, IE5
5321 http = new ActiveXObject("Microsoft.XMLHTTP");
5322 }
5323
5324 var url = "http://10.1.100.201/eip/action/SA001/chkTC_CTR11.php";
5325 var params = "tc_ctr11_03=" + ta_occ09.substr(0,2) + "&tc_ctr11_01=" + occ11;
5326 var result;
5327
5328 if ("withCredentials" in http) {
5329 http.open('POST', url + "?" + params, false); //false : 同步請求 ; true 非同步請求
5330 //http.open('POST', url + "?" + params, true); //false : 同步請求 ; true 非同步請求
5331 }
5332 else if (typeof XDomainRequest != "undefined") {
5333 http = new XDomainRequest();
5334 http.open('POST', url + "?" + params, false);
5335 //http.open('POST', url + "?" + params, true);
5336 }
5337 //http.timeout = 2000;
5338
5339 http.onreadystatechange = function() {//Call a function when the state changes.
5340 if(http.readyState == 4 && http.status == 200) {
5341 //alert("http.responseText = " + http.responseText);
5342 result = http.responseText;
5343 if (result == 1) {
5344 document.getElementById("ta_occ09").value = "";
5345 alert("此為業務區舊客戶,不可新增在不同分公司的業務區域");
5346 }
5347 if (result == 2) {
5348 document.getElementById("ta_occ09").value = "";
5349 alert("此為其他分公司客服區舊客戶,不可新增在業務區,請新增在客服區");
5350 }
5351 }
5352 }
5353 http.send(null);
5354 }
<?php
header("Access-Control-Allow-Origin: *");
$v = $_REQUEST;
foreach($v as $i=>$v)
{
#$temp = $temp."$i=$v,";
if ($i == "occ03") {$occ03 = $v;}
if ($i == "occ11") {$occ11 = $v;}
}
$dbconn = oci_connect("xxx","yyy",
"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xxx.xxx)(PORT=1521))(CONNECT_DATA=(SID=xxx)))",
"AL32UTF8");
$sql = "
select count(*)
from occ_file
where occ03 = substr(:occ03,1,2)
and occ11 = :occ11
order by 1
";
$stid = oci_parse($dbconn, $sql);
oci_bind_by_name($stid,":occ03",$occ03);
oci_bind_by_name($stid,":occ11",$occ11);
//echo "2";
oci_execute($stid);
while ($row = oci_fetch_row($stid)) {
echo "$row[0]";
#echo "var occ11_cnt=$row[0];";
}
oci_close($dbconn);
?>
2. 由於是asynch,所以javascript在判斷時要在 onreadystatechange 就改變原本網頁element的值,另外sleep兩秒(因為asynch,太短時間怕抓到為修改以前的值)
3. 也許使用 XmlHttpRequest 的 sync option (底下true的地方) 也可以,但我未測試
function ... (
chkOCC11();
sleep(2000);
var str = document.getElementById("occ11").value;
if (str.match("請重新輸入")) {
//alert("統一編號重複,請確認")
return false;
};
return true;
)
function chkOCC11() {
var occ03 = document.getElementById("occ03").value;
var occ11 = document.getElementById("occ11").value;
var http ;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
http = new XMLHttpRequest();
} else {// code for IE6, IE5
http = new ActiveXObject("Microsoft.XMLHTTP");
}
var url = "http://10.1.100.201/eip/action/SA001/chkOCC11.php";
var params = "occ03=" + occ03.substr(0,2) + "&occ11=" + occ11;
var occ11_cnt;
if ("withCredentials" in http) {
http.open('POST', url + "?" + params, true);
}
else if (typeof XDomainRequest != "undefined") {
http = new XDomainRequest();
http.open('POST', url + "?" + params, true);
}
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
occ11_cnt = http.responseText;
if (occ11_cnt > 0) {
document.getElementById("occ11").value = "請重新輸入";
alert("統一編號重複,請重新輸入");
}
}
}
http.send(null);
}
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
4.2017/05/02 經過測試,使用同步,不使用非同步的方式就可以檢查值的正確性
5313 function chkTC_CTR11() {
5314 var ta_occ09 = document.getElementById("ta_occ09").value;
5315 var occ11 = document.getElementById("occ11").value;
5316
5317 var http ;
5318 if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
5319 http = new XMLHttpRequest();
5320 } else {// code for IE6, IE5
5321 http = new ActiveXObject("Microsoft.XMLHTTP");
5322 }
5323
5324 var url = "http://10.1.100.201/eip/action/SA001/chkTC_CTR11.php";
5325 var params = "tc_ctr11_03=" + ta_occ09.substr(0,2) + "&tc_ctr11_01=" + occ11;
5326 var result;
5327
5328 if ("withCredentials" in http) {
5329 http.open('POST', url + "?" + params, false); //false : 同步請求 ; true 非同步請求
5330 //http.open('POST', url + "?" + params, true); //false : 同步請求 ; true 非同步請求
5331 }
5332 else if (typeof XDomainRequest != "undefined") {
5333 http = new XDomainRequest();
5334 http.open('POST', url + "?" + params, false);
5335 //http.open('POST', url + "?" + params, true);
5336 }
5337 //http.timeout = 2000;
5338
5339 http.onreadystatechange = function() {//Call a function when the state changes.
5340 if(http.readyState == 4 && http.status == 200) {
5341 //alert("http.responseText = " + http.responseText);
5342 result = http.responseText;
5343 if (result == 1) {
5344 document.getElementById("ta_occ09").value = "";
5345 alert("此為業務區舊客戶,不可新增在不同分公司的業務區域");
5346 }
5347 if (result == 2) {
5348 document.getElementById("ta_occ09").value = "";
5349 alert("此為其他分公司客服區舊客戶,不可新增在業務區,請新增在客服區");
5350 }
5351 }
5352 }
5353 http.send(null);
5354 }
2016年9月19日 星期一
rcp 出現 permission denied
不要著急,在linux主機上,tail -f /var/log/messages,我們會發現如下信息
Jan 14 21:43:10 Sim32_01 pam_rhosts_auth[28313]: denied to userofwinsows@windowsserver as useroflinux: access not allowed
Jan 14 21:43:10 Sim32_01 in.rshd[28313]: rsh denied to userofwindows@192.168.100.151 as useroflinux: Permission denied.
哦,原來是pam.d的事兒啊...vi /etc/pam.d/rsh,裡面內容如下:
#%PAM-1.0
# For root login to succeed here with pam_securetty, "rsh" must be
# listed in /etc/securetty.
auth required /lib/security/pam_nologin.so
auth required /lib/security/pam_securetty.so
auth required /lib/security/pam_env.so
auth required /lib/security/pam_rhosts_auth.so
account required /lib/security/pam_stack.so service=system-auth
session required /lib/security/pam_stack.so service=system-auth
把auth required /lib/security/pam_rhosts_auth.so
這一行註釋掉,再試,OK,搞定!
Jan 14 21:43:10 Sim32_01 pam_rhosts_auth[28313]: denied to userofwinsows@windowsserver as useroflinux: access not allowed
Jan 14 21:43:10 Sim32_01 in.rshd[28313]: rsh denied to userofwindows@192.168.100.151 as useroflinux: Permission denied.
哦,原來是pam.d的事兒啊...vi /etc/pam.d/rsh,裡面內容如下:
#%PAM-1.0
# For root login to succeed here with pam_securetty, "rsh" must be
# listed in /etc/securetty.
auth required /lib/security/pam_nologin.so
auth required /lib/security/pam_securetty.so
auth required /lib/security/pam_env.so
auth required /lib/security/pam_rhosts_auth.so
account required /lib/security/pam_stack.so service=system-auth
session required /lib/security/pam_stack.so service=system-auth
把auth required /lib/security/pam_rhosts_auth.so
這一行註釋掉,再試,OK,搞定!
2016年6月14日 星期二
走路這樣做!醫生創「3天見效」減肥法
http://photo.chinatimes.com/20160614003616-260804
無痛減肥法真的誕生了嗎?!常常聽到,身邊有80%的人說要減肥,但是真正能做到「克制食欲、堅持運動」的人,卻只有20%。如果在減肥過程中,不需忍耐和努力,絕對是許多人的夢想,尤其是現代人,壓力大飲食口味重,大多數都是外食族,一不小心,就變成大「腹」婆(翁)。
在日本,一位醫生叫川村昌嗣,他出了一本十分暢銷的書,書名為《走路瘦肚法》,書裡面寫到,只要用正確的方式走路,就能夠輕鬆「享瘦」。而且方式非
常簡單:只要在走路時「縮肚」、「挺肚」,搭配「一吸一吐」的呼吸節奏就可以了。此動作的要點為:右腳往前踏出時,默數「一」,左腳往前踏出時,默數
「二」。
一邊默數一邊走路,數「一」時縮腹,數「二」時把肚子鼓起來,不要大幅度擺動手臂,也不要駝背,因為這樣會在肚子鼓起和內縮時,出現反作用力,導致
肌肉的熱量消耗減少,還會給腰部帶來不必要的負擔。川村昌嗣在親身實踐後,3個月內減重10公斤,腰圍也減少了17公分。而且完全沒有復胖,甚至有讀者反
應,這個方法還能緩解便秘。
走路這樣做!醫生創「3天見效」減肥法
文章來源:珠江時報
2016年5月3日 星期二
2016年4月20日 星期三
2016年3月27日 星期日
在執行 rsh 的時候要怎樣才能不必等遠方指令執行結束就回到 shell?
http://hkbsd.net/www/unixfaq/node27.html
以下這些憑直覺想到的答案都達不到這個效果:
如果您在遠端使用csh:
附註: 任何檔案都可以用於遠端機器的輸出入轉向,而不僅限於 /dev/null。
在許多狀況下,這個複雜的命令當中有很多部份都是非必要的。
如何將遠端的ps結果回傳後顯示process id
rsh 10.1.100.113 -n 'ps -ef | grep fglrun ' < /dev/null | awk ' {print $2} '
以下這些憑直覺想到的答案都達不到這個效果:
rsh machine command &或
rsh machine 'command &'例如, 執行 rsh machine 'sleep 60 &' 這個命令時,我們可以觀察到:rsh 並 不會立刻結束,而是等到遠方的 sleep 命令完成以後才結束,即使我們在遠 方使用背景方式執行此命令。所以要怎樣才能讓 rsh 在 sleep 命令啟動後立 刻結束呢? 答案如下-
如果您在遠端使用csh:
rsh machine -n 'command >&/dev/null </dev/null &'如果您在遠端使用 sh:
rsh machine -n 'command >/dev/null 2>&1 </dev/null &'為什麼呢?因為 "-n" 會把 rsh 的 stdin 接到 /dev/null,因此您可以在本地 機器以背景方式執行整個 rsh 命令。不管是使用 -n 選項或者在指令結尾使 用 "/dev/null",其效果都是一樣的。此外,在遠端機器使用的輸出入轉向(寫 在單引號內的部份)會讓 rsh 認定此次連線可逕行結束(因為已無其他輸 入資料)。
附註: 任何檔案都可以用於遠端機器的輸出入轉向,而不僅限於 /dev/null。
在許多狀況下,這個複雜的命令當中有很多部份都是非必要的。
如何將遠端的ps結果回傳後顯示process id
rsh 10.1.100.113 -n 'ps -ef | grep fglrun ' < /dev/null | awk ' {print $2} '
2016年3月24日 星期四
ssh 信任关系建立后仍需要输入密码
http://blog.itpub.net/29500582/viewspace-1251139/
ssh 建立信任后,依旧需要密码
原因分析,以及处理步骤:
1 查看 /var/log/secure,分析问题在何处;检查/var/log/messages
這次問題(2016/03/25):$HOME 權限要drwxr-x---
2 查看 /root/.ssh/authorized_keys文件的属性,以及.ssh文件属性 是不是权限过大。.ssh目录的权限必须是700,同时本机的私钥的权限必须设置成600:
3 修改/etc/ssh/sshd_config文件, 把密码认证关闭, 将认证改为 passwordAuthentication no 重启下sshd。 service sshd restart;
4 执行setenforce 0,暂时关闭selinux
1 /usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态
1 临时关闭(不用重启机器):
附录:
ssh信任关系建立方法
1 在服务器上,进入当前用户根目录下的隐藏目录 .ssh 命令:
cd ~/.ssh
通过 ls –a 命令观察到
2 生成S服务器的私钥和公钥
ssh-keygen -t rsa
ssh-keygen生成密钥用于信任关系生成
-此时会显示Generating public/private key pair. 并提示生成的公钥私钥文件的存放路径和文件名,默认是放在 /home/username/.ssh/id_rsa 这样的文件里的,通常不用改,回车
然后Enter passphrase(empty for no passphrase): 通常直接回车
Enter same passphrase again: 也直接回车
然后会显式密钥fingerprint生成好的提示,并给出一个RSA加密协议的方框图形。此时在.ssh目录下ls,可以看到生成好的私钥文件id_rsa和公钥文件id_rsa.pub
以下是各种补充说明:
注1:如果此时提示 id_rsaalready exists,Overwrite(y/n) 则说明之前已经有人建好了密钥,此时选择n 忽略本次操作就行,可以直接用之前生成好的文件;当然选y覆盖一下也无妨
注2:公钥用于加密,它是向所有人公开的(pub是公开的单词public的缩写);私钥用于解密,只有密文的接收者持有
3 在Server服务器上加载私钥文件
仍然在.ssh目录下,执行命令:
ssh-add id_rsa
系统如果提示:Identity added: id_rsa (id_rsa) 就表明加载成功了
下面有几个异常情况处理:
–如果系统提示:could not open a connection to your authentication agent
则需要执行一下命令:
ssh-agent bash
然后再执行上述的ssh-add id_rsa命令
–如果系统提示id_rsa: No such file or directory
-这是系统无法找到私钥文件id_rsa,需要看看当前路径是不是不在.ssh目录,或者私钥文件改了名字,例如如果建立的时候改成 aa_rsa,则这边命令中也需要相应改一下
-如果系统提示 command not found,那肯定是你命令敲错字符了
-提示Agent admitted failure to sign using the key,私钥没有加载成功,重试ssh-add
-注意id_rsa/id_rsa.pub文件不要删除,存放在.ssh目录下
4 把公钥拷贝至Client服务器上
很简单,例如 scp id_rsa.pub user@10.11.xx.xx:~
5 ssh登录到Client服务器上,然后在Client服务器上,把公钥的内容追加到authorized_keys文件末尾(这个文件也在隐藏文件夹.ssh下,没有的话可以建立,没有关系)
cat id_rsa.pub >> ~/.ssh/authorized_keys
以下是各种补充说明,遇到问题时可以参考:
注1:这里不推荐用文件覆盖的方式,有些教程直接scp id_rsa.pub 到Client服务器的authorized_keys文件,会导致之前建的其他信任关系的数据被破坏,追加到末尾是更稳妥的方式;
注2: cat 完以后,Client服务器上刚才拷贝过来的id_rsa.pub文件就不需要了,可以删除或移动到其它地方)
注 3:ssh-keygen 命令通过-b参数可以指定生成的密钥文件的长度,如果不指定则默认为1024,如果ssh-keygen –b 4096(最长4096),则加密程度提高,但是生成和验证时间会增加。对一般的应用来说,默认长度已经足够胜任了。如果是rsa加密方式,那么最短长度 为768 byte
注4:authorized_keys文件的权限问题。如果按上述步骤建立关系后,仍然要验证密码,并且没有其他报错,那么需要检查一下authorized_keys文件的权限,需要作下修改: chmod g-w authorized_keys
OK,现在试试在Server端拷贝一个文件到Client服务器,应该无需交互直接就传过去了。
但是此时从Client传数据到Server服务器,仍然是需要密码验证的。如果需要两台服务器间能直接互传数据,则反过来按上述步骤操作一下就可以了
异常情况处理:
–提示 port 22: Connection refused
可能的原因:没有正确安装最新的openssh-server,安装方法如下
sudo apt-get install openssh-server
不支持apt安装的,可以手工下载:
wget http://ftp.ssh.com/pub/ssh/ssh-3.2.9.1.tar.gz
–关于目录和文件的权限设置
.ssh目录的权限必须是700,同时本机的私钥的权限必须设置成600:
chmod 600 id_rsa
否则ssh服务器会拒绝登录
关于ssh_config_sshd_config配置文件:
/etc/ssh/ssh_config:
Host *
选项“Host”只对能够匹配后面字串的计算机有效。“*”表示所有的计算机。
ForwardAgent no
“ForwardAgent”设置连接是否经过验证代理(如果存在)转发给远程计算机。
ForwardX11 no
“ForwardX11”设置X11连接是否被自动重定向到安全的通道和显示集(DISPLAY set)。
RhostsAuthentication no
“RhostsAuthentication”设置是否使用基于rhosts的安全验证。
RhostsRSAAuthentication no
“RhostsRSAAuthentication”设置是否使用用RSA算法的基于rhosts的安全验证。
RSAAuthentication yes
“RSAAuthentication”设置是否使用RSA算法进行安全验证。
PasswordAuthentication yes
“PasswordAuthentication”设置是否使用口令验证。
FallBackToRsh no
“FallBackToRsh”设置如果用ssh连接出现错误是否自动使用rsh。
UseRsh no
“UseRsh”设置是否在这台计算机上使用“rlogin/rsh”。
BatchMode no
“BatchMode”如果设为“yes”,passphrase/password(交互式输入口令)的提示将被禁止。当不能交互式输入口令的时候,这个选项对脚本文件和批处理任务十分有用。
CheckHostIP yes
“CheckHostIP”设置ssh是否查看连接到服务器的主机的IP地址以防止DNS欺骗。建议设置为“yes”。
StrictHostKeyChecking no
“StrictHostKeyChecking”如果设置成“yes”,ssh就不会自动把计算机的密匙加入“$HOME/.ssh/known_hosts”文件,并且一旦计算机的密匙发生了变化,就拒绝连接。
IdentityFile ~/.ssh/identity
“IdentityFile”设置从哪个文件读取用户的RSA安全验证标识。
Port 22
“Port”设置连接到远程主机的端口。
Cipher blowfish
“Cipher”设置加密用的密码。
EscapeChar ~
“EscapeChar”设置escape字符。
/etc/ssh/sshd_config:
Port 22
“Port”设置sshd监听的端口号。
ListenAddress 192.168.1.1
“ListenAddress”设置sshd服务器绑定的IP地址。
HostKey /etc/ssh/ssh_host_key
“HostKey”设置包含计算机私人密匙的文件。
ServerKeyBits 1024
“ServerKeyBits”定义服务器密匙的位数。
LoginGraceTime 600
“LoginGraceTime”设置如果用户不能成功登录,在切断连接之前服务器需要等待的时间(以秒为单位)。
KeyRegenerationInterval 3600
“KeyRegenerationInterval”设置在多少秒之后自动重新生成服务器的密匙(如果使用密匙)。重新生成密匙是为了防止用盗用的密匙解密被截获的信息。
PermitRootLogin no
“PermitRootLogin”设置root能不能用ssh登录。这个选项一定不要设成“yes”。
IgnoreRhosts yes
“IgnoreRhosts”设置验证的时候是否使用“rhosts”和“shosts”文件。
IgnoreUserKnownHosts yes
“IgnoreUserKnownHosts”设置ssh daemon是否在进行RhostsRSAAuthentication安全验证的时候忽略用户的“$HOME/.ssh/known_hosts”
StrictModes yes
“StrictModes”设置ssh在接收登录请求之前是否检查用户家目录和rhosts文件的权限和所有权。这通常是必要的,因为新手经常会把自己的目录和文件设成任何人都有写权限。
X11Forwarding no
“X11Forwarding”设置是否允许X11转发。
PrintMotd yes
“PrintMotd”设置sshd是否在用户登录的时候显示“/etc/motd”中的信息。
SyslogFacility AUTH
“SyslogFacility”设置在记录来自sshd的消息的时候,是否给出“facility code”。
LogLevel INFO
“LogLevel”设置记录sshd日志消息的层次。INFO是一个好的选择。查看sshd的man帮助页,已获取更多的信息。
RhostsAuthentication no
“RhostsAuthentication”设置只用rhosts或“/etc/hosts.equiv”进行安全验证是否已经足够了。
RhostsRSAAuthentication no
“RhostsRSA”设置是否允许用rhosts或“/etc/hosts.equiv”加上RSA进行安全验证。
RSAAuthentication yes
“RSAAuthentication”设置是否允许只有RSA安全验证。
PasswordAuthentication yes
“PasswordAuthentication”设置是否允许口令验证。
PermitEmptyPasswords no
“PermitEmptyPasswords”设置是否允许用口令为空的帐号登录。
AllowUsers admin
“AllowUsers”的后面可以跟着任意的数量的用户名的匹配串(patterns)或user@host这样的匹配串,这些字符串用空格隔开。主机名可以是DNS名或IP地址。
原因分析,以及处理步骤:
1 查看 /var/log/secure,分析问题在何处;检查/var/log/messages
這次問題(2016/03/25):$HOME 權限要drwxr-x---
2 查看 /root/.ssh/authorized_keys文件的属性,以及.ssh文件属性 是不是权限过大。.ssh目录的权限必须是700,同时本机的私钥的权限必须设置成600:
3 修改/etc/ssh/sshd_config文件, 把密码认证关闭, 将认证改为 passwordAuthentication no 重启下sshd。 service sshd restart;
4 执行setenforce 0,暂时关闭selinux
查看selinux状态:
1 /usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态
SELinux status: enabled
2 getenforce ##可以用这个命令检查
关闭selinux:
1 临时关闭(不用重启机器):
setenforce 0 ##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
2 配置文件修改需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启机器即可
附录:
ssh信任关系建立方法
1 在服务器上,进入当前用户根目录下的隐藏目录 .ssh 命令:
cd ~/.ssh
通过 ls –a 命令观察到
2 生成S服务器的私钥和公钥
ssh-keygen -t rsa
ssh-keygen生成密钥用于信任关系生成
-此时会显示Generating public/private key pair. 并提示生成的公钥私钥文件的存放路径和文件名,默认是放在 /home/username/.ssh/id_rsa 这样的文件里的,通常不用改,回车
然后Enter passphrase(empty for no passphrase): 通常直接回车
Enter same passphrase again: 也直接回车
然后会显式密钥fingerprint生成好的提示,并给出一个RSA加密协议的方框图形。此时在.ssh目录下ls,可以看到生成好的私钥文件id_rsa和公钥文件id_rsa.pub
以下是各种补充说明:
注1:如果此时提示 id_rsaalready exists,Overwrite(y/n) 则说明之前已经有人建好了密钥,此时选择n 忽略本次操作就行,可以直接用之前生成好的文件;当然选y覆盖一下也无妨
注2:公钥用于加密,它是向所有人公开的(pub是公开的单词public的缩写);私钥用于解密,只有密文的接收者持有
3 在Server服务器上加载私钥文件
仍然在.ssh目录下,执行命令:
ssh-add id_rsa
系统如果提示:Identity added: id_rsa (id_rsa) 就表明加载成功了
下面有几个异常情况处理:
–如果系统提示:could not open a connection to your authentication agent
则需要执行一下命令:
ssh-agent bash
然后再执行上述的ssh-add id_rsa命令
–如果系统提示id_rsa: No such file or directory
-这是系统无法找到私钥文件id_rsa,需要看看当前路径是不是不在.ssh目录,或者私钥文件改了名字,例如如果建立的时候改成 aa_rsa,则这边命令中也需要相应改一下
-如果系统提示 command not found,那肯定是你命令敲错字符了
-提示Agent admitted failure to sign using the key,私钥没有加载成功,重试ssh-add
-注意id_rsa/id_rsa.pub文件不要删除,存放在.ssh目录下
4 把公钥拷贝至Client服务器上
很简单,例如 scp id_rsa.pub user@10.11.xx.xx:~
5 ssh登录到Client服务器上,然后在Client服务器上,把公钥的内容追加到authorized_keys文件末尾(这个文件也在隐藏文件夹.ssh下,没有的话可以建立,没有关系)
cat id_rsa.pub >> ~/.ssh/authorized_keys
以下是各种补充说明,遇到问题时可以参考:
注1:这里不推荐用文件覆盖的方式,有些教程直接scp id_rsa.pub 到Client服务器的authorized_keys文件,会导致之前建的其他信任关系的数据被破坏,追加到末尾是更稳妥的方式;
注2: cat 完以后,Client服务器上刚才拷贝过来的id_rsa.pub文件就不需要了,可以删除或移动到其它地方)
注 3:ssh-keygen 命令通过-b参数可以指定生成的密钥文件的长度,如果不指定则默认为1024,如果ssh-keygen –b 4096(最长4096),则加密程度提高,但是生成和验证时间会增加。对一般的应用来说,默认长度已经足够胜任了。如果是rsa加密方式,那么最短长度 为768 byte
注4:authorized_keys文件的权限问题。如果按上述步骤建立关系后,仍然要验证密码,并且没有其他报错,那么需要检查一下authorized_keys文件的权限,需要作下修改: chmod g-w authorized_keys
OK,现在试试在Server端拷贝一个文件到Client服务器,应该无需交互直接就传过去了。
但是此时从Client传数据到Server服务器,仍然是需要密码验证的。如果需要两台服务器间能直接互传数据,则反过来按上述步骤操作一下就可以了
异常情况处理:
–提示 port 22: Connection refused
可能的原因:没有正确安装最新的openssh-server,安装方法如下
sudo apt-get install openssh-server
不支持apt安装的,可以手工下载:
wget http://ftp.ssh.com/pub/ssh/ssh-3.2.9.1.tar.gz
–关于目录和文件的权限设置
.ssh目录的权限必须是700,同时本机的私钥的权限必须设置成600:
chmod 600 id_rsa
否则ssh服务器会拒绝登录
关于ssh_config_sshd_config配置文件:
/etc/ssh/ssh_config:
Host *
选项“Host”只对能够匹配后面字串的计算机有效。“*”表示所有的计算机。
ForwardAgent no
“ForwardAgent”设置连接是否经过验证代理(如果存在)转发给远程计算机。
ForwardX11 no
“ForwardX11”设置X11连接是否被自动重定向到安全的通道和显示集(DISPLAY set)。
RhostsAuthentication no
“RhostsAuthentication”设置是否使用基于rhosts的安全验证。
RhostsRSAAuthentication no
“RhostsRSAAuthentication”设置是否使用用RSA算法的基于rhosts的安全验证。
RSAAuthentication yes
“RSAAuthentication”设置是否使用RSA算法进行安全验证。
PasswordAuthentication yes
“PasswordAuthentication”设置是否使用口令验证。
FallBackToRsh no
“FallBackToRsh”设置如果用ssh连接出现错误是否自动使用rsh。
UseRsh no
“UseRsh”设置是否在这台计算机上使用“rlogin/rsh”。
BatchMode no
“BatchMode”如果设为“yes”,passphrase/password(交互式输入口令)的提示将被禁止。当不能交互式输入口令的时候,这个选项对脚本文件和批处理任务十分有用。
CheckHostIP yes
“CheckHostIP”设置ssh是否查看连接到服务器的主机的IP地址以防止DNS欺骗。建议设置为“yes”。
StrictHostKeyChecking no
“StrictHostKeyChecking”如果设置成“yes”,ssh就不会自动把计算机的密匙加入“$HOME/.ssh/known_hosts”文件,并且一旦计算机的密匙发生了变化,就拒绝连接。
IdentityFile ~/.ssh/identity
“IdentityFile”设置从哪个文件读取用户的RSA安全验证标识。
Port 22
“Port”设置连接到远程主机的端口。
Cipher blowfish
“Cipher”设置加密用的密码。
EscapeChar ~
“EscapeChar”设置escape字符。
/etc/ssh/sshd_config:
Port 22
“Port”设置sshd监听的端口号。
ListenAddress 192.168.1.1
“ListenAddress”设置sshd服务器绑定的IP地址。
HostKey /etc/ssh/ssh_host_key
“HostKey”设置包含计算机私人密匙的文件。
ServerKeyBits 1024
“ServerKeyBits”定义服务器密匙的位数。
LoginGraceTime 600
“LoginGraceTime”设置如果用户不能成功登录,在切断连接之前服务器需要等待的时间(以秒为单位)。
KeyRegenerationInterval 3600
“KeyRegenerationInterval”设置在多少秒之后自动重新生成服务器的密匙(如果使用密匙)。重新生成密匙是为了防止用盗用的密匙解密被截获的信息。
PermitRootLogin no
“PermitRootLogin”设置root能不能用ssh登录。这个选项一定不要设成“yes”。
IgnoreRhosts yes
“IgnoreRhosts”设置验证的时候是否使用“rhosts”和“shosts”文件。
IgnoreUserKnownHosts yes
“IgnoreUserKnownHosts”设置ssh daemon是否在进行RhostsRSAAuthentication安全验证的时候忽略用户的“$HOME/.ssh/known_hosts”
StrictModes yes
“StrictModes”设置ssh在接收登录请求之前是否检查用户家目录和rhosts文件的权限和所有权。这通常是必要的,因为新手经常会把自己的目录和文件设成任何人都有写权限。
X11Forwarding no
“X11Forwarding”设置是否允许X11转发。
PrintMotd yes
“PrintMotd”设置sshd是否在用户登录的时候显示“/etc/motd”中的信息。
SyslogFacility AUTH
“SyslogFacility”设置在记录来自sshd的消息的时候,是否给出“facility code”。
LogLevel INFO
“LogLevel”设置记录sshd日志消息的层次。INFO是一个好的选择。查看sshd的man帮助页,已获取更多的信息。
RhostsAuthentication no
“RhostsAuthentication”设置只用rhosts或“/etc/hosts.equiv”进行安全验证是否已经足够了。
RhostsRSAAuthentication no
“RhostsRSA”设置是否允许用rhosts或“/etc/hosts.equiv”加上RSA进行安全验证。
RSAAuthentication yes
“RSAAuthentication”设置是否允许只有RSA安全验证。
PasswordAuthentication yes
“PasswordAuthentication”设置是否允许口令验证。
PermitEmptyPasswords no
“PermitEmptyPasswords”设置是否允许用口令为空的帐号登录。
AllowUsers admin
“AllowUsers”的后面可以跟着任意的数量的用户名的匹配串(patterns)或user@host这样的匹配串,这些字符串用空格隔开。主机名可以是DNS名或IP地址。
2016年3月23日 星期三
在 RHEL 安裝 YUM Package Manager 的 安裝步驟
在 RHEL 安裝 YUM Package Manager 的 安裝步驟
- wget http://yum.baseurl.org/download/2.0/yum-2.0.8-1.src.rpm
- rpmbuild --rebuild yum-2.0.8-1.src.rpm
- cd /usr/src/redhat/RPMS/noarch/
- rpm -ivh yum-2.0.8-1.noarch.rpm
- vim /etc/yum.conf # 將 baseurl 換成下述 (換成台灣 Server)
baseurl= http://vault.centos.org/4.9/os/x86_64
baseurl= http://vault.centos.org/4.9/updates/x86_64 - yum update # 這樣子就可以用囉~
2016年3月22日 星期二
Rsync + SSH -- 讓 Server 自動異地備援也加密
http://dz.adj.idv.tw/thread-48-1-4.html
一.前言
自從911事件之後...異地備援這個名稱就常聽人提起...不過就是滿少看到大家在討論...剛好這次因為有需要...不得不研究這個東西...順便看看大家都是怎樣實作異地備援的...底下是個人的一點點心得...
這次主要分成三個部份...單向 Trusted SSH Authorized...Rsync...Crontab....姑且不論傳輸速度為何...以及無時差的異地備援...相信這樣的Solutions應該可以滿足一般人的需求吧
二.準備
測試系統: Red Hat Linux 7.3 to Red Hat 7.3 ...
Local 端需要啟動 Rsync...套件 openssh-3.4p1-1
** 假設: A (10.0.0.1) 要對 B (192.168.0.1) 做異地備援
PS:角色定位要明確...當然您要巔倒的來做也行...
參考網站 : http://www.fanqiang.com/a6/b7/20010908/1305001258_b.html
三.開始實作
1.完成單向Trusted SSH Authorized﹕
我
要 A (10.0.0.1) 要對 B (192.168.0.1) 做異地備援 ...所以我針對 A 讓它使用SSH連到 B
時...不需要輸入密碼...User 是 Root...SSH
Version2的版本..首先要先在A(10.0.0.1)產生public/private dsa key pair..
[root@mondeo home]# cd /root/.ssh/
|
這時會在系統下看到兩個檔案...id_dsa與id_dsa.pub 現在要把id_dsa.pub丟到192.168.0.1 並且更名為 authorized_keys2
[root@mondeo .ssh]# scp id_dsa.pub 192.168.0.1:/root/.ssh/authorized_keys2root@192.168.0.1's password:
|
現在您可以執行ssh 192.168.0.1 看看能否登入而不需要輸入密碼...
2.使用rsync 做Remote sync﹕
rsync特性簡介 :
rsync是unix-like系統下的數據鏡像備份工具,從命名上就可以看出來了remote sync。它的特性如下:
1、可以鏡像保存整個目錄樹和文件系統。
2、可以很容易做到保持原來文件的權限、時間等等。
3、無須特殊權限即可安裝。
4、優化的流程,文件傳輸效率高。
5、可以使用rcp、ssh等方式來傳輸文件,當然也可以通過直接的socket連接。
6、支持匿名傳輸。
首先要先對B(192.168.0.1)把Rsync的Server on起來...
[root@linux /]#chkconfig --list rsync
|
現在我先在A(10.0.0.1)上建一個 Backup directory...然後對B(192.168.0.1)的mysql跟html的目錄做異地備援...偶寫一個簡單的script如下:
[root@mondeo /]# mkdir backup
|
參數意義如下﹕
-a, --archive
It is a quick way of saying you want recursion and want to preserve almost everything.
-v, --verbose
This option increases the amount of information you are given during the transfer.
-l, --links
When symlinks are encountered, recreate the symlink on the destination.
-R, --relative
Use relative paths. 保留相對路徑...才不會讓子目錄跟 parent 擠在同一層...
--delete
是指如果Server端刪除了一文件,那客戶端也相應把這一文件刪除,保持真正的一致。
-e ssh
建立起加密的連接。
參數的使用因人而異...您可以man rsync來使用更多的參數...
測試看看:
[root@mondeo backup]# ./syncreceiving file list ... done
|
看到沒詢問密碼....以及有把檔案copy過來就沒問題囉....當然你可以把遠端的資料做個變動...看是否真有同步啦....
3.使用crontab 來做自動排程﹕
現在設好之後...我希望每天的0點0分...夜深人靜的時後再來幫我做sync....當然您想要多久做 sync 看個人需求囉...
[root@mondeo backup]# crontab -e0 0 * * * /backup/sync |
如此一來..算是大功告成了...原則上您已具備自動加密異地備援囉....趕緊找兩台機器來試試吧...
以上只是個人測試結果...如有錯誤...煩請指教!!!
2016年3月9日 星期三
MySQL : Convert Integer to DateTime and DateTime to Integer
SELECT UNIX_TIMESTAMP('2016-03-14 18:00:00')
SELECT FROM_UNIXTIME(1457949600,'%Y %m %d %H %i %s')
2016年2月16日 星期二
How to do Redirect in PHP with POST and not GET
https://www.sitepoint.com/community/t/how-to-do-redirect-in-php-with-post-and-not-get/4968
<form name='fr' action='redirect.php' method='POST'>
<input type='hidden' name='var1' value='val1'>
<input type='hidden' name='var2' value='val2'>
</form>
<script type='text/javascript'>
document.fr.submit();
</script>
<form name='fr' action='redirect.php' method='POST'>
<input type='hidden' name='var1' value='val1'>
<input type='hidden' name='var2' value='val2'>
</form>
<script type='text/javascript'>
document.fr.submit();
</script>
2016年2月15日 星期一
使用PHP,Google MAPS API 呈現客戶地理資訊 example
google_map.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
<script src="http://maps.googleapis.com/maps/api/js"> </script>
<script>
//var coordinates = [[22.5805149,120.4227832,'大連化學','image3'],[22.5789818,120.3178123,'建榮冷凍食品','image2']];
var offices = {"5310" : [25.055308,121.593377, "台北分公司"],
"5320" : [24.9545639,121.2026673, "桃園分公司"],
"5330" : [24.673791, 120.887685, "竹苗分公司"],
"5340" : [24.181775, 120.617205, "台中分公司"],
"5350" : [23.041664, 120.234495, "台南分公司"],
"5360" : [22.595090, 120.359171, "高雄分公司"]
};
function initialize(locations)
{
var coordinates = locations;
var oea15 = document.getElementById("oea15");
//alert(oea15.value);
//alert(offices[oea15.value][0] + "," + offices[oea15.value][1]);
var myCenter=new google.maps.LatLng(offices[oea15.value][0],offices[oea15.value][1]);
//var myCenter=new google.maps.LatLng(22.595090, 120.359171);
var mapProp = {
center:myCenter,
zoom:13,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
map.data.loadGeoJson('./twtown2010.4.json');
//map.data.loadGeoJson('./twcounty2010.6.json');
var image1 = {url : "http://labs.google.com/ridefinder/images/mm_20_red.png", size : new google.maps.Size(32, 32)};
var image2 = {url : "http://labs.google.com/ridefinder/images/mm_20_yellow.png", size : new google.maps.Size(32, 32)};
var image3 = {url : "http://labs.google.com/ridefinder/images/mm_20_green.png", size : new google.maps.Size(32, 32)};
var marker=new google.maps.Marker({
position:myCenter,
title: offices[oea15.value][2],
});
marker.setMap(map);
var idx;
for (idx=0; idx<coordinates.length; idx++) {
//alert(coordinates[idx]["LAT"] + "," + coordinates[idx]["LNG"] + "," + coordinates[idx]["OCC18"] + "," + coordinates[idx]["IMG"]);
var str = "var marker=new google.maps.Marker({ position:new google.maps.LatLng(" + coordinates[idx]["LAT"] + "," + coordinates[idx]["LNG"] + "), title: '" + coordinates[idx]["OCC18"] + "', icon:" + coordinates[idx]["IMG"] + " }); marker.setMap(map);"
eval(str);
}
//var marker=new google.maps.Marker({
// position:new google.maps.LatLng(22.5805149,120.4227832),
// title: '大連化學工業股份有限公司',
// icon: image3
//});
//marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<script>
$(function() {
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$("#from").datepicker("option", "dateFormat", "yy/mm/dd");
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
$("#to").datepicker("option", "dateFormat", "yy/mm/dd");
});
</script>
<script>
var Submit=function(){
var URLs="http://10.1.100.201/eip/report/google_map/getDNLatLng.php";
$.ajax({
url: URLs,
data: $('#DNLatLng').serialize(),
type:"POST",
dataType:'json',
success: function(msg){
//alert(msg);
initialize(msg)
},
error:function(xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
}
});
}
</script>
</head>
<body>
<form id="DNLatLng">
<label for="分公司">分公司</label>
<select name="oea15" id="oea15">
<option value="NA" selected="selected">===請選擇===</option>
<option value="5310">台北分公司</option>
<option value="5320">桃園分公司</option>
<option value="5330">竹苗分公司</option>
<option value="5340">台中分公司</option>
<option value="5350">台南分公司</option>
<option value="5360">高雄分公司</option>
</select>
<label for="from">送貨日期 From</label>
<input type="text" id="from" name="from">
<label for="to"> to</label>
<input type="text" id="to" name="to">
<input type=button id=btn1 value=送出 onClick="Submit()"> </input>
</form>
<div id="googleMap" style="width:800;height:900px;"></div>
</body>
</html>
getDNLatLng.php
<?php
$oea15 = $_REQUEST['oea15'];
$oea02b = $_REQUEST['from'];
$oea02e = $_REQUEST['to'];
$dbstr = "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST=tiptopdb)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = topprod)))";
$dbconn = oci_connect("echo01","echo01","$dbstr","utf8");
$sql = "
select lat,lng,occ18,case when max(交運方式) != min(交運方式) then 'image2' when max(交運方式) = '外車' then 'image1' when max(交運方式) = '其它' then 'image3' end img
from (
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo01.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and a.oeauser = zx01
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200 -- < 200L
union all
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo02.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200
union all
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo03.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200
union all
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo3a.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200
union all
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo06.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200
),clq_file
where oea04 = occ01
and lat is not null
group by occ18,lat,lng
";
$stid = oci_parse($dbconn, $sql);
oci_bind_by_name($stid, ":oea15", $oea15);
oci_bind_by_name($stid, ":oea02b", $oea02b);
oci_bind_by_name($stid, ":oea02e", $oea02e);
oci_execute($stid);
$rows = array();
while($row = oci_fetch_assoc($stid)) {
$rows[] = $row;
}
$locations =(json_encode($rows));
echo $locations;
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
<script src="http://maps.googleapis.com/maps/api/js"> </script>
<script>
//var coordinates = [[22.5805149,120.4227832,'大連化學','image3'],[22.5789818,120.3178123,'建榮冷凍食品','image2']];
var offices = {"5310" : [25.055308,121.593377, "台北分公司"],
"5320" : [24.9545639,121.2026673, "桃園分公司"],
"5330" : [24.673791, 120.887685, "竹苗分公司"],
"5340" : [24.181775, 120.617205, "台中分公司"],
"5350" : [23.041664, 120.234495, "台南分公司"],
"5360" : [22.595090, 120.359171, "高雄分公司"]
};
function initialize(locations)
{
var coordinates = locations;
var oea15 = document.getElementById("oea15");
//alert(oea15.value);
//alert(offices[oea15.value][0] + "," + offices[oea15.value][1]);
var myCenter=new google.maps.LatLng(offices[oea15.value][0],offices[oea15.value][1]);
//var myCenter=new google.maps.LatLng(22.595090, 120.359171);
var mapProp = {
center:myCenter,
zoom:13,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
map.data.loadGeoJson('./twtown2010.4.json');
//map.data.loadGeoJson('./twcounty2010.6.json');
var image1 = {url : "http://labs.google.com/ridefinder/images/mm_20_red.png", size : new google.maps.Size(32, 32)};
var image2 = {url : "http://labs.google.com/ridefinder/images/mm_20_yellow.png", size : new google.maps.Size(32, 32)};
var image3 = {url : "http://labs.google.com/ridefinder/images/mm_20_green.png", size : new google.maps.Size(32, 32)};
var marker=new google.maps.Marker({
position:myCenter,
title: offices[oea15.value][2],
});
marker.setMap(map);
var idx;
for (idx=0; idx<coordinates.length; idx++) {
//alert(coordinates[idx]["LAT"] + "," + coordinates[idx]["LNG"] + "," + coordinates[idx]["OCC18"] + "," + coordinates[idx]["IMG"]);
var str = "var marker=new google.maps.Marker({ position:new google.maps.LatLng(" + coordinates[idx]["LAT"] + "," + coordinates[idx]["LNG"] + "), title: '" + coordinates[idx]["OCC18"] + "', icon:" + coordinates[idx]["IMG"] + " }); marker.setMap(map);"
eval(str);
}
//var marker=new google.maps.Marker({
// position:new google.maps.LatLng(22.5805149,120.4227832),
// title: '大連化學工業股份有限公司',
// icon: image3
//});
//marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<script>
$(function() {
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$("#from").datepicker("option", "dateFormat", "yy/mm/dd");
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
$("#to").datepicker("option", "dateFormat", "yy/mm/dd");
});
</script>
<script>
var Submit=function(){
var URLs="http://10.1.100.201/eip/report/google_map/getDNLatLng.php";
$.ajax({
url: URLs,
data: $('#DNLatLng').serialize(),
type:"POST",
dataType:'json',
success: function(msg){
//alert(msg);
initialize(msg)
},
error:function(xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
}
});
}
</script>
</head>
<body>
<form id="DNLatLng">
<label for="分公司">分公司</label>
<select name="oea15" id="oea15">
<option value="NA" selected="selected">===請選擇===</option>
<option value="5310">台北分公司</option>
<option value="5320">桃園分公司</option>
<option value="5330">竹苗分公司</option>
<option value="5340">台中分公司</option>
<option value="5350">台南分公司</option>
<option value="5360">高雄分公司</option>
</select>
<label for="from">送貨日期 From</label>
<input type="text" id="from" name="from">
<label for="to"> to</label>
<input type="text" id="to" name="to">
<input type=button id=btn1 value=送出 onClick="Submit()"> </input>
</form>
<div id="googleMap" style="width:800;height:900px;"></div>
</body>
</html>
getDNLatLng.php
<?php
$oea15 = $_REQUEST['oea15'];
$oea02b = $_REQUEST['from'];
$oea02e = $_REQUEST['to'];
$dbstr = "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST=tiptopdb)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = topprod)))";
$dbconn = oci_connect("echo01","echo01","$dbstr","utf8");
$sql = "
select lat,lng,occ18,case when max(交運方式) != min(交運方式) then 'image2' when max(交運方式) = '外車' then 'image1' when max(交運方式) = '其它' then 'image3' end img
from (
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo01.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and a.oeauser = zx01
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200 -- < 200L
union all
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo02.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200
union all
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo03.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200
union all
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo3a.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200
union all
select substr(to_char(oea02,'yyyymm'),1,6) yyyymm,oea15,oea43,ged02,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end 交運方式,
count(*) 次數,oea04,occ18,occ11,--oeb04,replace(oeb06,',',null) oeb06,
sum(oeb14*oea24) oeb14,oeb01,
oeauser,zx02,oeb04,oeb06,oeb12
from echo06.oea_file a,ged_file b,echo01.occ_file,echo01.oeb_file,echo01.zx_file,ima_file
where oea43 = b.ged01
and oea04 = occ01
and oea01 = oeb01
and oeaconf = 'Y'
and oeb04 = ima01
and imaud03 is null --冰品
and regexp_like(oea01,'SO[123789]-')
and ta_oea04 != '3'
and oea15 = :oea15
and oea02 between to_date(:oea02b,'yyyy/mm/dd') and to_date(:oea02e,'yyyy/mm/dd')
group by substr(to_char(oea02,'yyyymm'),1,6),oea43,ged02,oea15,
case when regexp_like(ged02,'大榮|大誠|日通|超峰|黑貓') then '外車' else '其它' end,oea04,occ18,occ11,--oeb04,oeb06,
oeauser,zx02,oeb01,oeb04,oeb06,oeb12
having sum(oeb12*ta_ima003/1000) < 200
),clq_file
where oea04 = occ01
and lat is not null
group by occ18,lat,lng
";
$stid = oci_parse($dbconn, $sql);
oci_bind_by_name($stid, ":oea15", $oea15);
oci_bind_by_name($stid, ":oea02b", $oea02b);
oci_bind_by_name($stid, ":oea02e", $oea02e);
oci_execute($stid);
$rows = array();
while($row = oci_fetch_assoc($stid)) {
$rows[] = $row;
}
$locations =(json_encode($rows));
echo $locations;
?>
2016年2月14日 星期日
Ubuntu11.10 使用 k3b 備份有CSS保護的DVD
https://jerry2yang.wordpress.com/2012/02/13/ubuntu11-10-%E4%BD%BF%E7%94%A8-k3b-%E5%82%99%E4%BB%BD%E6%9C%89css%E4%BF%9D%E8%AD%B7%E7%9A%84dvd/
要如何讓 k3b 可以備份有 CSS 保護的 DVD 呢?重點就是在如何安裝「libdvdcss」這個套件的方法了。
安裝「libdvdcss」:
拜訪 Linux Package Search,Search 「libdvdcss」套件, 找出符合系統版本的連結並依照說明安裝 「libdvdcss-dev」套件。

安裝步驟:
操作:
接著就和正常的操作一樣,直接複製媒體。在必要時可能要需要使用「忽略讀取錯誤」進階選項。
安裝「libdvdcss」:
拜訪 Linux Package Search,Search 「libdvdcss」套件, 找出符合系統版本的連結並依照說明安裝 「libdvdcss-dev」套件。

安裝步驟:
- Add the following line to /etc/apt/sources.list:
deb http://www.deb-multimedia.org wheezy main
- Update the package index:
# sudo apt-get update
- Install GPG key of the repository:
# sudo apt-get install deb-multimedia-keyring
- Install libdvdcss2 deb package:
# sudo apt-get install libdvdcss2
操作:
接著就和正常的操作一樣,直接複製媒體。在必要時可能要需要使用「忽略讀取錯誤」進階選項。

2016年2月2日 星期二
Google Maps API example
http://www.w3schools.com/googleapi/google_maps_overlays.asp
https://developers.google.com/maps/documentation/javascript/markers?hl=zh-tw
https://developers.google.com/maps/documentation/javascript/symbols?hl=zh-tw
example 1:
<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js">
</script>
<script>
var myCenter=new google.maps.LatLng(51.508742,-0.120850);
function initialize()
{
var mapProp = {
center:myCenter,
zoom:8,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker=new google.maps.Marker({
position:new google.maps.LatLng(51.508742,-0.120850),
icon: {
path: google.maps.SymbolPath.CIRCLE,
scale: 3
},
});
marker.setMap(map);
var marker=new google.maps.Marker({
position:new google.maps.LatLng(52,-0.120850),
icon: {
path: google.maps.SymbolPath.BACKWARD_CLOSED_ARROW,
scale: 3
},
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>
example 2:
<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js">
</script>
<script>
var myCenter=new google.maps.LatLng(25.03174,121.5297);
function initialize()
{
var mapProp = {
center:myCenter,
zoom:13,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var image1 = {url : "http://labs.google.com/ridefinder/images/mm_20_yellow.png", size : new google.maps.Size(32, 32)};
var image2 = {url : "http://labs.google.com/ridefinder/images/mm_20_red.png", size : new google.maps.Size(32, 32)};
var marker=new google.maps.Marker({
position:new google.maps.LatLng(24.9785,121.41),
icon: image1
});
marker.setMap(map);
var marker=new google.maps.Marker({
position:new google.maps.LatLng(24.988,121.412),
icon: image1
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:800;height:900px;"></div>
</body>
</html>
example 3:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
<script
src="http://maps.googleapis.com/maps/api/js">
</script>
<script>
var myCenter=new google.maps.LatLng(22.595090, 120.359171);
var coordinates = [[22.5805149,120.4227832,'大連化學','image3'],[22.5789818,120.3178123,'建榮冷凍食品','image2']];
function initialize()
{
var mapProp = {
center:myCenter,
zoom:13,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var image1 = {url : "http://labs.google.com/ridefinder/images/mm_20_red.png", size : new google.maps.Size(32, 32)};
var image2 = {url : "http://labs.google.com/ridefinder/images/mm_20_yellow.png", size : new google.maps.Size(32, 32)};
var image3 = {url : "http://labs.google.com/ridefinder/images/mm_20_green.png", size : new google.maps.Size(32, 32)};
var idx;
for (idx=0; idx<coordinates.length; idx++) {
var str = "var marker=new google.maps.Marker({ position:new google.maps.LatLng(" + coordinates[idx][0] + "," + coordinates[idx][1] + "), title: '" + coordinates[idx][2] + "', icon:" + coordinates[idx][3] + " }); marker.setMap(map);"
eval(str);
}
//var marker=new google.maps.Marker({
// position:new google.maps.LatLng(22.5805149,120.4227832),
// title: '大連化學工業股份有限公司',
// icon: image3
//});
//marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<script>
$(function() {
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$("#from").datepicker("option", "dateFormat", "yy/mm/dd");
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
$("#to").datepicker("option", "dateFormat", "yy/mm/dd");
});
</script>
</head>
<body>
<label for="分公司">分公司</label>
<input type=text id=txt1> </input>
<label for="from">From</label>
<input type="text" id="from" name="from">
<label for="to">to</label>
<input type="text" id="to" name="to">
<input type=button id=btn1 value=提交> </input>
<div id="googleMap" style="width:800;height:900px;"></div>
</body>
</html>
https://developers.google.com/maps/documentation/javascript/markers?hl=zh-tw
https://developers.google.com/maps/documentation/javascript/symbols?hl=zh-tw
example 1:
<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js">
</script>
<script>
var myCenter=new google.maps.LatLng(51.508742,-0.120850);
function initialize()
{
var mapProp = {
center:myCenter,
zoom:8,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker=new google.maps.Marker({
position:new google.maps.LatLng(51.508742,-0.120850),
icon: {
path: google.maps.SymbolPath.CIRCLE,
scale: 3
},
});
marker.setMap(map);
var marker=new google.maps.Marker({
position:new google.maps.LatLng(52,-0.120850),
icon: {
path: google.maps.SymbolPath.BACKWARD_CLOSED_ARROW,
scale: 3
},
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>
example 2:
<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js">
</script>
<script>
var myCenter=new google.maps.LatLng(25.03174,121.5297);
function initialize()
{
var mapProp = {
center:myCenter,
zoom:13,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var image1 = {url : "http://labs.google.com/ridefinder/images/mm_20_yellow.png", size : new google.maps.Size(32, 32)};
var image2 = {url : "http://labs.google.com/ridefinder/images/mm_20_red.png", size : new google.maps.Size(32, 32)};
var marker=new google.maps.Marker({
position:new google.maps.LatLng(24.9785,121.41),
icon: image1
});
marker.setMap(map);
var marker=new google.maps.Marker({
position:new google.maps.LatLng(24.988,121.412),
icon: image1
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:800;height:900px;"></div>
</body>
</html>
example 3:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
<script
src="http://maps.googleapis.com/maps/api/js">
</script>
<script>
var myCenter=new google.maps.LatLng(22.595090, 120.359171);
var coordinates = [[22.5805149,120.4227832,'大連化學','image3'],[22.5789818,120.3178123,'建榮冷凍食品','image2']];
function initialize()
{
var mapProp = {
center:myCenter,
zoom:13,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var image1 = {url : "http://labs.google.com/ridefinder/images/mm_20_red.png", size : new google.maps.Size(32, 32)};
var image2 = {url : "http://labs.google.com/ridefinder/images/mm_20_yellow.png", size : new google.maps.Size(32, 32)};
var image3 = {url : "http://labs.google.com/ridefinder/images/mm_20_green.png", size : new google.maps.Size(32, 32)};
var idx;
for (idx=0; idx<coordinates.length; idx++) {
var str = "var marker=new google.maps.Marker({ position:new google.maps.LatLng(" + coordinates[idx][0] + "," + coordinates[idx][1] + "), title: '" + coordinates[idx][2] + "', icon:" + coordinates[idx][3] + " }); marker.setMap(map);"
eval(str);
}
//var marker=new google.maps.Marker({
// position:new google.maps.LatLng(22.5805149,120.4227832),
// title: '大連化學工業股份有限公司',
// icon: image3
//});
//marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<script>
$(function() {
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$("#from").datepicker("option", "dateFormat", "yy/mm/dd");
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
$("#to").datepicker("option", "dateFormat", "yy/mm/dd");
});
</script>
</head>
<body>
<label for="分公司">分公司</label>
<input type=text id=txt1> </input>
<label for="from">From</label>
<input type="text" id="from" name="from">
<label for="to">to</label>
<input type="text" id="to" name="to">
<input type=button id=btn1 value=提交> </input>
<div id="googleMap" style="width:800;height:900px;"></div>
</body>
</html>
2016年1月31日 星期日
FourJS : 最簡單的 SQL + FOREACH 範例,還有呼叫PL/SQL方式
CASE 1
DECLARE cur64 CURSOR FOR
SELECT ogb14
FROM ogb_file, ima_file
WHERE ogb01=g_oga.oga01
AND ogb04 = ima01
AND ta_ima001 = '64-17-5' #==酒精
FOREACH cur64 INTO l_ogb14 #==酒精類產品不可用於本作業!!
CALL cl_err('','PL0017',1)
LET g_success = 'N' #FUN-580155
RETURN
END FOREACH
CASE 2 (PL/SQL)
FUNCTION t400_chk_oeb904_2()
DEFINE l_sql STRING
DEFINE l_ret SMALLINT
LET l_ret = 0
LET l_sql = "SELECT axm_pkg_oeb904.axm_func_true_false(?) FROM DUAL"
PREPARE p1 FROM l_sql
EXECUTE p1 USING g_oea.oea01 INTO l_ret
IF l_ret = 0 THEN
RETURN FALSE
ELSE
RETURN TRUE
END IF
END FUNCTION
CASE 3 (PL/SQL)
LET l_ret2 = "0"
LET l_sql = "BEGIN echo01.axm_pkg_t410.axm_proc_yn_cs_dist(?,?,?); END;"
PREPARE p4 FROM l_sql
EXECUTE p4 USING g_oea.oea01 IN, g_user IN, l_ret2 OUT
DECLARE cur64 CURSOR FOR
SELECT ogb14
FROM ogb_file, ima_file
WHERE ogb01=g_oga.oga01
AND ogb04 = ima01
AND ta_ima001 = '64-17-5' #==酒精
FOREACH cur64 INTO l_ogb14 #==酒精類產品不可用於本作業!!
CALL cl_err('','PL0017',1)
LET g_success = 'N' #FUN-580155
RETURN
END FOREACH
CASE 2 (PL/SQL)
FUNCTION t400_chk_oeb904_2()
DEFINE l_sql STRING
DEFINE l_ret SMALLINT
LET l_ret = 0
LET l_sql = "SELECT axm_pkg_oeb904.axm_func_true_false(?) FROM DUAL"
PREPARE p1 FROM l_sql
EXECUTE p1 USING g_oea.oea01 INTO l_ret
IF l_ret = 0 THEN
RETURN FALSE
ELSE
RETURN TRUE
END IF
END FUNCTION
CASE 3 (PL/SQL)
LET l_ret2 = "0"
LET l_sql = "BEGIN echo01.axm_pkg_t410.axm_proc_yn_cs_dist(?,?,?); END;"
PREPARE p4 FROM l_sql
EXECUTE p4 USING g_oea.oea01 IN, g_user IN, l_ret2 OUT
2016年1月27日 星期三
DIY自己的TIPTOP显示界面
http://blog.csdn.net/Gandalfwen/article/details/25246483
TIPTOP ERP的界面比较简单,怎么才能修改成有自己企业特色的呢?请看:
1.登入画面提示信息
多工厂用户在登陆时会弹出工厂编号选择作业,其中的欢迎信息存放在:错误信息资料维护作业(p_ze) 信息编号:a00-007
2.主画面图片
主画面右边基本资料里显示的图片存放在/u1/topprod/tiptop/doc/pic/tiptop_image.jpg,可以自己修改或更换。
修改不同的帐套显示不同的画面:
打开/u1/topprod/tiptop/azz/4gl/udm_tree.4gl
找到:LET ls_lake_pic = ms_pic_url || “/tiptop/pic/tiptop_image.jpg”修改为:
CASE
WHEN g_plant=’DEMO-1′
LET ls_lake_pic = ms_pic_url || “/tiptop/pic/tiptop_image0.jpg”WHEN g_plant=’PLANT-1′
LET ls_lake_pic = ms_pic_url || “/tiptop/pic/tiptop_image1.jpg”WHEN g_plant=’PLANT-2′
LET ls_lake_pic = ms_pic_url || “/tiptop/pic/tiptop_image2.jpg”WHEN g_plant=’PLANT-3′
LET ls_lake_pic = ms_pic_url || “/tiptop/pic/tiptop_image3.jpg”WHEN g_plant=’PLANT-4′…
OTHERWISE
LET ls_lake_pic = ms_pic_url || “/tiptop/pic/tiptop_image.jpg”.com
END CASE
3.系统流程的背景画面
系统流程的背景画面放在/u1/topprod/tiptop/doc/pic/tiptopbg.jpg,可以自己修改或更换。
4.WEB方式登陆窗口LOGO
WEB方式登陆窗口LOGO存放在/u1/topprod/tiptop/doc/pic/login.jpg,可以自己修改或更换。