Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/banking.ncriptech.com/../ecampus.ncriptech.com/application/helpers/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); // -------------------------------------------------------------------- /** * Evaluates a strings PHP code. Used especially for outputing FUEL page data * * @param string string to evaluate * @param mixed variables to pass to the string * @return string */ if (!function_exists('eval_string')) { function eval_string($str, $vars = array()) { $CI =& get_instance(); extract($CI->load->get_vars()); // extract cached variables extract($vars); // fix XML $str = str_replace('<?xml', '<@xml', $str); ob_start(); if ((bool) @ini_get('short_open_tag') === FALSE AND $CI->config->item('rewrite_short_tags') == TRUE) { $str = eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', $str)).'<?php '); } else { $str = eval('?>'.$str.'<?php '); } $str = ob_get_clean(); // change XML back $str = str_replace('<@xml', '<?xml', $str); return $str; } } // -------------------------------------------------------------------- /** * Add an s to the end of s string based on the number * * @param int number to compare against to determine if it needs to be plural * @param string string to evaluate * @param string plural value to add * @return string */ // if (!function_exists('pluralize')) { function pluralize($num, $str = '', $plural = 's') { if (is_array($num)) { $num = count($num); } if ($num != 1) { $str .= $plural; } return $str; } } // -------------------------------------------------------------------- /** * Strips extra whitespace from a string * * @param string * @return string */ if (!function_exists('strip_whitespace')) { function strip_whitespace($str) { return trim(preg_replace('/\s\s+|\n/m', '', $str)); } } // -------------------------------------------------------------------- /** * Trims extra whitespace from the end and beginning of a string on multiple lines * * @param string * @return string */ if (!function_exists('trim_multiline')) { function trim_multiline($str) { return trim(implode("\n", array_map('trim', explode("\n", $str)))); } } // -------------------------------------------------------------------- /** * Converts words to title case and allows for exceptions * * @param string string to evaluate * @param mixed variables to pass to the string * @return string */ if (!function_exists('smart_ucwords')) { function smart_ucwords($str, $exceptions = array('of', 'the')) { $out = ""; $i = 0; foreach (explode(" ", $str) as $word) { $out .= (!in_array($word, $exceptions) OR $i == 0) ? strtoupper($word[0]) . substr($word, 1) . " " : $word . " "; $i++; } return rtrim($out); } } // -------------------------------------------------------------------- /** * Removes "Gremlin" characters * * (hidden control characters that the remove_invisible_characters function misses) * * @param string string to evaluate * @param string the value used to replace a gremlin * @return string */ if (!function_exists('zap_gremlins')) { function zap_gremlins($str, $replace = '') { // there is a hidden bullet looking thingy that photoshop likes to include in it's text' // the remove_invisible_characters doesn't seem to remove this $str = preg_replace('/[^\x0A\x0D\x20-\x7E]/', $replace, $str); return $str; } } // -------------------------------------------------------------------- /** * Removes javascript from a string * * @param string string to remove javascript * @return string */ if (!function_exists('strip_javascript')) { function strip_javascript($str) { $str = preg_replace('#<script[^>]*>.*?</script>#is', '', $str); return $str; } } // -------------------------------------------------------------------- /** * Safely converts a string's entities without encoding HTML tags and quotes * * @param string string to evaluate * @param boolean determines whether to encode the ampersand or not * @return string */ if (!function_exists('safe_htmlentities')) { function safe_htmlentities($str, $protect_amp = TRUE) { // convert all hex single quotes to numeric ... // this was due to an issue we saw with htmlentities still encoding it's ampersand again'... // but was inconsistent across different environments and versions... not sure the issue // may need to look into other hex characters $str = str_replace(''', ''', $str); // setup temp markers for existing encoded tag brackets $find = array('<','>'); $replace = array('__TEMP_LT__','__TEMP_GT__'); $str = str_replace($find,$replace, $str); // encode just & if ($protect_amp) { $str = preg_replace('/&(?![a-z#]+;)/i', '__TEMP_AMP__', $str); } // safely translate now if (version_compare(PHP_VERSION, '5.2.3', '>=')) { //$str = htmlspecialchars($str, ENT_NOQUOTES, 'UTF-8', FALSE); $str = htmlentities($str, ENT_NOQUOTES, config_item('charset'), FALSE); } else { $str = preg_replace('/&(?!(?:#\d++|[a-z]++);)/ui', '&', $str); $str = str_replace(array('<', '>'), array('<', '>'), $str); } // translate everything back $str = str_replace($find, array('<','>'), $str); $str = str_replace($replace, $find, $str); if ($protect_amp) { $str = str_replace('__TEMP_AMP__', '&', $str); } return $str; } } // -------------------------------------------------------------------- /** * Convert PHP syntax to templating syntax * * @param string string to evaluate * @return string */ function php_to_template_syntax($str, $engine = NULL) { $CI =& get_instance(); if (empty($engine)) { $engine = $CI->fuel->config('parser_engine'); } return $CI->fuel->parser->set_engine($engine)->php_to_syntax($str); } // -------------------------------------------------------------------- /** * Convert string to templating syntax * * @param string string to evaluate * @param array variables to parse with string * @param string the templating engine to use * @param array an array of configuration variables like compile_dir, delimiters, allowed_functions, refs and data * @return string */ function parse_template_syntax($str, $vars = array()) { CI()->load->library('parser'); return CI()->parser->parse_string($str, $vars, TRUE); } function url_slug($str, $options = array()) { // Make sure string is in UTF-8 and strip invalid UTF-8 characters $str = mb_convert_encoding((string)$str, 'UTF-8', mb_list_encodings()); $defaults = array( 'delimiter' => '-', 'limit' => null, 'lowercase' => true, 'replacements' => array(), 'transliterate' => false, ); // Merge options $options = array_merge($defaults, $options); $char_map = array( // Latin 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'AE', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ð' => 'D', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ő' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ű' => 'U', 'Ý' => 'Y', 'Þ' => 'TH', 'ß' => 'ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'ae', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'd', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ő' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'ű' => 'u', 'ý' => 'y', 'þ' => 'th', 'ÿ' => 'y', // Latin symbols '©' => '(c)', // Greek 'Α' => 'A', 'Β' => 'B', 'Γ' => 'G', 'Δ' => 'D', 'Ε' => 'E', 'Ζ' => 'Z', 'Η' => 'H', 'Θ' => '8', 'Ι' => 'I', 'Κ' => 'K', 'Λ' => 'L', 'Μ' => 'M', 'Ν' => 'N', 'Ξ' => '3', 'Ο' => 'O', 'Π' => 'P', 'Ρ' => 'R', 'Σ' => 'S', 'Τ' => 'T', 'Υ' => 'Y', 'Φ' => 'F', 'Χ' => 'X', 'Ψ' => 'PS', 'Ω' => 'W', 'Ά' => 'A', 'Έ' => 'E', 'Ί' => 'I', 'Ό' => 'O', 'Ύ' => 'Y', 'Ή' => 'H', 'Ώ' => 'W', 'Ϊ' => 'I', 'Ϋ' => 'Y', 'α' => 'a', 'β' => 'b', 'γ' => 'g', 'δ' => 'd', 'ε' => 'e', 'ζ' => 'z', 'η' => 'h', 'θ' => '8', 'ι' => 'i', 'κ' => 'k', 'λ' => 'l', 'μ' => 'm', 'ν' => 'n', 'ξ' => '3', 'ο' => 'o', 'π' => 'p', 'ρ' => 'r', 'σ' => 's', 'τ' => 't', 'υ' => 'y', 'φ' => 'f', 'χ' => 'x', 'ψ' => 'ps', 'ω' => 'w', 'ά' => 'a', 'έ' => 'e', 'ί' => 'i', 'ό' => 'o', 'ύ' => 'y', 'ή' => 'h', 'ώ' => 'w', 'ς' => 's', 'ϊ' => 'i', 'ΰ' => 'y', 'ϋ' => 'y', 'ΐ' => 'i', // Turkish 'Ş' => 'S', 'İ' => 'I', 'Ç' => 'C', 'Ü' => 'U', 'Ö' => 'O', 'Ğ' => 'G', 'ş' => 's', 'ı' => 'i', 'ç' => 'c', 'ü' => 'u', 'ö' => 'o', 'ğ' => 'g', // Russian 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'Yo', 'Ж' => 'Zh', 'З' => 'Z', 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sh', 'Ъ' => '', 'Ы' => 'Y', 'Ь' => '', 'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya', 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sh', 'ъ' => '', 'ы' => 'y', 'ь' => '', 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', // Ukrainian 'Є' => 'Ye', 'І' => 'I', 'Ї' => 'Yi', 'Ґ' => 'G', 'є' => 'ye', 'і' => 'i', 'ї' => 'yi', 'ґ' => 'g', // Czech 'Č' => 'C', 'Ď' => 'D', 'Ě' => 'E', 'Ň' => 'N', 'Ř' => 'R', 'Š' => 'S', 'Ť' => 'T', 'Ů' => 'U', 'Ž' => 'Z', 'č' => 'c', 'ď' => 'd', 'ě' => 'e', 'ň' => 'n', 'ř' => 'r', 'š' => 's', 'ť' => 't', 'ů' => 'u', 'ž' => 'z', // Polish 'Ą' => 'A', 'Ć' => 'C', 'Ę' => 'e', 'Ł' => 'L', 'Ń' => 'N', 'Ó' => 'o', 'Ś' => 'S', 'Ź' => 'Z', 'Ż' => 'Z', 'ą' => 'a', 'ć' => 'c', 'ę' => 'e', 'ł' => 'l', 'ń' => 'n', 'ó' => 'o', 'ś' => 's', 'ź' => 'z', 'ż' => 'z', // Latvian 'Ā' => 'A', 'Č' => 'C', 'Ē' => 'E', 'Ģ' => 'G', 'Ī' => 'i', 'Ķ' => 'k', 'Ļ' => 'L', 'Ņ' => 'N', 'Š' => 'S', 'Ū' => 'u', 'Ž' => 'Z', 'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n', 'š' => 's', 'ū' => 'u', 'ž' => 'z' ); // Make custom replacements $str = preg_replace(array_keys($options['replacements']), $options['replacements'], $str); // Transliterate characters to ASCII if ($options['transliterate']) { $str = str_replace(array_keys($char_map), $char_map, $str); } // Replace non-alphanumeric characters with our delimiter $str = preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str); // Remove duplicate delimiters $str = preg_replace('/(' . preg_quote($options['delimiter'], '/') . '){2,}/', '$1', $str); // Truncate slug to max. characters $str = mb_substr($str, 0, ($options['limit'] ? $options['limit'] : mb_strlen($str, 'UTF-8')), 'UTF-8'); // Remove delimiter from ends $str = trim($str, $options['delimiter']); $str = str_replace('-amp-', '-and-', $str); return $options['lowercase'] ? mb_strtolower($str, 'UTF-8') : $str; } function check_date($string){ if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $string)) { $exp=explode('-', $string); if (checkdate($exp[1], $exp[2], $exp[0])) { $error = true; }else{ $error=false; } } else { $error = false; } return $error; } function check_format($string,$format){ if (!preg_match($format, $string, $matches)){ return false; }else{ return true; } } function check_adhar($string){ if(check_format($string,'/^\d{12}$/')){ return true; }else{ return false; } } function check_pan($string){ if(check_format($string,'/^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/')){ return true; }else{ return false; } } function check_ind_phone($string){ if(check_format($string,'/^[6-9]\d{9}$/')){ return true; }else{ return false; } } function validate_email($email){ $exp = "//"; if(check_format($email,'/^\d{10}$/')){ return true; }else{ return false; } } function check_time_format($date, $format = 'h:i:s'){ $dateObj = DateTime::createFromFormat($format, $date); return $dateObj && $dateObj->format($format) == $date; } function isTime($time) { return preg_match("#([0-1]{1}[0-9]{1}|[2]{1}[0-3]{1}):[0-5]{1}[0-9]{1}#", $time); } function columnLetter($c){ $c = intval($c); //if ($c<= 0) return ''; $letter = ''; while($c != 0){ $p = ($c - 1) % 26; $c = intval(($c - $p) / 26); $letter = chr(65 + $p) . $letter; } return $letter; } function odd_even($number){ if ($number % 2 == 0){ return true;//even }else{ return false;//odd } } function check_your_datetime($x) { return (date('d-M-Y', strtotime($x)) == $x); } if ( ! function_exists('return_json')) { /** * Outputs anything in JSON format * * @access public * @param mixed * @param boolean * @return string */ function return_json($str, $b = false) { // If b (beautify is set to true) $str = ($b === true) ? beautify_json($str) : json_encode($str); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json'); echo $str; } } if ( ! function_exists('beautify_json')) { /** * Makes the json encoded string human-readable * * @access public * @param mixed * @return string */ function beautify_json($str = false) { // make sure array is provided if ( ! $str or empty($str)) return null; //Encode the string $json = json_encode($str); $result = ''; $pos = 0; $str_len = strlen($json); $indent_str = ' '; $new_line = "\n"; $prev_char = ''; $out_of_quotes = true; for ($i = 0; $i <= $str_len; $i++) { // grab the next character in the string $char = substr($json, $i, 1); // are we inside a quoted string? if ($char == '"' and $prev_char != '\\') { $out_of_quotes = !$out_of_quotes; } // if this character is the end of an element, output a new line and indent the next line elseif (($char == '}' or $char == ']') and $out_of_quotes) { $result .= $new_line; $pos--; for ($j = 0; $j < $pos; $j++) { $result .= $indent_str; } } // add the character to the result string $result .= $char; // if the last character was the beginning of an element, output a new line and indent the next line if (($char == ',' or $char == '{' or $char == '[') and $out_of_quotes) { $result .= $new_line; if ($char == '{' or $char == '[') { $pos++; } for ($j = 0; $j < $pos; $j++) { $result .= $indent_str; } } $prev_char = $char; } // return result return $result.$new_line; } } /** * Finds all of the keywords (words that appear most) on param $str * and return them in order of most occurrences to less occurrences. * @param string $str The string to search for the keywords. * @param int $minWordLen[optional] The minimun length (number of chars) of a word to be considered a keyword. * @param int $minWordOccurrences[optional] The minimun number of times a word has to appear * on param $str to be considered a keyword. * @param boolean $asArray[optional] Specifies if the function returns a string with the * keywords separated by a comma ($asArray = false) or a keywords array ($asArray = true). * @return mixed A string with keywords separated with commas if param $asArray is true, * an array with the keywords otherwise. */ function extract_keywords($str, $minWordLen = 3, $minWordOccurrences = 2, $asArray = false) { function keyword_count_sort($first, $sec) { return $sec[1] - $first[1]; } $str = preg_replace('/[^\p{L}0-9 ]/', ' ', $str); $str = trim(preg_replace('/\s+/', ' ', $str)); $words = explode(' ', $str); $keywords = array(); while(($c_word = array_shift($words)) !== null) { if(strlen($c_word) < $minWordLen) continue; $c_word = strtolower($c_word); if(array_key_exists($c_word, $keywords)) $keywords[$c_word][1]++; else $keywords[$c_word] = array($c_word, 1); } usort($keywords, 'keyword_count_sort'); $final_keywords = array(); foreach($keywords as $keyword_det) { if($keyword_det[1] < $minWordOccurrences) break; array_push($final_keywords, $keyword_det[0]); } return $asArray ? $final_keywords : implode(', ', $final_keywords); } function beliefmedia_keywords($string, $min_word_length = 3, $min_word_occurrence = 2, $as_array = false, $max_words = 8, $restrict = false) { function keyword_count_sort($first, $sec) { return $sec[1] - $first[1]; } $string = preg_replace('/[^\p{L}0-9 ]/', ' ', $string); $string = trim(preg_replace('/\s+/', ' ', $string)); $words = explode(' ', $string); /* Only compare to common words if $restrict is set to false Tags are returned based on any word in text If we don't restrict tag usage, we'll remove common words from array */ if ($restrict === false) { $commonWords = array('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerning','consequently','consider','considering','contain','containing','contains','corresponding','could','couldn\'t','course','c\'s','currently','d','dare','daren\'t','definitely','described','despite','did','didn\'t','different','directly','do','does','doesn\'t','doing','done','don\'t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','end','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','formerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting','given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadn\'t','half','happens','hardly','has','hasn\'t','have','haven\'t','having','he','he\'d','he\'ll','hello','help','hence','her','here','hereafter','hereby','herein','here\'s','hereupon','hers','herself','he\'s','hi','him','himself','his','hither','home','hopefully','how','howbeit','however','hundred','i','i\'d','ie','if','ignored','i\'ll','i\'m','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','inside','insofar','instead','into','inward','is','isn\'t','it','it\'d','it\'ll','its','it\'s','itself','i\'ve','j','just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latterly','least','less','lest','let','let\'s','like','liked','likely','likewise','little','look','looking','looks','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','mayn\'t','me','mean','meantime','meanwhile','merely','might','mightn\'t','mine','minus','miss','more','moreover','most','mostly','mr','mrs','much','must','mustn\'t','my','myself','n','name','namely','nd','near','nearly','necessary','need','needn\'t','needs','neither','never','neverf','neverless','nevertheless','new','next','nine','ninety','no','nobody','non','none','nonetheless','noone','no-one','nor','normally','not','nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','okay','old','on','once','one','ones','one\'s','only','onto','opposite','or','other','others','otherwise','ought','oughtn\'t','our','ours','ourselves','out','outside','over','overall','own','p','particular','particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','provided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','recently','regarding','regardless','regards','relatively','respectively','right','round','s','said','same','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems','seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shan\'t','she','she\'d','she\'ll','she\'s','should','shouldn\'t','since','six','so','some','somebody','someday','somehow','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','specify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','th','than','thank','thanks','thanx','that','that\'ll','thats','that\'s','that\'ve','the','their','theirs','them','themselves','then','thence','there','thereafter','thereby','there\'d','therefore','therein','there\'ll','there\'re','theres','there\'s','thereupon','there\'ve','these','they','they\'d','they\'ll','they\'re','they\'ve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','three','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tried','tries','truly','try','trying','t\'s','twice','two','u','un','under','underneath','undoing','unfortunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','useful','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','wants','was','wasn\'t','way','we','we\'d','welcome','well','we\'ll','went','were','we\'re','weren\'t','we\'ve','what','whatever','what\'ll','what\'s','what\'ve','when','whence','whenever','where','whereafter','whereas','whereby','wherein','where\'s','whereupon','wherever','whether','which','whichever','while','whilst','whither','who','who\'d','whoever','whole','who\'ll','whom','whomever','who\'s','whose','why','will','willing','wish','with','within','without','wonder','won\'t','would','wouldn\'t','x','y','yes','yet','you','you\'d','you\'ll','your','you\'re','yours','yourself','yourselves','you\'ve','z','zero'); $words = array_udiff($words, $commonWords,'strcasecmp'); } /* Restrict Keywords based on values in the $allowedWords array */ if ($restrict !== false) { $allowedWords = array('engine','boeing','electrical','pneumatic','ice'); $words = array_uintersect($words, $allowedWords,'strcasecmp'); } $keywords = array(); while(($c_word = array_shift($words)) !== null) { if (strlen($c_word) < $min_word_length) continue; $c_word = strtolower($c_word); if (array_key_exists($c_word, $keywords)) $keywords[$c_word][1]++; else $keywords[$c_word] = array($c_word, 1); } usort($keywords, 'keyword_count_sort'); $final_keywords = array(); foreach ($keywords as $keyword_det) { if ($keyword_det[1] < $min_word_occurrence) break; array_push($final_keywords, $keyword_det[0]); } $final_keywords = array_slice($final_keywords, 0, $max_words); return $as_array ? $final_keywords : implode(', ', $final_keywords); } function generateKeywordsFromText($text){ // List of words NOT to be included in keywords $stopWords = array('i','a','about','an','and','are','as','at','be','by','com','de','en','for','from','how','in','is','it','la','of','on','or','that','the','this','to','was','what','when','where','who','will','with','und','the','www', "such", "have", "then",'a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerning','consequently','consider','considering','contain','containing','contains','corresponding','could','couldn\'t','course','c\'s','currently','d','dare','daren\'t','definitely','described','despite','did','didn\'t','different','directly','do','does','doesn\'t','doing','done','don\'t','down','downwards','during','e','each','edu','eg','eight','eighty','either','else','elsewhere','end','ending','enough','entirely','especially','et','etc','even','ever','evermore','every','everybody','everyone','everything','everywhere','ex','exactly','example','except','f','fairly','far','farther','few','fewer','fifth','first','five','followed','following','follows','for','forever','former','formerly','forth','forward','found','four','from','further','furthermore','g','get','gets','getting','given','gives','go','goes','going','gone','got','gotten','greetings','h','had','hadn\'t','half','happens','hardly','has','hasn\'t','have','haven\'t','having','he','he\'d','he\'ll','hello','help','hence','her','here','hereafter','hereby','herein','here\'s','hereupon','hers','herself','he\'s','hi','him','himself','his','hither','home','hopefully','how','howbeit','however','hundred','i','i\'d','ie','if','ignored','i\'ll','i\'m','immediate','in','inasmuch','inc','inc.','indeed','indicate','indicated','indicates','inner','inside','insofar','instead','into','inward','is','isn\'t','it','it\'d','it\'ll','its','it\'s','itself','i\'ve','j','just','k','keep','keeps','kept','know','known','knows','l','last','lately','later','latter','latterly','least','less','lest','let','let\'s','like','liked','likely','likewise','little','look','looking','looks','low','lower','ltd','m','made','mainly','make','makes','many','may','maybe','mayn\'t','me','mean','meantime','meanwhile','merely','might','mightn\'t','mine','minus','miss','more','moreover','most','mostly','mr','mrs','much','must','mustn\'t','my','myself','n','name','namely','nd','near','nearly','necessary','need','needn\'t','needs','neither','never','neverf','neverless','nevertheless','new','next','nine','ninety','no','nobody','non','none','nonetheless','noone','no-one','nor','normally','not','nothing','notwithstanding','novel','now','nowhere','o','obviously','of','off','often','oh','ok','okay','old','on','once','one','ones','one\'s','only','onto','opposite','or','other','others','otherwise','ought','oughtn\'t','our','ours','ourselves','out','outside','over','overall','own','p','particular','particularly','past','per','perhaps','placed','please','plus','possible','presumably','probably','provided','provides','q','que','quite','qv','r','rather','rd','re','really','reasonably','recent','recently','regarding','regardless','regards','relatively','respectively','right','round','s','said','same','saw','say','saying','says','second','secondly','see','seeing','seem','seemed','seeming','seems','seen','self','selves','sensible','sent','serious','seriously','seven','several','shall','shan\'t','she','she\'d','she\'ll','she\'s','should','shouldn\'t','since','six','so','some','somebody','someday','somehow','someone','something','sometime','sometimes','somewhat','somewhere','soon','sorry','specified','specify','specifying','still','sub','such','sup','sure','t','take','taken','taking','tell','tends','th','than','thank','thanks','thanx','that','that\'ll','thats','that\'s','that\'ve','the','their','theirs','them','themselves','then','thence','there','thereafter','thereby','there\'d','therefore','therein','there\'ll','there\'re','theres','there\'s','thereupon','there\'ve','these','they','they\'d','they\'ll','they\'re','they\'ve','thing','things','think','third','thirty','this','thorough','thoroughly','those','though','three','through','throughout','thru','thus','till','to','together','too','took','toward','towards','tried','tries','truly','try','trying','t\'s','twice','two','u','un','under','underneath','undoing','unfortunately','unless','unlike','unlikely','until','unto','up','upon','upwards','us','use','used','useful','uses','using','usually','v','value','various','versus','very','via','viz','vs','w','want','wants','was','wasn\'t','way','we','we\'d','welcome','well','we\'ll','went','were','we\'re','weren\'t','we\'ve','what','whatever','what\'ll','what\'s','what\'ve','when','whence','whenever','where','whereafter','whereas','whereby','wherein','where\'s','whereupon','wherever','whether','which','whichever','while','whilst','whither','who','who\'d','whoever','whole','who\'ll','whom','whomever','who\'s','whose','why','will','willing','wish','with','within','without','wonder','won\'t','would','wouldn\'t','x','y','yes','yet','you','you\'d','you\'ll','your','you\'re','yours','yourself','yourselves','you\'ve','z','zero','0'); //Let us do some basic clean up! on the text before getting to real keyword generation work $text = preg_replace('/\s\s+/i', '', $text); // replace multiple spaces etc. in the text $text = trim($text); // trim any extra spaces at start or end of the text $text = preg_replace('/[^a-zA-Z0-9 -]/', '', $text); // only take alphanumerical characters, but keep the spaces and dashes too… $text = strtolower($text); // Make the text lowercase so that output is in lowercase and whole operation is case in sensitive. // Find all words preg_match_all('/\b.*?\b/i', $text, $allTheWords); $allTheWords = $allTheWords[0]; //Now loop through the whole list and remove smaller or empty words foreach ( $allTheWords as $key=>$item ) { if ( $item == '' || in_array(strtolower($item), $stopWords) || strlen($item) <= 3 ) { unset($allTheWords[$key]); } } // Create array that will later have its index as keyword and value as keyword count. $wordCountArr = array(); // Now populate this array with keywrds and the occurance count if ( is_array($allTheWords) ) { foreach ( $allTheWords as $key => $val ) { $val = strtolower($val); if ( isset($wordCountArr[$val]) ) { $wordCountArr[$val]++; } else { $wordCountArr[$val] = 1; } } } // Sort array by the number of repetitions arsort($wordCountArr); //Keep first 10 keywords, throw other keywords $wordCountArr = array_slice($wordCountArr, 0, 10); // Now generate comma separated list from the array $words=""; foreach ($wordCountArr as $key=>$value) $words .= ", " . $key ; // Trim list of comma separated keyword list and return the list return trim($words,","); } function get_values_uder_first_p_tag($html){ $start = strpos($html, '<p>'); $end = strpos($html, '</p>', $start); $paragraph = strip_tags(substr($html, $start, $end-$start+4)); return $paragraph; } function abbreviate($string){ return implode( array_map( function ($w) { return substr($w,0,1); }, explode(" ", $string) ) ); } /* End of file MY_string_helper.php */