function createUTFName($first_name, $last_name) { $this_first_name = ucname_utf8(strtolower_utf8(utf8_encode($first_name))); $this_last_name = ucname_utf8(strtolower_utf8(utf8_encode($last_name))); $response = $this_first_name . " " . $this_last_name; return $response; }
/** * Smarty {occ} function plugin * * Type: function<br> * Name: occ<br> * Date: Feb 17, 2003<br> * Purpose: return a <br> * Input:<br> * - label * - element * - separator * - class * * Examples: * <pre> * {occ label=AUTOR element=$doc->au separator=; class=author} * </pre> * @author Vinicius Andrade <viniciusdeandrade at gmail dot com> * @version 0.1 * @param array * @param Smarty * @return string */ function smarty_function_occ($params, &$smarty) { $output = ""; $element = $params['element']; $text_transform = $params['text_transform']; if (!isset($element) || $element == '' || count($element) == 0) { return; } $element = $params['element']; if (isset($params['class'])) { $output .= "<div class=\"" . $params['class'] . "\">\n"; } if (isset($params['label'])) { $output .= $params['label'] . ": "; } if (isset($params['span'])) { $output .= "<span>"; } if (is_array($element)) { for ($occ = 0; $occ < count($element); $occ++) { if ($occ > 0) { $output .= $params['separator'] . " "; } if (isset($params['translation'])) { $text = smarty_function_occ_translate($element[$occ], $params['suffix'], $params['translation']); } else { $text = $element[$occ]; } if (isset($text_transform) && $text_transform != '') { if ($text_transform == 'lowercase') { $text = strtolower_utf8($text); } elseif ($text_transform == 'uppercase') { $text = strtoupper_utf8($text); } elseif ($text_transform == 'capitalize') { $text = capitalize_utf8($text); } } $output .= $text; } } else { if (isset($params['translation'])) { $output .= smarty_function_occ_translate($element, $params['suffix'], $params['translation']); } else { $output .= $element; } } if (isset($params['span'])) { $output .= "</span>"; } if (isset($params['class'])) { $output .= "</div>\n"; } return $output; }
function ProcessData($strData, $Process) { global $loaded_modules; //echo 'process = ' . $Process . ' and posted cur = '; print_r($posted_currencies); echo '<br />'; switch ($Process) { case "uc": return strtoupper_utf8($strData); case "lc": return strtolower_utf8($strData); case "neg": return -$strData; case "n2wrd": return value_to_words_en_us($strData); case "rnd2d": if (!is_numeric($strData)) { return $strData; } return number_format(round($strData, 2), 2, '.', ''); case "date": return gen_locale_date($strData); case "null-dlr": return (double) $strData == 0 ? '' : '$ ' . number_format($strData, 2); case "dlr": if (!is_numeric($strData)) { return $strData; } return '$ ' . number_format(round($strData, 2), 2); case "euro": if (!is_numeric($strData)) { return $strData; } return chr(128) . ' ' . number_format(round($strData, 2), 2); // assumes standard FPDF fonts // assumes standard FPDF fonts case 'yesBno': return $strData ? TEXT_YES : ''; case 'blank': return ''; case 'printed': return $strData ? '' : TEXT_DUPLICATE; } // now try loaded modules for processing foreach ($loaded_modules as $mod) { $mod_function = "pf_process_" . $mod; if (function_exists($mod_function)) { $strData = $mod_function($strData, $Process); } } if (function_exists('pf_extra_process')) { $strData = pf_extra_process($strData, $Process); } return $strData; }
/** * Detects searchtype by search query fragment * * @param string $term * @return string */ public function detectSearchType($term) { $result = ''; $term = trim($term); if (!empty($term)) { $term = strtolower_utf8($term); $this->loadRawdata(); if (!empty($this->rawData)) { foreach ($this->rawData as $io => $each) { if (ispos($each['lower'], $term)) { $result = $each['type']; break; } } } } return $result; }
function catvbs_MonthDetect($string) { $string = strtolower_utf8($string); $montharr = array('01' => 'январь', '02' => 'февраль', '03' => 'март', '04' => 'апрель', '05' => 'май', '06' => 'июнь', '07' => 'июль', '08' => 'август', '09' => 'сентябрь', '10' => 'октябрь', '11' => 'ноябрь', '12' => 'декабрь'); $result = false; foreach ($montharr as $io => $eachmonth) { if (ispos($string, $eachmonth)) { $result = $io; } else { if (!$result) { $result = false; } } } return $result; }
function make_cloud($matches) { global $phpwcms, $content; // use $matches for // $rendermode,$which_ID,$setLP,$landing $rendermode = trim($matches[1]); $which_ID = trim($matches[2]); $setLP = trim($matches[3]); $landing = isset($matches[4]) ? intval($matches[4]) : 0; $conf =& $content['tagcloud']; // check integrity of user_settings --- else use defaults +++ OG new style if (empty($conf['min'])) { $conf['min'] = 4; } if (empty($conf['min_chars'])) { $conf['min_chars'] = 4; } if (!isset($conf['sort'])) { $conf['sort'] = false; } if (empty($conf['inc_or_ex'])) { $conf['inc_or_ex'] = 0; } // avoid php notice: undefined variable if (empty($allmyhds)) { $allmyhds = ''; } if (empty($allmycps)) { $allmycps = ''; } if (empty($at)) { $at = ''; } if (empty($ast)) { $ast = ''; } if (empty($asm)) { $asm = ''; } // avoid php notice: undefined index //if(isset($conf['add_t'])) {$auswert_t = $conf['add_t'];} // NOW, FINALLY IT'S TIME TO LET A FRESH BREEZE BLOWING UP PRETTY CLOUDS if (!empty($landing)) { // check if landing page has an article alias ( only versions > 1.3.5 else use fallback ) // original code has been deleted because +++ o-ton OG: "so geht es schneller" $landalias = _dbGet('phpwcms_article', 'article_alias', "article_id=" . $landing . " AND article_alias != ''"); // "So muss weitermachen...". Hey, here we are: if (!empty($landalias[0]['article_alias'])) { $aliasfound = $landalias[0]['article_alias']; } // second BREEZE BLOWING if (!empty($setLP)) { switch ($setLP) { case 'L': if (isset($aliasfound)) { $landing = 'index.php?' . $aliasfound . '#'; } else { $landing = 'index.php?aid=' . $landing . '#'; //fallback for older versions //$old_style $landing = 'index.php?id=0,'. $landing . ',0,0,1,0#'; //much older versions } break; case 'S': if (isset($aliasfound)) { $landing = 'index.php?' . $aliasfound . '&searchwords='; } else { $landing = 'index.php?aid=' . $landing . '&searchwords='; //fallback for older versions //$old_style $landing = 'index.php?id=0,'. $landing . ',0,0,1,0&searchwords='; //much older versions } break; } } else { $landing = 'index.php#'; echo "TagCloud ERROR: Wrong setup of RT! MISSING --> (L) = Landing page OR --> (S) = Search page"; } } else { //die("TagCloud ERROR: Article_ID of your (L)Landing Page or your (S)Search Page is missing!"); echo "TagCloud ERROR: Wrong setup of RT! Article ID of (L) = Landing Page or (S) = Search Page MISSING!"; $landing = 'index.php#'; } switch ($rendermode) { case 'E': //exclude array stuff by marcus@localhorst $excludeid = explode(',', $which_ID); $struct = array_keys($content['struct']); $only_cat_id = array_diff($struct, $excludeid); break; case 'I': $only_cat_id = explode(',', $which_ID); break; default: echo "TagCloud ERROR: Rendermode not defined! (I) = match all articles withIN named categories or vice versa (E) = exclude categories!"; break; } if (is_array($only_cat_id)) { foreach ($only_cat_id as $slid) { $sql = "SELECT SQL_CACHE article_id"; if ($conf['add_t']) { $sql .= ",article_title"; } if ($conf['add_st']) { $sql .= ",article_subtitle"; } if ($conf['add_sm']) { $sql .= ",article_summary"; } $sql .= " FROM " . DB_PREPEND . "phpwcms_article WHERE article_cid={$slid}"; $sql .= " AND article_public=1 AND article_aktiv=1 AND article_deleted=0"; $sql .= " AND article_begin < NOW() AND article_end > NOW()"; $result = _dbQuery($sql); foreach ($result as $row) { $ai = $row['article_id']; if ($conf['add_t']) { $at = $row['article_title']; } if ($conf['add_st']) { $ast = $row['article_subtitle']; } if ($conf['add_sm']) { $asm = $row['article_summary']; } $allmyhds .= $at . ' ' . $ast . ' ' . $asm . ' '; $sec_sql = "SELECT SQL_CACHE acontent_html"; if ($conf['add_cpt']) { $sec_sql .= ",acontent_title"; } if ($conf['add_cpst']) { $sec_sql .= ",acontent_subtitle"; } if ($conf['add_cptximg']) { $sec_sql .= ",acontent_text"; } $sec_sql .= " FROM " . DB_PREPEND . "phpwcms_articlecontent WHERE acontent_aid={$ai}"; $sec_sql .= " AND acontent_visible=1 AND acontent_trash=0"; $scd_result = _dbQuery($sec_sql); foreach ($scd_result as $scd_row) { $allmycps .= $scd_row['acontent_html'] . ' '; if ($conf['add_cpt']) { $allmycps .= $scd_row['acontent_title'] . ' '; } if ($conf['add_cpst']) { $allmycps .= $scd_row['acontent_subtitle'] . ' '; } if ($conf['add_cptximg']) { $allmycps .= $scd_row['acontent_text'] . ' '; } } } } /***************************************************************** * JOIN ALL the text of content --> Titles, Summary, CPs *****************************************************************/ $tagtext = $allmyhds . $allmycps; /***************************************************************** * add NEWS when set =1 *****************************************************************/ if ($conf['news_to_cloud'] == 1) { $news_sql = "SELECT SQL_CACHE cnt_title, "; $news_sql .= "cnt_subtitle, cnt_teasertext, cnt_text"; $news_sql .= " FROM " . DB_PREPEND . "phpwcms_content WHERE cnt_status=1"; $news_sql .= " AND cnt_livedate < NOW() AND cnt_killdate > NOW()"; $news_result = _dbQuery($news_sql); foreach ($news_result as $news_row) { $newscontent .= $news_row['cnt_title'] . ' '; $newscontent .= $news_row['cnt_subtitle'] . ' '; $newscontent .= $news_row['cnt_teasertext'] . ' '; $newscontent .= $news_row['cnt_text'] . ' '; } //article content plus news $tagtext = $tagtext . $newscontent; } /***************************************************************** and do some convertions *****************************************************************/ $tagtext = clean_replacement_tags($tagtext); $tagtext = stripped_cache_content($tagtext); //delete not wantend and then str_all to lower if (phpwcms_seems_utf8($tagtext)) { $tagtext = strtolower_utf8(str_replace($conf['del_signs'], '', $tagtext)); } else { $tagtext = strtolower(str_replace($conf['del_signs'], '', $tagtext)); } $tagtext = explode(' ', $tagtext); //split in separate words $anzahl = array_count_values($tagtext); //count the words -- into new array $tags = array(); switch ($conf['inc_or_ex']) { case '0': foreach ($anzahl as $key => $tagword) { if ($tagword >= $conf['min'] && !in_array($key, $conf['exclude'])) { //look if the word counts the required minimum and is not in the exclude list if (strlen($key) >= $conf['min_chars']) { //ignore words on web site that are NOT longer than (chief inspector even longer) defined in: var min_chars $tags[$key] = $tagword; //put them in a new array } // else { $this_word_out[$key] = $tagword; } } } break; case '1': foreach ($anzahl as $key => $tagword) { if ($tagword >= $conf['min'] && in_array($key, $conf['include'])) { //look if the word counts the required minimum and is not in the exclude list if (strlen($key) >= $conf['min_chars']) { //ignore words on web site that are NOT longer than (chief inspector even longer) defined in: var min_chars $tags[$key] = $tagword; //now put them in a new array } // else { $this_word_out[$key] = $tagword; } } } break; default: break; } if (!empty($tags)) { //unset($tags['phpwcms']); //if you want to override the value of words (in this case 'phpwcms'), uncomment it and put in your word //$weight = count($tags); $max_hits = max($tags); //tag with most hits if (!empty($max_hits)) { //$tags['phpwcms']=8; // put in again your deleted word and value from 4 lines above switch ($conf['sort']) { case 'asc': ksort($tags); //sort them alphabetically break; case 'desc': krsort($tags); //sort them reverse alphabetically break; case 'random': $keys = array_keys($tags); shuffle($keys); $random_words = array(); foreach ($keys as $key) { $random_words[$key] = $tags[$key]; } $tags = $random_words; break; default: break; } // FULL BLOWN CLOUDS LIKE HORNBLOWER $tag_cloud = '<div class="' . $conf['class'] . '">'; foreach ($tags as $key => $tagword) { $key = html_specialchars($key); // new maths by Heiko H. $percent = round(100 * $tagword / $max_hits, 0); $size = ceil($percent / 10); // prepare TC font size for CSS $tag_cloud .= '<a class="tcfs' . $size . '" href="' . PHPWCMS_URL . $landing . urlencode($key) . '">' . $key . '</a>'; if ($conf['showCount']) { $tag_cloud .= $conf['SC_before'] . $tagword . $conf['SC_after']; } $tag_cloud .= ' ' . LF; } $tag_cloud .= '</div>'; } } } return $tag_cloud; }
function bs_SearchLoginByAddresspart($queryaddress, $queryname, $checkarr) { $queryaddress = mysql_real_escape_string($queryaddress); $queryaddress = strtolower_utf8($queryaddress); $queryname = mysql_real_escape_string($queryname); $queryname = strtolower_utf8($queryname); $result = array(); if (!empty($checkarr)) { foreach ($checkarr as $io => $check) { // искаем логин по паре фамилия+пароль if (ispos($queryaddress, strtolower_utf8($check['address']))) { if (!empty($check['realname'])) { if (ispos($queryname, strtolower_utf8($check['realname']))) { $result[] = $io; } } } } } return $result; }
function ProcessData($strData, $Process) { global $currencies, $posted_currencies, $rw_xtra_jrnl_defs; //echo 'process = ' . $Process . ' and posted cur = '; print_r($posted_currencies); echo '<br />'; switch ($Process) { case "uc": return strtoupper_utf8($strData); case "lc": return strtolower_utf8($strData); case "neg": return -$strData; case "rnd2d": if (!is_numeric($strData)) { return $strData; } else { return number_format(round($strData, 2), 2, '.', ''); } case "rnd_dec": if (!is_numeric($strData)) { return $strData; } else { return $currencies->format($strData); } case "rnd_pre": if (!is_numeric($strData)) { return $strData; } else { return $currencies->precise($strData); } case "def_cur": if (!is_numeric($strData)) { return $strData; } else { return $currencies->format_full($strData, true, DEFAULT_CURRENCY, 1, 'fpdf'); } case "null_dcur": if (!is_numeric($strData)) { return $strData; } else { return !$strData ? '' : $currencies->format_full($strData, true, DEFAULT_CURRENCY, 1, 'fpdf'); } case "posted_cur": if (!is_numeric($strData)) { return $strData; } else { return $currencies->format_full($strData, true, $posted_currencies['currencies_code'], $posted_currencies['currencies_value'], 'fpdf'); } case "null_pcur": if (!is_numeric($strData)) { return $strData; } else { return !$strData ? '' : $currencies->format_full($strData, true, $posted_currencies['currencies_code'], $posted_currencies['currencies_value'], 'fpdf'); } case "dlr": if (!is_numeric($strData)) { return $strData; } else { return '$ ' . number_format(round($strData, 2), 2); } case "euro": if (!is_numeric($strData)) { return $strData; } else { return chr(128) . ' ' . number_format(round($strData, 2), 2); } // assumes standard FPDF fonts // assumes standard FPDF fonts case "n2wrd": return value_to_words_en_us($strData); // for checks primarily // for checks primarily case "terms": return gen_terms_to_language($strData, $short = true, $type = 'ar'); case "date": return gen_spiffycal_db_date_short($strData); case "null-dlr": return !$strData ? '' : '$ ' . number_format($strData, 2); case "ordr_qty": return pull_order_qty($strData); case "branch": return rw_get_branch_name($strData); case "rep_id": return rw_get_user_name($strData); case "ship_name": return rw_get_ship_name($strData); case 'j_desc': return isset($rw_xtra_jrnl_defs[$strData]) ? $rw_xtra_jrnl_defs[$strData] : $strData; case 'yesBno': return $strData ? TEXT_YES : ''; case 'printed': return $strData ? '' : TEXT_DUPLICATE; } $processed_value = false; if (function_exists('rw_extra_processing')) { $processed_value = rw_extra_processing($strData, $Process); } return $processed_value === false ? $strData : $processed_value; // do nothing if Process not recognized }
show_window(__('Builds editor'), web_StreetListerBuildsEdit()); } else { if (isset($_GET['streetid'])) { $streetid = vf($_GET['streetid']); if ($_GET['action'] == 'edit') { if (isset($_POST['newbuildnum'])) { if (!empty($_POST['newbuildnum'])) { //check for exist of same build at this street $existingBuilds_raw = zb_AddressGetBuildAllDataByStreet($streetid); $existingBuilds = array(); if (!empty($existingBuilds_raw)) { foreach ($existingBuilds_raw as $ix => $eachbuilddata) { $existingBuilds[] = strtolower_utf8($eachbuilddata['buildnum']); } } if (!in_array(strtolower_utf8($_POST['newbuildnum']), $existingBuilds)) { zb_AddressCreateBuild($streetid, $_POST['newbuildnum']); } else { show_error(__('The same build already exists')); } } else { show_error(__('Empty building number')); } } $streetname = zb_AddressGetStreetData($streetid); $streetname = $streetname['streetname']; show_window(__('Add build'), web_BuildAddForm()); show_window(__('Available buildings on street') . ' ' . $streetname, web_BuildLister($streetid)); } if ($_GET['action'] == 'delete') { if (!zb_AddressBuildProtected($_GET['buildid'])) {
$newstreetcityid = $_POST['citysel']; if (isset($_POST['newstreetalias'])) { $newstreetalias = trim($_POST['newstreetalias']); } else { $newstreetalias = ''; } if (!empty($newstreetname)) { //check for existing same street in city $existingStreets_raw = zb_AddressGetStreetAllDataByCity($newstreetcityid); $existingStreets = array(); if (!empty($existingStreets_raw)) { foreach ($existingStreets_raw as $ix => $eachstreetdata) { $existingStreets[] = strtolower_utf8($eachstreetdata['streetname']); } } if (!in_array(strtolower_utf8($newstreetname), $existingStreets)) { zb_AddressCreateStreet($newstreetcityid, $newstreetname, $newstreetalias); } else { show_error(__('The same street already exists')); } } else { show_error(__('Empty street name')); } } if (isset($_GET['action'])) { if (isset($_GET['streetid'])) { $streetid = $_GET['streetid']; if ($_GET['action'] == 'delete') { if (!zb_AddressStreetProtected($streetid)) { zb_AddressDeleteStreet($streetid); rcms_redirect('?module=streets');
function db_store_html($seed, $strHTML, $strURL) { /*!! TODO: Encoding Issues, pull date from header*/ #store strHTML and current datetime #echo "start db_store_html(....)\n"; #echo "$strHTML"; //ENCODING!!!!!!!!!! try { $enc = get_encoding($strHTML, true); if (strlen($enc) > 0) { $enc = $enc . ","; } $enc = $enc . "x-euc-jp,EUC-JP,JIS,SJIS,iso-8859-1,ASCII"; #mb_detect_encoding($strHTML,$enc) $strHTML = mb_convert_encoding($strHTML, "UTF-8", $enc); //$strHTML = html_entity_decode( $strHTML, ENT_QUOTES, "UTF-8" ); //$strHTML = remove($strHTML,"<script","</script>");//strip JavaScript //$strHTML=strip_tags($strHTML);//Remove html tags $strHTML = strtolower_utf8($strHTML); $return = $strHTML; try { $strHTML = $strHTML; if ($strURL && clean_url($strURL) != clean_url($seed["strURL"])) { $domain = get_domain($strURL); $cleanURL = clean_url($strURL); $url = $strURL; $strSQL = "UPDATE tblPages SET strURL=?, strCleanURL=?, strHTML=? WHERE iPageID=?"; $params = array($url, $cleanURL, $strHTML, $seed["iPageID"]); } else { $strSQL = "UPDATE tblPages SET strHTML=? WHERE iPageID=?"; $params = array($strHTML, $seed["iPageID"]); } db_run_query($strSQL, $params); #echo "end db_store_html(...)\n"; #'" . date("YmdHi___NEED SECONDS__") . "'" #e.g. '20100131000000' 2010-01-31 00:00:00 #CurDate(), CurTime, Now() } catch (Exception $e) { //ignore } return $return; } catch (Exception $e) { print "Exeception {$e}\n"; return null; } }
function urls_amigables($url, $tabla) { require 'config.php'; global $db; //Rememplazamos caracteres especiales latinos $find = array('�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', 'á', 'é', '�*', 'ó', 'ú', 'ñ', '�', 'É', 'Í', '�"', 'Ú', '�\''); $repl = array('a', 'e', 'i', 'o', 'u', 'n', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u', 'n', 'a', 'e', 'i', 'o', 'u', 'n'); $url = str_replace($find, $repl, $url); // Tranformamos todo a minusculas $url = strtolower_utf8($url); // A�adimos los guiones $find = array(' ', '&', '\\r\\n', '\\n', '+', '%', '#', '.', ',', '"', '\'', '!', '�', '?', '�', '�', '/', '$', '*', '_', ':', ';', '{', '}', '[', ']'); $url = str_replace($find, '-', $url); // Eliminamos y Reemplazamos dem�s caracteres especiales $find = array('/[^a-z0-9\\-<>]/', '/[\\-]+/', '/<[^>]*>/'); $repl = array('', '-', ''); $url = preg_replace($find, $repl, $url); // Verificamos que la url amigale no exista $sw = true; $isw = 0; while ($sw) { $isw++; $row = $db->select(getRow, $tabla, array('where' => 'url_amigable="' . $url . '"', 'order' => 'url_amigable')); if (count($row) == 0) { $sw = false; } else { $url = $isw . '_' . $url; } } // Retornamos la url amigable return $url; }
/** * Rerurns corp id by name part * * @param string $searchterm * * @return int */ protected function searchCorpIdbyName($searchterm) { $result = ''; if (!empty($this->corps)) { if (!empty($searchterm)) { $searchterm = strtolower_utf8($searchterm); foreach ($this->corps as $io => $each) { if (ispos(strtolower_utf8($each['corpname']), $searchterm)) { $result = $io; } } } } return $result; }
/** * Performs login search by partial address * * @global object $ubillingConfig * @param string $query * @return array */ function zb_UserSearchAddressPartial($query) { global $ubillingConfig; $altercfg = $ubillingConfig->getAlter(); $query = mysql_real_escape_string($query); if (!$altercfg['SEARCHADDR_AUTOCOMPLETE']) { $query = strtolower_utf8($query); } $alluseraddress = zb_AddressGetFulladdresslist(); $result = array(); if (!empty($alluseraddress)) { if (!$altercfg['SEARCHADDR_AUTOCOMPLETE']) { foreach ($alluseraddress as $login => $address) { if (ispos(strtolower_utf8($address), $query)) { $result[] = $login; } } } else { foreach ($alluseraddress as $login => $address) { if (ispos($address, $query)) { $result[] = $login; } } } } return $result; }
/** * detects user login by its address * * @param string $address address to guess * * @return string */ public function getLogin($address) { if (!$this->caseSensitive) { $address = strtolower_utf8($address); } if (isset($this->alladdress[$address])) { return $this->alladdress[$address]; } else { return false; } }
/** * Do the search in dead switches time machine * * @param string $query * @return string */ function ub_SwitchesTimeMachineSearch($request) { $request = strtolower_utf8($request); $result = ''; $query = "SELECT * from `switchdeadlog` ORDER BY `id` DESC"; $raw = simple_queryall($query); $deadcount = 0; $tmpArr = array(); if (!empty($raw)) { foreach ($raw as $io => $each) { if (!empty($each)) { $switchData = unserialize($each['swdead']); foreach ($switchData as $switchIp => $switchLocation) { if (ispos(strtolower_utf8($switchIp), $request) or ispos(strtolower_utf8($switchLocation), $request)) { $searchId = zb_rand_string(8); $tmpArr[$searchId]['date'] = $each['date']; $tmpArr[$searchId]['ip'] = $switchIp; $tmpArr[$searchId]['location'] = $switchLocation; } } } } } if (!empty($tmpArr)) { $cells = wf_TableCell(__('Date')); $cells .= wf_TableCell(__('IP')); $cells .= wf_TableCell(__('Location')); $rows = wf_TableRow($cells, 'row1'); foreach ($tmpArr as $ia => $eachResult) { $cells = wf_TableCell($eachResult['date']); $cells .= wf_TableCell($eachResult['ip']); $cells .= wf_TableCell($eachResult['location']); $rows .= wf_TableRow($cells, 'row3'); $deadcount++; } $result = wf_TableBody($rows, '100%', 0, 'sortable'); $result .= __('Total') . ': ' . $deadcount; } else { $result = __('Nothing found'); } return $result; }
//Suche $sstring = trim(Joom_mosGetParam('sstring', '', 'post')); if ($sstring == '') { $sstring = trim(Joom_mosGetParam('sstring', '')); } function strtolower_utf8($inputstring) { $outputString = utf8_decode($inputstring); $outputString = strtolower($outputString); $outputString = utf8_encode($outputString); return $outputString; } switch ($sorting) { case 'find': $searchstring = trim(strtolower_utf8($sstring)); $searchstring2 = htmlentities(trim(strtolower_utf8($sstring)), ENT_QUOTES, 'UTF-8'); $query1 = " SELECT \n a.*,\n a.owner AS owner,\n u.username, \n ca.name AS name\n FROM \n #__joomgallery AS a, \n #__joomgallery_catg AS ca, \n #__users AS u\n WHERE \n a.catid = ca.cid \n AND a.owner = u.id \n AND (u.username LIKE '%{$searchstring}%'\n OR a.imgtitle LIKE '%{$searchstring}%'\n OR a.imgtext LIKE '%{$searchstring2}%')\n AND a.published = '1' \n AND ca.published = '1' \n AND a.approved = '1' \n AND ca.access <= " . $user->get('aid') . "\n GROUP BY \n a.id\n ORDER BY \n a.id DESC \n "; $tl_title = JText::_('JGS_SEARCH_RESULTS') . "<b> {$sstring}</b>"; break; case 'lastcomment': $query1 = " SELECT \n a.*, \n cc.*, \n ca.*, \n u.username, \n a.owner AS owner \n FROM \n #__joomgallery AS a, \n #__joomgallery_catg AS ca, \n #__joomgallery_comments AS cc \n LEFT JOIN \n #__users AS u on cc.userid = u.id\n WHERE \n a.id = cc.cmtpic \n AND a.catid = ca.cid \n AND a.published = '1' \n AND a.approved = '1' \n AND cc.published = '1' \n AND ca.published = '1' \n AND cc.approved = '1' \n AND ca.access <= " . $user->get('aid') . "\n ORDER BY \n cc.cmtdate DESC \n LIMIT " . $config->jg_toplist; $tl_title = JText::_('JGS_TOP') . ' ' . $config->jg_toplist . ' ' . JText::_('JGS_LAST_COMMENTED_PICTURE'); break; case 'lastadd': $query1 = " SELECT \n *, \n a.owner AS owner\n FROM \n #__joomgallery As a, \n #__joomgallery_catg AS ca\n WHERE \n a.catid = ca.cid \n AND a.published = '1' \n AND a.approved = '1' \n AND ca.published = '1' \n AND ca.access <= " . $user->get('aid') . "\n ORDER BY \n a.id DESC \n LIMIT " . $config->jg_toplist; $tl_title = JText::_('JGS_TOP') . ' ' . $config->jg_toplist . ' ' . JText::_('JGS_LAST_ADDED_PICTURE'); break; case 'rating': $query1 = " SELECT \n *, \n a.owner AS owner, \n ROUND(imgvotesum/imgvotes, 2) AS rating\n FROM \n #__joomgallery AS a, \n #__joomgallery_catg AS ca\n WHERE \n a.catid = ca.cid \n AND a.imgvotes > '0' \n AND a.published = '1' \n AND a.approved = '1' \n AND ca.published = '1' \n AND ca.access <= " . $user->get('aid') . "\n ORDER BY \n rating DESC,\n imgvotesum DESC \n LIMIT " . $config->jg_toplist; $tl_title = JText::_('JGS_TOP') . ' ' . $config->jg_toplist . ' ' . JText::_('JGS_BEST_RATED_PICTURE'); break;
function getKurs($stock, $date) { global $stocks; $instrument = null; if (isset($stocks[$stock])) { $instrument = $stocks[$stock]; } else { foreach ($stocks as $key => $value) { if (stripos(strtolower_utf8($key), $stock) !== false) { $instrument = $value; $stocks[$stock] = $value; break; } //print_r($key . " => " . $value . "<br />"); } } if ($instrument == null) { throw new Exception("Hittade inte instrument"); } return getKursFromNASDAQ($instrument, $date); }
function getRec($newsurl, $debug = false) { global $analyshus; global $companys; if (substr($newsurl, 0, 5) != "http:") { $newsurl = "http://di.se" . $newsurl; } $html = scraperWiki::scrape($newsurl); $dom = new simple_html_dom(); $dom->load($html); $arr = array(); // bolag $rub_el = $dom->find("h1", 0); if (is_null($rub_el)) { throw new Exception("Hittade inte rubrikelementet " . $newsurl); } $rub = preg_replace("/[\n\r]/", "", getPlaintext($rub_el)); $i = 0; if (preg_match("/([\\wåäöÅÄÖ& ]+)\\s*:\\s*(.+)/i", $rub, $matches)) { $stock = strtolower_utf8(trim($matches[1])); $hus = trim($matches[2]); array_push($arr, array("stock" => $stock, "rek" => "", "to" => -1, "by" => "", "rub" => $rub, "url" => $newsurl, "text" => "", "date" => "", "currency" => "")); foreach ($analyshus as $key => $value) { if (stripos($hus, $key) > -1) { $arr[0]["by"] = $value; break; } } //print_r($arr[0]["by"] . ", l:" . count(trim($arr[0]["by"]))); if (strlen($arr[0]["by"]) == 0) { throw new Exception("'{$hus}' är inte en mäklare, rub: " . $rub . " " . $newsurl); } } else { throw new Exception("Ingen matchande rubrik hittades: " . $newsurl . " " . getPlaintext($dom->find("#articleBody", 0))); } if ($arr[0]["by"] == "") { throw new Exception("Hittade inte mäklare: " . $rub); } // kolla om bolaget finns // först kollas om nyckeln finns i arrayen, sen om ej fanns så söks arrayen igenom och om strängen finns i början av nyckel $stockname = null; if (array_key_exists(strtolower($stock), $companys)) { $stockname = $companys[strtolower($stock)]; } if (is_null($stockname)) { $stockname = getitem_array_in_string($companys, strtolower($stock)); } if (is_null($stockname)) { $stockname = getitem_array_in_string($companys, str_replace(" ", "", strtolower($stock))); } if (is_null($stockname)) { throw new Exception("{$stock} är inte en aktie " . $newsurl); } $arr[0]["stock"] = $stockname; // datum $datebox = $dom->find("#phArticle .date", 0); if (!is_null($datebox)) { $arr[0]["date"] = trim(str_replace("Uppdaterad ", "", getPlaintext($datebox))); } if ($arr[0]["date"] == "") { throw new Exception("Inget datum " . $newsurl); } // riktkurs $to = -1; $intro = $dom->find("#articleIntro", 0); $arttext = $dom->find("#articleBody", 0); $text = ""; if (!is_null($intro) && strlen(getPlaintext($intro)) > 0) { $text = getPlaintext($intro) . utf8_encode(". "); } if (!is_null($arttext)) { $text = $text . getPlaintext($arttext); } array_merge($arr[0], getRiktkursAndCurrency($text)); //$text = iconv("UTF-8","UTF-8//IGNORE",$text); $arr[0]["text"] = preg_replace("/[\n\r]/", "", $text); //preg_replace('/[^(\x20-\xFF)]*/','', $text); $rek = ""; // rekommendation $rekindex = iarray_in_string(array("rekommendation", "höjer", "sänker"), $text); if ($rekindex > -1) { $words = explode(" ", strtolower(preg_replace("/[!\\.,]/", "", substr($text, $rekindex)))); $starkt = false; for ($i = 0; $i < count($words); $i++) { switch ($words[$i]) { case "starkt": $starkt = true; case "köp": case "övervikt": case "öka": case "köprekommendation": case "outperform": $rek = "+"; break; case "buy": $rek = "+"; if ($i > 0 && strtolower($words[$i - 1]) == "conviction") { $rek = "++"; } break; case "perform": if ($i > 0 && strtolower($words[$i - 1]) == "sector") { $rek = "-"; } case "minska": case "undervikt": case "sälj": case "säljrekommendation": case "underperform": $rek = "-"; break; case "neutral": case "jämvikt": case "behåll": case "behållrekommendation": $rek = "0"; break; } //print $words[$i] . " => " . $rek; if (strlen($rek) > 0) { if ($rek != "0" && $starkt) { $rek = $rek . $rek; } // else nått konstigt om else inträffar här break; } } if (strlen($rek) > 0) { $arr[0]["rek"] = $rek; } } if ($rek == "") { if (stripos($text, "köprekommendation") > -1) { $rek = "+"; } if (iarray_in_string(array("säljrekommendation", "säljlista"), $text) > -1) { $rek = "-"; } if (stripos($text, "behållrekommendation") > -1) { $rek = "0"; } if (strlen($rek) > 0) { $arr[0]["rek"] = $rek; } } if ($debug) { print_r($arr[0]); } return $arr; }