亂貼小站公告欄

目前分類:動態網頁 (11)

瀏覽方式: 標題列表 簡短摘要

今天在資訊社,聽了大開學長的Drupal分享
真的讓我的一個小小目標前進了一大步
就是把我所學與 Drupal 結合
讓他可以幫我省下更多 coding 的時間
學到頗多東西! 大開學長的課質量很高
謝謝他願意把自己吃飯的傢伙教給我
期待自己的進步!

在這裡筆記一些關鍵字

Slideshow

Display Suite -> Extra -> Field Template -> Export 專家模式

Code Field

Code 寫進 Block or Full HTML code

views 格式:Slideshow

jQuery Cycle plugin

colorbox

jcarousel

www.greentrade.com

QuickTab 將 Views 疊在一起,達成 tab switch

 


文章標籤

和風信使 發表在 痞客邦 留言(0) 人氣()

<%@page contentType="text/html; charset=utf8" import="java.util.*" %>
<%@ include file="20111019_DBSetup.jsp" %>
<% 
request.setCharacterEncoding("utf8");
if( request.getParameter("username") != null )
{
        // 檢查
        String query ;
        query = "select * from `account` where `username` = '"+request.getParameter("username")+"' and `password` = '"+request.getParameter("password")+"'";
        ResultSet res = stmt.executeQuery(query);
        if(res.next())
        {
                out.println("<h1 style=\"color:red\">帳號 "+request.getParameter("username")+" 登入成功</h1>");
                session.setAttribute("Login","OK");    // 設定 session
                response.sendRedirect("20111019_memberQuery.jsp");  // 轉換網頁。
        }
        else
        {
                out.println("<h1 style=\"color:red\">帳號或密碼錯誤</h1>");
        }
        res.close();
}
else
{
        String Login = (String)session.getAttribute("Login");
        if(Login != null && Login.equals("OK"))
        {
                out.println("<h1 style=\"color:red\">welcome.</h1>");
                response.setHeader("Refresh","1;url=20111019_memberQuery.jsp");  // 延遲五秒後轉向
        }
        else
        {%>
<html><head><title>memberAdd</title></head><body>
<form action="" method="post">
        帳號:<input type="text" name="username" value="taichunmin"/><br />
        密碼:<input type="password" name="password" value="1234" />
        <input type="submit" value="登入" />
</form>

</body></html>
        <%}
}
%>

 

<%@page contentType="text/html; charset=utf8" import="java.util.*" %>
<%@ include file="2011.10.19_DBSetup.jsp" %>
<html>
        <head><title>query</title></head>
        <body>
        <div><a href="20111019_memberAdd.jsp">新增使用者</a> <a href="20111019_memberLogin.jsp">使用者登入</a> <a href="20111019_memberLogout.jsp">使用者登出</a></div>
        <table width="100%" cellspacing="0" border="1">
        <%
                String query = "select * from `account` order by `username`";
                ResultSet res = stmt.executeQuery(query);
                while(res.next())
                {
                        out.println("<tr>");
                        String username = res.getString("username");
                        out.println("<td>"+username+"</td>");
                        out.println("<td>"+res.getString("password")+"</td>");
                        out.println("<td><a href=\"20111019_memberUpdate.jsp?username=" + username + "\">修改</a></td>");
                        out.println("<td><a href=\"20111019_memberDelete.jsp?username=" + username + "\">刪除</a></td>");
                        out.println("</tr>");
                }
                res.close();
        %>
        </table>
        </body>
</html>

 

<%@page contentType="text/html; charset=utf8" import="java.util.*" %>
<%@ include file="20111019_DBSetup.jsp" %>
<% 
        session.setAttribute("Login",null);    // 設定 session
        response.sendRedirect("20111019_memberQuery.jsp");  // 轉換網頁。
%>

 

<%@page contentType="text/html; charset=utf8" import="java.util.*" %>
<%@ include file="20111019_DBSetup.jsp" %>
<% 
request.setCharacterEncoding("utf8");
if( request.getParameter("username") != null )
{
        if( request.getParameter("password") != null )
        {
                String query ;
                query = "select * from `account` where `username` = '"+request.getParameter("username")+"' and `password` = '"+request.getParameter("password")+"'";
                ResultSet res = stmt.executeQuery(query);
                if(res.next())
                {
                        if(request.getParameter("password_n1")!=null && request.getParameter("password_n2")!=null && request.getParameter("password_n1").equals(request.getParameter("password_n2")))
                        {
                                query = "update `account` set `password` = ? where `username`=?";
                                pstmt = conn.prepareStatement(query);
                                pstmt.setString(1, request.getParameter("password_n1"));
                                pstmt.setString(2, request.getParameter("username"));
                                pstmt.executeUpdate();
                                response.sendRedirect("20111019_memberQuery.jsp");  // 立即轉換網頁
                        }
                }
                else
                {
                        out.println("<h1 style=\"color:red\">帳號或密碼錯誤</h1>");
                }
                res.close();
        }
}
else
{
        out.println("<h1 style=\"color:red\">沒有 username = "+request.getParameter("username")+"</h1>");
        response.sendRedirect("20111019_memberQuery.jsp");  // 轉換網頁。
}
%>
<html><head><title>memberAdd</title></head><body>
<form action="" method="post">
        <input type="hidden" name="username" value="<%= request.getParameter("username") %>" />
        舊密碼:<input type="password" name="password" value="1234" />
        新密碼:<input type="password" name="password_n1" value="12345" />
        確認密碼:<input type="password" name="password_n2" value="12345" />
        <input type="submit" value="登入" />
</form>

</body></html>

 

<%@page contentType="text/html; charset=utf8" import="java.util.*" %>
<%@ include file="20111019_DBSetup.jsp" %>
<% 
request.setCharacterEncoding("utf8");
if( request.getParameter("username") != null )
{
        // 檢查
        String query ;
        query = "select * from `account` where `username` = '"+request.getParameter("username")+"'";
        ResultSet res = stmt.executeQuery(query);
        if(!(res.next()==true))
        {
                query = "insert into `account` (`username`,`password`) values (?,?)";
                pstmt = conn.prepareStatement(query);
                pstmt.setString(1, request.getParameter("username"));
                pstmt.setString(2, request.getParameter("password"));
                pstmt.executeUpdate();
                response.sendRedirect("20111019_memberQuery.jsp");  // 立即轉換網頁
        }
        else
        {
                out.println("<h1 style=\"color:red\">帳號 "+request.getParameter("username")+" 重複</h1>");
                response.setHeader("Refresh","5;url=20111019_memberQuery.jsp");  // 延遲五秒後轉向
        }
        res.close();
}
%>
<html><head><title>memberAdd</title></head><body>
<form action="" method="post">
        帳號:<input type="text" name="username" value="taichunmin"/><br />
        密碼:<input type="password" name="password" value="1234" />
        <input type="submit" value="Add" />
</form>

</body></html>

 

<%@page contentType="text/html; charset=utf8" import="java.util.*" %>
<%@ include file="20111019_DBSetup.jsp" %>
<% 
request.setCharacterEncoding("utf8");
if( request.getParameter("username") != null )
{
        String query;
        query = "delete from `account` where `username`=?";
        pstmt = conn.prepareStatement(query);
        pstmt.setString(1, request.getParameter("username"));
        pstmt.executeUpdate();
        response.sendRedirect("20111019_memberQuery.jsp");
}
%>
<html><head><title>memberAdd</title></head><body>
<form action="" method="post">
        帳號:<input type="text" name="username" value="taichunmin"/><br />
        <input type="submit" value="delete" />
</form>

</body></html>

 

<%@ page import="java.sql.*" %>
<%!
        Connection conn;
        PreparedStatement pstmt = null;
        Statement stmt = null;
%>
<%
        try{
                Class.forName("org.gjt.mm.mysql.Driver");
                String user="root",password="mis",dbName="db20111019";  // 在課堂上的設定
                //String user="jsp",password="mis",dbName="test";  // 在宿舍的設定
                String url="jdbc:mysql://localhost:3306/"+dbName+"?characterEncoding=utf8&useUnicode=true";
                conn = DriverManager.getConnection(url,user,password);
                stmt = conn.createStatement();
        }catch(SQLException sqle)
        {
                out.println("Sql Exception: "+sqle);
        }
%>

和風信使 發表在 痞客邦 留言(0) 人氣()

jquery在google的一些在線資源

jquery是一個不錯的Js庫,相信也用得比較多,但是大家不可能在每一台自己用的電腦都本地下載一個jquery文件,而且jquery更新也比較多,版本之間多少有一些偏差。所以這就讓我們有點頭痛了,但是其實我們可以藉用GOOGLECODE的在線資料。

加載在線jquery最新版本:

如果你想使用jquery的最新版本,那麼你在文件中加載:

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js”></script>

就OK了,這是jquery的最新版本。如果你想用特定的版本那就用:

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js”></script>

上面是1.4.2版本的,如果你想用其它版本就把上面紅色的1.4.2換成你要的版本號就OK了。

在線查看jquery中文手冊:

http://jquery-api-zh-cn.googlecode.com/svn/trunk/xml/jqueryapi.xml

下載jquery中文手冊:

http://code.google.com/p/jquery-api-zh-cn/downloads/list


文章標籤

和風信使 發表在 痞客邦 留言(0) 人氣()

這個PHP程式是幫我弟寫的

主要用途,就是從給予的成大公告網頁上,分析演講的訊息

然後跳轉到 Google 日曆的新增行程畫面

以方便進行修改及新增

<?php
        ob_start();
    header('Content-type: text/html; charset=utf8');
        set_time_limit(1000);
        function tai_noEndl($html)
        {
                return str_replace(array("\n","\r","\t"),array("","",""),$html);
        }
        function tai_getHtml($url)
        {
        $html = tai_noEndl(file_get_contents($url));
        if(empty($html))tai_show('錯誤:網頁抓取失敗,請檢查網路。('.$url.')。');
                return $html;
        }
        if(isset($_POST['url']) && preg_match('`^http://[^/]+?ncku\.edu\.tw/`',$_POST['url']))
        {
                /* 原公告
                        http://cge.ncku.edu.tw/files/13-1024-83826.php
                */
                /* 目標網址
                https://www.google.com/calendar/b/0/render?
                        action=TEMPLATE
                        &text=講題:『熱度★夢想』--無樂不作的咖啡魂
                        &dates=20111102T193000/20111102T213000
                        &location=國際會議廳第一演講室
                        &details=主講人:王宏榮(紅龍)
                        &pli=1
                        &sf=true
                        &output=xml
                */
                $html = tai_getHtml($_POST['url']);
                //echo htmlspecialchars($html);
                unset($httpQueryArray);
                
                $httpQueryArray['action']='TEMPLATE';
                
                preg_match('`講題.*?(?:</div>|<br />|<br>)`i',$html,$text);
                $httpQueryArray['text']=preg_replace('`<[^>]*>`','',$text[0]);
                
                preg_match('`時間.*?(?:</div>|<br />|<br>)`i',$html,$dates);
                $dates=preg_replace('`<[^>]*>`','',$dates[0]);
                preg_match('`(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+)`',$dates,$dates);
                $dates[4]=(($dates[4]<8)?($dates[4]+12):$dates[4]);
                $dates[6]=(($dates[6]<8)?($dates[6]+12):$dates[6]);
                $httpQueryArray['dates'] = sprintf("%04d%02d%02dT%02d%02d00",$dates[1]+1911,$dates[2],$dates[3],$dates[4],$dates[5]).'/'.
                                                                   sprintf("%04d%02d%02dT%02d%02d00",$dates[1]+1911,$dates[2],$dates[3],$dates[6],$dates[7]);
                
                preg_match('`地點.*?(?:</div>|<br />|<br>)`i',$html,$location);
                $httpQueryArray['location']=preg_replace('`<[^>]*>`','',substr($location[0],9));
                
                preg_match('`主講人.*?(?:</div>|<br />|<br>)`i',$html,$details);
                $httpQueryArray['details']=preg_replace('`<[^>]*>`','',$details[0]);
                
                //echo '<a href="https://www.google.com/calendar/b/0/render?'.http_build_query($httpQueryArray).'">連結</a>';
                header('location:https://www.google.com/calendar/b/0/render?'.http_build_query($httpQueryArray));
                exit(0);
        }
?>
<h1>成功大學「通識教育生活實踐」認證講座網址輸入</h1>
<form action="" method="post">
        <input type="text" size="100" name="url" />
        <input type="submit" value="submit" />
</form>
        

文章標籤

和風信使 發表在 痞客邦 留言(0) 人氣()

轉載自:Google API 1.7.7

<?php
        function getCurrentUrl() 
        {
          global $_SERVER;

          /**
           * Filter php_self to avoid a security vulnerability.
           */
          $php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0, strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES);

          if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
                $protocol = 'https://';
          } else {
                $protocol = 'http://';
          }
          $host = $_SERVER['HTTP_HOST'];
          if ($_SERVER['SERVER_PORT'] != '' &&
                 (($protocol == 'http://' && $_SERVER['SERVER_PORT'] != '80') ||
                 ($protocol == 'https://' && $_SERVER['SERVER_PORT'] != '443'))) {
                $port = ':' . $_SERVER['SERVER_PORT'];
          } else {
                $port = '';
          }
          return $protocol . $host . $port . $php_request_uri;
        }
?>

和風信使 發表在 痞客邦 留言(0) 人氣()

資料來源:http://php.net/manual/en/function.preg-match.php

<?php
$pattern = '`^((?P<protocol>[^:/?#]+):)?(//(?P<host>[^/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<label>.*))?`i';
$subject = 'http://example.com/defg/abcd/index.php?m=1&b=2#taichunmin';
preg_match($pattern,$subject,$match);
//可取用的資料如下
echo 'protocol = '  .$match['protocol']. '<br />';
echo 'host = '      .$match['host'    ]. '<br />';
echo 'path = '      .$match['path'    ]. '<br />';
echo 'query = '     .$match['query'   ]. '<br />';
echo 'label = '     .$match['label'   ]. '<br />';
?>

文章標籤

和風信使 發表在 痞客邦 留言(0) 人氣()

需先安裝外掛模組 NppExec

第一次使用先按 F6

把下面的程式碼貼上

並自行更改 JSP_www 和 JSP_url

以後就只需要按 Ctrl + F6 即可直接看到結果

 

NPP_CONSOLE ?
npp_save
set JSP_www = C:\Tomcat 7.0\webapps\ROOT\
set JSP_url = http://localhost:8080/
cmd.exe /c copy /Y "$(FULL_CURRENT_PATH)" "$(JSP_www)$(FILE_NAME)"
cmd.exe /c start "" "$(JSP_url)$(FILE_NAME)"


文章標籤

和風信使 發表在 痞客邦 留言(0) 人氣()

問題:

在 PHP 的 curl 中抓取 https 的時候,遇到底下的錯誤訊息:

SSL certificate problem, verify that the CA cert is OK. 

解法:

curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);

這可用來跳過驗證網站。

 

最近在寫 gCalMsg,一直遇到 curl 抓取不到 https 網頁的問題,

使用了 curl_error 之後 就輸出了上面的訊息

Google 一下就有答案了XD

資料來源:

http://www.bsdlover.cn/html/43/n-5943.html

http://www.php.net/manual/en/function.curl-setopt.php


和風信使 發表在 痞客邦 留言(2) 人氣()

  • 這篇文章限定好友觀看。
    若您是好友,登入後即可閱讀。

在學到PHP裡面的preg之後,就一直很想用這個來抓出網頁中我想要的資料

(網頁是使用 file_get_contents( 'http://........' ); 取得的)

可是不管怎麼嘗試

就是抓不出我想要的東西

我還曾經幾度懷疑我學的正則表達式是不是跟別人不一樣...

後來乾脆寫了一個測試的網頁

才真正發現了問題所在

原來PHP裡面的 preg_match 和 preg_match_all 不把換行( \r\n 和 \n )視為萬用字元 (.)

所以在下正則表達式時,就會遇上麻煩了...

所以我後來的解決辦法是

先使用 str_replace(array("\r\n","\n"),array("",""),$html); 去除所有的換行

這樣就成功解決的這個奇怪的問題~


文章標籤

和風信使 發表在 痞客邦 留言(0) 人氣()

找到新目標之後

果然生活就變成彩色的XD

前幾天不知道為什麼會突然想到

好像可以寫應用程式放到臉書上面

然後就不怕死的去申請了應用程式啦XDD

經過幾天非常熱血的狂寫程式+瘋狂debug

終於到目前是小有成果了

同時,也有兩個學弟來用我的應用程式了耶   (  感動中!!

目前好友排行已經完成

然後接下來 可能會寫邀請好友

或者是幫好友補全 zerojudge 帳號之類的功能吧

不然排行榜裡面的人數太少

看起來真的超沒fu的

可是 到底要怎麼選擇臉書上面的好朋友,並且輸入zerojudge的帳號呢?

天啊 像我七百多個好友 不寫一個好用的介面

連我自己都會受不了啊= =

沒辦法了 慢慢想吧

在這裡附上目前的截圖  和一段文字XDD

1000516_1.jpg   
這個是我這個亂七八糟的作者想說的話 

和風信使 發表在 痞客邦 留言(1) 人氣()