Blame | Last modification | View Log | RSS feed
<?phpif(!function_exists('getCache')){function getCache($module=array(),$restriction=array()){$CI =& get_instance();$CI->load->library(array('cache'));$returnresponse =array();if(isset($module) and !empty($module)){if(isset($module['header']) and !empty($module['header']) and in_array('header', $restriction)){$headerdata =array();foreach($module['header'] as $key=>$header){$cache = $CI->cache->get($header);if(isset($cache) and !empty($cache)){ $headerdata[$header]=$cache;unset($module['header'][$key]);}}$returnresponse['header']=$headerdata;}if(isset($module['footer']) and !empty($module['footer']) and in_array('footer', $restriction)){$footerdata =array();foreach($module['footer'] as $key=>$footer){$cache = $CI->cache->get($footer);if(isset($cache) and !empty($cache)){$footerdata[$footer]=$cache;unset($module['footer'][$key]);}}$returnresponse['footer']=$footerdata;}if(isset($module['response']) and !empty($module['response']) and in_array('response', $restriction)){$responsedata =array();foreach($module['response'] as $key=>$response){$cache = $CI->cache->get($response);if(isset($cache) and !empty($cache)){$responsedata[$response]=$cache;unset($module['response'][$key]);}}$returnresponse['response']=$responsedata;}$returnresponse['module']=$module;}return $returnresponse;}}if(!function_exists('setCache')){function setCache($module=array(),$restriction=array(),$data=array()){$CI =& get_instance();$CI->load->library(array('cache'));if(isset($module) and !empty($module)){if(isset($module['header']) and !empty($module['header']) and in_array('header', $restriction)){foreach($module['header'] as $header){$CI->cache->write($data['header'][$header], $header,600);}}if(isset($module['footer']) and !empty($module['footer']) and in_array('footer', $restriction)){foreach($module['footer'] as $footer){$CI->cache->write($data['footer'][$footer], $footer,600);}}if(isset($module['response']) and !empty($module['response']) and in_array('response', $restriction)){foreach($module['response'] as $response){if($response != 'recommended_accessories' && $response != 'recharge_icons'){if(isset($data['response'][$response]) && !empty($data['response'][$response]))$CI->cache->write($data['response'][$response], $response,600);}}}}return true;}}if(!function_exists('setFileCache')){function setFileCache($content=null,$filename=null,$expires=null){$CI =& get_instance();$CI->load->library(array('cache'));if(isset($content) && ($content != null)){$CI->cache->write($content, $filename,$expires);}return true;}}if(!function_exists('getFileCache')){function getFileCache($filename=null){$CI =& get_instance();$CI->load->library(array('cache'));$returnresponse =array();if(isset($filename) && ($filename != null)){$cache = $CI->cache->get($filename);if(isset($cache) && !empty($cache)){$returnresponse = $cache;}}return $returnresponse;}}if(!function_exists('deleteFileCache')){function deleteFileCache($filename=null){$CI =& get_instance();$CI->load->library(array('cache'));if(isset($filename) && ($filename != null)){$CI->cache->delete($filename);}}}//share helper start hereif( !function_exists('share_check') ){/*** Check type of share and return $URL or FALSE** @param string $type type of share* @return string|bool*/function share_check( $type='' ){$url = array('twitter' => 'http://twitter.com/share','facebook' => 'http://facebook.com/sharer.php','buzz' => 'http://www.google.com/buzz/post','vkontakte' => 'http://vkontakte.ru/share.php',);return (isset($url[$type])) ? $url[$type] : FALSE;}}if( !function_exists('share_url') ){/*** Generate url for share at some social networks** @param string $type type of share* @param array $args parameters for share* @return string*/function share_url( $type='', $args=array() ){$url = share_check( $type );if( $url === FALSE ){log_message( 'debug', 'Please check your type share_url('.$type.')' );return "#ERROR-check_share_url_type";}$params = array();if( $type == 'twitter' ){foreach( explode(' ', 'url via text related count lang counturl') as $v ){if( isset($args[$v]) ) $params[$v] = $args[$v];}}elseif( $type == 'facebook' ){$params['u'] = $args['url'];$params['t'] = $args['text'];}elseif( $type == 'buzz'){$params['url'] = $args['url'];$params['imageurl'] = $args['image'];$params['message'] = $args['text'];}elseif( $type == 'vkontakte'){$params['url'] = $args['url'];}$param = '';foreach( $params as $k=>$v ) $param .= '&'.$k.'='.urlencode($v);return $url.'?'.trim($param, '&');}}if( !function_exists('share_button') ){/*** Generate buttons for share at some social networks** @param string $type type of share* @param array $args parameters for share* @return string*/function share_button( $type='', $args=array() ){$url = share_check( $type );if( $url === FALSE ){log_message( 'debug', 'Please check your type share_button('.$type.')' );return "#ERROR-check_share_button_type";}$params = array();$param = '';if( $type == 'twitter'){if( isset($args['iframe']) ){$url = share_url( $type, $args );list($url, $param) = explode('?', $url);$button = <<<DOT<iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:130px; height:50px;"src="http://platform.twitter.com/widgets/tweet_button.html?{$param}"></iframe>DOT;}else{foreach( explode(' ', 'url via text related count lang counturl') as $v ){if( isset($args[$v]) ) $params[] = 'data-'.$v.'="'.$args[$v].'"';}$param = implode( ' ', $params );$button = <<<DOT<a href="http://twitter.com/share" class="twitter-share-button" {$param}>Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>DOT;}}elseif( $type == 'facebook' ){if( !isset($args['type']) ) $args['type'] = 'button_count';if( isset($args['fb']) ){$params = array( 'type'=>'type', 'href'=>'url', 'class'=>'class' );foreach( $params as $k=>$v ){if( isset($args[$v]) ) $param .= $k.'="'.$args[$v].'"';}$button = "<fb:share-button {$param}></fb:share-button>";}else{$params = array( 'type'=>'type', 'share_url'=>'url' );foreach( $params as $k=>$v ){if( isset($args[$v]) ) $param .= $k.'="'.$args[$v].'"';}if( !isset($args['button_text']) ) $args['button_text'] = 'Share to Facebook';$button = <<<DOT<a name="fb_share" {$param}>{$args['button_text']}</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>DOT;}}elseif( $type == 'buzz' ){$params = array( 'button-style'=>'type', 'local'=>'lang', 'url'=>'url', 'imageurl'=>'image');foreach( $params as $k=>$v ){if( isset($args[$v]) ) $param .= ' data-'.$k.'="'.$args[$v].'"';}if( !isset($args['title']) ) $args['title'] = 'Share to Google Buzz';$button = <<<DOT<a title="{$args['title']}" class="google-buzz-button" href="http://www.google.com/buzz/post" {$param}></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script>DOT;}elseif( $type == 'vkontakte' ){$url = isset($args['url']) ? '{url: "'.$args['url'].'"}' : 'false';foreach( explode(' ', 'type text') as $v ){if( isset($args[$v]) ) $param[] = $k.': "'.urlencode($args[$v]).'"';}$param = implode( ', ', $params );if( !empty($param) ) $param = ', {'.$param.'}';$button = <<<DOT<script type="text/javascript" src="http://vkontakte.ru/js/api/share.js?9" charset="windows-1251"></script><script type="text/javascript">document.write(VK.Share.button({$url}{$param}));</script>DOT;}return $button;}}//end of share helperif (!function_exists('getChecksum')) {function getChecksum($MerchantId, $OrderId, $Amount, $redirectUrl, $WorkingKey) {$str = "$MerchantId|$OrderId|$Amount|$redirectUrl|$WorkingKey";$adler = 1;$adler = adler32($adler,$str);return $adler;}}if (!function_exists('adler32')) {function adler32($adler , $str){$BASE = 65521 ;$s1 = $adler & 0xffff ;$s2 = ($adler >> 16) & 0xffff;for($i = 0 ; $i < strlen($str) ; $i++){$s1 = ($s1 + Ord($str[$i])) % $BASE ;$s2 = ($s2 + $s1) % $BASE ;}return leftshift($s2 , 16) + $s1;}}if(!function_exists('leftshift')){function leftshift($str , $num){$str = DecBin($str);for( $i = 0 ; $i < (64 - strlen($str)) ; $i++)$str = "0".$str ;for($i = 0 ; $i < $num ; $i++){$str = $str."0";$str = substr($str , 1 ) ;//echo "str : $str <BR>";}return cdec($str) ;}}if (!function_exists('cdec')) {function cdec($num){$dec=0;for ($n = 0 ; $n < strlen($num) ; $n++){$temp = $num[$n] ;$dec = $dec + $temp*pow(2 , strlen($num) - $n - 1);}return $dec;}}if (!function_exists('verifyChecksum')) {function verifyChecksum($MerchantId , $OrderId, $Amount, $AuthDesc, $WorkingKey, $CheckSum){$str = "";$str = "$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey";$adler = 1;$adler = adler32($adler,$str);if($adler==$CheckSum) return true;else return false;}}?>