1 |
$cell = mb_substr(strip_tags($cell),0,30,"UTF-8"); |
1 |
$cell = mb_substr(strip_tags($cell),0,30,"UTF-8"); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/'; session_write_close(); $request = array( //CURLOPT_HTTPHEADER => array('Content-type: application/x-www-form-urlencoded'), //CURLOPT_POST => false, CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17', CURLOPT_AUTOREFERER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_POSTFIELDS => http_build_query($params), CURLOPT_COOKIE => $strCookie, CURLOPT_RETURNTRANSFER => false //Important! ); |
http://www.smooka.com/blog/2009/07/24/maintaining-php-session-when-using-curl/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<table id="data_table" class="table"> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td></td> </tr> </tbody> </table> |
1 |
basename($_SERVER['PHP_SELF']); |
This works even in included page
The use operator is for giving aliases to names of classes
1 2 3 4 5 |
<form id="register_form" name="register_form" action="<?=base_url()?>index.php/api/member/register" method="post" enctype="multipart/form-data" novalidate> Name: <input type="text" name="name" /> Comment: <textarea name="comment"></textarea> <input type="submit" value="Submit Comment" /> </form> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
$(document).ready(function(){ form_funs.init(); }); var form_funs = { get_form: function(){ return $('#register_form'); }, init: function(){ var wrap = this; var $form = wrap.get_form(); var $select_field = $form.find('.file_field'); var $select_button = $form.find('.select_button'); wrap.init_form(); $select_button.on('click', function(e){ e.preventDefault(); $select_field.trigger('click'); }); }, init_form: function(){ var wrap = this; var $form = wrap.get_form(); var $submit_button = $form.find('.bt_submit'); $submit_button.on('click', function(e){ e.preventDefault(); $form.submit(); }); $form.submit(function() { $(this).ajaxSubmit({ beforeSubmit: function(arr, $form, options) { var result = wrap.validate(arr, $form); return result; }, data: { }, success: function(data, statusText, xhr, $form) { if(data.status == 'success'){ window.location.href = base_url + 'index.php/competition/upload'; }else{ alert(data.message); } }, error: function(){ alert("ERROR"); } }); return false; }); }, validate: function(arr, $form){ var wrap = this; for(var i = 0; i < arr.length; i++){ var obj = arr[i]; if(obj.type == 'textarea'){ var $e = $('#' + obj.name); if($e.hasClass('ckeditor') == true){ //arr[i].value = get_cke(obj.name); } } if(obj.required == true && (obj.value == null || obj.value == '')){ var $field = $('input[name="' + obj.name + '"]'); var label = $field.attr('title'); if(typeof label == 'undefined' || label == null){ alert('Please enter all fields.'); }else{ alert('Please enter ' + label); } $field.focus(); return false; } } if(wrap.validate_password() == false){ return false; } return true; }, validate_password: function(){ var wrap = this; var $form = wrap.get_form(); var $pw1 = $form.find('input[name="passwd"]'); var $pw2 = $form.find('input[name="confirm_passwd"]'); var length_limit = 5; if($pw1.val().length < length_limit){ alert('密碼長度至少要5個字元'); $pw1.focus(); return false; } if($pw1.val() != $pw2.val()){ alert('請確認輸入相同的密碼'); $pw2.focus(); return false; } return true; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
$seats.find('a.seat').not('.disabled').popover({ html: true, trigger: 'manual', title: function(){ return '訂票資訊'; }, content: function(){ var $this = $(this); var $c = $('<div class="pop">' + '<select name="ticket" class="input-medium"><option value="">-- 選擇票種 --</option><option value="1">學生</option></select>' + '</div>'); $c.find('select').change(function(event){ selected($(this).val(), $this); $this.addClass('selected').popover('hide'); }); return $c[0]; } }).click(function(event){ $(this).popover('toggle'); event.stopPropagation(); }); |
Note:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
<?php require_once('../includes/init_page_public.php'); //Error log error_reporting(E_ALL); set_error_handler('error_handler'); function error_handler($no, $msg, $filename, $line){ $p = 'werror_log.txt'; $handle = fopen($p, 'w+'); $err = "File name: " . $filename . "<br/>" . "Line: " . $line . "<br/>" . "Message: " . $msg . "<br/>"; //echo $err; fwrite($handle, $err . PHP_EOL); exit(); } //Process log $p = 'ipn_log.txt'; $handle = fopen($p, 'w+'); wlog('Log file created'); function wlog($msg){ global $handle; fwrite($handle, $msg . PHP_EOL); } // Read the post from PayPal and add 'cmd' $req = 'cmd=_notify-validate'; $header = ''; if(function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } $params = $_POST; foreach ($params as $key => $value) // Handle escape characters, which depends on setting of magic quotes { if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1){ $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&$key=$value"; } wlog($req); // Post back to PayPal to validate //$paypal = 'www.paypal.com'; $paypal = 'www.sandbox.paypal.com'; $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Host: " . $paypal . "\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://' . $paypal, 443, $errno, $errstr, 30); wlog($errstr); // Process validation from PayPal // TODO: This sample does not test the HTTP response code. All // HTTP response codes must be handles or you should use an HTTP // library, such as cUrl if (!$fp) { // HTTP ERROR wlog('Paypal IPN Listener - HTTP Error'); } else { // NO HTTP ERROR fputs ($fp, $header . $req); wlog($errstr); while (!feof($fp)) { $res = fgets ($fp, 1024); wlog($res); if (strcmp ($res, "VERIFIED") == 0 && strcmp ($params["payment_status"], "Completed") == 0) { wlog("response verified"); // TODO: // Check the payment_status is Completed // Check that txn_id has not been previously processed // Check that receiver_email is your Primary PayPal email // Check that payment_amount/payment_currency are correct // Process payment /* If 'VERIFIED', send an email of IPN variables and values to the specified email address foreach ($_POST as $key => $value){ $emailtext .= $key . " = " .$value ."\n\n"; } */ //Check receiver email //if(strcmp ($params["receiver_email"], "[email protected]") <> 0){ // wlog("Receiver email is not valid"); // break; //} //Check transaction id //if(strlen($err) == 0 && txnExists($params["txn_id"]) == true){ // $err = "Transaction ID: " . $params["txn_id"] . " exists already"; // break; //} //Check payment gross according to product ID //if($err == "" && checkGross($productID, $_POST["mc_gross"], $_POST["mc_currency"], $_POST["exchange_rate"]) == false){ // $err = "Payment gross amount is not equivalent to the setting of this product: " . $_POST["txn_id"]; //} $sql = "INSERT INTO `orders` (`payment_vender`, `account_id`, `product_id`, `payment_status`, `product_name`, `receiver_id`, `receiver_email`, `transaction_id`, `transaction_type`, `invoice_number`, `item_name`, `item_number`, `quantity`, `charset`, `currency`, `exchange_rate`, `fee`, `gross`, `country`, `payer_email`, `payment_date`, `created_time`, `updated_time`) VALUES (" . $db->formatSQLInput(1) . ", " . $db->formatSQLInput(0) . ", " . $db->formatSQLInput(0) . ", " . $db->formatSQLInput($params['payment_status']) . ", " . $db->formatSQLInput('Test') . ", " . $db->formatSQLInput($params['receiver_id']) . ", " . $db->formatSQLInput($params['receiver_email']) . ", " . $db->formatSQLInput($params['txn_id']) . ", " . $db->formatSQLInput($params['txn_type']) . ", " . $db->formatSQLInput($params['invoice']) . ", " . $db->formatSQLInput($params['item_name']) . ", " . $db->formatSQLInput($params['item_number']) . ", " . $db->formatSQLInput($params['quantity']) . ", " . $db->formatSQLInput($util->out($params, 'charset', 'UTF-8')) . ", " . $db->formatSQLInput($util->out($params, 'mc_currency', 'USD')) . ", " . $db->formatSQLInput($util->out($params, 'exchange_rate', '')) . ", " . $db->formatSQLInput($params['mc_fee']) . ", " . $db->formatSQLInput($params['mc_gross']) . ", " . $db->formatSQLInput($params['residence_country']) . ", " . $db->formatSQLInput($params['payer_email']) . ", " . $db->format_sql_date($params['payment_date']) . ", " . $db->format_sql_date(NULL, true) . ", " . $db->format_sql_date(NULL, true) . " " . ")"; wlog($sql); $rs = $db->query($sql); } else if (strcmp ($res, "INVALID") == 0) { //If 'INVALID', send an email. TODO: Log for manual investigation. $values = 'response: INVALID'; wlog($values); } } } fclose($fp); if($err == ""){ wlog("Store Listener - Completed", "Transaction"); }else{ wlog("Store Listener - Error"); } ?> |
Reference:
1 2 3 4 5 6 7 8 9 10 11 12 |
var versions = []; var version = {}; version.folder = 'banners'; version.width = 1000; version.height = 600; version.crop = 'true'; version.root = 'true'; versions.push(version); console.log(JSON.stringify(versions)); // [{"folder":"banners","width":1000,"height":600,"crop":"true","root":"true"}] |
Use CSS instead of “columnDefs”:
Reference:
CSS:
1 |
#film_table tr.row_selected td{background:#CCC;} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
var cat_id = 1; var d_table = null; var order = [[ 6, "asc" ], [ 5, "" ]]; var selected_id = 0; var datatable = { init: function(){ var wrap = this; d_table = $('#datatable').dataTable( { 'pageLength': 20, //20 items per page "lengthMenu": [[20, 50, -1], [20, 50, "All"]], "ajax": { 'url': '<?=base_url()?>index.php/admin/page/all/' + cat_id, 'data': function(d){ d.param = 'value'; } }, "order": order, "columnDefs": [ { "targets": [ 6 ], "visible": false, "searchable": false, "orderable": false, "className": "class_name" } ], 'fnServerParams': function(aoData){ //Append extra parameters //console.log(aoData); aoData.push({ 'name': 'countries', 'value': $('#country').val() }); }, //This callback will be triggered multiple times "drawCallback": function( settings ) { var api = this.api(); wrap.loaded(settings); }, //This callback will be triggered only once "fnInitComplete": function(oSettings, json) { console.log('fnInitComplete'); console.log($('#datatable input[name="users"]').size()); } }); $('#datatable tbody').on( 'click', 'tr', function () { if ( $(this).hasClass('selected') ) { $(this).removeClass('selected'); }else { d_table.$('tr.selected').removeClass('selected'); $(this).addClass('selected'); } //console.log( table.row( this ).data() ); selected_id = wrap.get_id($(this)); $('#item_id').val(selected_id); }); $('#datatable tbody').on( 'click', '.edit_item', function (e) { e.preventDefault(); window.location.href = '<?=base_url()?>index.php/admin/page/edit/' + cat_id + '/' + selected_id; }); $('#datatable tbody').on( 'click', '.sort_up', function (e) { e.preventDefault(); var cat_id = $('#cat_id').val(); wrap.sort(cat_id, selected_id, 'up'); }); $('#datatable tbody').on( 'click', '.sort_down', function (e) { e.preventDefault(); var cat_id = $('#cat_id').val(); wrap.sort(cat_id, selected_id, 'down'); }); }, loaded: function(oSettings){ //Table loaded var wrap = datatable; var $table = $('#datatable'); $table.find('tbody tr').unbind().on( 'click', function () { if ( $(this).hasClass('selected') ) { $(this).removeClass('selected'); }else { d_table.$('tr.selected').removeClass('selected'); $(this).addClass('selected'); } //console.log( table.row( this ).data() ); selected_id = wrap.get_id($(this)); $('#item_id').val(selected_id); }); $table.find('.edit_item').unbind().on( 'click', function (e) { e.preventDefault(); window.location.href = '<?=base_url()?>index.php/admin/product/edit/' + cat_id + '/' + selected_id; }); }, get_id: function($row){ return $row.find('>td:first').text(); }, refresh: function(){ var wrap = this; d_table.fnDestroy(); wrap.init(); }, delete_item: function(){ var wrap = this; var params = { id: selected_id } $.ajax('<?=base_url()?>index.php/admin/page/delete', { type: 'POST', data: params, success: function(data, textStatus, jqXHR){ //console.log(data); if(typeof data.err_code == 'undefined'){ show_msg('Error', data); }else if(data.err_code == 0){ //show_msg('Info', 'Item has been deleted'); window.location.reload(); }else{ show_error(data.err_code, data.err); } }, error: function(jqXHR, textStatus, errorThrown){ alert('Error:' + jqXHR.responseText); wrapper.refresh_tree(); } }); }, sort: function(cat_id, selected_id, direction){ var wrap = this; var params = { cat_id: cat_id, id: selected_id, direction: direction, sort_direction: 'desc' } $.ajax('<?=base_url()?>index.php/admin/page/sort', { type: 'POST', data: params, success: function(data, textStatus, jqXHR){ //console.log(data.err_code == 0 && err == ''); //return; if(typeof data.err_code == 'undefined'){ show_msg('Error', data); }else if(data.err_code == 0 && data.err == ''){ //console.log(wrap); //window.location.reload(); wrap.refresh(); }else{ show_error(data.err_code, data.err); } }, error: function(jqXHR, textStatus, errorThrown){ alert('Error:' + jqXHR.responseText); } }); } } |
Localized txt file content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
{ "sProcessing": "處理中...", "sLengthMenu": "_MENU_ <span>筆/頁</span>", "sZeroRecords": "沒有資料.", "sInfo": "顯示 <span>_START_</span> 到 <span>_END_</span> 共 <span>_TOTAL_</span> 筆資料", "sInfoEmpty": "顯示 <span>0</span> 到 <span>0</span> 共 <span>0</span> 筆資料", "sInfoFiltered": "(gefiltert von _MAX_ Einträgen)", "sInfoPostFix": "", "sSearch": "<span>查詢:</span> ", "sUrl": "", "oPaginate": { "sFirst": "第一頁", "sPrevious": "上一頁", "sNext": "下一頁", "sLast": "最後一頁" } } |
Reference: