⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.php

📁 太烦了
💻 PHP
📖 第 1 页 / 共 2 页
字号:
	}	$recs = $zipcodes;	$zipcodes=array();	if ($all == 'Y') {		$zipcodes['AA'] = ($recs['AA']!='')?$recs['AA']:'All Zip/Pin Codes';	}	foreach ($recs as $key => $val) {//		if ($key != 'AA') {			$zipcodes[$key] = $val;//		}	}	return $zipcodes;}function zipsAvailable($cntry_code) {	/* Function to check if zip code data is available for this country */	global $db;	$ret = $db->getOne('select 1 from ! where countrycode = ? limit 1,1', array( ZIPCODES_TABLE, $cntry_code) );	if (isset($ret) && $ret > 0) return $ret;	return 0;}function mailSender ($hdr_from, $hdr_to, $email, $subject, $body, $attachment='') {/*This is a wrapper function for sending emails	$hdr_from  - THe from address to be kept in the header	$hdr_to    - The to name and address to be kept in the Header	$email     - Email address to which the mail to be sent	$subject   - Subject of the email	$body      - The body of the email	$attachment - Mail Attachment*/	/* Construct the header portion */	/* clear html injects Begin */	$hdr_from = stripslashes(clearPost($hdr_from));	$hdr_to = stripslashes(clearPost($hdr_to));	$email = clearPost($email);	$subject = clearPost($subject);	$body = clearPost($body);	/* Html inject removed */	include_once (PEAR_DIR.'Mail/mime.php');	$siteurl = HTTP_METHOD . $_SERVER['SERVER_NAME'] . DOC_ROOT;	global $bannerURL, $config, $t;	$crlf = chr(13);	$headers = array (		'From'    	=> $hdr_from,		'Subject' 	=> stripslashes($subject)	);	$mime = new Mail_mime($crlf);	/* modify the encoding in mine with what is given for chosen language */	$mime->_build_params['text_encoding'] = get_lang('mail_text_encoding');	$mime->_build_params['html_encoding'] = get_lang('mail_html_encoding');	$mime->_build_params['html_charset'] = get_lang('mail_html_charset');	$mime->_build_params['text_charset'] = get_lang('mail_text_charset');	$mime->_build_params['head_charset'] = get_lang('mail_head_charset');	if (strtolower(MAIL_FORMAT) == 'html') {		$body = str_replace('#email_hdr_left#', $t->fetch('email_hdr_left.tpl'), $body);		$t->assign('message',$body);		$body = $t->fetch('html_emails.tpl');	}	$body = str_replace('#AdminName#', $config['admin_name'], $body);	$siteurl = HTTP_METHOD . $_SERVER['SERVER_NAME'] . DOC_ROOT ;	$body = str_replace('#link#', $siteurl,$body);	$body = str_replace('#SiteUrl#', $siteurl,$body);	$body = str_replace('#SkinName#', $config['skin_name'],$body);	$body = str_replace('#siteName#', $config['site_name'], $body);	$body = str_replace('#SiteName#', $config['site_name'], $body);	$body = str_replace('#AdminEmail#', $config['admin_email'], $body);	if (MAIL_FORMAT == 'text') {		$body = str_replace('<br>',$crlf,$body);		$body = str_replace('<br />',$crlf,$body);		$body = str_replace('<br/>',$crlf,$body);		// replace site link with full URL		global $config;		$body = str_replace('#SiteUrlLogin#', $siteurl.'login.php',str_replace("#AdminEmail#",$config['admin_email'],get_lang('mail','hdr_text'))).$body;/*		$site_name = $config['site_name'];		$site_url = 'http://' . $_SERVER['SERVER_NAME'] . DOC_ROOT;		$site_link = '<a href="' . $site_url . '">' . $site_name . '</a>';		$body = str_replace( $site_link, $site_url, $body );*/		// remove any final tags		$body = strip_tags( $body );		$mime->setTXTBody($body);	} else {		$body = str_replace("#SiteUrlLogin#",$siteurl.'login.php',str_replace("MAIL_HDR",str_replace("#AdminEmail#",$config['admin_email'],get_lang('mail','hdr_html')),$body));		/* Add banner advertisement if set in configuration settings */		if (($config['banner_in_emails'] == 'Y' || $config['banner_in_emails'] == '1') && $bannerURL != '') {			$body = $body.'<font style="font-size: 9px;"><br>Advertisement</font><br>'.str_replace('banclick.php',$siteurl.'banclick.php',$bannerURL);		}		$parserfile = INC_DIR.'internal/css_parser.php';		require_once($parserfile);		$cssparser = & new cssParser();		//$css is css stylesheet string		//$cssparser->ParseStr($css);		$cssfile = ROOT_DIR.'templates/'.$config['skin_name'].'/email.css';		$cssparser->parseFile($cssfile);		$htmlholder =& new htmlholder($body);		$htmlholder->replaceCSS($cssparser->codestr_holder);		$page = $htmlholder->out();		$page = str_replace('#SiteUrl#', $siteurl,$page);		$page = str_replace('#SkinName#', $config['skin_name'],$page);		$mime->setHTMLBody($page);	}	if (!is_array($attachment) ) {		$attach_files = explode(',',$attachment);	} else {		$attach_files = $attachment;	}	if (count($attach_files) > 0) {		foreach ($attach_files as $file) {			if ($file != '') {				$mime->addAttachment("../emailimages/".$file);			}		}	}	$body = $mime->get();	$hdrs = $mime->headers($headers);        $params = false;	if (MAIL_TYPE == 'smtp') {		$params['host'] = SMTP_HOST;		$params['port'] = SMTP_PORT;		$params['auth'] = (SMTP_AUTH=='1') ? true : false ;		$params['username'] = SMTP_USER;		$params['password'] = SMTP_PASS;	}	if ( trim( MAIL_TYPE ) == '' ) {		$mail_type = 'mail';	}	else {		$mail_type = MAIL_TYPE;	}	$mail_object =& Mail::factory( $mail_type, $params );	return($mail_object->send( $email, $hdrs, $body ) );}function process_payment_info($params) {	global $db;	// get the user information for this transaction	$trnrec=$db->getRow('select * from ! where invoice_no = ? ', array(TRANSACTIONS_TABLE, $params['pay_txn_id'] ));	$user_id = $trnrec['user_id'];	$user_level		= $trnrec['to_membership'];	$levelvars = $db->getRow( 'select activedays, name from ! where roleid = ?', array( MEMBERSHIP_TABLE, $user_level ) );	$activedays		= $levelvars['activedays'];	$level_name		= $levelvars['name'];	if ( $params['valid'] && $trnrec['payment_status'] != 'Completed') {		$sql = 'update ! set payment_email = ?, amount_paid = ?, txn_id = ?, txn_date = ?, payment_vars = ?, payment_status=? where invoice_no = ?';		$db->query( $sql, array( TRANSACTIONS_TABLE, $params['email'], $params['amount'], $params['txn_id'], date('Y-m-d'), $params['vars'], $params['payment_status'], $params['pay_txn_id'] ) );		// determine when this user's membership was to expire, then extend it by $activedays days		if (trim($params['payment_status']) == 'Completed') {			$curlevel = $db->getRow( 'select levelend, level from ! where id = ?', array( USER_TABLE, $user_id ) );			$levelend = $curlevel['levelend'];			if ( $levelend < time() ) {				$levelend = time();			}			// new expiration date for this member			if ($curlevel['level'] != $user_level) {				$levelend = strtotime( "+$activedays day", time() );			} else {				$levelend = strtotime( "+$activedays day", $levelend );			}			$sql = 'UPDATE ! SET level = ?, levelend = ? WHERE id = ?';			$db->query( $sql, array( USER_TABLE, $user_level, $levelend, $user_id ) );		}	}	return $level_name;}function getTplFile ($resource_type, $resource_name, &$template_source, &$template_timestamp, &$smarty_obj){	global $skin_name;	if ( !is_readable ( $resource_name )) {		// create the template file, return contents.		$new_resource = str_replace('/templates/'.$skin_name.'/','/templates/default/',$smarty_obj->template_dir).$resource_name;		$template_timestamp = filemtime($new_resource);		$template_source = file_get_contents($new_resource);		return true;	}}## clear html injects Begin ##function clearPost($post_val) // remove email headder injects{	$injection_strings = array(	"'apparently-to' i",	"'bcc:' i",	"'cc:' i",	"'to:' i",	"'boundary=' i",	"'charset:' i",	"'content-disposition' i",	"'content-type' i",	"'content-transfer-encoding' i",	"'errors-to' i",	"'in-reply-to' i",	"'message-id' i",	"'mime-version' i",	"'multipart/mixed' i",	"'multipart/alternative' i",	"'multipart/related' i",	"'reply-to:' i",	"'x-mailer' i",	"'x-sender' i",	"'x-uidl' i"	);	$replace_strings = array(	"apparently_to",	"bcc_:",	"cc_:",	"to_:",	"boundary_=",	"charset_:",	"content_disposition",	"content_type",	"content_transfer_encoding",	"errors_to",	"in_reply_to",	"message_id",	"mime_version",	"multipart_mixed",	"multipart_alternative",	"multipart_related",	"reply_to:",	"x_mailer",	"x_sender",	"x_uidl"	);	$post_val = preg_replace($injection_strings, $replace_strings, $post_val);	return $post_val;} //function clearPostfunction DeleteCacheFiles($fromdir, $tm, $recursed = 1 ) {	if ($fromdir == "" or !is_dir($fromdir)) {		echo ('Invalid directory');		return false;	}	$filelist = array();	$dir = opendir($fromdir);	while($file = readdir($dir)) {		if($file == "." || $file == ".." || $file == 'readme.txt' || $file == 'index.html' || $file == 'index.htm' || $file == 'lasttime.dat' ) {			continue;		} elseif (is_dir($fromdir."/".$file)) {			if ($recursed == 1) {				$temp = DeleteCacheFiles($fromdir."/".$file, $recursed);			}		} elseif (file_exists($fromdir."/".$file) && filemtime($fromdir."/".$file) < $tm) {			unlink($fromdir."/".$file);		}	}	closedir($dir);	return true;}function deleteCache() {	global $config;	/* This function will delete cache files.. */	$tm = time() - $config['time_cache_expiry']*60;	$lasttime = 0;	if (is_readable(CACHE_DIR.'lasttime.dat')) {		$lt = file(CACHE_DIR.'lasttime.dat');		$lasttime = trim($lt[0]);	}	if ($lasttime < $tm) {		DeleteCacheFiles(CACHE_DIR,$tm);		$fp = @fopen(CACHE_DIR.'lasttime.dat','wb');		if ($fp) {			fwrite($fp, time());			fclose($fp);		}	}}function updateLoadedPicturesCnt($userid) {	/* This function will update teh User Table for the loaded picture count */	$picscnt = $GLOBALS['db']->getOne('select count(*) from ! where userid = ?',array(USER_SNAP_TABLE, $userid));	$GLOBALS['db']->query('update ! set pictures_cnt = ? where id = ?',array(USER_TABLE, $picscnt, $userid));}function updateLoadedVideosCnt($userid) {	/* This function will update teh User Table for the loaded picture count */	$vdscnt = $GLOBALS['db']->getOne('select count(*) from ! where userid = ?',array(USER_VIDEOS_TABLE, $userid));	$GLOBALS['db']->query('update ! set videos_cnt = ? where id = ?',array(USER_TABLE, $vdscnt, $userid));}function stripEmails( $instring ){/* Thanks to premiumMatch for providing this function code */	$replacementString = " = email Address Removed = ";	// normal email format	$instring = preg_replace( "/[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}/i", $replacementString, $instring );	// "at dot" format	$instring = preg_replace( "/[A-Z0-9._%-]+ at [A-Z0-9._%-]+ dot [A-Z]{2,6}/i", $replacementString, $instring );	return $instring;}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -