Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 1.1.3.0
- * @ Author : DeZender
- * @ Release on : 17.05.2011
- * @ Official site : http://DeZender.Net
- *
- */
- function trigger_db_error(&$obj) {
- global $CFG;
- $error_arr = debug_backtrace( );
- $subject = 'Report bug - Sql error - VAR_SITE_URL';
- $content = '<u><b>Url :</b></u>
- VAR_CURRENT_URL
- <u><b>Error File :</b></u>
- VAR_FILE
- <u><b>Error Line No :</b></u>
- VAR_LINE
- <u><b>Error Sql :</b></u>
- VAR_SQL
- <u><b>Error Description:</b></u>
- VAR_ERROR';
- $frmobj = new FormHandler( );
- $frmobj->setEmailTemplateValue( 'CURRENT_URL', $CFG['site']['current_url'] );
- $frmobj->setEmailTemplateValue( 'FILE', $error_arr[0]['file'] );
- $frmobj->setEmailTemplateValue( 'LINE', $error_arr[0]['line'] );
- $frmobj->setEmailTemplateValue( 'SQL', $error_arr[0]['args'][0]->sql );
- $frmobj->setEmailTemplateValue( 'ERROR', $error_arr[0]['args'][0]->debug_output );
- $frmobj->buildEmailTemplate( $subject, $content, false, true );
- sendBugEmail( $frmobj );
- trigger_error( 'Error at ' . $error_arr[0]['file'] . ' on line ' . $error_arr[0]['line'] . '<br>' . $obj->ErrorNo( ) . ' ' . $obj->ErrorMsg( ), E_USER_ERROR );
- }
- function setUserConfigVariables() {
- global $CFG;
- if (!isMember( )) {
- return false;
- }
- $CFG['user']['user_id'] = $_SESSION['user']['user_id'];
- $CFG['user']['user_name'] = $_SESSION['user']['user_name'];
- $CFG['user']['time_zone'] = (isset( $_SESSION['user']['time_zone'] ) ? $_SESSION['user']['time_zone'] : '');
- $CFG['user']['email'] = (isset( $_SESSION['user']['email'] ) ? $_SESSION['user']['email'] : '');
- $CFG['user']['openid_type'] = (isset( $_SESSION['user']['openid_type'] ) ? $_SESSION['user']['openid_type'] : '');
- $CFG['user']['name'] = (isset( $_SESSION['user']['name'] ) ? $_SESSION['user']['name'] : '');
- $CFG['user']['pref_lang'] = (isset( $_SESSION['user']['pref_lang'] ) ? $_SESSION['user']['pref_lang'] : '');
- $CFG['user']['last_logged'] = (isset( $_SESSION['user']['last_logged'] ) ? $_SESSION['user']['last_logged'] : '');
- $CFG['user']['num_visits'] = (isset( $_SESSION['user']['num_visits'] ) ? $_SESSION['user']['num_visits'] : '');
- $CFG['user']['useragent_hash'] = (isset( $_SESSION['user']['useragent_hash'] ) ? $_SESSION['user']['useragent_hash'] : '');
- $CFG['user']['is_upload_background_image'] = (isset( $_SESSION['user']['is_upload_background_image'] ) ? $_SESSION['user']['is_upload_background_image'] : '');
- $CFG['user']['is_paid_member'] = (isset( $_SESSION['user']['is_paid_member'] ) ? $_SESSION['user']['is_paid_member'] : '');
- $CFG['user']['ip'] = (isset( $_SESSION['user']['ip'] ) ? $_SESSION['user']['ip'] : '');
- $CFG['user']['is_logged_in'] = (isset( $_SESSION['user']['is_logged_in'] ) ? $_SESSION['user']['is_logged_in'] : '');
- $CFG['user']['adult'] = (isset( $_SESSION['user']['adult'] ) ? $_SESSION['user']['adult'] : '');
- $CFG['user']['content_filter'] = (isset( $_SESSION['user']['content_filter'] ) ? $_SESSION['user']['content_filter'] : '');
- $CFG['user']['usr_access'] = (isset( $_SESSION['user']['usr_access'] ) ? $_SESSION['user']['usr_access'] : '');
- $CFG['user']['user_actions'] = (isset( $_SESSION['user']['user_actions'] ) ? $_SESSION['user']['user_actions'] : '');
- return true;
- }
- function sendBugEmail($frmobj) {
- global $CFG;
- $EasySwift = new EasySwift( )( );
- $EasySwift->flush( );
- $EasySwift->addPart( $frmobj->getEmailContent( true ), 'text/html' );
- $from_email = $CFG['site']['noreply_email'];
- $EasySwift->send( 'r.senthilvasan@agriya.in', $from_email, $frmobj->getEmailSubject( ) );
- }
- function getCurrentMemberUrl() {
- global $CFG;
- return $CFG['site']['current_url'];
- }
- function getMemberAvatarDetails($user_id) {
- global $db;
- global $CFG;
- $details = array( );
- $defaultPhotoDetails = true;
- $udetails = getUserDetail( 'user_id', $user_id );
- if (( $udetails && $udetails['image_ext'] )) {
- $defaultPhotoDetails = false;
- $imgUrl = (!empty( $udetails['image_server_url'] ) ? $udetails['image_server_url'] : $CFG['site']['url']);
- $img = $imgUrl . $CFG['admin']['members_profile']['user_profile_folder'] . '/';
- $udetails['image_name'] = ($udetails['image_name'] ? $udetails['image_name'] : $user_id);
- $details['l_url'] = $img . $udetails['image_name'] . $CFG['image_large_name'] . '.' . $udetails['image_ext'];
- $details['t_url'] = $img . $udetails['image_name'] . $CFG['image_thumb_name'] . '.' . $udetails['image_ext'];
- $details['s_url'] = $img . $udetails['image_name'] . $CFG['image_small_name'] . '.' . $udetails['image_ext'];
- $details['m_url'] = $img . $udetails['image_name'] . $CFG['image_medium_name'] . '.' . $udetails['image_ext'];
- $details['s_width'] = $udetails['small_width'];
- $details['t_width'] = $udetails['thumb_width'];
- $details['l_width'] = $udetails['large_width'];
- $details['m_width'] = $udetails['mini_width'];
- $details['s_height'] = $udetails['small_height'];
- $details['t_height'] = $udetails['thumb_height'];
- $details['l_height'] = $udetails['large_height'];
- $details['m_height'] = $udetails['mini_height'];
- }
- if ($defaultPhotoDetails) {
- $tWidth = $CFG['image_thumb_width'];
- $tHeight = $CFG['image_thumb_height'];
- $sWidth = $CFG['image_small_width'];
- $sHeight = $CFG['image_small_height'];
- $lWidth = $CFG['image_thumb_width'];
- $lHeight = $CFG['image_thumb_height'];
- $mWidth = $CFG['image_medium_width'];
- $mHeight = $CFG['image_medium_height'];
- $url = $CFG['site']['url'] . 'design/templates/' . $CFG['html']['template']['default'] . '/root/images/' . $CFG['html']['stylesheet']['screen']['default'] . '/no_image';
- if (( isset( $udetails['sex'] ) && $udetails['sex'] == 'female' )) {
- $details['l_url'] = $url . '/no-femaleprofile_L.jpg';
- $details['t_url'] = $url . '/no-femaleprofile_T.jpg';
- $details['s_url'] = $url . '/no-femaleprofile_S.jpg';
- $details['m_url'] = $url . '/no-femaleprofile_M.jpg';
- } else {
- $details['l_url'] = $url . '/no-maleprofile_L.jpg';
- $details['t_url'] = $url . '/no-maleprofile_T.jpg';
- $details['s_url'] = $url . '/no-maleprofile_S.jpg';
- $details['m_url'] = $url . '/no-maleprofile_M.jpg';
- }
- $details['s_width'] = $sWidth;
- $details['t_width'] = $tWidth;
- $details['l_width'] = $lWidth;
- $details['m_width'] = $lWidth;
- $details['s_height'] = $sHeight;
- $details['t_height'] = $tHeight;
- $details['l_height'] = $lHeight;
- $details['m_height'] = $lHeight;
- }
- return $details;
- }
- function setUserDetails($column_name, &$column_value) {
- global $CFG;
- global $db;
- if (!$column_value) {
- return false;
- }
- if (isset( $CFG['user_details'][$column_value] )) {
- return null;
- }
- $condition = ' AND usr_status!=\'Deleted\'';
- $sql = ' SELECT * FROM ' . $CFG['db']['tbl']['users'] . ' WHERE' . ' ' . $column_name . ' = ' . $db->Param( 'column_name' ) . $condition;
- $stmt = $db->Prepare( $sql );
- $rs = $db->Execute( $stmt, array( $column_value ) );
- if (!$rs) {
- trigger_db_error( $db );
- }
- if ($row = $rs->FetchRow( )) {
- $row['display_name'] = getUserDisplayName( $row );
- $row['profile_url'] = getMemberProfileUrl( $row['user_id'], $row['user_name'] );
- $row['user_actions'] = getUserActions( $row['usr_type'] );
- $CFG['user_details'][strtolower( $row['user_name'] )] = $row;
- $CFG['user_details'][strtolower( $row['user_id'] )] = $row;
- $CFG['user_details'][strtolower( $row['email'] )] = $row;
- return true;
- }
- $CFG['user_details'][$column_value] = '';
- return false;
- }
- function getUserDetail($column_name, $column_value, $return_column_name = '') {
- global $CFG;
- $column_name = strtolower( $column_name );
- $column_value = strtolower( $column_value );
- if (!isset( $CFG['user_details'][$column_value] )) {
- setUserDetails( $column_name, $column_value );
- }
- if (isset( $CFG['user_details'][$column_value] )) {
- if (!$return_column_name) {
- return $CFG['user_details'][$column_value];
- }
- if (isset( $CFG['user_details'][$column_value][$return_column_name] )) {
- return $CFG['user_details'][$column_value][$return_column_name];
- }
- }
- return false;
- }
- function getUserActions($usr_type) {
- global $CFG;
- global $db;
- $field_values = array( );
- if ($usr_type) {
- $sql = 'SELECT type_name, type_actions FROM ' . $CFG['db']['tbl']['user_type_settings'] . ' WHERE type_id = ' . $db->Param( $usr_type ) . ' AND type_status = \'Active\'';
- $field_values = array( $usr_type );
- } else {
- $sql = 'SELECT type_name, type_actions FROM ' . $CFG['db']['tbl']['user_type_settings'] . ' WHERE default_type = \'Yes\' LIMIT 0, 1';
- }
- $stmt = $db->Prepare( $sql );
- $rs = $db->Execute( $stmt, $field_values );
- if (!$rs) {
- trigger_db_error( $db );
- }
- $user_actions = array( );
- if ($row = $rs->FetchRow( )) {
- $row['type_actions'] = unserialize( $row['type_actions'] );
- $user_actions = $row;
- }
- return $user_actions;
- }
- function checkUserPermission($user_actions, $action, $sub_actions = '') {
- if ($sub_actions) {
- if (!strpos( $sub_actions, ',' )) {
- if (isset( $user_actions['type_actions'][$action][$sub_actions] )) {
- return ($user_actions['type_actions'][$action][$sub_actions] != '' ? true : false);
- }
- } else {
- $sub_actions = explode( ', ', $sub_actions );
- foreach ($sub_actions as $sub_action) {
- if (isset( $user_actions['type_actions'][$action][$sub_action] )) {
- if ($user_actions['type_actions'][$action][$sub_action] != '') {
- return true;
- }
- continue;
- }
- }
- return false;
- }
- }
- if (( !$sub_actions && isset( $user_actions['type_actions'][$action] ) )) {
- return (is_array( $user_actions['type_actions'][$action] ) ? true : $user_actions['type_actions'][$action]);
- }
- return false;
- }
- function postForm($url, $post_value) {
- $ch = curl_init( );
- curl_setopt( $ch, CURLOPT_URL, $url );
- curl_setopt( $ch, CURLOPT_POST, 1 );
- curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_value );
- $result = curl_exec( $ch );
- curl_close( $ch );
- }
- function chkIsSiteUnderMaintenance() {
- global $CFG;
- if (!isAdmin( )) {
- $currentPage = strtolower( $CFG['html']['current_script_name'] );
- if (( $CFG['admin']['module']['site_maintenance'] && $currentPage != 'maintenance' )) {
- $_SESSION = array( );
- if (isset( $_COOKIE[session_name( )] )) {
- setcookie( session_name( ), '', time( ) - 42000, '/' );
- }
- session_destroy( );
- session_write_close( );
- setcookie( $CFG['cookie']['starting_text'] . '_bba', '', time( ) - 42000, '/' );
- $murl = getUrl( $CFG['redirect']['maintenance_module_url']['file_name'], $CFG['redirect']['maintenance_module_url']['normal'], $CFG['redirect']['maintenance_module_url']['htaccess'], 'root' );
- $CFG['site']['current_url'];
- if ($CFG['site']['current_url'] != $murl) {
- Redirect2Url( $murl );
- exit( );
- return null;
- }
- }
- } else {
- $value_array = explode( '/', $CFG['site']['relative_url'] );
- if (( !in_array( 'admin', $value_array ) && $CFG['admin']['module']['site_maintenance'] )) {
- $admin_url = $CFG['site']['url'] . 'admin/index.php';
- Redirect2URL( $admin_url );
- }
- }
- }
- function chkIsAllowedCountry() {
- global $CFG;
- $country_code = apache_note( 'GEOIP_COUNTRY_CODE' );
- if (in_array( $country_code, $CFG['admin']['geo_country'] )) {
- return false;
- }
- return true;
- }
- function findinside($start, $end, $string) {
- preg_match_all( '/' . preg_quote( $start, '/' ) . '([^\.)]+)' . preg_quote( $end, '/' ) . '/i', $string, $m );
- return $m[1];
- }
- function MatchPattern($PATTERN = '', $CONTENT = '', $KEY = '') {
- if (( $PATTERN && $CONTENT )) {
- preg_match_all( $PATTERN, $CONTENT, $Match );
- }
- if ($KEY != '') {
- return $Match[$KEY];
- }
- return $Match;
- }
- function DISP_IMAGE($cfg_width = 0, $cfg_height = 0, $img_width = 0, $img_height = 0) {
- if (( ( ( 0 < $cfg_width && 0 < $cfg_height ) && $cfg_width < $img_width ) && $cfg_height < $img_height )) {
- $tmpHeight = $cfg_width / $img_width * $img_height;
- if ($tmpHeight <= $cfg_height) {
- $attr = ' width="' . $cfg_width . '"';
- } else {
- $height = $tmpHeight - ( $tmpHeight - $cfg_height );
- $attr = ' height="' . $height . '"';
- }
- } else {
- if (( 0 < $cfg_width && $cfg_width < $img_width )) {
- $attr = ' width="' . $cfg_width . '"';
- } else {
- if (( 0 < $cfg_height && $cfg_height < $img_height )) {
- $attr = ' height="' . $cfg_height . '"';
- } else {
- $attr = '';
- }
- }
- }
- return $attr;
- }
- function word_limiter($str, $limit = 100, $end_char = '…') {
- if (trim( $str ) == '') {
- return $str;
- }
- preg_match( '/^\s*+(?:\S++\s*+){1,' . (int)$limit . '}/', $str, $matches );
- if (strlen( $str ) == strlen( $matches[0] )) {
- $end_char = '';
- }
- return rtrim( $matches[0] ) . $end_char;
- }
- function character_limiter($str, $n = 500, $end_char = '…') {
- if (strlen( $str ) < $n) {
- return $str;
- }
- $str = preg_replace( '/\s+/', ' ', preg_replace( '/(
- |
- |
- )/', ' ', $str ) );
- if (strlen( $str ) <= $n) {
- return $str;
- }
- $out = '';
- foreach (explode( ' ', trim( $str ) ) as $val) {
- $out .= $val . ' ';
- if ($n <= strlen( $out )) {
- return trim( $out ) . $end_char;
- }
- }
- }
- function word_censor($str, $censored, $replacement = '') {
- if (!is_array( $censored )) {
- return $str;
- }
- $str = ' ' . $str . ' ';
- foreach ($censored as $badword) {
- if ($replacement != '') {
- $str = preg_replace( '/\b(' . str_replace( '\*', '\w*?', preg_quote( $badword ) ) . ')\b/i', $replacement, $str );
- continue;
- }
- $str = preg_replace( '/\b(' . str_replace( '\*', '\w*?', preg_quote( $badword ) ) . ')\b/ie', 'str_repeat(\'#\', strlen(\'\1\'))', $str );
- }
- return trim( $str );
- }
- function highlight_code(&$str) {
- $str = str_replace( array( '<', '>' ), array( '<', '>' ), $str );
- $str = str_replace( array( '<?', '?>', '<%', '%>', '\', '</script>' ), array( 'phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose' ), $str );
- $str = '<?php tempstart' . '
- ' . $str . 'tempend ?>';
- $str = highlight_string( $str, TRUE );
- if (abs( phpversion( ) ) < 5) {
- $str = str_replace( array( '<font ', ',', ',', ',', ',', '</font>' ), array( '<span ', ',', ',', ',', ',', '</span>' ), $str );
- $str = preg_replace( '#color="(.*?)"#', 'style="color: \1"', $str );
- }
- $str = preg_replace( '#\<code\>.+?tempstart\<br />(?:\</span\>)?#is', '<code>
- ', $str );
- $str = preg_replace( '#tempend.+#is', '</span>
- </code>', $str );
- $str = str_replace( array( 'phptagopen', 'phptagclose', 'asptagopen', 'asptagclose', 'backslashtmp', 'scriptclose' ), array( '<?', '?>', '<%', '%>', '\', '</script>' ), $str );
- return $str;
- }
- function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>') {
- if ($str == '') {
- return '';
- }
- if ($phrase != '') {
- return preg_replace( '/(' . preg_quote( $phrase, '/' ) . ')/i', $tag_open . '\1' . $tag_close, $str );
- }
- return $str;
- }
- function word_wrap($str, $charlim = '76') {
- if (!is_numeric( $charlim )) {
- $charlim = 76;
- }
- $str = preg_replace( '| +|', ' ', $str );
- $str = preg_replace( '/
- |
- /', '
- ', $str );
- $unwrap = array( );
- if (preg_match_all( '|(\{unwrap\}.+?\{/unwrap\})|s', $str, $matches )) {
- $i = 0;
- while ($i < count( $matches['0'] )) {
- $unwrap[] = $matches['1'][$i];
- $str = str_replace( $matches['1'][$i], '{{unwrapped' . $i . '}}', $str );
- ++$i;
- }
- }
- $str = wordwrap( $str, $charlim, '
- ', FALSE );
- $output = '';
- foreach (explode( '
- ', $str ) as $line) {
- if (strlen( $line ) <= $charlim) {
- $output .= $line . '
- ';
- continue;
- }
- $temp = '';
- while ($charlim < strlen( $line )) {
- if (preg_match( '!\[url.+\]|://|wwww.!', $line )) {
- break;
- }
- $temp .= substr( $line, 0, $charlim - 1 );
- $line = substr( $line, $charlim - 1 );
- }
- if ($temp != '') {
- $output .= $temp . '
- ' . $line;
- } else {
- $output .= $line;
- }
- $output .= '
- ';
- }
- if (0 < count( $unwrap )) {
- foreach ($unwrap as $key => $val) {
- $output = str_replace( '{{unwrapped' . $key . '}}', $val, $output );
- }
- }
- $output = str_replace( array( '{unwrap}', '{/unwrap}' ), '', $output );
- return $output;
- }
- function stripSpecifiedTag($str, $tags) {
- if (!is_array( $tags )) {
- $tags = (stripos( $str, '>' ) !== false ? explode( '>', str_ireplace( '<', '', $tags ) ) : array( $tags ));
- if (end( $tags ) == '') {
- array_pop( $tags );
- }
- }
- foreach ($tags as $tag) {
- $str = preg_replace( '#</?' . $tag . '[^>]*>#is', '', $str );
- }
- return $str;
- }
- function directory_map($source_dir, $top_level_only = FALSE) {
- if ($fp = @opendir( $source_dir )) {
- $filedata = array( );
- while (FALSE !== $file = readdir( $fp )) {
- if (( ( @is_dir( $source_dir . $file ) && substr( $file, 0, 1 ) != '.' ) && $top_level_only == FALSE )) {
- $temp_array = array( );
- $temp_array = directory_map( $source_dir . $file . '/' );
- $filedata[$file] = $temp_array;
- continue;
- }
- if (substr( $file, 0, 1 ) != '.') {
- $filedata[] = $file;
- continue;
- }
- }
- return $filedata;
- }
- }
- function read_file($file) {
- if (!file_exists( $file )) {
- return FALSE;
- }
- if (function_exists( 'file_get_contents' )) {
- return file_get_contents( $file );
- }
- if (!$fp = @fopen( $file, 'rb' )) {
- return FALSE;
- }
- flock( $fp, LOCK_SH );
- $data = '';
- if (0 < filesize( $file )) {
- $data = &fread( $fp, filesize( $file ) );
- }
- flock( $fp, LOCK_UN );
- fclose( $fp );
- return $data;
- }
- function write_file($path, $data, $mode = 'w+') {
- if (!$fp = @fopen( $path, $mode )) {
- return FALSE;
- }
- flock( $fp, LOCK_EX );
- fwrite( $fp, $data );
- @chmod( $path, 511 );
- flock( $fp, LOCK_UN );
- fclose( $fp );
- return TRUE;
- }
- function readDirectory($dir_path, $return = 'both') {
- $return_arr = array( );
- if (is_dir( $dir_path )) {
- if ($handle = opendir( $dir_path )) {
- while (false !== $file = readdir( $handle )) {
- if (( ( $file != '.' && $file != '..' ) && $file != '.svn' )) {
- if (( ( ( is_file( $dir_path . $file ) && $return == 'file' ) || ( is_dir( $dir_path . $file ) && $return == 'dir' ) ) || $return == 'both' )) {
- $return_arr[] = $file;
- continue;
- }
- continue;
- }
- }
- closedir( $handle );
- }
- }
- return $return_arr;
- }
- function force_download($filename = '', &$data = '') {
- global $CFG;
- if (( $filename == '' || $data == '' )) {
- return FALSE;
- }
- if (FALSE === strpos( $filename, '.' )) {
- return FALSE;
- }
- $x = explode( '.', $filename );
- $extension = end( $x );
- @include( $CFG['site']['project_path'] . 'common/configs/config_mimes.inc..php' );
- if (!isset( $mimes[$extension] )) {
- $mime = 'application/octet-stream';
- } else {
- $mime = (is_array( $mimes[$extension] ) ? $mimes[$extension][0] : $mimes[$extension]);
- }
- if (strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' )) {
- header( 'Content-Type: "' . $mime . '"' );
- header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
- header( 'Expires: 0' );
- header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
- header( 'Content-Transfer-Encoding: binary' );
- header( 'Pragma: public' );
- header( 'Content-Length: ' . strlen( $data ) );
- } else {
- header( 'Content-Type: "' . $mime . '"' );
- header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
- header( 'Content-Transfer-Encoding: binary' );
- header( 'Expires: 0' );
- header( 'Pragma: no-cache' );
- header( 'Content-Length: ' . strlen( $data ) );
- }
- echo $data;
- }
- function strip_slashes($str) {
- if (is_array( $str )) {
- foreach ($str as $key => $val) {
- $str[$key] = strip_slashes( $val );
- }
- } else {
- $str = stripslashes( $str );
- }
- return $str;
- }
- function isCronRunning($script_name = '') {
- global $CFG;
- if (strstr( $CFG['site']['url'], '/localhost/' )) {
- return false;
- }
- $max_cron_allowed = 1;
- $cronRunning = false;
- if ($script_name) {
- $command = ' ps -eaf | grep ' . $script_name;
- $result = @shell_exec( $command );
- $scriptCount = intval( @substr_count( $result, $script_name ) );
- $max_cron_allowed = $max_cron_allowed + 3;
- $cronRunning = $max_cron_allowed <= $scriptCount;
- }
- return $cronRunning;
- }
- function callMultipleCronCheck() {
- global $CFG;
- $cronUrl = $CFG['site']['current_url'];
- $time = date( 'd-m-y H:i:s' );
- print ( '' . '
- CRON: ' . $cronUrl . ':
- TIME:' . $time . '
- ' );
- if (isCronRunning( $cronUrl )) {
- print '' . 'CRON : ' . $cronUrl . '
- TIME:' . $cronUrl . '
- Concurrent Process Detected
- So Skipping ' . $cronUrl . ' CRON at ' . date( 'd-M-y H:i:s' ) . '
- ';
- exit( );
- }
- }
- function getMD5Text($text, $count = 15) {
- $text = md5( $text );
- return substr( $text, 0, $count - 1 );
- }
- function doEncode($text, $size = 0) {
- $text = str_pad( $text, $size, '0', STR_PAD_LEFT );
- $text = base64_encode( $text );
- $text = urlencode( $text );
- return $text;
- }
- function doDecode($text) {
- $text = urldecode( $text );
- $text = base64_decode( $text );
- return $text;
- }
- function getTimeDiffInSeconds($date) {
- global $CFG;
- global $db;
- $sql = 'SELECT TIMEDIFF(NOW(), \'' . $date . '\') AS date_added';
- $stmt = $db->Prepare( $sql );
- $rs = $db->Execute( $stmt );
- if (!$rs) {
- trigger_db_error( $db );
- }
- $row = $rs->FetchRow( );
- return $row['date_added'];
- }
- function getDateTimeDiff($date, &$today) {
- list( $year, $month, $day, $hrs, $min, $sec ) = split( '[ \:-]', $date );
- list( $year1, $month1, $day1, $hrs1, $min1, $sec1 ) = split( '[ \:-]', $today );
- $secs = mktime( $hrs1, $min1, $sec1, $month1, $day1, $year1 ) - mktime( $hrs, $min, $sec, $month, $day, $year );
- $mins = floor( $secs / 60 );
- $hrs = floor( $mins / 60 );
- $secs = $secs % 60;
- $mins = $mins % 60;
- $row['date_added'] = $hrs . ':' . $mins . ':' . $secs;
- return ;
- }
- function str_replace_once($needle, $replace, $haystack) {
- $pos = strpos( $haystack, $needle );
- if ($pos === false) {
- return $haystack;
- }
- return substr_replace( $haystack, $replace, $pos, strlen( $needle ) );
- }
- function getFullTextSearchString($tags) {
- $tags = rawurlencode( $tags );
- return $tags = '[[:<:]]' . preg_replace( '/\s+/', '|', addslashes( $tags ) ) . '[[:>:]]';
- }
- function getSearchRegularExpressionQueryForums($tags, $field_name, $extra = '') {
- global $CFG;
- $not_allowed_search_array = $CFG['admin']['not_allowed_chars'];
- $tags = replaceCharacter( $not_allowed_search_array, '-', $tags );
- $tags = addslashes( $tags );
- $additional_query = ' (' . $field_name . ' REGEXP \'' . formatSearchString( $tags ) . '\') ' . $extra . ' ';
- return $additional_query;
- }
- function replaceCharacter($search_value, $replace, $text) {
- if (is_array( $search_value )) {
- foreach ($search_value as $key => $value) {
- $text = str_replace( $value, $replace, $text );
- }
- return $text;
- }
- return str_replace( $char, $replace, $text );
- }
- function formatSearchString($tags) {
- return $tags = '[[:<:]]' . preg_replace( '/\s+/', '|', $tags ) . '[[:>:]]';
- }
- function getSearchRegularExpressionQuery($tags, $field_name, $extra = '') {
- global $CFG;
- $tags = addslashes( $tags );
- if ($CFG['admin']['search']['regular_expression']) {
- $additional_query = ' (' . $field_name . ' REGEXP \'' . getFullTextSearchString( $tags ) . '\') ' . $extra . ' ';
- } else {
- $additional_query = ' MATCH(' . $field_name . ') AGAINST (\'' . $tags . '\' IN BOOLEAN MODE) ' . $extra . ' ';
- }
- return $additional_query;
- }
- function createMultiLevelFolder($folderName) {
- $folder_arr = explode( '/', $folderName );
- $folderName = '';
- foreach ($folder_arr as $key => $value) {
- $folderName .= $value . '/';
- if (( $value == '..' || $value == '.' )) {
- continue;
- }
- if (!is_dir( $folderName )) {
- mkdir( $folderName );
- @chmod( $folderName, 511 );
- continue;
- }
- }
- }
- function removeDirectory($dirname) {
- if (is_dir( $dirname )) {
- $result = array( );
- if (substr( $dirname, 0 - 1 ) != '/') {
- $dirname .= '/';
- }
- $handle = opendir( $dirname );
- while (false !== $file = readdir( $handle )) {
- if (( $file != '.' && $file != '..' )) {
- $path = $dirname . $file;
- if (is_dir( $path )) {
- $result = array_merge( $result, removeDirectory( $path ) );
- continue;
- }
- unlink( $path );
- $result-> .= $path;
- continue;
- }
- }
- closedir( $handle );
- rmdir( $dirname );
- $result-> .= $dirname;
- return $result;
- }
- return false;
- }
- function setHeaderStart($check_login = false) {
- global $CFG;
- ob_start( );
- header( 'Pragma: no-cache' );
- header( 'Cache-Control: no-cache, must-revalidate' );
- header( 'Expires: 0' );
- header( 'Content-type: text/css; charset="' . $CFG['site']['charset'] . '"' );
- }
- function setHeaderEnd() {
- ob_end_flush( );
- }
- function chkIsValidUrlUsingCurl($url) {
- if (!strstr( $url, '://' )) {
- $url = 'http://' . $url;
- }
- if (function_exists( 'curl_init' )) {
- $ch = @curl_init( );
- if ($ch) {
- curl_setopt( $ch, CURLOPT_URL, $url );
- curl_setopt( $ch, CURLOPT_HEADER, 0 );
- curl_setopt( $ch, CURLOPT_NOBODY, 1 );
- curl_setopt( $ch, CURLOPT_RANGE, '0-1' );
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 0 );
- curl_setopt( $ch, CURLOPT_TIMEOUT, 10 );
- $result = curl_exec( $ch );
- $errno = curl_errno( $ch );
- curl_close( $ch );
- if ($errno != 0) {
- return false;
- }
- }
- }
- return true;
- }
- function getContents($url) {
- $result = '';
- if (!strstr( $url, '://' )) {
- $url = 'http://' . $url;
- }
- if (function_exists( 'curl_init' )) {
- $ch = curl_init( $url );
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
- curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2' );
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
- $result = curl_exec( $ch );
- if (!curl_errno( $ch )) {
- curl_close( $ch );
- } else {
- $result = false;
- }
- } else {
- set_time_limit( 180 );
- $result = file_get_contents( $url );
- }
- return $result;
- }
- function setFontSizeForTagCloud($tag_array = array( )) {
- $formattedArray = $tag_array;
- $max_qty = max( array_values( $formattedArray ) );
- $min_qty = min( array_values( $formattedArray ) );
- $max_font_size = 28;
- $min_font_size = 12;
- $spread = $max_qty - $min_qty;
- if (0 == $spread) {
- $spread = 1;
- }
- $step = ( $max_font_size - $min_font_size ) / $spread;
- foreach ($tag_array as $catname => $count) {
- $size = $min_font_size + ( $count - $min_qty ) * $step;
- $formattedArray[$catname] = ceil( $size );
- }
- return $formattedArray;
- }
- function setTemplateFolder($template_for = '', $module = '') {
- global $smartyObj;
- global $CFG;
- $smartyObj->config_dir = $CFG['site']['project_path'] . 'design/templates/' . $CFG['html']['template']['default'] . '/configs/';
- if ($module) {
- if ($template_for == 'admin/') {
- $smartyObj->template_dir = $CFG['site']['project_path'] . '/design/templates/default/' . $template_for . $module . '/';
- $smartyObj->compile_dir = $CFG['site']['project_path'] . '/design/templates/default/' . getTplFolder( ) . $module . '/templates_c/';
- $smartyObj->css_path = $CFG['site']['url'] . '/design/templates/default/' . $template_for . $module . '/css/' . $CFG['html']['stylesheet']['screen']['default'] . '/';
- } else {
- if (isAdmin( )) {
- $smartyObj->template_dir = $CFG['site']['project_path'] . $module . '/design/templates/' . $CFG['html']['template']['default'] . '/' . $template_for;
- $smartyObj->compile_dir = $CFG['site']['project_path'] . $module . '/design/templates/' . $CFG['html']['template']['default'] . '/members/templates_c/';
- $smartyObj->css_path = $CFG['site']['url'] . $module . '/design/templates/' . $CFG['html']['template']['default'] . '/' . $template_for . 'css/' . $CFG['html']['stylesheet']['screen']['default'] . '/';
- } else {
- $smartyObj->template_dir = $CFG['site']['project_path'] . $module . '/design/templates/' . $CFG['html']['template']['default'] . '/' . $template_for;
- $smartyObj->compile_dir = $CFG['site']['project_path'] . $module . '/design/templates/' . $CFG['html']['template']['default'] . '/' . getTplFolder( ) . 'templates_c/';
- $smartyObj->css_path = $CFG['site']['url'] . $module . '/design/templates/' . $CFG['html']['template']['default'] . '/' . $template_for . 'css/' . $CFG['html']['stylesheet']['screen']['default'] . '/';
- }
- if (( isAdmin( ) && 0 < strpos( $CFG['site']['relative_url'], 'admin/' ) )) {
- $smartyObj->template_dir = $CFG['site']['project_path'] . '/design/templates/default/' . $template_for;
- $smartyObj->compile_dir = $CFG['site']['project_path'] . '/design/templates/default' . '/' . getTplFolder( ) . '/templates_c/';
- $smartyObj->css_path = $CFG['site']['url'] . '/design/templates/default' . '/' . $template_for . '/css/' . $CFG['html']['stylesheet']['screen']['default'] . '/';
- } else {
- if (!is_dir( $smartyObj->template_dir )) {
- foreach ($CFG['html']['template']['allowed'] as $available_template) {
- $available_template_dir = $CFG['site']['project_path'] . $module . '/design/templates/' . $available_template . '/' . $template_for;
- if (is_dir( $available_template_dir )) {
- foreach ($CFG['html']['stylesheet'][$available_template]['allowed'] as $available_css) {
- $available_css_path = $CFG['site']['project_path'] . $module . '/design/templates/' . $available_template . '/root/css/' . $available_css . '/';
- if (is_dir( $available_css_path )) {
- $smartyObj->template_dir = $available_template_dir;
- $smartyObj->compile_dir = $CFG['site']['project_path'] . $module . '/design/templates/' . $available_template . '/' . getTplFolder( ) . 'templates_c/';
- $smartyObj->css_path = $CFG['site']['url'] . $module . '/design/templates/' . $available_template . '/' . $template_for . 'css/' . $available_css . '/';
- break;
- }
- }
- continue;
- }
- }
- }
- }
- }
- } else {
- $smartyObj->template_dir = $CFG['site']['project_path'] . 'design/templates/' . $CFG['html']['template']['default'] . '/' . $template_for;
- $smartyObj->compile_dir = $CFG['site']['project_path'] . 'design/templates/' . $CFG['html']['template']['default'] . '/' . getTplFolder( ) . 'templates_c/';
- $smartyObj->css_path = $CFG['site']['url'] . 'design/templates/' . $CFG['html']['template']['default'] . '/' . $template_for . 'css/' . $CFG['html']['stylesheet']['screen']['default'] . '/';
- if ($template_for == 'admin/') {
- $smartyObj->template_dir = $CFG['site']['project_path'] . '/design/templates/default/' . $template_for;
- $smartyObj->compile_dir = $CFG['site']['project_path'] . '/design/templates/default' . '/' . getTplFolder( ) . '/templates_c/';
- $smartyObj->css_path = $CFG['site']['url'] . '/design/templates/default' . '/' . $template_for . '/css/' . $CFG['html']['stylesheet']['screen']['default'] . '/';
- } else {
- if (!empty( $CFG['site']['is_module_page'] )) {
- $template_dir_module = $CFG['site']['project_path'] . $CFG['site']['is_module_page'] . '/design/templates/' . $CFG['html']['template']['default'] . '/' . $template_for;
- if (( isAdmin( ) && 0 < strpos( $CFG['site']['relative_url'], 'admin/' ) )) {
- $smartyObj->template_dir = $CFG['site']['project_path'] . '/design/templates/default/' . $template_for;
- $smartyObj->compile_dir = $CFG['site']['project_path'] . '/design/templates/default' . '/' . getTplFolder( ) . '/templates_c/';
- $smartyObj->css_path = $CFG['site']['url'] . '/design/templates/default' . '/' . $template_for . '/css/' . $CFG['html']['stylesheet']['screen']['default'] . '/';
- } else {
- if (!is_dir( $template_dir_module )) {
- foreach ($CFG['html']['template']['allowed'] as $available_template) {
- $available_template_dir = $CFG['site']['project_path'] . $CFG['site']['is_module_page'] . '/design/templates/' . $available_template . '/' . $template_for;
- if (is_dir( $available_template_dir )) {
- $CFG['html']['template']['default'] = $available_template;
- foreach ($CFG['html']['stylesheet'][$available_template]['allowed'] as $available_css) {
- $available_css_path = $CFG['site']['project_path'] . $CFG['site']['is_module_page'] . '/design/templates/' . $available_template . '/root/css/' . $available_css . '/';
- if (is_dir( $available_css_path )) {
- $CFG['html']['stylesheet']['screen']['default'] = $available_css;
- $smartyObj->template_dir = $CFG['site']['project_path'] . 'design/templates/' . $available_template . '/' . $template_for;
- $smartyObj->compile_dir = $CFG['site']['project_path'] . 'design/templates/' . $available_template . '/' . getTplFolder( ) . 'templates_c/';
- $smartyObj->css_path = $CFG['site']['url'] . 'design/templates/' . $available_template . '/' . $template_for . 'css/' . $available_css . '/';
- break;
- }
- }
- continue;
- }
- }
- }
- }
- }
- }
- }
- $smartyObj->cache_dir = $CFG['site']['project_path'] . 'design/templates/' . $CFG['html']['template']['default'] . '/' . getTplFolder( ) . 'cache/';
- $image_path = $CFG['site']['url'] . 'design/templates/' . $CFG['html']['template']['default'] . '/root/images/' . $CFG['html']['stylesheet']['screen']['default'] . '/';
- $smartyObj->assign( 'html_stylesheet', $smartyObj->css_path . $CFG['html']['stylesheet']['screen']['default_file'] . '.css' );
- $smartyObj->css_defalut_path = $smartyObj->css_path . $CFG['html']['stylesheet']['screen']['default_file'] . '.css';
- $smartyObj->assign( 'images_path', $image_path );
- $smartyObj->assign( 'html_stylesheet_path', $smartyObj->css_path );
- }
- function URL($url) {
- return $url;
- }
- function isAjaxPage() {
- return ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' );
- }
- function ShowHelpTip($tip_key, $tipfor = '') {
- global $LANG;
- global $CFG;
- $tipfor = ($tipfor ? $tipfor : $tip_key);
- $tip = str_replace( '
- ', ' ', $LANG['help'][$tip_key] );
- echo '<div class="clsHelpText" id="';
- echo $tipfor;
- echo '_Help" style="visibility:hidden">';
- echo $tip;
- echo '</div>
- ';
- }
- function isAjax() {
- return ( ( isset( $_REQUEST['ajax_page'] ) && $_REQUEST['ajax_page'] == true ) || ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) );
- }
- function FMT_DATE($date) {
- return $date;
- }
- function FMT_AMOUNT($amount) {
- global $CFG;
- $exponent = pow( 10, $CFG['framework']['no_of_decimals'] );
- return floor( $amount * $exponent ) / $exponent;
- }
- function ExposeQuery($msg, $newline = '') {
- global $SQL_QUERIES;
- $SQL_QUERIES .= '
- ' . $msg . '
- ';
- }
- function DEBUG($var_name, $var_desc = '') {
- global $CFG;
- global $DEBUG_TRACE;
- if ($CFG['debug']['is_debug_mode']) {
- $DEBUG_TRACE .= '
- ' . $var_desc . ':';
- if (!is_array( $var_name )) {
- $var_name = htmlspecialchars( $var_name );
- }
- $DEBUG_TRACE .= print_r( $var_name, true );
- if (is_array( $var_name )) {
- reset( $var_name );
- }
- $DEBUG_TRACE .= '
- ';
- }
- }
- function Redirect2URL($url) {
- global $CFG;
- if (( isAjaxPage( ) || $CFG['admin']['session_redirect_light_window_page'] )) {
- if (!isMember( )) {
- unset( $_SESSION[url] );
- $param = '';
- $url = getUrl( 'login' ) . $param;
- }
- }
- if (!headers_sent( )) {
- header( 'Location: ' . URL( $url ) );
- if (stristr( $_SERVER['SERVER_SIGNATURE'], 'IIS' )) {
- header( 'Refresh: 0;url=' . $url );
- }
- } else {
- trigger_error( 'Headers already sent', E_USER_NOTICE );
- echo '<meta http-equiv="refresh" content="0; URL=' . URL( $url ) . '" />' . '
- ';
- echo '<p>Please click this <a href="' . URL( $url ) . '">link</a> to continue...</p>' . '
- ';
- }
- exit( 0 );
- }
- function getAdvertisement($block, &$not_allowed_page_name = array( )) {
- global $CFG;
- global $db;
- global $______ADVERTISEMENT_ID;
- $block_condition = '';
- if (!chkAllowedModule( array( 'banner' ) )) {
- return null;
- }
- $cur_page_name = strtolower( basename( $_SERVER['SCRIPT_NAME'], '.php' ) );
- if (( 0 < sizeof( $not_allowed_page_name ) && in_array( $cur_page_name, $not_allowed_page_name ) )) {
- return false;
- }
- $sql = 'SELECT add_id, source FROM ' . $CFG['db']['tbl']['advertisement'] . ' WHERE' . ' block=\'' . $block . '\'' . ' AND status=\'activate\'';
- if ($CFG['admin']['banner']['impressions_date']) {
- $sql .= ' AND NOW()>=start_date AND (((allowed_impressions!=\'\' AND allowed_impressions!=0) AND' . ' (completed_impressions < allowed_impressions)) OR ((allowed_impressions=\'\'' . ' OR allowed_impressions=0) AND (end_date!=\'0000-00-00 00:00:00\'' . ' AND end_date > NOW())))';
- }
- $stmt = $db->Prepare( $sql );
- $rs = $db->Execute( $stmt, array( ) );
- if (!$rs) {
- trigger_db_error( $db );
- }
- $total_count = $rs->PO_RecordCount( );
- if (!$total_count) {
- $sql = 'SELECT add_id, source FROM ' . $CFG['db']['tbl']['advertisement'] . ' WHERE' . ' block LIKE \'%' . $block . '\'' . ' AND status=\'activate\'';
- if ($CFG['admin']['banner']['impressions_date']) {
- $sql .= ' AND NOW()>=start_date AND (((allowed_impressions!=\'\' AND allowed_impressions!=0) AND' . ' (completed_impressions < allowed_impressions)) OR ((allowed_impressions=\'\'' . ' OR allowed_impressions=0) AND (end_date!=\'0000-00-00 00:00:00\'' . ' AND end_date > NOW())))';
- }
- $stmt = $db->Prepare( $sql );
- $rs = $db->Execute( $stmt );
- if (!$rs) {
- trigger_db_error( $db );
- }
- $total_count = $rs->PO_RecordCount( );
- }
- if (!$total_count) {
- return false;
- }
- ...............................
- ...................
- ........
Add Comment
Please, Sign In to add comment