X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=8f16dfc02a44ac1f7a4583722005bce6404b7573;hp=5557b88024ad1605fc245b8157f3d51856d2f639;hb=e6cc8e9581807e21cf173c8a891869f1983fc935;hpb=bdd8949ee8b336ef33a7c83ae2c00ac0134dad0f diff --git a/inc/functions.php b/inc/functions.php index 5557b88024..8f16dfc02a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -85,16 +85,7 @@ function outputHtml ($htmlCode, $newLine = true) { app_die(__FUNCTION__, __LINE__, '{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}'); break; } // END - switch - } elseif ((getPhpCaching() == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) { - // Headers already sent? - if (headers_sent()) { - // Log this error - logDebugMessage(__FUNCTION__, __LINE__, 'Headers already sent! We need debug backtrace here.'); - - // Trigger an user error - debug_report_bug('Headers are already sent!'); - } // END - if - + } elseif (getPhpCaching() == 'on') { // Output cached HTML code $GLOBALS['output'] = ob_get_contents(); @@ -108,12 +99,12 @@ function outputHtml ($htmlCode, $newLine = true) { $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']); } // END - if - // Compile and run finished rendered HTML code - compileFinalOutput(); - // Send all HTTP headers sendHttpHeaders(); + // Compile and run finished rendered HTML code + compileFinalOutput(); + // Output code here, DO NOT REMOVE! ;-) outputRawCode($GLOBALS['output']); } elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($GLOBALS['output']))) { @@ -122,12 +113,12 @@ function outputHtml ($htmlCode, $newLine = true) { $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']); } // END - if - // Compile and run finished rendered HTML code - compileFinalOutput(); - // Send all HTTP headers sendHttpHeaders(); + // Compile and run finished rendered HTML code + compileFinalOutput(); + // Output code here, DO NOT REMOVE! ;-) outputRawCode($GLOBALS['output']); } @@ -142,7 +133,7 @@ function sendHttpHeaders () { sendHeader('HTTP/1.1 200'); // General headers for no caching - sendHeader('Expired: ' . $now); // RFC2616 - Section 14.21 + sendHeader('Expires: ' . $now); // RFC2616 - Section 14.21 sendHeader('Last-Modified: ' . $now); sendHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 sendHeader('Pragma: no-cache'); // HTTP/1.0 @@ -177,8 +168,26 @@ function compileFinalOutput () { $cnt++; } // END - while + // Compress it? + if (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos('gzip', $_SERVER['HTTP_ACCEPT_ENCODING']) !== null)) { + // Compress it for HTTP gzip + $GLOBALS['output'] = gzencode($GLOBALS['output'], 9, true); + + // Add header + sendHeader('Content-Encoding: gzip'); + } elseif (!empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos('deflate', $_SERVER['HTTP_ACCEPT_ENCODING']) !== null)) { + // Compress it for HTTP deflate + $GLOBALS['output'] = gzcompress($GLOBALS['output'], 9); + + // Add header + sendHeader('Content-Encoding: deflate'); + } + // Add final length sendHeader('Content-Length: ' . strlen($GLOBALS['output'])); + + // Flush all headers + flushHeaders(); } // Output the raw HTML code @@ -400,7 +409,7 @@ function detectExtraTemplatePath ($template) { } // Loads an email template and compiles it -function loadEmailTemplate ($template, $content = array(), $UID = '0') { +function loadEmailTemplate ($template, $content = array(), $userid = '0') { global $DATA; // Make sure all template names are lowercase! @@ -409,53 +418,33 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') { // Default 'nickname' if extension is not installed $nick = '---'; - // Prepare IP number and User Agent - $REMOTE_ADDR = detectRemoteAddr(); - $HTTP_USER_AGENT = detectUserAgent(); - - // Default admin - $ADMIN = getConfig('MAIN_TITLE'); - - // Is the admin logged in? - if (isAdmin()) { - // Get admin id - $adminId = getCurrentAdminId(); - - // Load Admin data - $ADMIN = getAdminEmail($adminId); - } // END - if - // Neutral email address is default $email = getConfig('WEBMASTER'); - // Expiration in a nice output format - // NOTE: Use $content[expiration] in your templates instead of $EXPIRATION - if (getConfig('auto_purge') == '0') { - // Will never expire! - $EXPIRATION = getMessage('MAIL_WILL_NEVER_EXPIRE'); - } else { - // Create nice date string - $EXPIRATION = createFancyTime(getConfig('auto_purge')); - } - // Is content an array? if (is_array($content)) { - // Add expiration to array, $EXPIRATION is now deprecated! - $content['expiration'] = $EXPIRATION; + // Add expiration to array + if (getConfig('auto_purge') == '0') { + // Will never expire! + $content['expiration'] = getMessage('MAIL_WILL_NEVER_EXPIRE'); + } else { + // Create nice date string + $content['expiration'] = createFancyTime(getConfig('auto_purge')); + } } // END - if // Load user's data - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):UID={$UID},template={$template},content[]=".gettype($content).'
'); - if (($UID > 0) && (is_array($content))) { + //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):UID={$userid},template={$template},content[]=".gettype($content).'
'); + if (($userid > 0) && (is_array($content))) { // If nickname extension is installed, fetch nickname as well - if ((isExtensionActive('nickname')) && (isNicknameUsed($UID))) { + if ((isExtensionActive('nickname')) && (isNicknameUsed($userid))) { //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NICKNAME!
"); // Load by nickname - fetchUserData($UID, 'nickname'); + fetchUserData($userid, 'nickname'); } else { //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NO-NICK!
"); /// Load by userid - fetchUserData($UID); + fetchUserData($userid); } // Merge data if valid @@ -473,7 +462,7 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') { if (isset($content['email'])) $email = $content['email']; // Store email for some functions in global data array - // @TODO Do only use $contentn, not $DATA or raw variables + // @TODO Do only use $content, not $DATA or raw variables $DATA['email'] = $email; // Base directory @@ -519,7 +508,7 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') { // Is there some content? if (empty($newContent)) { // Compiling failed - $newContent = "Compiler error for template {$template}!\nUncompiled content:\n" . $GLOBALS['tpl_content']; + $newContent = "Compiler error for template " . $template . " !\nUncompiled content:\n" . $GLOBALS['tpl_content']; // Add last error if the required function exists if (function_exists('error_get_last')) $newContent .= "\n--------------------------------------\nDebug:\n".print_r(error_get_last(), true)."--------------------------------------\nPlease don't alter these informations!\nThanx."; @@ -938,28 +927,19 @@ function redirectToUrl ($URL) { $rel = ''; } // END - if - // Get output buffer - $GLOBALS['output'] = ob_get_contents(); - - // Clear it only if there is content - if (!empty($GLOBALS['output'])) { - clearOutputBuffer(); - } // END - if - // Three different ways to debug... //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL)); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'URL=' . $URL); //* DEBUG: */ die($URL); // Simple probe for bots/spiders from search engines - if ((strpos(detectUserAgent(), 'spider') !== false) || (strpos(detectUserAgent(), 'bot') !== false)) { + if (isSpider()) { // Secure the URL against bad things such als HTML insertions and so on... $URL = secureString($URL); // Output new location link as anchor outputHtml('' . $URL . ''); } elseif (!headers_sent()) { - //* DEBUG: */ debug_report_bug("URL={$URL}"); // Clear own output buffer $GLOBALS['output'] = ''; @@ -1844,19 +1824,19 @@ function sendRawRequest ($host, $request) { // Do we use proxy? if ($useProxy === true) { // Generate CONNECT request header - $proxyTunnel = "CONNECT " . $host . ":80 HTTP/1.1" . getConfig('HTTP_EOL'); - $proxyTunnel .= "Host: " . $host . getConfig('HTTP_EOL'); + $proxyTunnel = 'CONNECT ' . $host . ':80 HTTP/1.1' . getConfig('HTTP_EOL'); + $proxyTunnel .= 'Host: ' . $host . getConfig('HTTP_EOL'); // Use login data to proxy? (username at least!) if (getConfig('proxy_username') != '') { // Add it as well $encodedAuth = base64_encode(compileRawCode(getConfig('proxy_username')) . getConfig('ENCRYPT_SEPERATOR') . compileRawCode(getConfig('proxy_password'))); - $proxyTunnel .= "Proxy-Authorization: Basic " . $encodedAuth . getConfig('HTTP_EOL'); + $proxyTunnel .= 'Proxy-Authorization: Basic ' . $encodedAuth . getConfig('HTTP_EOL'); } // END - if // Add last new-line $proxyTunnel .= getConfig('HTTP_EOL'); - //* DEBUG: */ print("proxyTunnel=
" . $proxyTunnel."
"); + //* DEBUG: */ print('proxyTunnel=
' . $proxyTunnel.'
'); // Write request fputs($fp, $proxyTunnel); @@ -1903,7 +1883,7 @@ function sendRawRequest ($host, $request) { } } // END - foreach - //* DEBUG: */ print("Response:
".print_r($response, true)."
"); + //* DEBUG: */ print('Response:
'.print_r($response, true).'
'); // Proxy agent found? if ((substr(strtolower($response[0]), 0, 11) == 'proxy-agent') && ($useProxy === true)) { @@ -1967,11 +1947,11 @@ function generateMemberAdminActionLinks ($userid, $status = '') { $targetArray = array('del_user', 'edit_user', 'lock_user', 'add_points', 'sub_points'); // Begin of navigation links - $OUT = "[ "; + $OUT = '[ '; foreach ($targetArray as $tar) { - $OUT .= ""); + $OUT .= '{--ADMIN_"; + $OUT .= '_TITLE--}">{--ADMIN_'; if (($tar == 'lock_user') && ($status == 'LOCKED')) { // Locked accounts shall be unlocked $OUT .= 'UNLOCK_USER'; @@ -1987,7 +1967,7 @@ function generateMemberAdminActionLinks ($userid, $status = '') { // All other status is fine $OUT .= strtoupper($tar); } - $OUT .= "--} | "; + $OUT .= '--} | '; } // Finish navigation link @@ -2051,15 +2031,15 @@ function generateHash ($plainText, $salt = '') { // Generate SHA1 sum from modula of number and the prime number $sha1 = sha1(($a % getConfig('_PRIME')) . $server . getConfig('ENCRYPT_SEPERATOR') . $keys . getConfig('ENCRYPT_SEPERATOR') . $data . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . $a); - //* DEBUG: */ outputHtml("SHA1=" . $sha1." (".strlen($sha1).")
"); + //* DEBUG: */ outputHtml('SHA1=' . $sha1.' ('.strlen($sha1).')
'); $sha1 = scrambleString($sha1); - //* DEBUG: */ outputHtml("Scrambled=" . $sha1." (".strlen($sha1).")
"); + //* DEBUG: */ outputHtml('Scrambled=' . $sha1.' ('.strlen($sha1).')
'); //* DEBUG: */ $sha1b = descrambleString($sha1); - //* DEBUG: */ outputHtml("Descrambled=" . $sha1b." (".strlen($sha1b).")
"); + //* DEBUG: */ outputHtml('Descrambled=' . $sha1b.' ('.strlen($sha1b).')
'); // Generate the password salt string $salt = substr($sha1, 0, getConfig('salt_length')); - //* DEBUG: */ outputHtml($salt." (".strlen($salt).")
"); + //* DEBUG: */ outputHtml($salt.' ('.strlen($salt).')
'); } else { // Use given salt //* DEBUG: */ print 'salt=' . $salt . '
'; @@ -2095,7 +2075,7 @@ function scrambleString($str) { } // Scramble string here - //* DEBUG: */ outputHtml("***Original=" . $str."***
"); + //* DEBUG: */ outputHtml('***Original=' . $str.'***
'); for ($idx = '0'; $idx < strlen($str); $idx++) { // Get char on scrambled position $char = substr($str, $scrambleNums[$idx], 1); @@ -2105,7 +2085,7 @@ function scrambleString($str) { } // END - for // Return scrambled string - //* DEBUG: */ outputHtml("***Scrambled=" . $scrambled."***
"); + //* DEBUG: */ outputHtml('***Scrambled=' . $scrambled.'***
'); return $scrambled; } @@ -2122,14 +2102,14 @@ function descrambleString($str) { // Begin descrambling $orig = str_repeat(' ', 40); - //* DEBUG: */ outputHtml("+++Scrambled=" . $str."+++
"); + //* DEBUG: */ outputHtml('+++Scrambled=' . $str.'+++
'); for ($idx = '0'; $idx < 40; $idx++) { $char = substr($str, $idx, 1); $orig = substr_replace($orig, $char, $scrambleNums[$idx], 1); } // END - for // Return scrambled string - //* DEBUG: */ outputHtml("+++Original=" . $orig."+++
"); + //* DEBUG: */ outputHtml('+++Original=' . $orig.'+++
'); return $orig; } @@ -2596,8 +2576,7 @@ function debug_report_bug ($message = '', $sendEmail = true) { // Prepare content $content = array( 'message' => trim($message), - 'backtrace' => trim(debug_get_mailable_backtrace()), - 'request_uri' => trim(getRequestUri()) + 'backtrace' => trim(debug_get_mailable_backtrace()) ); // Send email to webmaster @@ -2619,34 +2598,33 @@ function getMessageFromErrorCode ($code) { $message = ''; switch ($code) { case '': break; - case getCode('LOGOUT_DONE') : $message = getMessage('LOGOUT_DONE'); break; - case getCode('LOGOUT_FAILED') : $message = "{--LOGOUT_FAILED--}"; break; - case getCode('DATA_INVALID') : $message = getMessage('MAIL_DATA_INVALID'); break; - case getCode('POSSIBLE_INVALID') : $message = getMessage('MAIL_POSSIBLE_INVALID'); break; - case getCode('ACCOUNT_LOCKED') : $message = getMessage('MEMBER_ACCOUNT_LOCKED_UNC'); break; - case getCode('USER_404') : $message = getMessage('USER_404'); break; - case getCode('STATS_404') : $message = getMessage('MAIL_STATS_404'); break; - case getCode('ALREADY_CONFIRMED'): $message = getMessage('MAIL_ALREADY_CONFIRMED'); break; - case getCode('WRONG_PASS') : $message = getMessage('LOGIN_WRONG_PASS'); break; - case getCode('WRONG_ID') : $message = getMessage('LOGIN_WRONG_ID'); break; - case getCode('ID_LOCKED') : $message = getMessage('LOGIN_ID_LOCKED'); break; - case getCode('ID_UNCONFIRMED') : $message = getMessage('LOGIN_ID_UNCONFIRMED'); break; - case getCode('ID_GUEST') : $message = getMessage('LOGIN_ID_GUEST'); break; - case getCode('COOKIES_DISABLED') : $message = getMessage('LOGIN_COOKIES_DISABLED'); break; - case getCode('BEG_SAME_AS_OWN') : $message = getMessage('BEG_SAME_UID_AS_OWN'); break; - case getCode('LOGIN_FAILED') : $message = getMessage('LOGIN_FAILED_GENERAL'); break; - case getCode('MODULE_MEM_ONLY') : $message = sprintf(getMessage('MODULE_MEM_ONLY'), getRequestElement('mod')); break; - case getCode('OVERLENGTH') : $message = getMessage('MEMBER_TEXT_OVERLENGTH'); break; - case getCode('URL_FOUND') : $message = getMessage('MEMBER_TEXT_CONTAINS_URL'); break; - case getCode('SUBJ_URL') : $message = getMessage('MEMBER_SUBJ_CONTAINS_URL'); break; - case getCode('BLIST_URL') : $message = "{--MEMBER_URL_BLACK_LISTED--}
\n{--MEMBER_BLIST_TIME--}: ".generateDateTime(getRequestElement('blist'), 0); break; - case getCode('NO_RECS_LEFT') : $message = getMessage('MEMBER_SELECTED_MORE_RECS'); break; - case getCode('INVALID_TAGS') : $message = getMessage('MEMBER_HTML_INVALID_TAGS'); break; - case getCode('MORE_POINTS') : $message = getMessage('MEMBER_MORE_POINTS_NEEDED'); break; - case getCode('MORE_RECEIVERS1') : $message = getMessage('MEMBER_ENTER_MORE_RECEIVERS'); break; - case getCode('MORE_RECEIVERS2') : $message = getMessage('MEMBER_NO_MORE_RECEIVERS_FOUND'); break; - case getCode('MORE_RECEIVERS3') : $message = sprintf(getMessage('MEMBER_ENTER_MORE_MIN_RECEIVERS'), getConfig('order_min')); break; - case getCode('INVALID_URL') : $message = getMessage('MEMBER_ENTER_INVALID_URL'); break; + case getCode('LOGOUT_DONE') : $message = getMessage('LOGOUT_DONE'); break; + case getCode('LOGOUT_FAILED') : $message = '{--LOGOUT_FAILED--}'; break; + case getCode('DATA_INVALID') : $message = getMessage('MAIL_DATA_INVALID'); break; + case getCode('POSSIBLE_INVALID') : $message = getMessage('MAIL_POSSIBLE_INVALID'); break; + case getCode('ACCOUNT_LOCKED') : $message = getMessage('MEMBER_ACCOUNT_LOCKED_UNC'); break; + case getCode('USER_404') : $message = getMessage('USER_404'); break; + case getCode('STATS_404') : $message = getMessage('MAIL_STATS_404'); break; + case getCode('ALREADY_CONFIRMED') : $message = getMessage('MAIL_ALREADY_CONFIRMED'); break; + case getCode('WRONG_PASS') : $message = getMessage('LOGIN_WRONG_PASS'); break; + case getCode('WRONG_ID') : $message = getMessage('LOGIN_WRONG_ID'); break; + case getCode('STATUS_LOCKED') : $message = getMessage('LOGIN_STATUS_LOCKED'); break; + case getCode('STATUS_UNCONFIRMED'): $message = getMessage('LOGIN_STATUS_UNCONFIRMED'); break; + case getCode('COOKIES_DISABLED') : $message = getMessage('LOGIN_COOKIES_DISABLED'); break; + case getCode('BEG_SAME_AS_OWN') : $message = getMessage('BEG_SAME_UID_AS_OWN'); break; + case getCode('LOGIN_FAILED') : $message = getMessage('LOGIN_FAILED_GENERAL'); break; + case getCode('MODULE_MEM_ONLY') : $message = sprintf(getMessage('MODULE_MEM_ONLY'), getRequestElement('mod')); break; + case getCode('OVERLENGTH') : $message = getMessage('MEMBER_TEXT_OVERLENGTH'); break; + case getCode('URL_FOUND') : $message = getMessage('MEMBER_TEXT_CONTAINS_URL'); break; + case getCode('SUBJ_URL') : $message = getMessage('MEMBER_SUBJ_CONTAINS_URL'); break; + case getCode('BLIST_URL') : $message = "{--MEMBER_URL_BLACK_LISTED--}
\n{--MEMBER_BLIST_TIME--}: ".generateDateTime(getRequestElement('blist'), 0); break; + case getCode('NO_RECS_LEFT') : $message = getMessage('MEMBER_SELECTED_MORE_RECS'); break; + case getCode('INVALID_TAGS') : $message = getMessage('MEMBER_HTML_INVALID_TAGS'); break; + case getCode('MORE_POINTS') : $message = getMessage('MEMBER_MORE_POINTS_NEEDED'); break; + case getCode('MORE_RECEIVERS1') : $message = getMessage('MEMBER_ENTER_MORE_RECEIVERS'); break; + case getCode('MORE_RECEIVERS2') : $message = getMessage('MEMBER_NO_MORE_RECEIVERS_FOUND'); break; + case getCode('MORE_RECEIVERS3') : $message = sprintf(getMessage('MEMBER_ENTER_MORE_MIN_RECEIVERS'), getConfig('order_min')); break; + case getCode('INVALID_URL') : $message = getMessage('MEMBER_ENTER_INVALID_URL'); break; case getCode('ERROR_MAILID'): if (isExtensionActive('mailid', true)) { @@ -2868,7 +2846,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { } // Send notification to admin function sendAdminNotification ($subject, $templateName, $content=array(), $userid = '0') { - if (isExtensionInstalledAndNewer('admins', '0.4.1')) { + if ((isExtensionInstalledAndNewer('admins', '0.4.1')) && (function_exists('sendAdminsEmails'))) { // Send new way sendAdminsEmails($subject, $templateName, $content, $userid); } else { @@ -3073,15 +3051,15 @@ function addNewBonusMail ($data, $mode = '', $output=true) { if ((empty($mode)) && (isset($data['mode']))) $mode = $data['mode']; // Generate receiver list - $RECEIVER = generateReceiverList($data['cat'], $data['receiver'], $mode); + $receiver = generateReceiverList($data['cat'], $data['receiver'], $mode); // Receivers added? - if (!empty($RECEIVER)) { + if (!empty($receiver)) { // Add bonus mail to queue addBonusMailToQueue( $data['subject'], $data['text'], - $RECEIVER, + $receiver, $data['points'], $data['seconds'], $data['url'], @@ -3581,7 +3559,7 @@ function determinePageTitle () { $pageTitle = $TITLE; } elseif ((isInstalled()) && (isAdminRegistered())) { // Installed, admin registered but no ext-sql_patches - $pageTitle = '[-- ' . getConfig('MAIN_TITLE').' - '.getModuleTitle(getModule()) . ' --]'; + $pageTitle = '[-- ' . getConfig('MAIN_TITLE') . ' - ' . getModuleTitle(getModule()) . ' --]'; } elseif ((isInstalled()) && (!isAdminRegistered())) { // Installed but no admin registered $pageTitle = sprintf(getMessage('SETUP_OF_MXCHANGE'), getConfig('MAIN_TITLE')); @@ -3597,7 +3575,7 @@ function determinePageTitle () { } // Return title - return $pageTitle; + return decodeEntities($pageTitle); } // Checks wethere there is a cache file there. This function is cached. @@ -3851,12 +3829,13 @@ function encodeUrl ($url, $outputMode = '0') { // Add it to URL if (session_id() != '') { + die($url); $url .= $seperator . session_name() . '=' . session_id(); } // END - if } // END - if // Add {?URL?} ? - if ((substr($url, 0, strlen(getConfig('URL'))) != getConfig('URL')) && (substr($url, 0, 7) == '{?URL?}')) { + if ((substr($url, 0, strlen(getConfig('URL'))) != getConfig('URL')) && (substr($url, 0, 7) != '{?URL?}') && (substr($url, 0, 7) != 'http://') && (substr($url, 0, 8) != 'https://')) { // Add it $url = '{?URL?}/' . $url; } // END - if @@ -3867,8 +3846,14 @@ function encodeUrl ($url, $outputMode = '0') { // Simple check for spider function isSpider () { + // Get the UA + $userAgent = strtolower(detectUserAgent(true)); + + // It should not be empty, if so it is better a spider/bot + if (empty($userAgent)) return true; + // Is it a spider? - return ((strpos('spider', strtolower(detectUserAgent(true))) !== false) || (strpos('bot', strtolower(detectUserAgent(true))) !== false)); + return ((strpos($userAgent, 'spider') !== false) || (strpos($userAgent, 'slurp') !== false) || (strpos($userAgent, 'bot') !== false)); } //////////////////////////////////////////////////