<?php if (isset($_GET['ajax'])) { $candidates = $DB->GetAll("SELECT " . $DB->Concat('m.name', '" "', 'p.name') . " AS name, p.id, p.ean, p.quantity\n\t\t\tFROM stck_products p\n\t\t\tLEFT JOIN stck_manufacturers m ON p.manufacturerid = m.id\n\t\t\tWHERE " . (preg_match('/^[0-9]+$/', $search) ? 'p.id = ' . intval($search) . ' OR ' : '') . "\n\t\t\t\tLOWER(" . $DB->Concat('m.name', "' '", 'p.name') . ") ?LIKE? LOWER({$sql_search})\n\t\t\t\tOR LOWER(p.ean) ?LIKE? LOWER({$sql_search})\n\t\t\t\tORDER by name, id\n\t\t\t\tLIMIT 15"); $eglible = array(); $actions = array(); $descriptions = array(); if ($candidates) { foreach ($candidates as $idx => $row) { $actions[$row['id']] = 'javascript:pad(\'' . $row['id'] . '\')'; $eglible[$row['id']] = escape_js(($row['deleted'] ? '<font class="blend">' : '') . truncate_str($row['name'], 150) . ($row['deleted'] ? '</font>' : '')); if (preg_match("~^{$search}\$~i", $row['id'])) { $descriptions[$row['id']] = escape_js(trans('Id:') . ' ' . $row['id']); continue; } if (preg_match("~{$search}~i", $row['name'])) { $descriptions[$row['id']] = ''; continue; } if (preg_match("~{$search}~i", $row['ean'])) { $descriptions[$row['id']] = escape_js(trans('EAN:') . ' ' . $row['ean']); continue; } $descriptions[$row['id']] = ''; } } header('Content-type: text/plain'); if ($eglible) { print "this.eligible = [\"" . implode('","', $eglible) . "\"];\n"; print "this.descriptions = [\"" . implode('","', $descriptions) . "\"];\n"; print "this.actions = [\"" . implode('","', $actions) . "\"];\n";
case DOC_INVOICE: $actions[$row['id']] = '?m=invoice&id=' . $row['id']; break; case DOC_RECEIPT: $actions[$row['id']] = '?m=receipt&id=' . $row['id']; break; case DOC_CNOTE: $actions[$row['id']] = '?m=note&id=' . $row['id']; break; default: $actions[$row['id']] = '?m=documentview&id=' . $row['id']; } */ $actions[$row['id']] = '?m=customerinfo&id=' . $row['cid']; $eglible[$row['id']] = escape_js($row['fullnumber']); $descriptions[$row['id']] = escape_js(truncate_str($row['customername'], 35)); //$descriptions[$row['id']] = trans('Document id:') . ' ' . $row['id']; } header('Content-type: text/plain'); if ($eglible) { print "this.eligible = [\"".implode('","',$eglible)."\"];\n"; print "this.descriptions = [\"".implode('","',$descriptions)."\"];\n"; print "this.actions = [\"".implode('","',$actions)."\"];\n"; } else { print "false;\n"; } $SESSION->close(); $DB->Destroy(); exit; }
FROM customersview WHERE ".(preg_match('/^[0-9]+$/', $search) ? 'id = '.intval($search).' OR ' : '')." LOWER(".$DB->Concat('lastname',"' '",'name').") ?LIKE? LOWER($sql_search) OR LOWER(address) ?LIKE? LOWER($sql_search) OR LOWER(post_name) ?LIKE? LOWER($sql_search) OR LOWER(post_address) ?LIKE? LOWER($sql_search) OR LOWER(email) ?LIKE? LOWER($sql_search) ORDER by deleted, username, email, address LIMIT 15"); $eglible=array(); $actions=array(); $descriptions=array(); if ($candidates) foreach($candidates as $idx => $row) { $actions[$row['id']] = '?m=customerinfo&id='.$row['id']; $eglible[$row['id']] = escape_js(($row['deleted'] ? '<font class="blend">' : '') .truncate_str($row['username'], 50).($row['deleted'] ? '</font>' : '')); if (preg_match("~^$search\$~i",$row['id'])) { $descriptions[$row['id']] = escape_js(trans('Id:').' '.$row['id']); continue; } if (preg_match("~$search~i",$row['username'])) { $descriptions[$row['id']] = ''; continue; } if (preg_match("~$search~i",$row['address'])) { $descriptions[$row['id']] = escape_js(trans('Address:').' '.$row['address']); continue; } else if (preg_match("~$search~i",$row['post_name'])) { $descriptions[$row['id']] = escape_js(trans('Name:').' '.$row['post_name']);
?> <br /> <?php echo $row["sec_desc"]; ?> <br /> <!-- <a href = 'index.php?module=icd9&func=view&browse=1&q=<!--[$code.sec_range]-->' title='<!--[$code.sec]-->' >search for all codes in this category</a>--> </div> </td> </tr> <tr valign="top"> <td>Sub-category:</td> <td> <?php echo truncate_str($row["cat"], 50); ?> <a href="javascript:toggleHiddenDiv('icd9_cat<?php echo $row["cat_id"]; ?> ');" style="padding: 3px;" title="<?php echo $row["cat"]; ?> ">(description)</a> <div class="tmz_tan" style=" display: none;" id="icd9_cat<?php echo $row["cat_id"]; ?> "> <?php echo $cat_range;
function rss_parsing_rss($nb) { $rss_tab = array(); $date_tab = array(); $flux = array(); $images = array(); $images_def = array(); $ids = array(); $args = array('exclude' => array(), 'orderby' => 'login', 'order' => 'ASC', 'fields' => 'all'); $users = get_users($args); foreach ($users as $usr) { $uid = $usr->ID; if (get_user_meta($uid, "rss_active", true) == "1") { //Admin enable this RSS $rss = get_user_meta($uid, "rss_address", true); if (!empty($rss)) { $flux[] = stripslashes($rss); $images[] = 1; $images_def[] = get_simple_local_avatar($uid, '96', '', false, true); $ids[] = $uid; } } } $html = ""; $n = 1; for ($j = 0; $j < sizeof($flux); $j++) { $error = 0; $rss_web = dirname(__FILE__) . "/cron/xml_v2/rss-" . $ids[$j] . ".xml"; if (!file_exists($rss_web)) { $error = 1; } else { if (!@($fluxrss = simplexml_load_file($rss_web, 'SimpleXMLElement', LIBXML_NOCDATA))) { $error = 1; } if (@file_get_contents($rss_web) == "") { $error = 1; } } if (empty($fluxrss->channel->title) || empty($fluxrss->channel->item->title)) { $error = 1; } if ($error == 0) { $i = 0; $rss_item = array(); foreach ($fluxrss->channel->item as $item) { $i++; if ($i <= $nb) { $rss_item = array(); $rss_item['blog_title'] = '' . $fluxrss->channel->title; $rss_item['blog_link'] = '' . $fluxrss->channel->link; $rss_item['title'] = '' . $item->title; $rss_item['link'] = '' . $item->link; $rss_item['description'] = '' . truncate_str(strip_tags('' . $item->description), 0, 300, $item->link); $rss_item['date'] = date(get_option('date_format'), strtotime($item->pubDate)); $rss_item['pub_date'] = '' . $item->pubDate . ' +0000'; //enclosure ! if ('' . $item->enclosure[0]['url'] != '') { $rss_item['enclosure'] = '' . $item->enclosure[0]['url']; } else { $rss_item['enclosure'] = $images_def[$j]; } $rss_tab[] = $rss_item; $index = sizeof($rss_tab) - 1; $date_tab[strtotime($item->pubDate)] = $index; } } } } krsort($date_tab); //GO TO FLUX RSS $page = get_page_by_path('blogs-de-runners'); $page_link = get_page_link($page->ID); $page_title = $page->post_title; $html .= '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" >'; $html .= '<channel>'; $html .= '<title>' . get_bloginfo('title') . ' - ' . $page_title . '</title>'; $html .= '<atom:link href="' . get_bloginfo('url') . '/runners-rss/' . '" rel="self" type="application/rss+xml" />'; $html .= '<link>' . $page_link . '</link>'; $html .= '<description>Le flux RSS des blogs de la runnosphère</description>'; $html .= '<lastBuildDate>' . date("D, d M Y H:i:s") . ' +0000</lastBuildDate>'; $html .= '<language>fr</language>'; $html .= '<sy:updatePeriod>hourly</sy:updatePeriod> '; $html .= '<sy:updateFrequency>1</sy:updateFrequency>'; $html .= ''; $html .= ''; foreach ($date_tab as $d => $id) { $my_item = $rss_tab[$id]; $html .= '<item>'; $html .= '<title><![CDATA[' . $my_item['blog_title'] . ' - ' . str_replace("&", "&", $my_item['title']) . ']]></title>'; $html .= '<link>' . str_replace("&", "&", $my_item['link']) . '</link>'; $html .= '<guid isPermaLink="true">' . str_replace("&", "&", $my_item['link']) . '</guid>'; $html .= '<description><![CDATA[' . $my_item['description'] . ']]></description>'; $date_base = $my_item['pub_date']; $new = date("D, d M Y H:i:s", strtotime($date_base)) . ' +0000'; $html .= '<pubDate>' . $new . '</pubDate>'; //Enclosure if ($my_item['enclosure'] != '') { $t = explode(".", $my_item['enclosure']); $ext = $t[sizeof($t) - 1]; if ($ext == 'jpg') { $ext = "jpeg"; } //TODO : Length for image $html .= '<enclosure url="' . str_replace("https", "http", $my_item['enclosure']) . '" type="image/' . $ext . '"></enclosure>'; } $html .= '</item>'; $n++; } $html .= '</channel></rss>'; return $html; }
<?php function truncate_str($str, $maxchars, $truncated_by = '') { $str = trim($str); if (strlen($str) > $maxchars) { $endpos = strrpos($str, ' ', (strlen($str) - ($maxchars - strlen($truncated_by))) * -1); $str = substr($str, 0, $endpos) . $truncated_by; } return $str; } $str = 'abc def ghi jkl mno pqr stu vwx yz'; echo truncate_str($str, 11); echo PHP_EOL; echo truncate_str($str, 11, '...');