sms5 추가
This commit is contained in:
933
plugin/sms5/JSON.php
Normal file
933
plugin/sms5/JSON.php
Normal file
@ -0,0 +1,933 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
/**
|
||||
* Converts to and from JSON format.
|
||||
*
|
||||
* JSON (JavaScript Object Notation) is a lightweight data-interchange
|
||||
* format. It is easy for humans to read and write. It is easy for machines
|
||||
* to parse and generate. It is based on a subset of the JavaScript
|
||||
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
|
||||
* This feature can also be found in Python. JSON is a text format that is
|
||||
* completely language independent but uses conventions that are familiar
|
||||
* to programmers of the C-family of languages, including C, C++, C#, Java,
|
||||
* JavaScript, Perl, TCL, and many others. These properties make JSON an
|
||||
* ideal data-interchange language.
|
||||
*
|
||||
* This package provides a simple encoder and decoder for JSON notation. It
|
||||
* is intended for use with client-side Javascript applications that make
|
||||
* use of HTTPRequest to perform server communication functions - data can
|
||||
* be encoded into JSON notation for use in a client-side javascript, or
|
||||
* decoded from incoming Javascript requests. JSON format is native to
|
||||
* Javascript, and can be directly eval()'ed with no further parsing
|
||||
* overhead
|
||||
*
|
||||
* All strings should be in ASCII or UTF-8 format!
|
||||
*
|
||||
* LICENSE: Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met: Redistributions of source code must retain the
|
||||
* above copyright notice, this list of conditions and the following
|
||||
* disclaimer. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* @category
|
||||
* @package Services_JSON
|
||||
* @author Michal Migurski <mike-json@teczno.com>
|
||||
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
|
||||
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
|
||||
* @copyright 2005 Michal Migurski
|
||||
* @version CVS: $Id: JSON.php 305040 2010-11-02 23:19:03Z alan_k $
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
|
||||
*/
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_SLICE', 1);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_STR', 2);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_ARR', 3);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_OBJ', 4);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_CMT', 5);
|
||||
|
||||
/**
|
||||
* Behavior switch for Services_JSON::decode()
|
||||
*/
|
||||
define('SERVICES_JSON_LOOSE_TYPE', 16);
|
||||
|
||||
/**
|
||||
* Behavior switch for Services_JSON::decode()
|
||||
*/
|
||||
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
|
||||
|
||||
/**
|
||||
* Behavior switch for Services_JSON::decode()
|
||||
*/
|
||||
define('SERVICES_JSON_USE_TO_JSON', 64);
|
||||
|
||||
/**
|
||||
* Converts to and from JSON format.
|
||||
*
|
||||
* Brief example of use:
|
||||
*
|
||||
* <code>
|
||||
* // create a new instance of Services_JSON
|
||||
* $json = new Services_JSON();
|
||||
*
|
||||
* // convert a complexe value to JSON notation, and send it to the browser
|
||||
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
|
||||
* $output = $json->encode($value);
|
||||
*
|
||||
* print($output);
|
||||
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
|
||||
*
|
||||
* // accept incoming POST data, assumed to be in JSON notation
|
||||
* $input = file_get_contents('php://input', 1000000);
|
||||
* $value = $json->decode($input);
|
||||
* </code>
|
||||
*/
|
||||
class Services_JSON
|
||||
{
|
||||
/**
|
||||
* constructs a new JSON instance
|
||||
*
|
||||
* @param int $use object behavior flags; combine with boolean-OR
|
||||
*
|
||||
* possible values:
|
||||
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
|
||||
* "{...}" syntax creates associative arrays
|
||||
* instead of objects in decode().
|
||||
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
|
||||
* Values which can't be encoded (e.g. resources)
|
||||
* appear as NULL instead of throwing errors.
|
||||
* By default, a deeply-nested resource will
|
||||
* bubble up with an error, so all return values
|
||||
* from encode() should be checked with isError()
|
||||
* - SERVICES_JSON_USE_TO_JSON: call toJSON when serializing objects
|
||||
* It serializes the return value from the toJSON call rather
|
||||
* than the object it'self, toJSON can return associative arrays,
|
||||
* strings or numbers, if you return an object, make sure it does
|
||||
* not have a toJSON method, otherwise an error will occur.
|
||||
*/
|
||||
function Services_JSON($use = 0)
|
||||
{
|
||||
$this->use = $use;
|
||||
$this->_mb_strlen = function_exists('mb_strlen');
|
||||
$this->_mb_convert_encoding = function_exists('mb_convert_encoding');
|
||||
$this->_mb_substr = function_exists('mb_substr');
|
||||
}
|
||||
// private - cache the mbstring lookup results..
|
||||
var $_mb_strlen = false;
|
||||
var $_mb_substr = false;
|
||||
var $_mb_convert_encoding = false;
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-16 char to one UTF-8 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf16 UTF-16 character
|
||||
* @return string UTF-8 character
|
||||
* @access private
|
||||
*/
|
||||
function utf162utf8($utf16)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if($this->_mb_convert_encoding) {
|
||||
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
|
||||
}
|
||||
|
||||
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
|
||||
|
||||
switch(true) {
|
||||
case ((0x7F & $bytes) == $bytes):
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x7F & $bytes);
|
||||
|
||||
case (0x07FF & $bytes) == $bytes:
|
||||
// return a 2-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xC0 | (($bytes >> 6) & 0x1F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
|
||||
case (0xFFFF & $bytes) == $bytes:
|
||||
// return a 3-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xE0 | (($bytes >> 12) & 0x0F))
|
||||
. chr(0x80 | (($bytes >> 6) & 0x3F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
}
|
||||
|
||||
// ignoring UTF-32 for now, sorry
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-8 char to one UTF-16 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf8 UTF-8 character
|
||||
* @return string UTF-16 character
|
||||
* @access private
|
||||
*/
|
||||
function utf82utf16($utf8)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if($this->_mb_convert_encoding) {
|
||||
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
||||
}
|
||||
|
||||
switch($this->strlen8($utf8)) {
|
||||
case 1:
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return $utf8;
|
||||
|
||||
case 2:
|
||||
// return a UTF-16 character from a 2-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x07 & (ord($utf8{0}) >> 2))
|
||||
. chr((0xC0 & (ord($utf8{0}) << 6))
|
||||
| (0x3F & ord($utf8{1})));
|
||||
|
||||
case 3:
|
||||
// return a UTF-16 character from a 3-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr((0xF0 & (ord($utf8{0}) << 4))
|
||||
| (0x0F & (ord($utf8{1}) >> 2)))
|
||||
. chr((0xC0 & (ord($utf8{1}) << 6))
|
||||
| (0x7F & ord($utf8{2})));
|
||||
}
|
||||
|
||||
// ignoring UTF-32 for now, sorry
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* encodes an arbitrary variable into JSON format (and sends JSON Header)
|
||||
*
|
||||
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
||||
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
||||
* if var is a strng, note that encode() always expects it
|
||||
* to be in ASCII or UTF-8 format!
|
||||
*
|
||||
* @return mixed JSON string representation of input var or an error if a problem occurs
|
||||
* @access public
|
||||
*/
|
||||
function encode($var)
|
||||
{
|
||||
header('Content-type: application/json');
|
||||
return $this->encodeUnsafe($var);
|
||||
}
|
||||
/**
|
||||
* encodes an arbitrary variable into JSON format without JSON Header - warning - may allow XSS!!!!)
|
||||
*
|
||||
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
||||
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
||||
* if var is a strng, note that encode() always expects it
|
||||
* to be in ASCII or UTF-8 format!
|
||||
*
|
||||
* @return mixed JSON string representation of input var or an error if a problem occurs
|
||||
* @access public
|
||||
*/
|
||||
function encodeUnsafe($var)
|
||||
{
|
||||
// see bug #16908 - regarding numeric locale printing
|
||||
$lc = setlocale(LC_NUMERIC, 0);
|
||||
setlocale(LC_NUMERIC, 'C');
|
||||
$ret = $this->_encode($var);
|
||||
setlocale(LC_NUMERIC, $lc);
|
||||
return $ret;
|
||||
|
||||
}
|
||||
/**
|
||||
* PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format
|
||||
*
|
||||
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
||||
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
||||
* if var is a strng, note that encode() always expects it
|
||||
* to be in ASCII or UTF-8 format!
|
||||
*
|
||||
* @return mixed JSON string representation of input var or an error if a problem occurs
|
||||
* @access public
|
||||
*/
|
||||
function _encode($var)
|
||||
{
|
||||
|
||||
switch (gettype($var)) {
|
||||
case 'boolean':
|
||||
return $var ? 'true' : 'false';
|
||||
|
||||
case 'NULL':
|
||||
return 'null';
|
||||
|
||||
case 'integer':
|
||||
return (int) $var;
|
||||
|
||||
case 'double':
|
||||
case 'float':
|
||||
return (float) $var;
|
||||
|
||||
case 'string':
|
||||
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
|
||||
$ascii = '';
|
||||
$strlen_var = $this->strlen8($var);
|
||||
|
||||
/*
|
||||
* Iterate over every character in the string,
|
||||
* escaping with a slash or encoding to UTF-8 where necessary
|
||||
*/
|
||||
for ($c = 0; $c < $strlen_var; ++$c) {
|
||||
|
||||
$ord_var_c = ord($var{$c});
|
||||
|
||||
switch (true) {
|
||||
case $ord_var_c == 0x08:
|
||||
$ascii .= '\b';
|
||||
break;
|
||||
case $ord_var_c == 0x09:
|
||||
$ascii .= '\t';
|
||||
break;
|
||||
case $ord_var_c == 0x0A:
|
||||
$ascii .= '\n';
|
||||
break;
|
||||
case $ord_var_c == 0x0C:
|
||||
$ascii .= '\f';
|
||||
break;
|
||||
case $ord_var_c == 0x0D:
|
||||
$ascii .= '\r';
|
||||
break;
|
||||
|
||||
case $ord_var_c == 0x22:
|
||||
case $ord_var_c == 0x2F:
|
||||
case $ord_var_c == 0x5C:
|
||||
// double quote, slash, slosh
|
||||
$ascii .= '\\'.$var{$c};
|
||||
break;
|
||||
|
||||
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
|
||||
// characters U-00000000 - U-0000007F (same as ASCII)
|
||||
$ascii .= $var{$c};
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xE0) == 0xC0):
|
||||
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
if ($c+1 >= $strlen_var) {
|
||||
$c += 1;
|
||||
$ascii .= '?';
|
||||
break;
|
||||
}
|
||||
|
||||
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
|
||||
$c += 1;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xF0) == 0xE0):
|
||||
if ($c+2 >= $strlen_var) {
|
||||
$c += 2;
|
||||
$ascii .= '?';
|
||||
break;
|
||||
}
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
@ord($var{$c + 1}),
|
||||
@ord($var{$c + 2}));
|
||||
$c += 2;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xF8) == 0xF0):
|
||||
if ($c+3 >= $strlen_var) {
|
||||
$c += 3;
|
||||
$ascii .= '?';
|
||||
break;
|
||||
}
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}));
|
||||
$c += 3;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xFC) == 0xF8):
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
if ($c+4 >= $strlen_var) {
|
||||
$c += 4;
|
||||
$ascii .= '?';
|
||||
break;
|
||||
}
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}));
|
||||
$c += 4;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xFE) == 0xFC):
|
||||
if ($c+5 >= $strlen_var) {
|
||||
$c += 5;
|
||||
$ascii .= '?';
|
||||
break;
|
||||
}
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}),
|
||||
ord($var{$c + 5}));
|
||||
$c += 5;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return '"'.$ascii.'"';
|
||||
|
||||
case 'array':
|
||||
/*
|
||||
* As per JSON spec if any array key is not an integer
|
||||
* we must treat the the whole array as an object. We
|
||||
* also try to catch a sparsely populated associative
|
||||
* array with numeric keys here because some JS engines
|
||||
* will create an array with empty indexes up to
|
||||
* max_index which can cause memory issues and because
|
||||
* the keys, which may be relevant, will be remapped
|
||||
* otherwise.
|
||||
*
|
||||
* As per the ECMA and JSON specification an object may
|
||||
* have any string as a property. Unfortunately due to
|
||||
* a hole in the ECMA specification if the key is a
|
||||
* ECMA reserved word or starts with a digit the
|
||||
* parameter is only accessible using ECMAScript's
|
||||
* bracket notation.
|
||||
*/
|
||||
|
||||
// treat as a JSON object
|
||||
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($var),
|
||||
array_values($var));
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
||||
return '{' . join(',', $properties) . '}';
|
||||
}
|
||||
|
||||
// treat it like a regular array
|
||||
$elements = array_map(array($this, '_encode'), $var);
|
||||
|
||||
foreach($elements as $element) {
|
||||
if(Services_JSON::isError($element)) {
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
||||
return '[' . join(',', $elements) . ']';
|
||||
|
||||
case 'object':
|
||||
|
||||
// support toJSON methods.
|
||||
if (($this->use & SERVICES_JSON_USE_TO_JSON) && method_exists($var, 'toJSON')) {
|
||||
// this may end up allowing unlimited recursion
|
||||
// so we check the return value to make sure it's not got the same method.
|
||||
$recode = $var->toJSON();
|
||||
|
||||
if (method_exists($recode, 'toJSON')) {
|
||||
|
||||
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
|
||||
? 'null'
|
||||
: new Services_JSON_Error(class_name($var).
|
||||
" toJSON returned an object with a toJSON method.");
|
||||
|
||||
}
|
||||
|
||||
return $this->_encode( $recode );
|
||||
}
|
||||
|
||||
$vars = get_object_vars($var);
|
||||
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($vars),
|
||||
array_values($vars));
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
||||
return '{' . join(',', $properties) . '}';
|
||||
|
||||
default:
|
||||
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
|
||||
? 'null'
|
||||
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* array-walking function for use in generating JSON-formatted name-value pairs
|
||||
*
|
||||
* @param string $name name of key to use
|
||||
* @param mixed $value reference to an array element to be encoded
|
||||
*
|
||||
* @return string JSON-formatted name-value pair, like '"name":value'
|
||||
* @access private
|
||||
*/
|
||||
function name_value($name, $value)
|
||||
{
|
||||
$encoded_value = $this->_encode($value);
|
||||
|
||||
if(Services_JSON::isError($encoded_value)) {
|
||||
return $encoded_value;
|
||||
}
|
||||
|
||||
return $this->_encode(strval($name)) . ':' . $encoded_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* reduce a string by removing leading and trailing comments and whitespace
|
||||
*
|
||||
* @param $str string string value to strip of comments and whitespace
|
||||
*
|
||||
* @return string string value stripped of comments and whitespace
|
||||
* @access private
|
||||
*/
|
||||
function reduce_string($str)
|
||||
{
|
||||
$str = preg_replace(array(
|
||||
|
||||
// eliminate single line comments in '// ...' form
|
||||
'#^\s*//(.+)$#m',
|
||||
|
||||
// eliminate multi-line comments in '/* ... */' form, at start of string
|
||||
'#^\s*/\*(.+)\*/#Us',
|
||||
|
||||
// eliminate multi-line comments in '/* ... */' form, at end of string
|
||||
'#/\*(.+)\*/\s*$#Us'
|
||||
|
||||
), '', $str);
|
||||
|
||||
// eliminate extraneous space
|
||||
return trim($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* decodes a JSON string into appropriate variable
|
||||
*
|
||||
* @param string $str JSON-formatted string
|
||||
*
|
||||
* @return mixed number, boolean, string, array, or object
|
||||
* corresponding to given JSON input string.
|
||||
* See argument 1 to Services_JSON() above for object-output behavior.
|
||||
* Note that decode() always returns strings
|
||||
* in ASCII or UTF-8 format!
|
||||
* @access public
|
||||
*/
|
||||
function decode($str)
|
||||
{
|
||||
$str = $this->reduce_string($str);
|
||||
|
||||
switch (strtolower($str)) {
|
||||
case 'true':
|
||||
return true;
|
||||
|
||||
case 'false':
|
||||
return false;
|
||||
|
||||
case 'null':
|
||||
return null;
|
||||
|
||||
default:
|
||||
$m = array();
|
||||
|
||||
if (is_numeric($str)) {
|
||||
// Lookie-loo, it's a number
|
||||
|
||||
// This would work on its own, but I'm trying to be
|
||||
// good about returning integers where appropriate:
|
||||
// return (float)$str;
|
||||
|
||||
// Return float or int, as appropriate
|
||||
return ((float)$str == (integer)$str)
|
||||
? (integer)$str
|
||||
: (float)$str;
|
||||
|
||||
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
|
||||
// STRINGS RETURNED IN UTF-8 FORMAT
|
||||
$delim = $this->substr8($str, 0, 1);
|
||||
$chrs = $this->substr8($str, 1, -1);
|
||||
$utf8 = '';
|
||||
$strlen_chrs = $this->strlen8($chrs);
|
||||
|
||||
for ($c = 0; $c < $strlen_chrs; ++$c) {
|
||||
|
||||
$substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
|
||||
$ord_chrs_c = ord($chrs{$c});
|
||||
|
||||
switch (true) {
|
||||
case $substr_chrs_c_2 == '\b':
|
||||
$utf8 .= chr(0x08);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\t':
|
||||
$utf8 .= chr(0x09);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\n':
|
||||
$utf8 .= chr(0x0A);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\f':
|
||||
$utf8 .= chr(0x0C);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\r':
|
||||
$utf8 .= chr(0x0D);
|
||||
++$c;
|
||||
break;
|
||||
|
||||
case $substr_chrs_c_2 == '\\"':
|
||||
case $substr_chrs_c_2 == '\\\'':
|
||||
case $substr_chrs_c_2 == '\\\\':
|
||||
case $substr_chrs_c_2 == '\\/':
|
||||
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
|
||||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
|
||||
$utf8 .= $chrs{++$c};
|
||||
}
|
||||
break;
|
||||
|
||||
case preg_match('/\\\u[0-9A-F]{4}/i', $this->substr8($chrs, $c, 6)):
|
||||
// single, escaped unicode character
|
||||
$utf16 = chr(hexdec($this->substr8($chrs, ($c + 2), 2)))
|
||||
. chr(hexdec($this->substr8($chrs, ($c + 4), 2)));
|
||||
$utf8 .= $this->utf162utf8($utf16);
|
||||
$c += 5;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
|
||||
$utf8 .= $chrs{$c};
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xE0) == 0xC0:
|
||||
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
||||
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= $this->substr8($chrs, $c, 2);
|
||||
++$c;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xF0) == 0xE0:
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= $this->substr8($chrs, $c, 3);
|
||||
$c += 2;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xF8) == 0xF0:
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= $this->substr8($chrs, $c, 4);
|
||||
$c += 3;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xFC) == 0xF8:
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= $this->substr8($chrs, $c, 5);
|
||||
$c += 4;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xFE) == 0xFC:
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= $this->substr8($chrs, $c, 6);
|
||||
$c += 5;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $utf8;
|
||||
|
||||
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
|
||||
// array, or object notation
|
||||
|
||||
if ($str{0} == '[') {
|
||||
$stk = array(SERVICES_JSON_IN_ARR);
|
||||
$arr = array();
|
||||
} else {
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$stk = array(SERVICES_JSON_IN_OBJ);
|
||||
$obj = array();
|
||||
} else {
|
||||
$stk = array(SERVICES_JSON_IN_OBJ);
|
||||
$obj = new stdClass();
|
||||
}
|
||||
}
|
||||
|
||||
array_push($stk, array('what' => SERVICES_JSON_SLICE,
|
||||
'where' => 0,
|
||||
'delim' => false));
|
||||
|
||||
$chrs = $this->substr8($str, 1, -1);
|
||||
$chrs = $this->reduce_string($chrs);
|
||||
|
||||
if ($chrs == '') {
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} else {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//print("\nparsing {$chrs}\n");
|
||||
|
||||
$strlen_chrs = $this->strlen8($chrs);
|
||||
|
||||
for ($c = 0; $c <= $strlen_chrs; ++$c) {
|
||||
|
||||
$top = end($stk);
|
||||
$substr_chrs_c_2 = $this->substr8($chrs, $c, 2);
|
||||
|
||||
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
|
||||
// found a comma that is not inside a string, array, etc.,
|
||||
// OR we've reached the end of the character list
|
||||
$slice = $this->substr8($chrs, $top['where'], ($c - $top['where']));
|
||||
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
|
||||
//print("Found split at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
// we are in an array, so just push an element onto the stack
|
||||
array_push($arr, $this->decode($slice));
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
// we are in an object, so figure
|
||||
// out the property name and set an
|
||||
// element in an associative array,
|
||||
// for now
|
||||
$parts = array();
|
||||
|
||||
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:/Uis', $slice, $parts)) {
|
||||
// "name":value pair
|
||||
$key = $this->decode($parts[1]);
|
||||
$val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$obj[$key] = $val;
|
||||
} else {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
} elseif (preg_match('/^\s*(\w+)\s*:/Uis', $slice, $parts)) {
|
||||
// name:value pair, where name is unquoted
|
||||
$key = $parts[1];
|
||||
$val = $this->decode(trim(substr($slice, strlen($parts[0])), ", \t\n\r\0\x0B"));
|
||||
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$obj[$key] = $val;
|
||||
} else {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
|
||||
// found a quote, and we are not inside a string
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
|
||||
//print("Found start of string at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == $top['delim']) &&
|
||||
($top['what'] == SERVICES_JSON_IN_STR) &&
|
||||
(($this->strlen8($this->substr8($chrs, 0, $c)) - $this->strlen8(rtrim($this->substr8($chrs, 0, $c), '\\'))) % 2 != 1)) {
|
||||
// found a quote, we're in a string, and it's not escaped
|
||||
// we know that it's not escaped becase there is _not_ an
|
||||
// odd number of backslashes at the end of the string so far
|
||||
array_pop($stk);
|
||||
//print("Found end of string at {$c}: ".$this->substr8($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($chrs{$c} == '[') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-bracket, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of array at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
|
||||
// found a right-bracket, and we're in an array
|
||||
array_pop($stk);
|
||||
//print("Found end of array at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($chrs{$c} == '{') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-brace, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of object at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
|
||||
// found a right-brace, and we're in an object
|
||||
array_pop($stk);
|
||||
//print("Found end of object at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($substr_chrs_c_2 == '/*') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a comment start, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
|
||||
$c++;
|
||||
//print("Found start of comment at {$c}\n");
|
||||
|
||||
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
|
||||
// found a comment end, and we're in one now
|
||||
array_pop($stk);
|
||||
$c++;
|
||||
|
||||
for ($i = $top['where']; $i <= $c; ++$i)
|
||||
$chrs = substr_replace($chrs, ' ', $i, 1);
|
||||
|
||||
//print("Found end of comment at {$c}: ".$this->substr8($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Ultimately, this should just call PEAR::isError()
|
||||
*/
|
||||
function isError($data, $code = null)
|
||||
{
|
||||
if (class_exists('pear')) {
|
||||
return PEAR::isError($data, $code);
|
||||
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
|
||||
is_subclass_of($data, 'services_json_error'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates length of string in bytes
|
||||
* @param string
|
||||
* @return integer length
|
||||
*/
|
||||
function strlen8( $str )
|
||||
{
|
||||
if ( $this->_mb_strlen ) {
|
||||
return mb_strlen( $str, "8bit" );
|
||||
}
|
||||
return strlen( $str );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns part of a string, interpreting $start and $length as number of bytes.
|
||||
* @param string
|
||||
* @param integer start
|
||||
* @param integer length
|
||||
* @return integer length
|
||||
*/
|
||||
function substr8( $string, $start, $length=false )
|
||||
{
|
||||
if ( $length === false ) {
|
||||
$length = $this->strlen8( $string ) - $start;
|
||||
}
|
||||
if ( $this->_mb_substr ) {
|
||||
return mb_substr( $string, $start, $length, "8bit" );
|
||||
}
|
||||
return substr( $string, $start, $length );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (class_exists('PEAR_Error')) {
|
||||
|
||||
class Services_JSON_Error extends PEAR_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* @todo Ultimately, this class shall be descended from PEAR_Error
|
||||
*/
|
||||
class Services_JSON_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
3
plugin/sms5/_common.php
Normal file
3
plugin/sms5/_common.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
include_once('../../common.php');
|
||||
?>
|
||||
70
plugin/sms5/ajax.sms_emoticon.php
Normal file
70
plugin/sms5/ajax.sms_emoticon.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
include_once("./_common.php");
|
||||
include_once("./JSON.php");
|
||||
|
||||
if( !function_exists('json_encode') ) {
|
||||
function json_encode($data) {
|
||||
$json = new Services_JSON();
|
||||
return( $json->encode($data) );
|
||||
}
|
||||
}
|
||||
|
||||
$page_size = 9;
|
||||
|
||||
if (!$page) $page = 1;
|
||||
|
||||
if (is_numeric($fg_no))
|
||||
$sql_group = " and fg_no='$fg_no' ";
|
||||
else
|
||||
$sql_group = "";
|
||||
|
||||
if ($st == 'all') {
|
||||
$sql_search = "and (fo_name like '%{$sv}%' or fo_content like '%{$sv}%')";
|
||||
} else if ($st == 'name') {
|
||||
$sql_search = "and fo_name like '%{$sv}%'";
|
||||
} else if ($st == 'content') {
|
||||
$sql_search = "and fo_content like '%{$sv}%'";
|
||||
} else {
|
||||
$sql_search = '';
|
||||
}
|
||||
|
||||
$total_res = sql_fetch("select count(*) as cnt from {$g5['sms5_form_table']} where fg_member = 1 $sql_group $sql_search");
|
||||
$total_count = $total_res['cnt'];
|
||||
|
||||
$total_page = (int)($total_count/$page_size) + ($total_count%$page_size==0 ? 0 : 1);
|
||||
$page_start = $page_size * ( $page - 1 );
|
||||
|
||||
$vnum = $total_count - (($page-1) * $page_size);
|
||||
|
||||
$group = array();
|
||||
$qry = sql_query("select * from {$g5['sms5_form_group_table']} where fg_member = 1 order by fg_name");
|
||||
while ($res = sql_fetch_array($qry)) array_push($group, $res);
|
||||
|
||||
$res = sql_fetch("select count(*) as cnt from {$g5['sms5_form_table']} where fg_no=0");
|
||||
$no_count = $res['cnt'];
|
||||
|
||||
$count = 1;
|
||||
$qry = sql_query("select * from {$g5['sms5_form_table']} where fg_member = 1 $sql_group $sql_search order by fo_no desc limit $page_start, $page_size");
|
||||
$list_text = array();
|
||||
|
||||
for($k=0;$res = sql_fetch_array($qry);$k++)
|
||||
{
|
||||
$tmp = sql_fetch("select fg_name from {$g5['sms5_form_group_table']} where fg_no='{$res['fg_no']}'");
|
||||
if (!$tmp)
|
||||
$group_name = '미분류';
|
||||
else
|
||||
$group_name = $tmp['fg_name'];
|
||||
|
||||
$list_text[$k]['fo_no'] = $res['fo_no'];
|
||||
$list_text[$k]['fo_content'] = $res['fo_content'];
|
||||
$list_text[$k]['fo_content'] = $res['fo_content'];
|
||||
$list_text[$k]['fo_name'] = cut_str($res['fo_name'],20);
|
||||
}
|
||||
|
||||
$arr_ajax_msg['error'] = "";
|
||||
$arr_ajax_msg['list_text'] = $list_text;
|
||||
$arr_ajax_msg['page'] = $page;
|
||||
$arr_ajax_msg['total_count'] = $total_count;
|
||||
$arr_ajax_msg['total_page'] = $total_page;
|
||||
die( json_encode($arr_ajax_msg) );
|
||||
?>
|
||||
11
plugin/sms5/index.php
Normal file
11
plugin/sms5/index.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
//SMS5 메인
|
||||
include_once('./_common.php');
|
||||
|
||||
$g5['title'] = "SMS5";
|
||||
include_once(G5_PATH.'/head.sub.php');
|
||||
|
||||
include_once("./write.php");
|
||||
|
||||
include_once(G5_PATH.'/tail.sub.php');
|
||||
?>
|
||||
BIN
plugin/sms5/skin/basic/img/ajax-loader.gif
Normal file
BIN
plugin/sms5/skin/basic/img/ajax-loader.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
plugin/sms5/skin/basic/img/box_ico.gif
Normal file
BIN
plugin/sms5/skin/basic/img/box_ico.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 60 B |
BIN
plugin/sms5/skin/basic/img/scemo_ico.gif
Normal file
BIN
plugin/sms5/skin/basic/img/scemo_ico.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 B |
48
plugin/sms5/skin/basic/mobile.css
Normal file
48
plugin/sms5/skin/basic/mobile.css
Normal file
@ -0,0 +1,48 @@
|
||||
#sms5_send {position:relative}
|
||||
|
||||
.sms5_box {position:relative;padding:10px;border-radius:5px;background:#fbec99}
|
||||
.sms5_box .box_ico {position:absolute;top:20px;left:-7px;width:7px;height:13px;background:url('img/box_ico.gif') no-repeat}
|
||||
.sms5_box .box_txt {border:0;background:transparent;word-break:break-all;resize:none;overflow:hidden}
|
||||
.sms5_box .box_square {width:100px;height:90px}
|
||||
|
||||
#send_write {padding:0 20px !important}
|
||||
#send_write h2 {padding:0 0 10px}
|
||||
#send_write .sms5_box {margin:0 0 5px;text-align:center}
|
||||
#send_write .box_txt {width:90%;height:80px}
|
||||
#wr_message_lbl {position:absolute;top:45px;left:48%;color:#999;font-size:0.95em;letter-spacing:-0.1em}
|
||||
|
||||
.write_inner {position:relative;padding:10px 0;border-bottom:1px solid #efefef;zoom:1}
|
||||
.write_inner:after {display:block;visibility:hidden;clear:both;content:''}
|
||||
.write_inner h2 {margin:0;padding:0 0 20px !important}
|
||||
.write_floater {position:absolute;top:10px;right:0;text-align:right}
|
||||
.write_floater_btn {margin:0;padding:0;border:0;background:transparent;color:#999;font-size:0.95em;letter-spacing:-0.1em}
|
||||
|
||||
#write_rcv {margin:0 0 10px}
|
||||
#write_rcv strong {display:inline-block;margin:0 10px 0 0}
|
||||
#write_reply label {display:inline-block;margin:0 10px 0 0;font-weight:bold}
|
||||
#write_reply #mh_reply {padding:0 5px;width:90px;height:20px;border:1px solid #e9e9e9;text-align:center;line-height:1.8em}
|
||||
|
||||
#write_rsv .rsv_line {display:block;height:10px}
|
||||
|
||||
.write_scemo strong {display:block;margin:0 0 10px}
|
||||
.write_scemo .scemo_btn {margin:0 0 1px;padding:10px 0;width:100%;border:0;background:#686868;color:#fff;text-align:center}
|
||||
.write_scemo .scemo_list {display:none;letter-spacing:-4px}
|
||||
.write_scemo .list_closer {margin:5px 0;text-align:right}
|
||||
.write_scemo .list_closer_btn {margin:0;padding:10px 0;width:100%;border:0;background:#383838;color:#fff;letter-spacing:0}
|
||||
.write_scemo .scemo_add {margin:0;padding:0;width:25%;height:40px;border:1px solid #e9e9e9;background:transparent;letter-spacing:0}
|
||||
#write_sc .scemo_list {margin:0 0 20px}
|
||||
|
||||
#sms_byte {position:absolute;top:-27px;right:0;color:#999}
|
||||
|
||||
#send_emo {position:relative;padding:20px;border-top:1px solid #e9e9e9;background:#f7f7f7}
|
||||
#send_emo h2 {margin:0 0 20px}
|
||||
#send_emo .tmp_loading {display:block;padding:180px 0 0;text-align:center}
|
||||
#send_emo #emo_sel {position:absolute;top:20px;right:20px;margin:0}
|
||||
#send_emo .emo_list {margin:0;padding:0;list-style:none}
|
||||
#send_emo li {float:left;margin:0 2% 10px 0;width:49%}
|
||||
#send_emo li:nth-of-type(even) {margin:0 0 10px}
|
||||
#send_emo .sms5_box {background:#fbec99}
|
||||
#send_emo .box_ico {display:none}
|
||||
#send_emo .box_txt {cursor:pointer}
|
||||
#send_emo .emo_tit {display:block;height:20px;line-height:2em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
#send_emo .btn_submit {padding:0 5px;height:24px;border:1px solid #ccc;background:#fafafa;color:#000;font-size:0.95em;vertical-align:middle;cursor:pointer}
|
||||
50
plugin/sms5/skin/basic/style.css
Normal file
50
plugin/sms5/skin/basic/style.css
Normal file
@ -0,0 +1,50 @@
|
||||
#sms5_send {position:relative}
|
||||
|
||||
.sms5_box {position:relative;padding:10px;border-radius:5px;background:#fbec99}
|
||||
.sms5_box .box_ico {position:absolute;top:20px;left:-7px;width:7px;height:13px;background:url('img/box_ico.gif') no-repeat}
|
||||
.sms5_box .box_txt {border:0;background:transparent;word-break:break-all;resize:none;overflow:hidden}
|
||||
.sms5_box .box_square {width:100px;height:90px}
|
||||
|
||||
#send_write {padding:0 20px !important}
|
||||
#send_write h2 {padding:0 0 10px}
|
||||
#send_write .sms5_box {margin:0 0 5px;text-align:center}
|
||||
#send_write .box_txt {width:390px;height:80px}
|
||||
#wr_message_lbl {position:absolute;top:45px;left:200px;color:#999;font-size:0.95em;letter-spacing:-0.1em}
|
||||
|
||||
.write_inner {position:relative;padding:10px 0;border-bottom:1px solid #efefef;zoom:1}
|
||||
.write_inner:after {display:block;visibility:hidden;clear:both;content:''}
|
||||
.write_inner h2 {margin:0;padding:0 0 10px !important}
|
||||
.write_floater {position:absolute;top:15px;right:0;text-align:right}
|
||||
.write_floater_btn {margin:0;padding:0;border:0;background:transparent;color:#999;font-size:0.95em;letter-spacing:-0.1em}
|
||||
|
||||
#write_rcv {float:left;height:22px;line-height:1.8em}
|
||||
#write_rcv strong {display:inline-block;margin:0 10px 0 0}
|
||||
#write_reply {float:right}
|
||||
#write_reply label {display:inline-block;margin:0 10px 0 0;font-weight:bold}
|
||||
#write_reply #mh_reply {padding:0 5px;width:90px;height:20px;border:1px solid #e9e9e9;text-align:center;line-height:1.8em}
|
||||
|
||||
.write_scemo {width:48%}
|
||||
.write_scemo strong {display:block;margin:0 0 10px}
|
||||
.write_scemo .scemo_list {letter-spacing:-4px}
|
||||
.write_scemo .scemo_add {margin:0;padding:0;height:25px;border:1px solid #e9e9e9;background:transparent;letter-spacing:0}
|
||||
#write_sc {float:left}
|
||||
#write_sc .scemo_add {width:25px}
|
||||
#write_emo {float:right}
|
||||
#write_emo .scemo_list {text-align:right}
|
||||
#write_emo .scemo_add {width:66px}
|
||||
#write_emo .emo_long {}
|
||||
|
||||
#sms_byte {position:absolute;top:-27px;right:0;color:#999}
|
||||
|
||||
#send_emo {position:relative;padding:20px;border-top:1px solid #e9e9e9;background:#f7f7f7}
|
||||
#send_emo h2 {margin:0 0 20px}
|
||||
#send_emo .tmp_loading {display:block;padding:180px 0 0;text-align:center}
|
||||
#send_emo #emo_sel {position:absolute;top:20px;right:20px;margin:0}
|
||||
#send_emo .emo_list {margin:0;padding:0;list-style:none}
|
||||
#send_emo li {float:left;margin:0 10px 10px 0 !important;margin:0 5px 10px 0;width:113px !important;width:110px}
|
||||
#send_emo li:nth-of-type(3n) {margin:0 0 10px !important}
|
||||
#send_emo .sms5_box {background:#fbec99}
|
||||
#send_emo .box_ico {display:none}
|
||||
#send_emo .box_txt {cursor:pointer}
|
||||
#send_emo .emo_tit {display:block;height:20px;line-height:2em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
#send_emo .btn_submit {padding:0 5px;height:24px;border:1px solid #ccc;background:#fafafa;color:#000;font-size:0.95em;vertical-align:middle;cursor:pointer}
|
||||
378
plugin/sms5/skin/basic/write.skin.php
Normal file
378
plugin/sms5/skin/basic/write.skin.php
Normal file
@ -0,0 +1,378 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
|
||||
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
|
||||
add_stylesheet('<link rel="stylesheet" href="'.$sms5_skin_url.'/style.css">', 0);
|
||||
?>
|
||||
|
||||
<div id="sms5_send" class="new_win">
|
||||
<h1 id="win_title">SMS 보내기</h1>
|
||||
|
||||
<div id="send_write">
|
||||
<form action="<?php echo $action_url?>" onsubmit="return smssend_submit(this);" name="smsform" method="post" autocomplete="off">
|
||||
<input type="hidden" name="token" value="<?php echo $token?>">
|
||||
<input type="hidden" name="mh_hp" value="">
|
||||
<input type="hidden" name="mb_id" value="<?php echo $mb_id?>">
|
||||
<h2>보낼내용</h2>
|
||||
<div class="sms5_box">
|
||||
<span class="box_ico"></span>
|
||||
<label for="mh_message" id="wr_message_lbl">내용</label>
|
||||
<textarea name="mh_message" id="mh_message" class="box_txt" onkeyup="byte_check('mh_message', 'sms_bytes');"></textarea>
|
||||
<div id="sms_byte"><span id="sms_bytes">0</span> / 80 byte</div>
|
||||
</div>
|
||||
|
||||
<div class="write_inner">
|
||||
<?php if( $mb['mb_id'] ){ //회원 아이디가 있다면 ?>
|
||||
<div id="write_rcv">
|
||||
<strong>수신회원</strong> <?php echo $mb['mb_nick']?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div id="write_reply">
|
||||
<label for="mh_reply">회신번호</label>
|
||||
<input type="text" name="mh_reply" value="<?php echo $member['mb_hp']?>" id="mh_reply" <?php if ($is_admin != 'super') { ?> readonly<?php } ?>>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="write_rsv" class="write_inner">
|
||||
<h2>예약전송</h2>
|
||||
|
||||
<div class="write_floater">
|
||||
<label for="booking_flag"><span class="sound_only">예약전송 </span>사용</label>
|
||||
<input type="checkbox" name="booking_flag" id="booking_flag" value="true" onclick="booking_show()" >
|
||||
</div>
|
||||
|
||||
<select name="mh_by" id="mh_by" disabled>
|
||||
<option value="<?php echo date('Y')?>"><?php echo date('Y')?></option>
|
||||
<option value="<?php echo date('Y')+1?>"><?php echo date('Y')+1?></option>
|
||||
</select> 년
|
||||
<select name="mh_bm" id="mh_bm" disabled>
|
||||
<?php for ($i=1; $i<=12; $i++) { ?>
|
||||
<option value="<?php echo sprintf("%02d",$i)?>" <?php echo date('m')==$i?'selected':''?>><?php echo sprintf("%02d",$i)?></option>
|
||||
<?php } ?>
|
||||
</select> 월
|
||||
<select name="mh_bd" id="mh_bd" disabled>
|
||||
<?php for ($i=1; $i<=31; $i++) { ?>
|
||||
<option value="<?php echo sprintf("%02d",$i)?>" <?php echo date('d')==$i?'selected':''?>><?php echo sprintf("%02d",$i)?></option>
|
||||
<?php } ?>
|
||||
</select> 일
|
||||
<select name="mh_bh" id="mh_bh" disabled>
|
||||
<?php for ($i=0; $i<24; $i++) { ?>
|
||||
<option value="<?php echo sprintf("%02d",$i)?>" <?php echo date('H')+1==$i?'selected':''?>><?php echo sprintf("%02d",$i)?></option>
|
||||
<?php } ?>
|
||||
</select> 시
|
||||
<select name="mh_bi" id="mh_bi" disabled>
|
||||
<?php for ($i=0; $i<=59; $i+=5) { ?>
|
||||
<option value="<?php echo sprintf("%02d",$i)?>"><?php echo sprintf("%02d",$i)?></option>
|
||||
<?php } ?>
|
||||
</select> 분
|
||||
</div>
|
||||
|
||||
<div class="write_inner">
|
||||
<div id="write_sc" class="write_scemo">
|
||||
<strong>특수기호</strong>
|
||||
<div class="scemo_list">
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('■')">■</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('□')">□</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▣')">▣</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◈')">◈</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◆')">◆</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◇')">◇</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♥')">♥</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♡')">♡</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('●')">●</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('○')">○</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▲')">▲</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▼')">▼</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▶')">▶</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▷')">▷</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◀')">◀</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◁')">◁</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☎')">☎</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☏')">☏</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♠')">♠</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♤')">♤</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♣')">♣</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♧')">♧</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('★')">★</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☆')">☆</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☞')">☞</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☜')">☜</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▒')">▒</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('⊙')">⊙</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('㈜')">㈜</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('№')">№</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('㉿')">㉿</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♨')">♨</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('™')">™</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('℡')">℡</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('∑')">∑</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('∏')">∏</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♬')">♬</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♪')">♪</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♩')">♩</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♭')">♭</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="write_emo" class="write_scemo">
|
||||
<strong>이모티콘</strong>
|
||||
<div class="scemo_list">
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('*^^*')">*^^*</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♡.♡')">♡.♡</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('@_@')">@_@</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☞_☜')">☞_☜</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('ㅠ ㅠ')">ㅠ ㅠ</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('Θ.Θ')">Θ.Θ</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('^_~♥')">^_~♥</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('~o~')">~o~</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('★.★')">★.★</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('(!.!)')">(!.!)</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('⊙.⊙')">⊙.⊙</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('q.p')">q.p</button>
|
||||
<button type="button" class="scemo_add emo_long" onclick="javascript:add('↖(^-^)↗')">↖(^-^)↗</button>
|
||||
<button type="button" class="scemo_add emo_long" onclick="javascript:add('(*^-^*)')">(*^-^*)</button>
|
||||
<button type="button" class="scemo_add emo_long" onclick="javascript:add('d(^-^)b')">d(^-^)b</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="win_btn">
|
||||
<input type="submit" value="전송" class="btn_submit">
|
||||
<button type="button" onclick="window.close();">창닫기</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if( count($emoticon_group) ){ //회원에게 공개된 이모티콘 그룹이 있다면 ?>
|
||||
<div id="send_emo">
|
||||
<h2>이모티콘 목록</h2>
|
||||
<form name="emoticon_form">
|
||||
<label for="emo_sel" class="sound_only">이모티콘 그룹</label>
|
||||
<select name="fg_no" id="emo_sel">
|
||||
<option value="" <?php echo $fg_no?'':'selected'?>>전체</option>
|
||||
<?php for($i=0; $i<count($emoticon_group); $i++) {?>
|
||||
<option value="<?php echo $emoticon_group[$i]['fg_no']?>"<?php echo ($fg_no==$emoticon_group[$i]['fg_no'])?'selected':''?>><?php echo $emoticon_group[$i]['fg_name']?> (<?php echo number_format($emoticon_group[$i]['fg_count'])?>)</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<ul class="emo_list">
|
||||
</ul>
|
||||
|
||||
<nav class="pg_wrap">
|
||||
<span class="pg" id="emoticon_pg"></span>
|
||||
</nav>
|
||||
|
||||
<form name="emoticon_search" id="emoticon_search">
|
||||
<input type="hidden" name="page" id="hidden_page" >
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function sms_error(obj, err) {
|
||||
alert(err);
|
||||
obj.value = '';
|
||||
}
|
||||
|
||||
function smssend_submit(f)
|
||||
{
|
||||
if (!f.mh_message.value)
|
||||
{
|
||||
alert('보내실 문자를 입력하십시오.');
|
||||
f.mh_message.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!f.mh_reply.value)
|
||||
{
|
||||
alert('발신 번호를 입력하십시오.\n\n발신 번호는 회원정보의 휴대폰번호입니다.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
//f.submit();
|
||||
//win.focus();
|
||||
}
|
||||
|
||||
function booking_show()
|
||||
{
|
||||
if (document.getElementById('booking_flag').checked) {
|
||||
document.getElementById('mh_by').disabled = false;
|
||||
document.getElementById('mh_bm').disabled = false;
|
||||
document.getElementById('mh_bd').disabled = false;
|
||||
document.getElementById('mh_bh').disabled = false;
|
||||
document.getElementById('mh_bi').disabled = false;
|
||||
} else {
|
||||
document.getElementById('mh_by').disabled = true;
|
||||
document.getElementById('mh_bm').disabled = true;
|
||||
document.getElementById('mh_bd').disabled = true;
|
||||
document.getElementById('mh_bh').disabled = true;
|
||||
document.getElementById('mh_bi').disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function add(str) {
|
||||
var conts = document.getElementById('mh_message');
|
||||
var bytes = document.getElementById('sms_bytes');
|
||||
conts.focus();
|
||||
conts.value+=str;
|
||||
byte_check('mh_message', 'sms_bytes');
|
||||
return;
|
||||
}
|
||||
|
||||
function byte_check(mh_message, sms_bytes)
|
||||
{
|
||||
var conts = document.getElementById(mh_message);
|
||||
var bytes = document.getElementById(sms_bytes);
|
||||
|
||||
var i = 0;
|
||||
var cnt = 0;
|
||||
var exceed = 0;
|
||||
var ch = '';
|
||||
|
||||
for (i=0; i<conts.value.length; i++)
|
||||
{
|
||||
ch = conts.value.charAt(i);
|
||||
if (escape(ch).length > 4) {
|
||||
cnt += 2;
|
||||
} else {
|
||||
cnt += 1;
|
||||
}
|
||||
}
|
||||
|
||||
bytes.innerHTML = cnt;
|
||||
|
||||
if (cnt > 80)
|
||||
{
|
||||
exceed = cnt - 80;
|
||||
alert('메시지 내용은 80바이트를 넘을수 없습니다.\n\n작성하신 메세지 내용은 '+ exceed +'byte가 초과되었습니다.\n\n초과된 부분은 자동으로 삭제됩니다.');
|
||||
var tcnt = 0;
|
||||
var xcnt = 0;
|
||||
var tmp = conts.value;
|
||||
for (i=0; i<tmp.length; i++)
|
||||
{
|
||||
ch = tmp.charAt(i);
|
||||
if (escape(ch).length > 4) {
|
||||
tcnt += 2;
|
||||
} else {
|
||||
tcnt += 1;
|
||||
}
|
||||
|
||||
if (tcnt > 80) {
|
||||
tmp = tmp.substring(0,i);
|
||||
break;
|
||||
} else {
|
||||
xcnt = tcnt;
|
||||
}
|
||||
}
|
||||
conts.value = tmp;
|
||||
bytes.innerHTML = xcnt;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
byte_check('mh_message', 'sms_bytes');
|
||||
</script>
|
||||
<script src="<?php echo G5_JS_URL?>/jquery.sms_paging.js"></script>
|
||||
<script>
|
||||
var emoticon_list = {
|
||||
go : function(fo_no){
|
||||
var wr_message = document.getElementById('mh_message');
|
||||
|
||||
//wr_message.focus();
|
||||
wr_message.value = document.getElementById('fo_contents_' + fo_no).value;
|
||||
|
||||
byte_check('mh_message', 'sms_bytes');
|
||||
}
|
||||
};
|
||||
(function($){
|
||||
$(".box_txt").bind("focus keydown", function(){
|
||||
$("#wr_message_lbl").hide();
|
||||
});
|
||||
|
||||
var $search_form = $("form#emoticon_search");
|
||||
emoticon_list.fn_paging = function( hash_val,total_page ){
|
||||
$('#emoticon_pg').paging({
|
||||
current:hash_val ? hash_val : 1,
|
||||
max:total_page == 0 || total_page ? total_page : 45,
|
||||
length : 5,
|
||||
liitem : 'span',
|
||||
format:'{0}',
|
||||
next:'next',
|
||||
prev:'prev',
|
||||
first:'<<',last:'>>',
|
||||
href:'#',
|
||||
itemCurrent:'pg_current',
|
||||
itemClass:'pg_page',
|
||||
appendhtml:'<span class="sound_only">페이지</span>',
|
||||
onclick:function(e,page){
|
||||
e.preventDefault();
|
||||
$("#hidden_page").val( page );
|
||||
var params = $($search_form).serialize();
|
||||
emoticon_list.select_page( params, "json" );
|
||||
}
|
||||
});
|
||||
}
|
||||
emoticon_list.loading = function( el, src ){
|
||||
if( !el || !src) return;
|
||||
$(el).append("<span class='tmp_loading'><img src='"+src+"' title='loading...' ></span>");
|
||||
}
|
||||
emoticon_list.loadingEnd = function( el ){
|
||||
$(".tmp_loading", $(el)).remove();
|
||||
}
|
||||
emoticon_list.select_page = function( params, type ){
|
||||
if( !type ){
|
||||
type = "json";
|
||||
}
|
||||
emoticon_list.loading(".emo_list", "<?php echo $sms5_skin_url?>/img/ajax-loader.gif" ); //로딩 이미지 보여줌
|
||||
$.ajax({
|
||||
url: "./ajax.sms_emoticon.php",
|
||||
cache:false,
|
||||
timeout : 30000,
|
||||
dataType:type,
|
||||
data:params,
|
||||
success: function(HttpRequest) {
|
||||
if( type == "json" ){
|
||||
if (HttpRequest.error) {
|
||||
alert(HttpRequest.error);
|
||||
return false;
|
||||
} else {
|
||||
var $emoticon_box = $(".emo_list");
|
||||
var list_text = "";
|
||||
$.each( HttpRequest.list_text , function(num) {
|
||||
var list_data = HttpRequest.list_text[num];
|
||||
list_text = list_text + "<li class=\"screen_list sms5_box\"><span class=\"box_ico\"></span><textarea class=\"sms_textarea box_txt box_square\" readonly onclick=\"emoticon_list.go("+list_data.fo_no+")\">"+list_data.fo_content+"</textarea><textarea id=\"fo_contents_"+list_data.fo_no+"\" style=\"display:none; width:0; height:0\">"+list_data.fo_content+"</textarea><strong class=\"emo_tit\">"+list_data.fo_name+"</strong></li>";
|
||||
});
|
||||
if( !list_text ){
|
||||
list_text = "<li>데이터가 없습니다.</li>";
|
||||
}
|
||||
$emoticon_box.html( list_text );
|
||||
emoticon_list.fn_paging( HttpRequest.page, HttpRequest.total_page );
|
||||
$("#hidden_page").val( HttpRequest.page );
|
||||
}
|
||||
}
|
||||
emoticon_list.loadingEnd(".emo_list"); //로딩 이미지 지움
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#emo_sel").bind("change", function(e){
|
||||
var params = { fg_no : $(this).val() };
|
||||
$search_form[0].reset();
|
||||
$("#hidden_fg_no").val( $(this).val() );
|
||||
emoticon_list.select_page( params, "json" );
|
||||
});
|
||||
$search_form.submit(function(e){
|
||||
e.preventDefault();
|
||||
var $form = $(this),
|
||||
params = $(this).serialize();
|
||||
emoticon_list.select_page( params, "json" );
|
||||
});
|
||||
if( $("#emo_sel").length ){
|
||||
$("#emo_sel").trigger("change");
|
||||
}
|
||||
})(jQuery);
|
||||
</script>
|
||||
394
plugin/sms5/skin/basic/write_mobile.skin.php
Normal file
394
plugin/sms5/skin/basic/write_mobile.skin.php
Normal file
@ -0,0 +1,394 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
|
||||
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
|
||||
add_stylesheet('<link rel="stylesheet" href="'.$sms5_skin_url.'/mobile.css">', 0);
|
||||
?>
|
||||
|
||||
<div id="sms5_send" class="new_win">
|
||||
<h1 id="win_title">SMS 보내기</h1>
|
||||
|
||||
<div id="send_write">
|
||||
<form action="<?php echo $action_url?>" onsubmit="return smssend_submit(this);" name="smsform" method="post" autocomplete="off">
|
||||
<input type="hidden" name="token" value="<?php echo $token?>">
|
||||
<input type="hidden" name="mh_hp" value="">
|
||||
<input type="hidden" name="mb_id" value="<?php echo $mb_id?>">
|
||||
<h2>보낼내용</h2>
|
||||
<div class="sms5_box">
|
||||
<span class="box_ico"></span>
|
||||
<label for="mh_message" id="wr_message_lbl">내용</label>
|
||||
<textarea name="mh_message" id="mh_message" class="box_txt" onkeyup="byte_check('mh_message', 'sms_bytes');"></textarea>
|
||||
<div id="sms_byte"><span id="sms_bytes">0</span> / 80 byte</div>
|
||||
</div>
|
||||
|
||||
<div class="write_inner">
|
||||
<?php if( $mb['mb_id'] ){ //회원 아이디가 있다면 ?>
|
||||
<div id="write_rcv">
|
||||
<strong>수신회원</strong> <?php echo $mb['mb_nick']?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div id="write_reply">
|
||||
<label for="mh_reply">회신번호</label>
|
||||
<input type="text" name="mh_reply" value="<?php echo $member['mb_hp']?>" id="mh_reply" <?php if ($is_admin != 'super') { ?> readonly<?php } ?>>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="write_rsv" class="write_inner">
|
||||
<h2>예약전송</h2>
|
||||
|
||||
<div class="write_floater">
|
||||
<label for="booking_flag"><span class="sound_only">예약전송 </span>사용</label>
|
||||
<input type="checkbox" name="booking_flag" id="booking_flag" value="true" onclick="booking_show()" >
|
||||
</div>
|
||||
|
||||
<select name="mh_by" id="mh_by" disabled>
|
||||
<option value="<?php echo date('Y')?>"><?php echo date('Y')?></option>
|
||||
<option value="<?php echo date('Y')+1?>"><?php echo date('Y')+1?></option>
|
||||
</select> 년
|
||||
<select name="mh_bm" id="mh_bm" disabled>
|
||||
<?php for ($i=1; $i<=12; $i++) { ?>
|
||||
<option value="<?php echo sprintf("%02d",$i)?>" <?php echo date('m')==$i?'selected':''?>><?php echo sprintf("%02d",$i)?></option>
|
||||
<?php } ?>
|
||||
</select> 월
|
||||
<span class="rsv_line"></span>
|
||||
<select name="mh_bd" id="mh_bd" disabled>
|
||||
<?php for ($i=1; $i<=31; $i++) { ?>
|
||||
<option value="<?php echo sprintf("%02d",$i)?>" <?php echo date('d')==$i?'selected':''?>><?php echo sprintf("%02d",$i)?></option>
|
||||
<?php } ?>
|
||||
</select> 일
|
||||
<select name="mh_bh" id="mh_bh" disabled>
|
||||
<?php for ($i=0; $i<24; $i++) { ?>
|
||||
<option value="<?php echo sprintf("%02d",$i)?>" <?php echo date('H')+1==$i?'selected':''?>><?php echo sprintf("%02d",$i)?></option>
|
||||
<?php } ?>
|
||||
</select> 시
|
||||
<select name="mh_bi" id="mh_bi" disabled>
|
||||
<?php for ($i=0; $i<=59; $i+=5) { ?>
|
||||
<option value="<?php echo sprintf("%02d",$i)?>"><?php echo sprintf("%02d",$i)?></option>
|
||||
<?php } ?>
|
||||
</select> 분
|
||||
</div>
|
||||
|
||||
<div class="write_inner">
|
||||
<div id="write_sc" class="write_scemo">
|
||||
<button type="button" id="scemo_sc" class="scemo_btn">특수기호</button>
|
||||
<div class="scemo_list scemo_sc">
|
||||
<div class="list_closer"><button type="button" class="list_closer_btn">특수기호닫기</button></div>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('■')">■</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('□')">□</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▣')">▣</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◈')">◈</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◆')">◆</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◇')">◇</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♥')">♥</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♡')">♡</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('●')">●</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('○')">○</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▲')">▲</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▼')">▼</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▶')">▶</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▷')">▷</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◀')">◀</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('◁')">◁</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☎')">☎</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☏')">☏</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♠')">♠</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♤')">♤</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♣')">♣</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♧')">♧</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('★')">★</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☆')">☆</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☞')">☞</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☜')">☜</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('▒')">▒</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('⊙')">⊙</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('㈜')">㈜</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('№')">№</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('㉿')">㉿</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♨')">♨</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('™')">™</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('℡')">℡</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('∑')">∑</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('∏')">∏</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♬')">♬</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♪')">♪</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♩')">♩</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♭')">♭</button>
|
||||
<div class="list_closer"><button type="button" class="list_closer_btn">특수기호닫기</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="write_emo" class="write_scemo">
|
||||
<button type="button" id="scemo_emo" class="scemo_btn">이모티콘</button>
|
||||
<div class="scemo_list scemo_emo">
|
||||
<div class="list_closer"><button type="button" class="list_closer_btn">이모티콘닫기</button></div>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('*^^*')">*^^*</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('♡.♡')">♡.♡</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('@_@')">@_@</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('☞_☜')">☞_☜</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('ㅠ ㅠ')">ㅠ ㅠ</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('Θ.Θ')">Θ.Θ</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('^_~♥')">^_~♥</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('~o~')">~o~</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('★.★')">★.★</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('(!.!)')">(!.!)</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('⊙.⊙')">⊙.⊙</button>
|
||||
<button type="button" class="scemo_add" onclick="javascript:add('q.p')">q.p</button>
|
||||
<button type="button" class="scemo_add emo_long" onclick="javascript:add('↖(^-^)↗')">↖(^-^)↗</button>
|
||||
<button type="button" class="scemo_add emo_long" onclick="javascript:add('(*^-^*)')">(*^-^*)</button>
|
||||
<button type="button" class="scemo_add emo_long" onclick="javascript:add('d(^-^)b')">d(^-^)b</button>
|
||||
<div class="list_closer"><button type="button" class="list_closer_btn">이모티콘닫기</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="win_btn">
|
||||
<input type="submit" value="전송" class="btn_submit">
|
||||
<button type="button" onclick="window.close();">창닫기</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if( count($emoticon_group) ){ //회원에게 공개된 이모티콘 그룹이 있다면 ?>
|
||||
<div id="send_emo">
|
||||
<h2>이모티콘 목록</h2>
|
||||
<form name="emoticon_form">
|
||||
<label for="emo_sel" class="sound_only">이모티콘 그룹</label>
|
||||
<select name="fg_no" id="emo_sel">
|
||||
<option value="" <?php echo $fg_no?'':'selected'?>>전체</option>
|
||||
<?php for($i=0; $i<count($emoticon_group); $i++) {?>
|
||||
<option value="<?php echo $emoticon_group[$i]['fg_no']?>"<?php echo ($fg_no==$emoticon_group[$i]['fg_no'])?'selected':''?>><?php echo $emoticon_group[$i]['fg_name']?> (<?php echo number_format($emoticon_group[$i]['fg_count'])?>)</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<ul class="emo_list">
|
||||
</ul>
|
||||
|
||||
<nav class="pg_wrap">
|
||||
<span class="pg" id="emoticon_pg"></span>
|
||||
</nav>
|
||||
|
||||
<form name="emoticon_search" id="emoticon_search">
|
||||
<input type="hidden" name="page" id="hidden_page" >
|
||||
</form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function sms_error(obj, err) {
|
||||
alert(err);
|
||||
obj.value = '';
|
||||
}
|
||||
|
||||
function smssend_submit(f)
|
||||
{
|
||||
if (!f.mh_message.value)
|
||||
{
|
||||
alert('보내실 문자를 입력하십시오.');
|
||||
f.mh_message.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!f.mh_reply.value)
|
||||
{
|
||||
alert('발신 번호를 입력하십시오.\n\n발신 번호는 회원정보의 휴대폰번호입니다.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
//f.submit();
|
||||
//win.focus();
|
||||
}
|
||||
|
||||
function booking_show()
|
||||
{
|
||||
if (document.getElementById('booking_flag').checked) {
|
||||
document.getElementById('mh_by').disabled = false;
|
||||
document.getElementById('mh_bm').disabled = false;
|
||||
document.getElementById('mh_bd').disabled = false;
|
||||
document.getElementById('mh_bh').disabled = false;
|
||||
document.getElementById('mh_bi').disabled = false;
|
||||
} else {
|
||||
document.getElementById('mh_by').disabled = true;
|
||||
document.getElementById('mh_bm').disabled = true;
|
||||
document.getElementById('mh_bd').disabled = true;
|
||||
document.getElementById('mh_bh').disabled = true;
|
||||
document.getElementById('mh_bi').disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function add(str) {
|
||||
var conts = document.getElementById('mh_message');
|
||||
var bytes = document.getElementById('sms_bytes');
|
||||
conts.focus();
|
||||
conts.value+=str;
|
||||
byte_check('mh_message', 'sms_bytes');
|
||||
return;
|
||||
}
|
||||
|
||||
function byte_check(mh_message, sms_bytes)
|
||||
{
|
||||
var conts = document.getElementById(mh_message);
|
||||
var bytes = document.getElementById(sms_bytes);
|
||||
|
||||
var i = 0;
|
||||
var cnt = 0;
|
||||
var exceed = 0;
|
||||
var ch = '';
|
||||
|
||||
for (i=0; i<conts.value.length; i++)
|
||||
{
|
||||
ch = conts.value.charAt(i);
|
||||
if (escape(ch).length > 4) {
|
||||
cnt += 2;
|
||||
} else {
|
||||
cnt += 1;
|
||||
}
|
||||
}
|
||||
|
||||
bytes.innerHTML = cnt;
|
||||
|
||||
if (cnt > 80)
|
||||
{
|
||||
exceed = cnt - 80;
|
||||
alert('메시지 내용은 80바이트를 넘을수 없습니다.\n\n작성하신 메세지 내용은 '+ exceed +'byte가 초과되었습니다.\n\n초과된 부분은 자동으로 삭제됩니다.');
|
||||
var tcnt = 0;
|
||||
var xcnt = 0;
|
||||
var tmp = conts.value;
|
||||
for (i=0; i<tmp.length; i++)
|
||||
{
|
||||
ch = tmp.charAt(i);
|
||||
if (escape(ch).length > 4) {
|
||||
tcnt += 2;
|
||||
} else {
|
||||
tcnt += 1;
|
||||
}
|
||||
|
||||
if (tcnt > 80) {
|
||||
tmp = tmp.substring(0,i);
|
||||
break;
|
||||
} else {
|
||||
xcnt = tcnt;
|
||||
}
|
||||
}
|
||||
conts.value = tmp;
|
||||
bytes.innerHTML = xcnt;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
byte_check('mh_message', 'sms_bytes');
|
||||
</script>
|
||||
<script src="<?php echo G5_JS_URL?>/jquery.sms_paging.js"></script>
|
||||
<script>
|
||||
var emoticon_list = {
|
||||
go : function(fo_no){
|
||||
var wr_message = document.getElementById('mh_message');
|
||||
|
||||
//wr_message.focus();
|
||||
wr_message.value = document.getElementById('fo_contents_' + fo_no).value;
|
||||
|
||||
byte_check('mh_message', 'sms_bytes');
|
||||
}
|
||||
};
|
||||
(function($){
|
||||
$(".box_txt").bind("focus keydown", function(){
|
||||
$("#wr_message_lbl").hide();
|
||||
});
|
||||
|
||||
var $search_form = $("form#emoticon_search");
|
||||
emoticon_list.fn_paging = function( hash_val,total_page ){
|
||||
$('#emoticon_pg').paging({
|
||||
current:hash_val ? hash_val : 1,
|
||||
max:total_page == 0 || total_page ? total_page : 45,
|
||||
length : 5,
|
||||
liitem : 'span',
|
||||
format:'{0}',
|
||||
next:'next',
|
||||
prev:'prev',
|
||||
first:'<<',last:'>>',
|
||||
href:'#',
|
||||
itemCurrent:'pg_current',
|
||||
itemClass:'pg_page',
|
||||
appendhtml:'<span class="sound_only">페이지</span>',
|
||||
onclick:function(e,page){
|
||||
e.preventDefault();
|
||||
$("#hidden_page").val( page );
|
||||
var params = $($search_form).serialize();
|
||||
emoticon_list.select_page( params, "json" );
|
||||
}
|
||||
});
|
||||
}
|
||||
emoticon_list.loading = function( el, src ){
|
||||
if( !el || !src) return;
|
||||
$(el).append("<span class='tmp_loading'><img src='"+src+"' title='loading...' ></span>");
|
||||
}
|
||||
emoticon_list.loadingEnd = function( el ){
|
||||
$(".tmp_loading", $(el)).remove();
|
||||
}
|
||||
emoticon_list.select_page = function( params, type ){
|
||||
if( !type ){
|
||||
type = "json";
|
||||
}
|
||||
emoticon_list.loading(".emo_list", "<?php echo $sms5_skin_url?>/img/ajax-loader.gif" ); //로딩 이미지 보여줌
|
||||
$.ajax({
|
||||
url: "./ajax.sms_emoticon.php",
|
||||
cache:false,
|
||||
timeout : 30000,
|
||||
dataType:type,
|
||||
data:params,
|
||||
success: function(HttpRequest) {
|
||||
if( type == "json" ){
|
||||
if (HttpRequest.error) {
|
||||
alert(HttpRequest.error);
|
||||
return false;
|
||||
} else {
|
||||
var $emoticon_box = $(".emo_list");
|
||||
var list_text = "";
|
||||
$.each( HttpRequest.list_text , function(num) {
|
||||
var list_data = HttpRequest.list_text[num];
|
||||
list_text = list_text + "<li class=\"screen_list\"><div class=\"sms5_box\"><span class=\"box_ico\"></span><textarea class=\"sms_textarea box_txt box_square\" readonly onclick=\"emoticon_list.go("+list_data.fo_no+")\">"+list_data.fo_content+"</textarea><textarea id=\"fo_contents_"+list_data.fo_no+"\" style=\"display:none; width:0; height:0\">"+list_data.fo_content+"</textarea><strong class=\"emo_tit\">"+list_data.fo_name+"</strong></div></li>";
|
||||
});
|
||||
if( !list_text ){
|
||||
list_text = "<li>데이터가 없습니다.</li>";
|
||||
}
|
||||
$emoticon_box.html( list_text );
|
||||
emoticon_list.fn_paging( HttpRequest.page, HttpRequest.total_page );
|
||||
$("#hidden_page").val( HttpRequest.page );
|
||||
}
|
||||
}
|
||||
emoticon_list.loadingEnd(".emo_list"); //로딩 이미지 지움
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#emo_sel").bind("change", function(e){
|
||||
var params = { fg_no : $(this).val() };
|
||||
$search_form[0].reset();
|
||||
$("#hidden_fg_no").val( $(this).val() );
|
||||
emoticon_list.select_page( params, "json" );
|
||||
});
|
||||
$search_form.submit(function(e){
|
||||
e.preventDefault();
|
||||
var $form = $(this),
|
||||
params = $(this).serialize();
|
||||
emoticon_list.select_page( params, "json" );
|
||||
});
|
||||
if( $("#emo_sel").length ){
|
||||
$("#emo_sel").trigger("change");
|
||||
}
|
||||
|
||||
$(".scemo_btn").click(function(){
|
||||
var scemoid = $(this).attr("id");
|
||||
$(this).hide();
|
||||
$(".scemo_list").hide();
|
||||
$("."+scemoid).show();
|
||||
});
|
||||
$(".list_closer_btn").click(function(){
|
||||
$(".scemo_btn").show();
|
||||
$(".scemo_list").hide();
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
269
plugin/sms5/sms5.lib.php
Normal file
269
plugin/sms5/sms5.lib.php
Normal file
@ -0,0 +1,269 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
/*************************************************************************
|
||||
**
|
||||
** sms5에 사용할 함수 모음
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
// 스킨디렉토리를 SELECT 형식으로 얻음
|
||||
function get_sms5_skin_select($skin_gubun, $id, $name, $selected='', $event='')
|
||||
{
|
||||
$skins = get_skin_dir($skin_gubun, G5_SMS5_PATH);
|
||||
$str = "<select id=\"$id\" name=\"$name\" $event>\n";
|
||||
for ($i=0; $i<count($skins); $i++) {
|
||||
if ($i == 0) $str .= "<option value=\"\">선택</option>";
|
||||
$str .= option_selected($skins[$i], $selected);
|
||||
}
|
||||
$str .= "</select>";
|
||||
return $str;
|
||||
}
|
||||
|
||||
if ( ! function_exists('array_overlap')) {
|
||||
function array_overlap($arr, $val) {
|
||||
for ($i=0, $m=count($arr); $i<$m; $i++) {
|
||||
if ($arr[$i] == $val)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists('get_hp')) {
|
||||
function get_hp($hp, $hyphen=1)
|
||||
{
|
||||
global $g5;
|
||||
|
||||
if (!is_hp($hp)) return '';
|
||||
|
||||
if ($hyphen) $preg = "$1-$2-$3"; else $preg = "$1$2$3";
|
||||
|
||||
$hp = str_replace('-', '', trim($hp));
|
||||
$hp = preg_replace("/^(01[016789])([0-9]{3,4})([0-9]{4})$/", $preg, $hp);
|
||||
|
||||
if ($g5['sms5_demo'])
|
||||
$hp = '0100000000';
|
||||
|
||||
return $hp;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists('is_hp')) {
|
||||
function is_hp($hp)
|
||||
{
|
||||
$hp = str_replace('-', '', trim($hp));
|
||||
if (preg_match("/^(01[016789])([0-9]{3,4})([0-9]{4})$/", $hp))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists('alert_just')) {
|
||||
// 경고메세지를 경고창으로
|
||||
function alert_just($msg='', $url='')
|
||||
{
|
||||
global $g5;
|
||||
|
||||
if (!$msg) $msg = '올바른 방법으로 이용해 주십시오.';
|
||||
|
||||
//header("Content-Type: text/html; charset=$g5[charset]");
|
||||
echo "<meta charset=\"utf-8\">";
|
||||
echo "<script language='javascript'>alert('$msg');";
|
||||
echo "</script>";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('utf2euc')) {
|
||||
function utf2euc($str) {
|
||||
return iconv("UTF-8","cp949//IGNORE", $str);
|
||||
}
|
||||
}
|
||||
if ( ! function_exists('is_ie')) {
|
||||
function is_ie() {
|
||||
return isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SMS 발송을 관장하는 메인 클래스이다.
|
||||
*
|
||||
* 접속, 발송, URL발송, 결과등의 실질적으로 쓰이는 모든 부분이 포함되어 있다.
|
||||
*/
|
||||
|
||||
class SMS5 extends SMS {
|
||||
var $Log = array();
|
||||
|
||||
function SMS_con($sms_server,$sms_id,$sms_pw,$port) {
|
||||
$this->ID=$sms_id; // 계약 후 지정
|
||||
$this->PWD=$sms_pw; // 계약 후 지정
|
||||
$this->SMS_Server=$sms_server;
|
||||
$this->SMS_Port=$port;
|
||||
$this->ID = spacing($this->ID,10);
|
||||
$this->PWD = spacing($this->PWD,10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 발송번호의 값이 정확한 값인지 확인합니다.
|
||||
*
|
||||
* @param strDest 발송번호 배열입니다.
|
||||
* nCount 배열의 크기입니다.
|
||||
* @return 처리결과입니다.
|
||||
*/
|
||||
function CheckCommonTypeDest($strDest, $nCount) {
|
||||
for ($i=0; $i<$nCount; $i++) {
|
||||
$hp_number = preg_replace("/[^0-9]/","",$strDest[$i]['bk_hp']);
|
||||
if (strlen($hp_number)<10 || strlen($hp_number)>11) return "휴대폰 번호가 틀렸습니다";
|
||||
|
||||
$CID=substr($hp_number,0,3);
|
||||
if ( preg_match("/[^0-9]/",$CID) || ($CID!='010' && $CID!='011' && $CID!='016' && $CID!='017' && $CID!='018' && $CID!='019') ) return "휴대폰 앞자리 번호가 잘못되었습니다";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 회신번호의 값이 정확한 값인지 확인합니다.
|
||||
*
|
||||
* @param strDest 회신번호입니다.
|
||||
* @return 처리결과입니다.
|
||||
*/
|
||||
function CheckCommonTypeCallBack($strCallBack) {
|
||||
if (preg_match("/[^0-9]/", $strCallBack)) return "회신 전화번호가 잘못되었습니다";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 예약날짜의 값이 정확한 값인지 확인합니다.
|
||||
*
|
||||
* @param text 원하는 문자열입니다.
|
||||
* size 원하는 길이입니다.
|
||||
* @return 처리결과입니다.
|
||||
*/
|
||||
function CheckCommonTypeDate($strDate) {
|
||||
$strDate=preg_replace("/[^0-9]/","",$strDate);
|
||||
if ($strDate) {
|
||||
if (!checkdate(substr($strDate,4,2),substr($strDate,6,2),substr($rsvTime,0,4))) return "예약날짜가 잘못되었습니다";
|
||||
if (substr($strDate,8,2)>23 || substr($strDate,10,2)>59) return "예약시간이 잘못되었습니다";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* URL콜백용으로 메세지 크기를 수정합니다.
|
||||
*
|
||||
* @param url URL 내용입니다.
|
||||
* msg 결과메시지입니다.
|
||||
* desk 문자내용입니다.
|
||||
*/
|
||||
function CheckCallCenter($url, $dest, $data) {
|
||||
switch (substr($dest,0,3)) {
|
||||
case '010': //20바이트
|
||||
return cut_char($data,20);
|
||||
break;
|
||||
case '011': //80바이트
|
||||
return cut_char($data,80);
|
||||
break;
|
||||
case '016': // 80바이트
|
||||
return cut_char($data,80);
|
||||
break;
|
||||
case '017': // URL 포함 80바이트
|
||||
return cut_char($data,80 - strlen($url));
|
||||
break;
|
||||
case '018': // 20바이트
|
||||
return cut_char($data,20);
|
||||
break;
|
||||
case '019': // 20바이트
|
||||
return cut_char($data,20);
|
||||
break;
|
||||
default:
|
||||
return cut_char($data,80);
|
||||
break;
|
||||
}
|
||||
}
|
||||
function Add($strDest, $strCallBack, $strCaller, $strURL, $strMessage, $strDate="", $nCount) {
|
||||
global $g5;
|
||||
|
||||
$Error = $this->CheckCommonTypeDest($strDest, $nCount);
|
||||
$Error = $this->CheckCommonTypeCallBack($strCallBack);
|
||||
$Error = $this->CheckCommonTypeDate($strDate);
|
||||
|
||||
$strCallBack = spacing($strCallBack,11);
|
||||
$strCaller = spacing($strCaller,10);
|
||||
$strDate = spacing($strDate,12);
|
||||
|
||||
|
||||
for ($i=0; $i<$nCount; $i++) {
|
||||
$hp_number = spacing($strDest[$i]['bk_hp'],11);
|
||||
$strData = $strMessage;
|
||||
if( !empty($strDest[$i]['bk_name']) ){
|
||||
$strData = str_replace("{이름}", $strDest[$i]['bk_name'], $strData);
|
||||
}
|
||||
// 아이코드에서는 문자에 utf-8 인코딩 형식을 아직 지원하지 않는다.
|
||||
$strData = iconv('utf-8', "euc-kr", stripslashes($strData));
|
||||
|
||||
if (!$strURL) {
|
||||
$strData = spacing(cut_char($strData,80),80);
|
||||
|
||||
$this->Data[$i] = '01144 '.$this->ID.$this->PWD.$hp_number.$strCallBack.$strCaller.$strDate.$strData;
|
||||
} else {
|
||||
$strURL = spacing($strURL,50);
|
||||
$strData = spacing($this->CheckCallCenter($strURL, $hp_number, $strData),80);
|
||||
|
||||
$this->Data[$i] = '05173 '.$this->ID.$this->PWD.$hp_number.$strCallBack.$strURL.$strDate.$strData;
|
||||
}
|
||||
}
|
||||
return true; // 수정대기
|
||||
}
|
||||
|
||||
function Send() {
|
||||
global $g5;
|
||||
|
||||
$count = 1;
|
||||
|
||||
if ($g5['sms5_demo_send']) {
|
||||
foreach($this->Data as $puts) {
|
||||
if (rand(0,10)) {
|
||||
$phone = substr($puts,26,11);
|
||||
$code = '47022497 ';
|
||||
} else {
|
||||
$phone = substr($puts,26,11);
|
||||
$code = 'Error(02)';
|
||||
}
|
||||
$this->Result[] = "$phone:$code";
|
||||
$this->Log[] = $puts;
|
||||
}
|
||||
$this->Data = "";
|
||||
return true;
|
||||
exit;
|
||||
}
|
||||
|
||||
$fsocket=fsockopen($this->SMS_Server,$this->SMS_Port);
|
||||
if (!$fsocket) return false;
|
||||
set_time_limit(300);
|
||||
|
||||
## php4.3.10일경우
|
||||
## zend 최신버전으로 업해주세요..
|
||||
## 또는 69번째 줄을 $this->Data as $tmp => $puts 로 변경해 주세요.
|
||||
|
||||
foreach($this->Data as $puts) {
|
||||
$dest = substr($puts,26,11);
|
||||
fputs($fsocket, $puts);
|
||||
while(!$gets) {
|
||||
$gets = fgets($fsocket,30);
|
||||
}
|
||||
if (substr($gets,0,19) == "0223 00".$dest) {
|
||||
$this->Result[] = $dest.":".substr($gets,19,10);
|
||||
$this->Log[] = $puts;
|
||||
} else {
|
||||
$this->Result[$dest] = $dest.":Error(".substr($gets,6,2).")";
|
||||
$this->Log[] = $puts;
|
||||
}
|
||||
$gets = "";
|
||||
|
||||
// 1천건씩 전송 후 5초 쉼
|
||||
if ($count++%1000 == 0) sleep(5);
|
||||
}
|
||||
fclose($fsocket);
|
||||
$this->Data = "";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
72
plugin/sms5/write.php
Normal file
72
plugin/sms5/write.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
if( !$sms5['bo_skin'] ){
|
||||
$sms5['bo_skin'] = "basic";
|
||||
}
|
||||
|
||||
$err = null;
|
||||
|
||||
if (!$mb_id){
|
||||
$err = "받는회원 아이디가 넘어오지 않았습니다.";
|
||||
alert_close($err);
|
||||
}
|
||||
if (!$sms5['cf_member']){
|
||||
$err = "문자전송이 허용되지 않았습니다.\\n\\n사이트 관리자에게 문의하여 주십시오.";
|
||||
alert_close($err);
|
||||
}
|
||||
if (!$err and !$is_member){
|
||||
$err = "로그인 해주세요.";
|
||||
alert_close($err);
|
||||
}
|
||||
if (!$err and $member['mb_level'] < $sms5['cf_level']){
|
||||
$err = "회원 {$sms5['cf_level']} 레벨 이상만 문자전송이 가능합니다.";
|
||||
alert_close($err);
|
||||
}
|
||||
// 오늘 문자를 보낸 총 건수
|
||||
$row = sql_fetch(" select count(*) as cnt from {$g5['sms5_member_history_table']} where mb_id='{$member['mb_id']}' and date_format(mh_datetime, '%Y-%m-%d') = '".G5_TIME_YMD."' ");
|
||||
$total = $row['cnt'];
|
||||
|
||||
// 건수 제한
|
||||
if (!$err and $sms5['cf_day_count'] > 0 && $is_admin != 'super') {
|
||||
if ($total >= $sms5['cf_day_count']) {
|
||||
$err = "하루에 보낼수 있는 문자갯수(".number_format($sms5['cf_day_count'])." 건)를 초과하였습니다.";
|
||||
alert_close($err);
|
||||
}
|
||||
}
|
||||
|
||||
// 포인트 검사
|
||||
if (!$err and $sms5['cf_point'] > 0 && $is_admin != 'super') {
|
||||
if ($sms5['cf_point'] > $member['mb_point']) {
|
||||
$err = "보유하신 포인트(".number_format($member['mb_point'])." 포인트)가 없거나 모자라서\\n\\n문자전송(".number_format($sms5['cf_point'])." 포인트)이 불가합니다.\\n\\n포인트를 적립하신 후 다시 시도 해 주십시오.";
|
||||
alert_close($err);
|
||||
}
|
||||
}
|
||||
|
||||
// 특정회원에게 문자 전송
|
||||
if ($mb_id) {
|
||||
$mb = get_member($mb_id);
|
||||
if (!$mb['mb_hp']) alert_close("회원 휴대폰번호가 없습니다.");
|
||||
if (!$mb['mb_open']) alert_close("정보를 공개하지 않았습니다.");
|
||||
if (!$mb['mb_sms']) alert_close("SMS 수신여부가 비활성화 되어 있습니다.");
|
||||
//$hp = $mb['mb_hp'];
|
||||
}
|
||||
|
||||
$g5['title'] = "문자전송";
|
||||
|
||||
$token = get_token();
|
||||
|
||||
$emoticon_group = array();
|
||||
$qry = sql_query("select * from {$g5['sms5_form_group_table']} where fg_member = 1 order by fg_name");
|
||||
while ($res = sql_fetch_array($qry)) array_push($emoticon_group, $res);
|
||||
|
||||
$action_url = "./write_update.php";
|
||||
|
||||
if( G5_IS_MOBILE ){
|
||||
$write_skin_page = "/write_mobile.skin.php";
|
||||
} else {
|
||||
$write_skin_page = "/write.skin.php";
|
||||
}
|
||||
include_once ($sms5_skin_path.$write_skin_page);
|
||||
echo PHP_EOL.'<!-- skin : '.$sms5_skin_path.' -->'.PHP_EOL;
|
||||
?>
|
||||
157
plugin/sms5/write_update.php
Normal file
157
plugin/sms5/write_update.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
include_once("./_common.php");
|
||||
|
||||
$g5['title'] = "문자전송중";
|
||||
|
||||
if (!($token && get_session("ss_token") == $token))
|
||||
die("올바른 방법으로 사용해 주십시오.");
|
||||
|
||||
if (!$sms5['cf_member'])
|
||||
die("문자전송이 허용되지 않았습니다. 사이트 관리자에게 문의하여 주십시오.");
|
||||
|
||||
if (!$is_member)
|
||||
die("로그인 해주세요.");
|
||||
|
||||
if ($member['mb_level'] < $sms5['cf_level'])
|
||||
alert("회원 {$sms5['cf_level']}레벨 이상만 문자전송이 가능합니다.");
|
||||
|
||||
if (!trim($mh_reply))
|
||||
alert('보내는 번호를 입력해주세요.');
|
||||
|
||||
if (!trim($mh_message))
|
||||
alert('메세지를 입력해주세요.');
|
||||
|
||||
if ($is_admin != 'super')
|
||||
{
|
||||
$mh_reply = get_hp($mh_reply, 0);
|
||||
if (!$mh_reply)
|
||||
alert("보내는 번호가 올바르지 않습니다.");
|
||||
}
|
||||
else
|
||||
{
|
||||
$mh_reply = str_replace("-", "", $mh_reply);;
|
||||
if (!check_string($mh_reply, G5_NUMERIC))
|
||||
alert("보내는 번호가 올바르지 않습니다.");
|
||||
}
|
||||
|
||||
$mh_hp = explode(',', $mh_hp);
|
||||
|
||||
if ($mb_id) {
|
||||
$mb = get_member($mb_id);
|
||||
if (!$mb['mb_sms'] || !$mb['mb_open']) {
|
||||
alert("정보를 공개하지 않았습니다.");
|
||||
}
|
||||
if( $mb['mb_hp'] ){
|
||||
array_push( $mh_hp, $mb['mb_hp'] );
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($mh_hp))
|
||||
alert('받는 번호를 입력해주세요.');
|
||||
|
||||
// 핸드폰 번호만 걸러낸다.
|
||||
$tmp = array();
|
||||
for ($i=0; $i<count($mh_hp); $i++)
|
||||
{
|
||||
$hp = trim($mh_hp[$i]);
|
||||
$hp = get_hp($hp);
|
||||
|
||||
if ($hp)
|
||||
$tmp[]['bk_hp'] = get_hp($hp, 0);
|
||||
}
|
||||
$mh_hp = $tmp;
|
||||
|
||||
$total = count($mh_hp);
|
||||
|
||||
// 건수 제한
|
||||
if ($sms5['cf_day_count'] > 0 && $is_admin != 'super') {
|
||||
$row = sql_fetch(" select count(*) as cnt from {$g5['sms5_member_history_table']} where mb_id='{$member['mb_id']}' and date_format(mh_datetime, '%Y-%m-%d') = '".G5_TIME_YMD."' ");
|
||||
if ($row['cnt'] + $total > $sms5['cf_day_count']) {
|
||||
alert("하루에 보낼수 있는 문자갯수(".number_format($sms5['cf_day_count']).")를 초과하였습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
// 포인트 검사
|
||||
if ($sms5['cf_point'] > 0 && $is_admin != 'super') {
|
||||
$minus_point = $sms5['cf_point'] * $total;
|
||||
if ($minus_point > $member['mb_point'])
|
||||
alert("보유하신 포인트(".number_format($member['mb_point']).")가 없거나 모자라서 문자전송(".number_format($minus_point).")이 불가합니다.\\n\\n포인트를 적립하신 후 다시 시도 해 주십시오.");
|
||||
} else
|
||||
$minus_point = 0;
|
||||
|
||||
// 예약전송
|
||||
if ($mh_by && $mh_bm && $mh_bd && $mh_bh && $mh_bi) {
|
||||
$mh_booking = "$mh_by-$mh_bm-$mh_bd $mh_bh:$mh_bi:00";
|
||||
$booking = $mh_by.$mh_bm.$mh_bd.$mh_bh.$mh_bi;
|
||||
} else {
|
||||
$mh_booking = '';
|
||||
$booking = '';
|
||||
}
|
||||
|
||||
$SMS = new SMS5;
|
||||
$SMS->SMS_con($config['cf_icode_server_ip'], $config['cf_icode_id'], $config['cf_icode_pw'], $config['cf_icode_server_port']);
|
||||
|
||||
$result = $SMS->Add($mh_hp, $mh_reply, '', '', $mh_message, $booking, $total);
|
||||
|
||||
$is_success = null;
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$result = $SMS->Send();
|
||||
|
||||
if ($result) //SMS 서버에 접속했습니다.
|
||||
{
|
||||
foreach ($SMS->Result as $result)
|
||||
{
|
||||
list($hp, $code) = explode(":", $result);
|
||||
|
||||
if (substr($code,0,5) == "Error")
|
||||
{
|
||||
$is_success = false;
|
||||
|
||||
switch (substr($code,6,2)) {
|
||||
case '02': // "02:형식오류"
|
||||
$mh_log = "형식이 잘못되어 전송이 실패하였습니다.";
|
||||
break;
|
||||
case '23': // "23:인증실패,데이터오류,전송날짜오류"
|
||||
$mh_log = "데이터를 다시 확인해 주시기바랍니다.";
|
||||
break;
|
||||
case '97': // "97:잔여코인부족"
|
||||
$mh_log = "잔여코인이 부족합니다.";
|
||||
break;
|
||||
case '98': // "98:사용기간만료"
|
||||
$mh_log = "사용기간이 만료되었습니다.";
|
||||
break;
|
||||
case '99': // "99:인증실패"
|
||||
$mh_log = "인증 받지 못하였습니다. 계정을 다시 확인해 주세요.";
|
||||
break;
|
||||
default: // "미 확인 오류"
|
||||
$mh_log = "알 수 없는 오류로 전송이 실패하었습니다.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$is_success = true;
|
||||
$mh_log = "문자전송:".get_hp($hp, 1);
|
||||
}
|
||||
|
||||
$hp = get_hp($hp, 1);
|
||||
$log = array_shift($SMS->Log);
|
||||
sql_query("insert into {$g5['sms5_member_history_table']} set mb_id='{$member['mb_id']}', mh_reply='$mh_reply', mh_hp='$hp', mh_datetime='".G5_TIME_YMDHIS."', mh_booking='$mh_booking', mh_log='$mh_log', mh_ip='".$_SERVER['REMOTE_ADDR']."'");
|
||||
|
||||
if ($is_admin == 'super')
|
||||
$sms5['cf_point'] = 0;
|
||||
|
||||
if ($is_success)
|
||||
insert_point($member['mb_id'], (-1) * $sms5['cf_point'], "$mh_log");
|
||||
|
||||
}
|
||||
$SMS->Init(); // 보관하고 있던 결과값을 지웁니다.
|
||||
}
|
||||
else alert("에러: SMS 서버와 통신이 불안정합니다.");
|
||||
}
|
||||
else alert("에러: SMS 데이터 입력도중 에러가 발생하였습니다.");
|
||||
|
||||
alert_close("$total 건의 문자메세지 전송을 완료하였습니다.");
|
||||
?>
|
||||
Reference in New Issue
Block a user