$fillUpOn = 'left'; } else { $fillUpOn = 'right'; } if ($return_value != 'string' && $return_value != 'array') { $return_value = 'string'; } // $table needs to be an associative array $max_string_length = array(); // set default for return value if ($return_value == 'array') { $return = array(); } else { $return = ''; } // Find the longest string foreach ($table as $key) { if (is_array($key) != TRUE) { $key = array($key); } $loopCounter = 0; foreach ($key as $subkey) { $length = mb_strlen($subkey, $CONFIG['charset']); if (empty($max_string_length[$loopCounter]) || $length > $max_string_length[$loopCounter]) { $max_string_length[$loopCounter] = $length; } $loopCounter++; } } // Fill the $return array / var foreach ($table as $key => $value) { if (is_array($value) != TRUE) { $value = array($value); } $loopCounter = 0; $temp = ''; foreach ($value as $subvalue) { if ($loopCounter != 0) { $temp .= $separator; } $temp .= cpg_fillArrayFieldWithSpaces($subvalue, $max_string_length[$loopCounter], $fillUpOn) ; $loopCounter++; } if ($return_value == 'array') { $return[$key] = $temp; } else { $return .= $temp . $LINEBREAK; } } return $return; } function cpg_get_comment_page_number($msg_id) { global $CONFIG; $result = cpg_db_query("SELECT pid FROM {$CONFIG['TABLE_COMMENTS']} WHERE msg_id = '$msg_id'"); list($pid) = $result->fetchRow(true); if (!$pid) { return false; } $result = cpg_db_query("SELECT COUNT(msg_id) FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='$pid'"); list($num) = $result->fetchRow(true); $page_count = ceil($num / $CONFIG['comments_per_page']); $comment_sort_order = ($CONFIG['comments_sort_descending'] == 1) ? 'ASC' : 'DESC'; // we need to count reversed $result = cpg_db_query("SELECT msg_id FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='$pid' ORDER BY msg_id $comment_sort_order"); $i = 0; $page = $page_count + 1; while ($row = $result->fetchAssoc()) { if (($i++ % $CONFIG['comments_per_page']) == 0) { $page--; } if ($row['msg_id'] == $msg_id) { break; } } $result->free(); return $page; } /** * cpg_lang_name2code * * @param string $lang_name the name of a language file * @return string $return language code (flag name) */ function cpg_lang_name2code($lang_name) { global $CONFIG; if ($lang_name != '') { $result = cpg_db_query("SELECT flag, abbr FROM {$CONFIG['TABLE_LANGUAGE']} WHERE lang_id='{$lang_name}' LIMIT 1"); list($flag, $abbr) = $result->fetchRow(true); if ($abbr != '') { return $abbr; } elseif ($flag != '') { return $flag; } else { return FALSE; } } } function cpg_get_guest_token() { global $CONFIG, $raw_ip; return md5($CONFIG['site_token'] . $raw_ip); } /** * str_ireplace * * PHP4-replacement, taken from the user comments at http://theserverpages.com/php/manual/en/function.str-ireplace.php */ if (!function_exists('str_ireplace')) { function str_ireplace($search, $replace, $subject) { if (is_array($search)) { foreach ($search as $word) { $words[] = "/" . $word . "/i"; } } else { $words = "/" . $search . "/i"; } return preg_replace($words, $replace, $subject); } } // Check if a an album is password protected album and the user has access rights to that album function cpg_pw_protected_album_access($aid) { global $CONFIG, $FORBIDDEN_SET_DATA; // Check if the user has already access to the album if (!in_array($aid, $FORBIDDEN_SET_DATA)) { return 2; } // Fetch all password protected albums $result = cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE alb_password != ''"); while($row = $result->fetchAssoc()) { $aid_w_pw[] = $row['aid']; } $result->free(); // Check if the user has access to the password protected album if he knows the correct password if (!in_array($aid, array_diff($FORBIDDEN_SET_DATA, $aid_w_pw))) { return 1; } else { return 0; } } /** * Get all user group IDs for a particular user * * @param integer $user_id * @return array */ function cpg_get_groups($user_id) { global $cpg_udb; if (!$cpg_udb->can_join_tables) { return false; } $f = $cpg_udb->field; if (isset($cpg_udb->usergroupstable)){ $sql = "SELECT u.{$f['user_id']} AS id, ug.{$f['usertbl_group_id']} AS group_id " . "FROM {$cpg_udb->usertable} AS u, {$cpg_udb->usergroupstable} AS ug " . "WHERE u.{$f['user_id']}=ug.{$f['user_id']} AND u.{$f['user_id']}='{$user_id}'"; } else { $sql = "SELECT u.{$f['user_id']} AS id, u.{$f['usertbl_group_id']} AS group_id " . "FROM {$cpg_udb->usertable} AS u " . "WHERE u.{$f['user_id']}='{$user_id}'"; } return $cpg_udb->get_groups(cpg_db_query($sql)->fetchAssoc(true)); } /** * Strip whitespaces from the beginning and end of each keyword * * @param string $keywords */ function cpg_trim_keywords(&$keywords) { global $CONFIG; $keywords_new = array(); $keywords = explode($CONFIG['keyword_separator'], trim(html_entity_decode($keywords))); foreach ($keywords as $word) { if (trim($word)) { $keywords_new[] = trim(Inspekt::getEscaped($word)); } } $keywords = implode($CONFIG['keyword_separator'], $keywords_new); } /** * Determine if an intermediate-sized picture should be used * The weird comparision is because only 'picture_width' is stored as config value * * @param integer $pwidth * @param integer $pheight * @return bool */ function cpg_picture_dimension_exceeds_intermediate_limit($pwidth, $pheight) { global $CONFIG; $resize_method = $CONFIG['picture_use'] == "thumb" ? ($CONFIG['thumb_use'] == "ex" ? "any" : $CONFIG['thumb_use']) : $CONFIG['picture_use']; if ($resize_method == 'ht' && $pheight > $CONFIG['picture_width']) { return true; } elseif ($resize_method == 'wd' && $pwidth > $CONFIG['picture_width']) { return true; } elseif ($resize_method == 'any' && max($pwidth, $pheight) > $CONFIG['picture_width']) { return true; } else { return false; } } /** * Dummy function to avoid error message when using the EXIF library on some systems * * @param string $str * @return string */ if (!function_exists('gettext')) { function gettext($str) { return $str; } } /** * Strip unneeded EXIF data * * @param array $exifRawData * @param array $exif_names * @return array */ function cpg_exif_strip_data($exifRawData, $exif_names) { $exif = array(); if (is_array($exifRawData['IFD0'])) { $exif = array_merge($exif, $exifRawData['IFD0']); } if (is_array($exifRawData['SubIFD'])) { $exif = array_merge($exif, $exifRawData['SubIFD']); } if (is_array($exifRawData['SubIFD']['MakerNote'])) { $exif = array_merge($exif, $exifRawData['SubIFD']['MakerNote']); } if (isset($exifRawData['IFD1OffSet'])) { $exif['IFD1OffSet'] = $exifRawData['IFD1OffSet']; } foreach ($exif as $key => $value) { if (!in_array($key, $exif_names)) { unset($exif[$key]); } } return $exif; } /** * htmlspecialchars_decode * * PHP4-replacement, taken from the user comments at http://www.php.net/manual/en/function.htmlspecialchars-decode.php * * @param string $str * @return string */ if (!function_exists('htmlspecialchars_decode')) { function htmlspecialchars_decode($str) { return strtr($str, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); } } function only_empty_albums_button() { global $CONFIG, $CPG_PHP_SELF, $lang_alb_select_box; $superCage = Inspekt::makeSuperCage(); if ($CONFIG['only_empty_albums'] == 1 || ($CONFIG['only_empty_albums'] == 2 && GALLERY_ADMIN_MODE)) { $sep = strpos($superCage->server->getRaw('REQUEST_URI'), '?') ? '&' : '?'; if ($superCage->get->keyExists('only_empty_albums')) { $only_empty_albums = ''.$lang_alb_select_box['all_albums'].''; } else { $only_empty_albums = ''.$lang_alb_select_box['only_empty_albums'].''; } } else { $only_empty_albums = ''; } return $only_empty_albums; } /** * cpg_normalize_path * * Method to normalize a virtual path that could handle .. references that go beyond the initial folder reference * Taken from http://php.net/manual/en/function.realpath.php#112367 */ function cpg_normalize_path($path) { $parts = array(); // Array to build a new path from the good parts $path = str_replace('\\', '/', $path); // Replace backslashes with forwardslashes $path = preg_replace('/\/+/', '/', $path); // Combine multiple slashes into a single slash $segments = explode('/', $path); // Collect path segments $test = ''; // Initialize testing variable foreach ($segments as $segment) { if ($segment != '.') { $test = array_pop($parts); if (is_null($test)) { $parts[] = $segment; } elseif ($segment == '..') { if ($test == '..') { $parts[] = $test; } if ($test == '..' || $test == '') { $parts[] = $segment; } } else { $parts[] = $test; $parts[] = $segment; } } } return implode(DIRECTORY_SEPARATOR, $parts); } /** * cpg_album_sort_order * * @param string $table_prefix * @return string */ function cpg_album_sort_order($table_alias = '') { global $CONFIG, $USER; $sort_array = array( 'ta' => "{$table_alias}title ASC, {$table_alias}aid ASC", 'td' => "{$table_alias}title DESC, {$table_alias}aid DESC", 'da' => "{$table_alias}aid ASC", 'dd' => "{$table_alias}aid DESC", 'pa' => "{$table_alias}pos ASC, {$table_alias}aid ASC", 'pd' => "{$table_alias}pos DESC, {$table_alias}aid DESC", 'va' => "{$table_alias}alb_hits ASC, {$table_alias}aid ASC", 'vd' => "{$table_alias}alb_hits DESC, {$table_alias}aid DESC", ); // TODO: add user defined sort order for albums //$sort_code = isset($USER['sort'])? $USER['sort'] : $CONFIG['album_sort_order']; //$sort_order = isset($sort_array[$sort_code]) ? $sort_array[$sort_code] : $sort_array[$CONFIG['album_sort_order']]; $sort_order = $sort_array[$CONFIG['album_sort_order']]; return $sort_order; } /** * cpg_load_plugin_language_file * * @param string $path */ function cpg_load_plugin_language_file($path) { global $CONFIG; if (file_exists('./plugins/'.$path.'/lang/english.php')) { $lg = 'lang_plugin_'.$path; global $$lg; include './plugins/'.$path.'/lang/english.php'; if ($CONFIG['lang'] != 'english' && file_exists('./plugins/'.$path.'/lang/'.$CONFIG['lang'].'.php')) { include './plugins/'.$path.'/lang/'.$CONFIG['lang'].'.php'; } } } /** * cpg_get_user_data * * Check user login credentials. Returns array of user data or FALSE. */ function cpg_get_user_data($sql_user_email, $password) { global $cpg_udb; $sql = "SELECT user_password, user_password_salt, user_password_hash_algorithm, user_password_iterations FROM {$cpg_udb->usertable} WHERE $sql_user_email AND user_active = 'YES' LIMIT 1"; $result = $cpg_udb->query($sql); if (!$result->numRows()) { return false; } require 'include/passwordhash.inc.php'; $password_params = $result->fetchAssoc(true); // Check for user in users table $sql = "SELECT user_id, user_name, user_password, user_password_salt FROM {$cpg_udb->usertable} WHERE $sql_user_email "; if (!$password_params['user_password_salt']) { $sql .= "AND BINARY user_password = '".md5($password)."'"; } elseif (!cpg_password_validate($password, $password_params)) { return false; } $sql .= " AND user_active = 'YES' LIMIT 1"; $result = $cpg_udb->query($sql); if (!$result->numRows()) { return false; } return $result->fetchAssoc(true); } //EOF
Fatal error: Uncaught Error: Call to undefined function cpg_db_query() in /home3/wvdknl/public_html/cpg/include/init.inc.php:180 Stack trace: #0 /home3/wvdknl/public_html/cpg/displayimage.php(19): require() #1 {main} thrown in /home3/wvdknl/public_html/cpg/include/init.inc.php on line 180