2012年7月25日 星期三

PHP-Foreach使用DMEO

     

AryEndPage as $row => $value):?>  
    
                AryEndPage[$this->OlympicsSD[$i]['Class']][$m])-1){?>    
        

Jquery-Ajax_Json傳值Demo

JQUERY
     

       $.ajax({
            url: '/demo/videochenge',
            cache: false,
            dataType: 'json',
            type:'GET',
                data: { SelVideoClass:  SelVideoClass,
                        SelKeyID:  SelKeyID},  
            error: function(xhr) {
                alert('Ajax request 發生錯誤');
            },
            success: function(response) {

                //alert(response[0].title);

                initializePlayer(response[0].video);
                $('.channel-bar-channel-list').text(response[0].title);
                $("#bd").attr("SelKeyID",response[0].SelKeyID);
                $("#bd").attr("SelVideoClass",response[0].SelVideoClass);

                SelKeyID = parseInt(response[0].SelKeyID);
                SelVideoClass  = parseInt(response[0].SelVideoClass);
            }
        });

PHP
     

    function videochengeAction(){ 
             $ReData[] = array ("SelKeyID"=>$SelKeyID,
                                "SelVideoClass"=>$SD_SelVideoClass); 
        
         echo json_encode($ReData);

      exit;
        
    }

2012年7月24日 星期二

Jquery-Div開關DENO

click 事件判斷
     

   $(".popup_share").hide();
        $(".channel-bar-button").click(function() {
             if($(".popup_share").is(':hidden')){
                         $('.popup_share').show();        
   }else{
    $('.popup_share').hide(); 
                }
        });
click Repeat事件
     

    $(".channel-bar-button").toggle(
        function () {
            $('.popup_share').show();
        },
        function () {
            $('.popup_share').hide();
        }
    );

mouseout Repeat事件
     

      $(".channel-bar-button").hover(
        function () {
            $('.popup_share').show();
        }, 
        function () {
            $('.popup_share').hide();
        }
        );

2012年7月18日 星期三

Jquery-輪播DMEO

               


Jquery-HashDemo

Jquery
               

Html
    
        

PHP-判斷迴圈

If Else
               

if($StrDemo){
 $StrDemo = $this->_request->get('StrDemo');
  }else{
 $StrDemo = 1;
}

if($StrDemo):
 $StrDemo = $this->_request->get('StrDemo');
  else:
 $StrDemo = 1;
endid;

$StrDemo?$StrDemo = $this->_request->get('StrDemo'): $StrDemo = 1; //縮短寫法

For
               

for($i=0;$i<=9;$i++){
 echo $i;
}

for($i=0;$i<=9;$i++):
 echo $i;
endfor;
Switch
               
switch($Demo){
 case 'A':
            echo 'A';  
        break;
        case 'B':
            echo 'B'; 
        break;
     default:
            echo 'Def'; 
   }


  switch($Demo):
 case 'A':
            echo 'A';  
        break;
        case 'B':
            echo 'B'; 
        break;
      default:
            echo 'Def'; 
  endswitch;
Foreach
               
foreach ($this->Demo as $rows => $value){
 echo $value['ID'];
}

foreach ($this->Demo as $rows => $value):
 echo $value['ID'];
endforeach;

PHP-VoteDemo

               

//VOTE_DEMO
$this->PrjectName = 'Ctrlzxcv';  
$this->Standard = array('ClassA','ClassB');
$this->DominName = 'www.ctrlzxcv.com'; 

  
    $residue = fmod($Int,10);// 設定除法餘數

    //$TodayName = $ObjVoteMod->TodayVoteName('ClassA',$residue);
    //投票基準名稱 標準話 Ctrlzxcv_Ary_TodayVote_20120614_ClassA_1   (類別,餘數)
    function TodayVoteName($Class,$Residue)
    {
        return $this->PrjectName.'_Ary_TodayVote_'.date("Ymd").'_'.$Class.'_'.$Residue; 
    } 

    //投票前台總數名稱 預餘顯示前台(ID)
     //$VtewTotalName = $ObjVoteMod->ViewTotalName('40');
    function ViewTotalName($Key)
    {
        return $this->PrjectName.'_Int_ViewTotal_'.$Key;  //直接顯示前台
    } 
    
    //用於快取 暫存資料 (ID) 
    function ViewNumName($Key)
    {
        return $this->PrjectName.'_Int_Num_'.$Key;  //直接顯示前台
    }  

PHP-MemcacheDemo

        
       
//寫入數據  
//$this->InMemcache($Str_ProjectName,'_Maple',$Int_Num+1);  
//(KEY,存放數據,存活時間(預設1天),伺服器位置)
public function InMemcache($InPkey,$arrData,$Intime="86400",$StrServerIP="127.0.0.1")
    {
        $ObjMemcache = new Memcache;
        $ObjMemcache->connect($StrServerIP, 11211);
        $ObjMemcache->set($InPkey,$arrData,false, $Intime);
    }  
 
//抓取數據 $this->SetMemcache($Str_ProjectName,'_Maple')  
//(KEY,伺服器位置)
public function SetMemcache($SePkey,$StrServerIP="127.0.0.1")
    {
        $ObjMemcache = new Memcache;
        $ObjMemcache->connect($StrServerIP, 11211);
        return $ObjMemcache->get($SePkey);  
    }

PHP-身分證驗證

               
public function userunicode($id){
              $id = strtoupper($id);
              //建立字母分數陣列
              $headPoint = array(
                'A'=>1,'I'=>39,'O'=>48,'B'=>10,'C'=>19,'D'=>28,
                'E'=>37,'F'=>46,'G'=>55,'H'=>64,'J'=>73,'K'=>82,
                'L'=>2,'M'=>11,'N'=>20,'P'=>29,'Q'=>38,'R'=>47,
                'S'=>56,'T'=>65,'U'=>74,'V'=>83,'W'=>21,'X'=>3,
                'Y'=>12,'Z'=>30
              );
              //建立加權基數陣列
              $multiply = array(8,7,6,5,4,3,2,1);
              //檢查身份字格式是否正確
              if (ereg("^[a-zA-Z][1-2][0-9]+$",$id) AND strlen($id) == 10){
                //切開字串
                $len = strlen($id);
                for($i=0; $i<$len; $i++){
                  $stringArray[$i] = substr($id,$i,1);
                }
                //取得字母分數
                $total = $headPoint[array_shift($stringArray)];
                //取得比對碼
                $point = array_pop($stringArray);
                //取得數字分數
                $len = count($stringArray);
                for($j=0; $j<$len; $j++){
                  $total += $stringArray[$j]*$multiply[$j];
                }
                //計算餘數碼並比對
                $last = (($total%10) == 0 )?0:(10-($total%10));
                if ($last != $point) {
                  return false;
                } else {
                  return true;
                }
              }  else {
                 return false;
              }
}

PHP-常用方法

               

 
//Zend 方法去除HTML碼
public function delhtml($strDel){
 $objDelHtml = new Zend_Filter_StripTags ();             
        $strPostId = $objDelHtml->filter($strDel);  
        return $strPostId; 
          } 

//判斷信箱格式
public function ChMail($CheckData){
 return ereg("[a-zA-Z0-9\._\+]+@([a-zA-Z0-9\.-]\.)*[a-zA-Z0-9\.-]+",trim($CheckData));
          }  

//產生隨機碼($InNumbre)
//(回傳總數)
public function Arnumber($InNumbre){
 return substr(md5(uniqid(rand(),true)),0,$InNumbre);;
}

//產生動態命名    
public function generator()
            {
              $password_len = 5;
              $password = '';
              $word = 'abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ';
              $len = strlen($word); 
              for ($i = 0; $i < $password_len; $i++) {
                $password .= $word[rand() % $len];
              }
              return $password;
            }
     
//使用者 IP回傳
    function Trueip(){
      if (!empty($_SERVER['HTTP_CLIENT_IP']))
        $ip=$_SERVER['HTTP_CLIENT_IP'];
          else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
          else
        $ip=$_SERVER['REMOTE_ADDR'];
        return $ip;    
    }

PHP-Ary搜索

               

//一維搜索   
//$SeAry = $ObjVoteMod->ArraySearchInt('100003865712991',$ObjVoteMod->SetMemcache($Str_Ary_List));
//(撈取數,撈取陣列) return IntKey;
//預設A 模式 回傳陣列[0]取的單一值  B模式 自動計算陣列上下頁功能 回傳陣列 裡面有預設三個數據
public function ArraySearchInt($InData,$Inarry,$model="A")
    {
       if($Inarry!=NULL){ 
            $IntRt=NULL;
            foreach ($Inarry  AS $nkey => $nvalue):
                if($nvalue == $InData){ 
                    $IntRt[] = $nkey; 
                }
            endforeach;
         if($IntRt){  
                if($model == "B"){
                    $IntRt[0] == 0? $FastData = 0:$FastData = $IntRt[0]-1;
                    $IntRt[0] ==count($Inarry)-1? $NextData = count($Inarry)-1:$NextData=$IntRt[0]+1;

                    $arr_RtData = array(
                            "Fast"=>$FastData,  //上一筆
                            "0"=>$IntRt[0],
                            "Next"=>$NextData);
                        return $arr_RtData;
                }else{
                    return $IntRt; //回傳單一值陣列
                }
            }else{
                return $IntRt=NULL;
            }   
            
        }else{
            return $IntRt=NULL;
        }
    }

//二維陣列搜索    
//$IntRt = $objTools->ArraySearch(array('ID'=>$this->_request->get('id')),$this->view->intData);
//(撈取陣列,撈取基準陣列) return IntKey;

public function ArraySearch($needle, $haystack) {
        if(empty($needle) || empty($haystack)) {return false;}    
            foreach ($haystack as $key => $value){
                $exists = 0;
                foreach ($needle as $nkey => $nvalue) {
                if (!empty($value[$nkey]) && $value[$nkey] == $nvalue) {
                    $exists = 1;
                    }else{
                    $exists = 0;
                }
            }
                if ($exists) return $key;
          }    
          return false;
    }






PHP-Ary宣告

               
//一維陣列宣告
$AryOne= array('A','B','C','D','E','F','G','H','I','J','K');
    
//二維陣列宣告
$WeatherSD[] = array('Area'=>'台北','City'=>'台北市');
$WeatherSD[] = array('Area'=>'新北','City'=>'新北市');
$WeatherSD[] = array('Area'=>'基隆','City'=>'基隆市');
  
//二維陣列Repage
foreach ($AryRepage as $rows => $value):    
 $AryRepage[] = array(
 'RepageA'=>$value['RepageA'],
        'RepageB'=>$value['RepageB'],
        'RepageC'=>$value['RepageC'],
        'RepageD'=>$value['RepageD'],
        'RepageE'=>$value['RepageE'],
        'RepageF'=>$value['RepageF']
        );
endforeach; 

ZEND-TPL-DEMO

TPL
               


ZEND-DB進階

抓取最新新增筆數
               
 $AryInData = array('DbTableName_A' => $this->_request->get('DbTableName_A'),
                           'DbTableName_B' => $this->_request->get('DbTableName_B'));
                  
 $this->objAdapters['DbConfig']->insert('TableName',$AryInData);     
        $IntNewID = $this->objAdapters['DbConfig']->lastInsertId(); 

ZEND-DB基礎

查詢
   
            
  $ObjSeJson = $this->objAdapters['DbConfig']
                        ->select()
                        ->from('TableName');
  
                        ->where('AdvertisingClass !='.'"App"');
                        ->where('Showx=?','1')
                        ->where('AdvertisingClass!=?','App');
                        ->where('lottery_userVoteID IS NULL')
                        ->where('lottery_userMail IS NOT NULL')
                        ->order('RAND()')
                        ->order(array('Sort','ID desc'))


  $aryJson = $this->objAdapters['DbConfig']->fetchall($ObjSeJson);  

新增
               
 $AryInData = array('DbTableName_A' => $this->_request->get('DbTableName_A'),
                           'DbTableName_B' => $this->_request->get('DbTableName_B'));
                  
 $this->objAdapters['DbConfig']->insert('TableName',$AryInData);     
        $IntNewID = $this->objAdapters['DbConfig']->lastInsertId(); 

修改
               
$AryInData = array('DbTableName_A' => $this->_request->get('DbTableName_A'),
                  'DbTableName_B'=>$this->_request->get('DbTableName_B'));                         
$this->objAdapters['DbConfig']->update('TableName',$AryInData,'ID='.$this->_request->get('ID'));

刪除
               
$this->objAdapters['DbConfig']->delete('TableName','ID='.$this->_request->get('ID'));

ZEND-View常用

               


ZEND-CTL常用

               

    
echo $this->view->baseUrl(); //輸出根目錄路徑
echo $this->view->baseUrl("/css/test.css"); //直接在根目錄後面串上路徑

    $this->view->StrCtl = $this->_request->getControllerName();  //取得CTL名稱
    $this->view->StrAct=  $this->_request->getActionName();       //取得ACT名稱

ZEND-Config設定

config.ini
     
          
[general]
strImgPath = /img/
strImgPath = /images/
strCssPath = /css/
strJsPath = /js/


[database]
db.name.adapter = PDO_MYSQL
db.name.config.host = 127.0.0.1
db.name.config.username = username
db.name.config.password = password
db.name.config.dbname = dbname
db.name.config.charset = utf8

Ctl.php
               
$this->objBasePath = Zend_Registry::get('Config');
$this->objDbAdapter = Zend_Registry::get('name');

//取得
$this->objBasePath->StrWebDomain;

JS-超連結新開視窗

//這種範例可以用於 Facebook 按下分享紐的應用 
//DEMO
TEST


//實例網站
http://pgm.nexttv.com.tw/appleenews

//實例寫法

Facebook

JQUERY與其他JS Framework並存

               




Zend-JSON讀取Function


$StrJsonName = 'Demo.js';
$StrJsonFileLink = '/';
StrJsFileLink = $StrJsonName.$StrJsonFileLink;

//生成JSON
//(數據,路徑)
    private function InJson($StrJsFileLink ,$InAryData)
    { 
        $jsonstr = json_encode($arySoft);
        $handle = fopen($InAryData, 'w');
        fwrite($handle ,$jsonstr);
        fclose($handle); 
    }
    
     $this->InJson($AryData,StrJsonName);  



//讀取JSON
//(路徑)
    function SeJson($StrJsFileLink)
    {
        return Zend_Json::decode(file_get_contents($StrJsFileLink));
    }

  $this->SeJson(StrJsFileLink);  


//未使用過方法
$arr = array("a"=> 1, "b" => 2);
$this->_helper->json($arr);

Zend-DeBugTool


DeBug              
if($this->_request->isPost()){}        //檢查Post是否有按下
if($this->_request->getPost('upCheck')){}     //檢查是否按下按鈕
var_dump($this->_request->getParams());       //列印出所有資料   

Json 

Jquery-圖片備援切換






Jquery-XXXX範例



















Class







Share
  1.  DIY
  2.  TEXT
  3.  MUSIC
  4.  VIDEO
Camera
  1.    MarryMe (婚禮)
  2.    Peoole (人像)
  3.    Business(商業)
  4.    Style(風格)


Web
  1. 作品集
  2. HTML 
  3. CSS
  4. JQUERY 
  •    DIY
  •    TOOL       
  1. PHP
  2. FUNCTION
  3. ZEND
  4. SQL 

  1. FaceBook API
  2. Picasa API

Cloud

  • AWS
http://kevintest.byethost15.com/administrator/index.php