function array_sort($array, $direction = "asc", $key = false) { global $_josh; $_josh["sort_key"] = $key ? $key : array_shift(array_keys($array[0])); error_debug("<b>arraySort</b> running for {$key}"); usort($array, "arrayKeyCompare" . format_title($direction)); return $array; }
function email_address_parse($address) { //eg josh@Joshreisner.com or Joshua Reisner <*****@*****.**> or Reisner, Joshua <*****@*****.**> $address = str_replace('"', "", strtolower($address)); //address has name or it doesn't if (stristr($address, "<")) { list($from, $email) = explode("<", str_replace(">", "", $address)); //name is possibly reversed if (stristr($from, ",")) { $from = implode(" ", array_reverse(array_map("trim", explode(",", $from)))); } } else { $email = $address; $from = substr($email, 0, strpos($email, "@")); } return array(trim($email), format_title(trim($from))); }
function index() { var_dump(format_title("Inona izao no mety Hasehon'ity?")); }
$ano = get_ano_proyecto($post->ID); $permalink = get_permalink($post->ID); $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); ?> <a class="[ full-height ][ block ][ relative ]" href="<?php echo $permalink; ?> "> <article class="[ column xmall-12 medium-6 large-4 ][ card ][ color-light ][ relative ][ margin-bottom ]"> <img class="[ card__image ][ center-full ]" src="<?php echo $image[0]; ?> " alt=""> <div class="[ card__info ][ xmall-12 ][ z-index-1 ]"> <h3 class="[ no-margin ]"><?php echo format_title(get_the_title()); ?> </h3> <p class="[ text-thin ]"><?php echo $lugar . '. ' . $ano; ?> </p> </div> </article> </a> <?php } ?> <div class="[ column xmall-12 ][ text-center ]"> <a href="<?php echo site_url('archivo');
function save() { $this->user->check_level($this->template['module'], LEVEL_ADD); $fields = array('id', 'cat', 'title', 'body', 'status', 'allow_comments', 'lang', 'notify'); $data = array(); foreach ($fields as $field) { $data[$field] = $this->input->post($field); } if ($date = $this->input->post('date')) { $day = substr($date, 0, 2); $month = substr($date, 3, 2); $year = substr($date, 6, 4); $data['date'] = mktime(date("H"), date("i"), date("s"), $month, $day, $year); } else { $data['date'] = mktime(); } // if uri is provided if ($this->input->post('uri')) { $data['uri'] = $this->input->post('uri'); } else { $data['uri'] = $this->news->generate_uri($this->input->post('title')); } if ($id = $this->input->post('id')) { //fixing missing uri /* $news = $this->news->get_news(array('news.id' => $id)); if (!$news['uri']) ($data['uri'] = $this->news->generate_uri($this->input->post('title'))); */ $this->user->check_level($this->template['module'], LEVEL_EDIT); //update $this->db->where('id', $id); $this->db->update('news', $data); } else { $this->user->check_level($this->template['module'], LEVEL_ADD); $data['author'] = $this->user->username; $data['email'] = $this->user->email; $this->db->insert('news', $data); $id = $this->db->insert_id(); //insert } //tags if ($this->input->post('id')) { $this->db->delete('news_tags', array('news_id' => $id)); } if ($tags = $this->input->post('tags')) { foreach ($tags as $tag) { if ($tag) { $datatag = array('news_id' => $id, 'tag' => $tag, 'uri' => format_title($tag)); $this->db->insert('news_tags', $datatag); } } } $this->cache->remove_group('news_list'); return $id; }
function cn_social_icon() { $cnss_width = get_option('cnss-width'); $cnss_height = get_option('cnss-height'); $cnss_margin = get_option('cnss-margin'); $cnss_rows = get_option('cnss-row-count'); $vorh = get_option('cnss-vertical-horizontal'); $text_align = get_option('cnss-text-align'); global $wpdb, $baseURL; $table_name = $wpdb->prefix . "cn_social_icon"; $image_file_path = $baseURL; $sql = "SELECT * FROM " . $table_name . " WHERE image_url<>'' AND url<>'' ORDER BY sortorder"; $video_info = $wpdb->get_results($sql); $icon_count = count($video_info); $_collectionSize = count($video_info); $_rowCount = $cnss_rows ? $cnss_rows : 1; $_columnCount = ceil($_collectionSize / $_rowCount); $li_margin = round($cnss_margin / 2); ob_start(); echo '<ul class="cnss-social-icon" style="text-align:' . $text_align . ';">'; $i = 0; foreach ($video_info as $icon) { if (strpos($icon->image_url, '/') === false) { $image_url = $image_file_path . '/' . $icon->image_url; } else { $image_url = $icon->image_url; } ?> <li class="<?php echo format_title($icon->title); ?> " style=" <?php echo $vorh == 'horizontal' ? 'display:inline-block;' : ''; ?> "><a <?php echo $icon->target == 1 ? 'target="_blank"' : ''; ?> title="<?php echo $icon->title; ?> " href="<?php echo $icon->url; ?> "><img src="<?php echo $image_url; ?> " border="0" width="<?php echo $cnss_width; ?> " height="<?php echo $cnss_height; ?> " alt="<?php echo $icon->title; ?> " style=" <?php echo 'margin:' . $li_margin . 'px;'; ?> " /></a></li><?php $i++; } echo '</ul>'; $out = ob_get_contents(); ob_end_clean(); return $out; }
$inheaders = 0; if (isset($headers['content-type'])) { if (preg_match('/charset=(["\']?)([\\w-]+)\\1/i', $headers['content-type'], $m)) { $charset = trim($m[2]); } if (preg_match('/boundary=(["\']?)(.+)\\1/is', $headers['content-type'], $m)) { $boundaries[] = trim($m[2]); $boundary = end($boundaries); } if (preg_match("/([^;]+)(;|\$)/", $headers['content-type'], $m)) { $mimetype = trim(strtolower($m[1])); ++$mimecount; } } if (!$started) { head("{$group}: " . format_title($headers['subject'], $charset)); start_article($group, $masterheaders, $charset); $started = 1; } $encoding = strtolower(trim(@$headers['content-transfer-encoding'])); if (strlen($mimetype) && $mimetype != "text/plain" && substr($mimetype, 0, 10) != "multipart/") { # Display a link to the attachment $name = ''; if ($headers['content-type'] && preg_match('/name=(["\']?)(.+)\\1/s', $headers['content-type'], $m)) { $name = trim($m[2]); } else { if ($headers['content-disposition'] && preg_match('/filename=(["\']?)(.+)\\1/s', $headers['content-type'], $m)) { $name = trim($m[2]); } } if ($headers['content-description']) {
return strip_tags($title); } // Format content accordingly function format_content($content) { // Convert all \n into <br/> for proper content display return str_replace("\n", '<br />', $content); } $post_controller = new PostController($db); // Initialize Post Controller // HTTP Requests if (isset($_POST['add'])) { // Publish a post $post_controller->publish($_SESSION['userid'], format_title($_POST['title']), format_content($_POST['content'])); } if (isset($_GET['delete'])) { // Delete a post $post = $post_controller->search_by_id($_GET['id']); // Ensure that only authors can delete their own posts if ($_SESSION['userid'] == $post['author_id']) { // Authorized $post_controller->delete($post['id']); } else { // Not Authorized header('Location: index.php'); } } if (isset($_POST['update'])) { // Update an existing post $post_controller->update($_POST['id'], format_title($_POST['title']), format_content($_POST['content'])); }
function save() { //data validating to be done $data = array('title' => strip_tags($this->input->post('title')), 'parent_id' => strip_tags($this->input->post('parent_id')), 'meta_keywords' => strip_tags($this->input->post('meta_keywords')), 'meta_description' => strip_tags($this->input->post('meta_description')), 'body' => $this->input->post('body'), 'active' => $this->input->post('status'), 'lang' => $this->input->post('lang'), 'g_id' => $this->input->post('g_id')); if ($this->input->post('options')) { $data['options'] = serialize($this->input->post('options')); } if ($this->input->post('uri') != '') { $data['uri'] = $this->input->post('uri'); } else { $parent_uri = ''; if ($parent_id = $this->input->post('parent_id')) { $parent = $this->pages->get_page(array('id' => $parent_id)); $parent_uri = $parent['uri'] . "/"; } $data['uri'] = $parent_uri . format_title($this->input->post('title')); } if ($id = $this->input->post('id')) { $this->pages->update($id, $data); } else { $data['date'] = mktime(); $id = $this->pages->save($data); } //images if no javascript if ($image_ids = $this->input->post('image_ids')) { foreach ($image_ids as $image_id) { $data = array('src_id' => $id); $this->pages->update_image($image_id, $data); } } $this->cache->remove('pagelist' . $this->user->lang, 'page'); if ($_FILES['image']['name'] != '') { //var_dump($this->input->post('image')); //there is an image attached $config['upload_path'] = './media/images/o/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '2000'; $config['max_width'] = '2058'; $config['max_height'] = '1524'; //var_dump($config['upload_path']); $this->load->library('upload', $config); if (!$this->upload->do_upload('image')) { $error = array('error' => $this->upload->display_errors()); $this->load->view('upload_form', $error); } else { $this->load->library('image_lib'); $image_data = $this->upload->data(); //var_dump($image_data); //resize to 150 $config['source_image'] = $image_data['full_path']; $config['new_image'] = './media/images/s/'; $config['width'] = 150; $config['height'] = 100; $config['maintain_ratio'] = true; $config['master_dim'] = 'width'; $config['create_thumb'] = FALSE; $this->image_lib->initialize($config); if ($this->image_lib->resize()) { $config['source_image'] = $image_data['full_path']; $config['new_image'] = './media/images/m/'; $config['width'] = 300; $config['height'] = 200; $config['maintain_ratio'] = TRUE; $config['master_dim'] = 'width'; $config['create_thumb'] = FALSE; $this->image_lib->initialize($config); $this->image_lib->resize(); $this->pages->attach($id, $image_data); } } } /* //group access if($this->input->post('groups')) { $groups = $this->input->post('groups'); $this->pages->set_group($id, $groups); } */ $this->plugin->do_action('page_save', $id); $this->session->set_flashdata('notification', 'Page "' . $this->input->post("title") . '" has been created, continue editing here'); redirect('admin/page/index/' . $this->input->post('parent_id')); }
$refsResolved = []; $refCount = 0; foreach ($references as $messageId) { if (!$messageId) { continue; } if ($refCount >= REFERENCES_LIMIT) { break; } $refsResolved[] = $nntpClient->xpath($messageId); $refCount++; } } catch (Exception $e) { error($e->getMessage()); } head("{$group}: " . format_title($mail['headers']['subject'], 'utf-8')); start_article($mail, $refsResolved); $lines = preg_split("@(?<=\r\n|\n)@", $mail['text']); $insig = 0; foreach ($lines as $line) { # fix lines that started with a period and got escaped if (substr($line, 0, 2) == "..") { $line = substr($line, 1); } # this is some amazingly simplistic code to color quotes/signatures # differently, and turn links into real links. it actually appears # to work fairly well, but could easily be made more sophistimicated. /* NOQUOTES? Why? It creates invalid HTML: http:"x */ $line = htmlentities($line, ENT_QUOTES, "utf-8"); $line = preg_replace("/((mailto|https?|ftp|nntp|news):.+?)(>|\\s|\\)|\\.\\s|\$)/", "<a href=\"\\1\">\\1</a>\\3", $line); if (!$insig && ($line == "-- \r\n" || $line == "--\r\n")) {
$book_data = $lookup_data->BookList->BookData; $book_attributes = $book_data->attributes(); $book_details = $book_data->Details->attributes(); $subjects = $book_data->Subjects->Subject; $dewey_guess = ""; if ($book_details->dewey_decimal_normalized != "") { $dewey_guess = preg_replace("/\\..*/", "", $book_details->dewey_decimal_normalized); } else { if ($book_details->dewey_decimal_normalized != "") { $dewey_guess = preg_replace("/\\..*/", "", $book_details->dewey_decimal); } // end if } // end if $_POST['title'] = format_title($book_data->Title); $_POST['parallel_title'] = format_title(preg_replace("/^" . preg_quote($book_data->Title) . "(:\\s|:|)/", "", $book_data->TitleLong)); $_POST['summary'] = $book_data->Summary; $_POST['summary'] = preg_replace("/’/", "'", $_POST['summary']); $_POST['type_ID'] = $db->ID_type_book; $_POST['location_ID'] = $db->ID_location_main; $_POST['height'] = trim(preg_replace("/(.*)(\\b\\d+?\\s*)(cm\\b)(.*)/", "\\2", $book_details->physical_description_text)); if (trim(strtolower($_POST['height'])) == trim(strtolower($book_details->physical_description_text))) { $_POST['height'] = ""; } // end if $_POST['length'] = trim(preg_replace("/(.*)(\\b\\d+?\\s*)((pages|pgs|pg|p)\\b)(.*)/", "\\2", $book_details->physical_description_text)); if (trim(strtolower($_POST['length'])) == trim(strtolower($book_details->physical_description_text))) { $_POST['length'] = ""; } // end if $_POST['isbn'] = $book_attributes->isbn;
function format_text_human($str, $convertdashes = true) { $return = str_replace("_", " ", strtolower($str)); if ($convertdashes) { $return = str_replace("-", " ", $return); } return format_title($return); }
$dir = dirname(__FILE__); $defaultIcon = 'icon.png'; $lang2Icon = file_exists($dir . "/{$lang2}.png") ? "{$lang2}.png" : $defaultIcon; // where translations are stored in the JSON $translationPositions = array(array('term0', 'PrincipalTranslations'), array('term0', 'Entries'), array('term0', 'AdditionalTranslations'), array('original', 'Compounds')); $uidPrefix = "wordref-{$langs}-{$query}-"; $uidIndex = 0; // for each position check if present and call the walker foreach ($translationPositions as $pos) { if (isset($translations->{$pos[0]}->{$pos[1]})) { foreach ($translations->{$pos[0]}->{$pos[1]} as $translation) { $orig = $translation->OriginalTerm; $note = $translation->Note; unset($translation->OriginalTerm, $translation->Note); foreach ($translation as $trkey => $tr) { $arg = serialize(array($langs, $orig->term, $tr->term)); $title = format_title($tr->term, $tr->POS, $tr->sense); $subtitle = format_title($orig->term, $orig->POS, $orig->sense, $note); $w->result($uidPrefix . $uidIndex++, $arg, $title, $subtitle, $lang2Icon, 'yes'); } } } } echo $w->toxml(); function format_title() { $args = func_get_args(); $term = array_shift($args); $details = join(' ,', array_filter($args)); return $term . ($details ? " ({$details})" : ''); }
for ($i = $last_level - $section->level; $i > 0; $i--) { $temp_tabs = str_repeat("\t", ($section->level + $i) * 2); echo $temp_tabs . "\t" . '</li>' . "\n"; echo $temp_tabs . '</ul>' . "\n"; } } if ($section->level > $last_level) { echo $tabs . '<ul class="statuslist level-' . $section->level . '">' . "\n"; } else { echo $tabs . "\t" . '</li>' . "\n"; } echo $tabs . "\t" . '<li class="state-' . htmlspecialchars($section->state) . '"><!-- level ' . $section->level . ' -->' . "\n"; $statePercent = calculateStatePercent($section->state, $counter); $statePercent = round($statePercent, 0); echo $tabs . "\t\t" . '<div class="progressbar ui-progressbar ui-widget ui-widget-content ui-corner-all" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="80"><div class="ui-progressbar-value ui-widget-header ui-corner-left" style="width:' . $statePercent . '%;">' . ($statePercent > 0 ? $statePercent . '%' : '') . '</div></div>' . "\n"; echo $tabs . "\t\t" . '<span title="Weight: ' . $section->weight . '">' . format_title($section->title) . '</span>' . "\n"; echo $tabs . "\t\t" . '<div style="clear:both"></div>' . "\n"; if ($section->level == $top_level && $section->weight > 0) { $numPercentTopLevelItems += $section->weight; $sumPercentTopLevelItems += $statePercent * $section->weight; } $last_level = $section->level; $counter++; } $average = round($sumPercentTopLevelItems / $numPercentTopLevelItems, 1); $buffer = ob_get_clean(); echo '<div id="mainprogressbar" class="progressbar ui-progressbar ui-widget ui-widget-content ui-corner-all" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="' . $average . '"><div class="ui-progressbar-value ui-widget-header ui-corner-left" style="width:' . $average . '%;">' . ($average > 0 ? $average . '%' : '') . '</div></div>' . "\n"; echo $buffer; function format_title($title) { static $replace;
function process_title($destination_title) { $title = format_title($destination_title); if ($wiki_path = get_wiki_text($title)) { $continue_with_clean = true; if ($continue_with_clean) { $str = file_get_contents($wiki_path); // $str = remove_others($str); // $str = remove_top_portion($str); if (are_there_comments($str)) { echo "\nthere are comments\n"; $comments = get_comments($str); } else { echo "\nthere are NO comments\n"; $comments = ""; } $adjusted_str = adjust_bottom_portion($str, $title); //$title here is just for echo if ($adjusted_str != $str) { if (stripos($adjusted_str, '</span> Comments===') !== false) { } elseif (stripos($adjusted_str, '</span> Comment===') !== false) { } else { $adjusted_str .= $comments; } save_adjustments_to_wiki($adjusted_str, $title); //start saving... } } else { echo "\nwiki not found...ERROR 1 \n"; } } else { echo "\nwiki not found...ERROR 2 \n"; } }
foreach ($set as $CRN) { if ($CRN > 100) { $valid_crn++; } // echo "</br>CRN: ".$CRN; $printCRN .= $CRN . ","; $query = "SELECT a.course_CRN, b.title, a.day, a.start, a.end, a.instructor, a.location FROM `class_" . $table . "` a, `course_" . $table . "` b WHERE a.course_CRN = b.CRN AND a.course_CRN={$CRN}"; $result = $db->query($query); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $class_length = strtotime(test($row['end'])) - strtotime(test($row['start'])); // echo 'Class Length ['.$row['course_CRN'].']:'.gmdate('H:i', $class_length).' : '.($class_length).'<br>'; if ($class_length > 3000) { $row['title'] = format_title($row["title"]) . " - " . format_title($row["instructor"]); } else { $row['title'] = format_title($row["title"]); } if ($row["day"] == "M") { $del .= "{id: '" . $row["course_CRN"] . "', title: '" . $row["title"] . "', start: '2016-02-15T" . test($row["start"]) . "', end: '2016-02-15T" . test($row["end"]) . "'}"; } else { if ($row["day"] == "T") { $del .= "{id: '" . $row["course_CRN"] . "', title: '" . $row["title"] . "', start: '2016-02-16T" . test($row["start"]) . "', end: '2016-02-16T" . test($row["end"]) . "'}"; } else { if ($row["day"] == "W") { $del .= "{id: '" . $row["course_CRN"] . "', title: '" . $row["title"] . "', start: '2016-02-17T" . test($row["start"]) . "', end: '2016-02-17T" . test($row["end"]) . "'}"; } else { if ($row["day"] == "R") { $del .= "{id: '" . $row["course_CRN"] . "', title: '" . $row["title"] . "', start: '2016-02-18T" . test($row["start"]) . "', end: '2016-02-18T" . test($row["end"]) . "'}"; } else { if ($row["day"] == "F") { $del .= "{id: '" . $row["course_CRN"] . "', title: '" . $row["title"] . "', start: '2016-02-19T" . test($row["start"]) . "', end: '2016-02-19T" . test($row["end"]) . "'}";
url_change_post("/press-clips/clip.php?id=" . $id); } elseif ($included) { $action = getString('add_new'); $_josh["request"]["path_query"] = "edit.php"; //shoddy way of setting the form target $r["url"] = "http://"; } elseif (url_id()) { $action = getString('edit'); echo drawTop(); $r = db_grab("SELECT id, title, url, publication, pub_date, description, type_id from press_clips WHERE id = " . $_GET["id"]); $r["title"] = format_title($r["title"], "US"); } else { $action = getString('add_new'); echo drawTop(); if (isset($_GET["title"])) { $r["title"] = format_title($_GET["title"], "US"); } if (isset($_GET["url"])) { $r["url"] = $_GET["url"]; $url = url_parse($r["url"]); if ($url["domainname"] == "nytimes") { $r["publication"] = "NY Times"; $r["title"] = str_replace("- Nytimes.com", "", $r["title"]); } elseif ($url["domainname"] == "latimes") { $r["publication"] = "LA Times"; $r["title"] = str_replace(" - Los Angeles Times", "", $r["title"]); } elseif ($url["domainname"] == "washingtonpost") { $r["publication"] = "Washington Post"; //$r["title"] = str_replace("The Associated Press: ", "", $r["title"]); } elseif ($url["domainname"] == "reuters") { $r["publication"] = "Reuters";
/** * Prepare query args for project filters * @param string $permalink * @param string $image * @param string $title * @param string $lugar * @param string $ano */ function get_html_project($permalink, $image, $title, $autor) { ?> <a class="[ full-height ][ block ][ relative ]" href="<?php echo $permalink; ?> "> <article class="[ column xmall-12 medium-6 large-4 ][ card ][ color-light ][ relative ][ margin-bottom ]"> <img class="[ card__image ][ center-full ]" src="<?php echo $image; ?> " alt=""> <div class="[ card__info ][ xmall-1z2 ][ z-index-1 ]"> <h3 class="[ no-margin ]"><?php echo format_title($title); ?> </h3> <p><?php echo $autor; ?> </p> </div> </article> </a> <?php }