參考網址:https://www.xnview.com/en/xnview/#downloads
看line下載的圖片常會出現 windows相片檢視器無法開啟/無法顯示的錯誤
索性把它換掉
參考網址:https://www.xnview.com/en/xnview/#downloads
看line下載的圖片常會出現 windows相片檢視器無法開啟/無法顯示的錯誤
索性把它換掉
//文字為黑色,避免全黑,全白,背景儘量淡一些 //黑色 #000000 白色#ffffff //ca color array //$ca=array("22","44","66","88","aa","cc","ee"); //$ca=array("11","22","33","44","55","66","77","88","99","aa"); $ca=array("66","77","88","99","aa","bb","cc","dd","ee","ff"); //cn color number-1 $cn=count($ca)-1; for($i=0;$i<50;$i++) { $c="#"; for($j=0;$j<3;$j++) { $c .= $ca[rand(0,$cn)]; } $bgcolor_arr[$i]=$c; echo "<span style='background-color:{$c}'>$c</span> "; } echo "<br><br>"; foreach ($bgcolor_arr as $k => $v) { echo '"'.$v.'",'; } echo "<br><br>";
參考書籍:python 操作excel 深智數位 洪錦魁 著 https://www.books.com.tw/products/0010929648
# ch5_1.py import openpyxl fn = "data5_1.xlsx" wb = openpyxl.load_workbook(fn) ws = wb.active ws.insert_rows(4,1) ws.insert_rows(6,1) ws.insert_rows(8) # 省略amount參數 ws.insert_rows(10) # 省略amount參數 wb.save("out5_1.xlsx")
sport_function.php 尋找混合-->全能 update `play_item` set play_item_name='全能運動' WHERE `play_item_id`=23 work\race_im.php
參考網址:alvinchen
整理如下:環境 lubuntu 22.04 cubi
步驟一: 安裝Awstats apt-get install awstats libgeo-ipfree-perl libnet-ip-perl 步驟二: 設定Awstats cp /etc/awstats/awstats.conf /etc/awstats/awstats.sp.idv.tw.conf vi /etc/awstats/awstats.sp.idv.tw.conf 改這些地方 LogFormat=1 SiteDomain="sp.idv.tw" HostAliases="localhost 127.0.0.1 sp.idv.tw" DNSLookup=0 Lang="tw" 步驟三:手動執行一次 /usr/lib/cgi-bin/awstats.pl -config=sp.idv.tw -update 步驟四:設定定期自動執行 vi /etc/cron.d/awstats 新增一行 */10 * * * * root /usr/lib/cgi-bin/awstats.pl -config=sp.idv.tw -update > /dev/null 步驟五:設定Apache Config,讓網頁可以看到資料 vi /etc/apache2/sites-available/awstats.conf Alias /awstatsclasses "/usr/share/awstats/lib/" Alias /awstats-icon/ "/usr/share/awstats/icon/" Alias /awstatscss "/usr/share/doc/awstats/examples/css" ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ ScriptAlias /awstats/ /usr/lib/cgi-bin/ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 步驟六:開啟apache cgi mode,並重新啟動 a2enmod cgi service apache2 restart 打開瀏覽器就可以看到網站的流量數字啦 http://sp.idv.tw/cgi-bin/awstats.pl?config=sp.idv.tw 統計圖會有破圖(步驟五的Alias /awstats-icon/ 似乎沒有作用) 直接把/usr/share/awstats/icon/. 複製到 /var/www/html/awstats-icon/. mkdir /var/www/html/awstats-icon cd /var/www/html/awstats-icon cp /usr/share/awstats/icon/. . -Rp
參考網址:如何在Ubuntu 20.04上使用Dnsmasq設置本地DNS解析器
Dnsmasq使用参考入门 http://www.freeoa.net/osuport/servap/dnsmasq-use-intro-refer_2480.html
Dnsmasq – Lightweight Name Resolution For Your Home Lab
https://dev.to/joeneville_/dnsmasq-lightweight-name-resolution-for-your-lab-2gim
在lubuntu 22.04安裝過程
參考書籍:O'REILLY Linux錦囊妙計 第二版 碁峯 P401~426
roki.tw tni設置
在系統中禁用Systemd解析的服務
systemctl disable --now systemd-resolved rm -rf /etc/resolv.conf #需先刪除,它原本是一個link echo "nameserver 192.168.1.9" > /etc/resolv.conf echo "nameserver 8.8.8.8" >> /etc/resolv.conf apt-get install dnsmasq dnsutils ldnsutils -y
/etc/NetworkManager/NetworkManager.conf 的[main]加入
dns=none
否則/etc/resolv.conf會一直被改掉
client端亦同
改完後要系統reboot才會生效
先把兩片網路卡裝好
eth0 192.168.1.19 負責對外
eth1 192.168.66.1 負責內部網路
兩片網卡透通 iptables -t nat -A POSTROUTING -o eth0 -s 192.168.66.0/24 -j MASQUERADE
vi /etc/dnsmasq.conf
##########DNS resolv-file=/etc/resolv.conf domain-needed bogus-priv expand-hosts #no-host的項目預設是關閉的,這個啟用的話會變成最先去找local端的host檔案。 no-hosts #通常與no-hosts對應的是addn-hosts設定檔部分, #這個就不是讀取/etc/hosts,而是自己定義要對應到哪個檔案去。 #(這邊的格式要跟/etc/hosts的一樣) #addn-hosts=/etc/add_hosts #domain=sp.idv.tw #local=/sp.idv.tw/ #這兩行設了反而無法連線到sp.idv.tw listen-address=127.0.0.1 listen-address=192.168.1.19 server=8.8.8.8 #要擋掉的網站 address=/tw.yahoo.com/192.168.1.19 address=/edition.cnn.com/192.168.1.19 address=/pchome.com.tw/192.168.1.19 address=/facebook.com/192.168.1.19 ###########DHCP dhcp-leasefile=/var/lib/misc/dnsmasq.leases listen-address=192.168.66.1 dhcp-option=eth1,3,192.168.66.1 #router dhcp-option=eth1,1,255.255.255.0 #mask dhcp-option=eth1,6,192.168.66.1 #dns-server dhcp-range=eth1,192.168.66.100,192.168.66.200,24h #dhcp-host=08:00:27:3c:da:1a,192.168.1.101 # Always give the host with Ethernet address 11:22:33:44:55:66 # the name fred and IP address 192.168.0.60 and lease time 45 minutes #dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m
service dnsmasq restart
netstat -rn 查詢gateway
dnsmasq –help dhcp 查詢服務的選項編號
https://thekelleys.org.uk/dnsmasq/doc.html 官方文件
client端的/etc/resolv.conf 設定
nameserver 192.168.1.9
nameserver 8.8.8.8
nslookup 指定server的用法
#先執行nslookup 出現>後再輸入server 192.168.1.9 nslookup >server 192.168.1.9
dig指定server的用法
dig @192.168.1.9
目前問題
1.dnsmasq server中的/etc/hosts 無法直接下放給windows 10 client使用
(nslookup可以查到該網站的對應,瀏覽器卻出不去。在ubuntu系統是可行的)
2.address=/tw.yahoo.com/192.168.1.19 檔不住網站,但address=/pchome.com.tw/192.168.1.19 卻可以檔掉
參考網址:在Linux上安裝MRTG流量監控套件
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html 時發生錯誤
https://stackoverflow.com/questions/16372969/mrtg-error-did-not-find-any-matching-data-in-cfg-file
Target[127.0.0.1_1]: 1:public@127.0.0.1: SetEnv[127.0.0.1_1]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo" MaxBytes[127.0.0.1_1]: 1250000 Title[127.0.0.1_1]: Traffic Analysis for local loopback PageTop[127.0.0.1_1]: <h1>Traffic Analysis for local loopback</h1>
https://bigair.pixnet.net/blog/post/22969043
這篇比較新,安裝在/var/www/mrtg 用Alias /mrtg "/var/www/mrtg/" 的方式改成/mrtg
https://hackmd.io/@nikerdy/rkCs0m7Qr
執行env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 出現錯誤
Received SNMP response with error code error status: noSuchName index 2 (OID: 1.3.6.1.2.1.2.2.1.16.1) SNMPv1_Session
解決方法參考https://www.linuxquestions.org/questions/linux-networking-3/snmp-response-error-nosuchname-79138/
The default settings of the SNMP were too restrictive for MTRG to access what it needed. Here is the revised section of the snmpd.conf file:
Code:
#### # First, map the community name "public" into a "security name" # sec.name source community com2sec linuxbox default public #### # Second, map the security name into a group name: # groupName securityModel securityName group mrtggrp v1 linuxbox group mrtggrp v2c linuxbox #### # Third, create a view for us to let the group have rights to: # name incl/excl subtree mask(optional) view mrtgview included .1 80 #### # Finally, grant the group read-only access to the systemview view. # group context sec.model sec.level prefix read write notif access mrtggrp "" any noauth exact mrtgview none none # -----------------------------------------------------------------------------
lubuntu 22.04 安裝過程記錄
apt-get install snmpd snmp vi /etc/snmp/snmpd.conf 新增一行 rocommunity public localhost 重啟 snmpd systemctl restart snmpd 測試snmpd snmpwalk -v 2c -c public localhost 安裝 MRTG apt-get install mrtg 重建 /etc/mrtg.cfg 檔案 cfgmaker public@localhost > /etc/mrtg.cfg 建立給 MRTG 的首頁 indexmaker /etc/mrtg.cfg > /var/www/html/mrtg/index.html 如果有出現ERROR: did not find any matching data in cfg file 才需要做 再做一次indexmaker /etc/mrtg.cfg > /var/www/html/mrtg/index.html env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 有錯誤找上面的文章解決 service snmpd restart 五分鐘執行一次 crontab -e */5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
參考網址:軒.net
一開始使用 shell 指令想直接抓出量
ls /var/lib/php/sessions/sess_*|wc -l
用 root 運作良好,but 變成 php
$session_count=\exec('ls /var/lib/php/sessions/sess_*|wc -l');
馬上因為權限問題掰掰。
查了一堆資料,session 本來就設定不給 www-data 使用
我也不想隨便改資料夾權限
就用其他方式解
寫一隻 session_count.sh 放在/var下
#!/bin/bash
ls /var/lib/php5/sess_*|wc -l
記得給執行權限
chmod u+x /var/session_count.sh
安裝 sudo
apt-get install sudo
編輯 sudoers
visudo
加上此行
www-data ALL = (root) NOPASSWD: /var/session_count.sh
之後在 php 內招換
$online_count = \exec("sudo /var/session_count.sh 2>&1");
if (!preg_match('/^\d+$/', $online_count)) {
$online_count = -1;
}
就得到 session 數量啦!
參考網址:domain.hinet.net
sa.ddns.net的網域名稱會被學術網路誤判為黑名單,索性花一些錢申請了hinet的網域名稱
sa.idv.tw已被申請了,可惜!
申請sp.idv.tw來用400元/年 10年3200元
https://tw.godaddy.com/whois 可以查到whois資料
https://www.net-chinese.com.tw/ 可以查到whois資料
設定範例https://www.evo-mailserver.com.tw/support/domain_name_hosting.php
DNS Server NameIP Address
admns1.hinet.net203.66.88.192
admns2.hinet.net203.74.116.192