星期日, 5月 05, 2019

PHP + JQUERY + AJAX 帳號欄位檢查

使用Ajax 前,建議你必須看得懂 Jquery語法,這樣才能方便修改




1. HTML 表單欄位 

設定欄位名稱及Javascript要抓取的ID為 account

<input name="username" class="form-control" id="account" type="text" value="" onkeyup="checkRegAcc()">
<span class="text-danger" id="msg_username"></span>

2. JQUERY Ajax 設定語法

網頁 先載入 jquery <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>

<!-- Ajax -->
  <script>
    $(document).ready(function(){
    checkRegAcc = function() {
    if ($('#account').val().length >= 2) {
        $.ajax({
            url: 'mag_admin_check.php',  // 判斷欄位是否存在的程式
            type: 'GET',    // 傳遞的方法
            data: {
                username: $('#account').val()
            },
            error: function(xhr) {          // 設定錯誤訊息
                alert('Ajax request 發生錯誤');
            },
            success: function(response) {   // 將回傳的訊息寫入網頁中
                $('#msg_username').html(response);
                $('#msg_username').fadeIn();
            }
        });
    } else {
        $('#msg_username').html('');
    }
};
});
</script>


3. PHP 判斷用的程式碼, 參考用,請依實際表單欄位更改

require 'config.inc.php';  // 連線資料庫

if (isset($_GET['username'])) {
    $rs = $pdo->prepare("SELECT * FROM `admin` WHERE `username`=:username");
    $rs->bindParam(':username', $_GET['username']);
    $rs->execute();
    $d = $rs->fetchObject();
 
    if ($d->username == '') {
        $ret = "此帳號可以使用";
    } else {
        $ret = "此帳號已經有人使用";
    }
    echo $ret;
}



參考資料 http://fecbob.pixnet.net/blog/post/43025230-php%28asp.net%29%2Bjquery%2Bajax%E5%B8%B3%E8%99%9F%E6%AA%A2%E6%9F%A5

















星期四, 9月 27, 2018

Plesk shows error with custom template: Template processing failed: file = /usr/local/psa/admin/conf/templates/default/domainVhostIpDefault.php

Symptoms

The following error is shown on main page of Plesk:
New configuration files for the Apache web server were not created due to the errors in configuration templates: Template processing failed: file = /usr/local/psa/admin/conf/templates/default/domainVhostIpDefault.php, error = TemplateException: Template domain/service/wordpress.php doesn't exists file: /usr/local/psa/admin/plib/Template/Processor.php line: 28 code: 0 Previous error: TemplateException: Template domain/service/wordpress.php doesn't exists file: /usr/local/psa/admin/plib/Template/Processor.php line: 28 code: 0 Previous error: Template_Exception: Template domain/service/wordpress.php doesn't exists file: /usr/local/psa/admin/plib/Template/Finder.php line: 25 code: 0. Detailed error descriptions were sent to you by email. Please resolve the issues and click here to generate broken configuration files once again or here to generate all configuration files. See the details in Configuration Troubleshooter

Cause

Corrupted or invalid /usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.phpfile, which acts as a custom template configuration files.

Resolution

  1. Connect to the server using SSH.
  2. Create a backup of /usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php using the following command:
    # mv /usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php.backup
  3. Rebuild Apache configuration:
    Warning: Reconfiguration implies downtime, which depends on the number of domains.
    # /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
  4. If the issue persists, move all the custom templates:
    # mv /usr/local/psa/admin/conf/templates/custom /usr/local/psa/admin/conf/templates/custom_old
  5. Delete information about failed configuration:
    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin -Dpsa -Ne "delete from Configurations where status='error'"
  6. Rebuild Apache configuration:
    Warning: Reconfiguration implies downtime, which depends on the number of domains.
    # /usr/local/psa/admin/sbin/httpdmng --reconfigure-all

星期一, 2月 12, 2018

石材切斷機 STONE CUTTER CM4SB2


鑽石鋸片尺寸 最大直徑: 110mm x 1 mm x 20mm * 鑽石鋸片另購
 能力
 (最大切割深度)
 34 mm (使用 110mm (4-3/8") 鑽石鋸片時) 
 31.5 mm (使用 105mm (4") 鑽石鋸片時)
 輸入功率 1,320 W
 無負載轉速 11,500 /min.
 尺寸 (L x H) 204mm ( 8-1/32") x 157mm (6-3/16")
 重量 (不含電線) 2.8 kg (6.2 lbs.)      
 標準附件 套筒板手x1, 扳手x1, 橡膠連接器x1, 水管x1, 乙烯軟管x1

一次只能最多切割20mm,超過需分次切割,避免電動機過載損壞。
切割混擬土 磁磚 石材或畫線時務必澆水

星期二, 1月 23, 2018

資料庫隱碼攻擊( SQL Injection )

分析 Log 內的特徵碼
與資料庫有關的語法
-- , %20-- , 'or'='or' ..... 等

星期一, 6月 19, 2017

install php 5.5 opcache on Centos 5.11

Oh, I've already got answer to my question :) Add it here, maybe, someone else will use it.
Initially I installed php using such command
# yum --enablerepo=remi,remi-php55 install php-pecl-apc php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
Now I just ADDED missing extension with this command
# yum --enablerepo=remi,remi-php55 install php-opcache
And it worked!!! phpinfo() shows needed module :)

星期二, 4月 25, 2017

Centos 5.X 升級更新問題

CentOS 5.X 己經停止支援了,所以各大 Mirror Site 都砍掉這些檔案

主要還是 yum update 不能用了, 像是


# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. /
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/5/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base
這時候就要修改 mirror 檔案, mark 掉所有 mirrorlist 的地方, 改從 valut 抓檔案

#vi /etc/yum.repos.d/CentOS-Base.repo , mark 掉所有 mirrorlist=

分別加上
baseurl=http://vault.centos.org/5.11/os/$basearch
baseurl=http://vault.centos.org/5.11/updates/$basearch
baseurl=http://vault.centos.org/5.11/extras/$basearch
baseurl=http://vault.centos.org/5.11/centosplus/$basearch
baseurl=http://vault.centos.org/5.11/contrib/$basearch

硬改 5.11 應該也沒有什麼關係,反正也不會再升級或是進版了

資料來源:https://blog.richliu.com/2017/04/26/2142/centos-5-x-%E5%8D%87%E7%B4%9A%E6%9B%B4%E6%96%B0%E5%95%8F%E9%A1%8C

星期二, 3月 28, 2017

Linux top 指令 說明

 PID USER      PR   NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
28163 root      18   0  4220  968  444 R 47.4  0.0   0:00.24 fuser
28164 root      18   0  4220  972  444 R 47.4  0.0   0:00.24 fuser
28165 root      18   0  4220  968  444 R 47.4  0.0   0:00.24 fuser
28162 root      17   0  4220  968  444 R 45.4  0.0   0:00.23 fuser


PID — 進程id
USER — 進程所有者
PR — 進程優先順序
NI — nice值。負值表示高優先順序,正值表示低優先順序
VIRT — 進程使用的虛擬記憶體總量,單位kb。VIRT=SWAP+RES
RES — 進程使用的、未被換出的實體記憶體大小,單位kb。RES=CODE+DATA
SHR — 共用記憶體大小,單位kb
S — 進程狀態。D=不可中斷的睡眠狀態 R=運行 S=睡眠 T=跟蹤/停止 Z=僵屍進程
%CPU — 上次更新到現在的CPU時間佔用百分比
%MEM — 進程使用的實體記憶體百分比
TIME+ — 進程使用的CPU時間總計,單位1/100秒
COMMAND — 進程名稱(命令名/命令行)