static function urlnicify($url, $id = '') { if ('' == $url) { return $url; } $url = trim($url); $url = strip_tags($url); $url = filter_text($url); $temp = explode("/", $url); $url = $temp[count($temp) - 1]; $url = preg_replace('|[^a-z0-9-~+_. #=&;,/:]|i', '', $url); $url = str_replace('/', '', $url); $url = str_replace(' ', '-', $url); $url = str_replace('&', '', $url); $url = str_replace("'", "", $url); $url = str_replace(';//', '://', $url); $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); $url = strtolower($url); //Últims canvis $url = trim(mb_eregi_replace("[^ A-Za-z0-9_-]", "", $url)); $url = mb_eregi_replace("[ \t\n\r]+", "-", $url); $url = mb_eregi_replace("[ -]+", "-", $url); $url = trim($url, '-'); if ($id == '') { return $url; } return $url . "-" . $id; }
function mobile_content_detail() { $_id = func_arg(0) != "" ? func_arg(0) : ""; $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Articles'); $lilo_mongo->selectCollection('ContentPage'); $dt = $lilo_mongo->findOne(array("_id" => $lilo_mongo->mongoid($_id))); $output = array('title' => "No Title", 'text' => "no Text", 'alias' => "no alias", 'document_update' => date("Y-m-d H:i:s"), 'state_document' => ""); if ($dt) { $tgl = ""; if ($dt['document_update'] != "") { $tgl = date('Y-m-d H:i:s', $dt['document_update']->sec); } $title = !isset($dt['title']) ? "" : $dt['title']; $text = !isset($dt['text']) ? "" : $dt['text']; $alias = !isset($dt['alias']) ? "" : $dt['alias']; $state_document = !isset($dt['state_document']) ? "" : $dt['state_document']; $output = array('title' => $title, 'alias' => $alias, 'text' => replace_text_content(filter_text($text)), 'document_update' => $tgl, 'state_document' => $state_document); } return json_encode($output); }
function mobile_stream_news() { $_id = func_arg(0) != "" ? func_arg(0) : ""; $lilo_mongo = new LiloMongo(); $lilo_mongo->selectDB('Articles'); $lilo_mongo->selectCollection('ContentNews'); $dt = $lilo_mongo->findOne(array("_id" => $lilo_mongo->mongoid($_id))); $output = array('title' => "No Title", 'text' => "no Text", 'update' => date("Y-m-d H:i:s"), 'state_document' => ""); if ($dt) { $tgl = ""; if ($dt['update'] != "") { $tgl = date('Y-m-d H:i:s', $dt['update']->sec); } $path_upload = URL_ASSET_IMAGE . "images/"; $title = !isset($dt['title']) ? "" : $dt['title']; $text = !isset($dt['text']) ? "" : $dt['text']; $state_document = !isset($dt['state_document']) ? "" : $dt['state_document']; $picture = !isset($dt['picture']) ? "" : $dt['picture']; $output = array('title' => $title, 'text' => replace_text_content(filter_text($text)), 'update' => $tgl, 'imageName' => $picture, 'pathImage' => $path_upload, 'state_document' => $state_document); } return json_encode($output); }
function sections($config) { global $COURSE, $CFG, $USER, $THEME; // probably inefficient, but it works get_all_mods($COURSE->id, $mods, $modnames, $modnamesplural, $modnamesused); // sections $sections = get_all_sections($COURSE->id); // name for sections $sectionname = get_string("name{$COURSE->format}", "format_{$COURSE->format}"); // TODO: this fallback should be unnecessary if ($sectionname == "[[name{$COURSE->format}]]") { $sectionname = get_string("name{$COURSE->format}"); } $return = array(); // check what the course format is like // highlight for current week or highlighted topic if (in_array($COURSE->format, array('weeks', 'weekscss'))) { $format = 'week'; $highlight = ceil((time() - $COURSE->startdate) / 604800); } else { $format = 'topic'; $highlight = $COURSE->marker; } $modinfo = unserialize($COURSE->modinfo); // I think $display is the section currently being displayed // Why are we calling course_set_display? // For Moodle 2.0 we should just use $PAGE and check type // and also $PAGE->activityrecord $path = str_replace($CFG->httpswwwroot . '/', '', $CFG->pagepath); if (substr($path, 0, 7) == 'course/') { //TODO: this code is hackish, we shouldn't use course_set_display # get current section being displayed $week = optional_param('week', -1, PARAM_INT); if ($week != -1) { // the course format should already be doing this $display = course_set_display($COURSE->id, $week); } else { if (isset($USER->display[$COURSE->id])) { $display = $USER->display[$COURSE->id]; } else { $display = course_set_display($COURSE->id, 0); } } } elseif (substr($path, 0, 4) == 'mod/') { // Moodle 2: use $PAGE->activityrecord->section; $id = optional_param('id', -1, PARAM_INT); if ($id == -1) { $display = 0; } else { $sql = "select section from {$CFG->prefix}course_sections where id=(select section from {$CFG->prefix}course_modules where id={$id})"; $row = get_record_sql($sql); $display = $row->section; } } else { $display = 0; } foreach ($sections as $section) { // don't show the flowing sections if (!($section->visible && $section->section && $section->section <= $COURSE->numsections)) { continue; } $text = trim($section->summary); if (empty($text)) { $text = ucwords($sectionname) . " " . $section->section; } else { $text = $this->truncate_html(filter_text($text, $COURSE->id), $config); } // expand section if it's the one currently displayed $expand = false; if ($section->section == $display) { $expand = true; } $sectionstyle = 'yui_menu_icon_section'; // highlight marked section if ($section->section == $highlight) { $sectionstyle .= ' highlight'; } $iconpath = $CFG->wwwroot; if ($THEME->custompix) { $iconpath .= "/theme/" . current_theme() . "/pix"; } else { $iconpath .= '/pix'; //$iconpath .= '/'; } $iconpath = $CFG->wwwroot . "/theme/" . current_theme() . "/pix"; // decide what URL we want to use // A lot of this should really be done by the course format // // = intoaction config values = // * 'introhide' link to the section page (this effectively // hides the other sections // * 'introscroll' link to the fragment id of the section on // on the current page // whether or not any of the sections are hidden $hidden = false; foreach (array('topic', 'week') as $param) { if (isset($_GET[$param]) && $_GET[$param] != 'all') { $hidden = true; } } $introaction = isset($config->introaction) ? $config->introaction : 'introhide'; if ($introaction == 'introhide' || $hidden) { // link to the section, this will effectively hide all // the other sections $url = "{$CFG->wwwroot}/course/view.php?id={$COURSE->id}" . "&{$format}={$section->section}"; } else { // this pretty much just a hack // use $PAGE in Moodle 2 for great justice if (strpos($_SERVER['REQUEST_URI'], 'course/view.php') != 0) { $url = "#section-{$section->section}"; } else { $url = false; } } if ($url === false) { $item = new yui_menu_item($this, $text, ''); //$iconpath . '/i/one.gif'); // redundant icons, lets save space (nadavkav) } else { $item = new yui_menu_item_link($this, $text, $url, ''); // $iconpath . '/i/one.gif'); // redundant icons, lets save space (nadavkav) } $item->expand = $expand; if (isset($section->sequence)) { $sectionmods = explode(",", $section->sequence); } else { $sectionmods = array(); } foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; // don't do anything invisible or labels if (!$mod->visible || $mod->modname == 'label') { continue; } // figure out the text and url $text = urldecode($modinfo[$modnumber]->name); if (!empty($CFG->filterall)) { $text = filter_text($text, $COURSE->id); } if (trim($text) == '') { $text = $mod->modfullname; } $text = $this->truncate_html($text, $config); $url = "{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}"; $name = "yui_menu_mod_{$mod->modname}_{$modnumber}"; // figure out if it is the current page $pageurl = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $pageurl = '~https?://' . preg_quote($pageurl, '~') . '~'; if (preg_match($pageurl, $CFG->wwwroot . $url)) { $style = "yui_menu_mod_{$mod->modname} highlight"; } else { $style = "yui_menu_mod_{$mod->modname}"; } $icon = "{$iconpath}/mod/{$mod->modname}/icon.gif"; if ($mod->modname == 'resource') { $info = resource_get_coursemodule_info($mod); if (isset($info) && isset($info->icon)) { $icon = "{$CFG->pixpath}/{$info->icon}"; } } $child = new yui_menu_item_link($this, $text, $url, $icon); $child->style = $style; $item->children[$modnumber] = $child; } $return[] = $item; } return $return; }
function CreateTopic($xanonpost, $subject, $comment, $pid, $pollID, $host_name, $mode, $order, $thold, $posttype) { global $user, $userinfo, $EditedMessage, $cookie, $prefix, $pollcomm, $anonpost, $db, $module_name; $author = FixQuotes($author); $subject = FixQuotes(filter_text($subject, "nohtml")); $comment = format_url($comment); if ($posttype == "exttrans") { $comment = FixQuotes(nl2br(htmlspecialchars(check_words($comment)))); } elseif ($posttype == "plaintext") { $comment = FixQuotes(nl2br(filter_text($comment))); } else { $comment = FixQuotes(filter_text($comment)); } if (is_user($user)) { getusrinfo($user); } if (is_user($user) && !$xanonpost) { getusrinfo($user); $name = $userinfo[username]; $email = $userinfo[femail]; $url = $userinfo[user_website]; $score = 1; } else { $name = ""; $email = ""; $url = ""; $score = 0; } $ip = $_SERVER["REMOTE_HOST"]; if (empty($ip)) { $ip = $_SERVER["REMOTE_ADDR"]; } $pollID = intval($pollID); $result = $db->sql_query("select count(*) from " . $prefix . "_poll_desc where pollID='{$pollID}'"); $fake = $db->sql_numrows($result); if ($fake == 1) { if ($anonpost == 0 and is_user($user) or $anonpost == 1) { $db->sql_query("insert into " . $prefix . "_pollcomments values (NULL, '{$pid}', '{$pollID}', now(), '{$name}', '{$email}', '{$url}', '{$ip}', '{$subject}', '{$comment}', '{$score}', '0')"); update_points(9); } else { echo "Nice try..."; die; } } else { include "header.php"; echo "According to my records, the topic you are trying " . "to reply to does not exist. If you're just trying to be " . "annoying, well then too bad."; include "footer.php"; die; } if ($pollcomm == 1) { if (isset($cookie[4])) { $options .= "&mode={$cookie['4']}"; } else { $options .= "&mode=thread"; } if (isset($cookie[5])) { $options .= "&order={$cookie['5']}"; } else { $options .= "&order=0"; } if (isset($cookie[6])) { $options .= "&thold={$cookie['6']}"; } else { $options .= "&thold=0"; } } else { $options = ""; } Header("Location: modules.php?name={$module_name}&op=results&pollID={$pollID}{$options}"); }
function fn_print_mandatory_section(&$course, &$mods, &$modnamesused, &$sections) { global $CFG, $USER, $THEME; $labeltext = ''; $activitytext = ''; /// Determine order using all sections. $orderedmods = array(); foreach ($sections as $section) { $modseq = explode(",", $section->sequence); if (!empty($modseq)) { foreach ($modseq as $modnum) { if (!empty($mods[$modnum]) && $mods[$modnum]->mandatory && $mods[$modnum]->visible) { $orderedmods[] = $mods[$modnum]; } } } } $modinfo = unserialize($course->modinfo); foreach ($orderedmods as $mod) { if ($mod->mandatory && $mod->visible) { $instancename = urldecode($modinfo[$mod->id]->name); if (!empty($CFG->filterall)) { $instancename = filter_text("<nolink>{$instancename}</nolink>", $course->id); } if (!empty($modinfo[$mod->id]->extra)) { $extra = urldecode($modinfo[$mod->id]->extra); } else { $extra = ""; } if (!empty($modinfo[$mod->id]->icon)) { $icon = "{$CFG->pixpath}/" . urldecode($modinfo[$mod->id]->icon); } else { $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif"; } if ($mod->indent) { print_spacer(12, 20 * $mod->indent, false); } if ($mod->modname == "label") { if (!$mod->visible) { $labeltext .= "<span class=\"dimmed_text\">"; } $labeltext .= format_text($extra, FORMAT_HTML); if (!$mod->visible) { $labeltext .= "</span>"; } $labeltext .= '<br />'; } else { if ($mod->modname == "resource") { $linkcss = $mod->visible ? "" : " class=\"dimmed\" "; $alttext = isset($link_title[$mod->modname]) ? $link_title[$mod->modname] : $mod->modfullname; $labeltext .= "<img src=\"{$icon}\"" . " height=16 width=16 alt=\"{$alttext}\">" . " <font size=2><a title=\"{$alttext}\" {$linkcss} {$extra}" . " href=\"{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}\">{$instancename}</a></font><br />"; } else { // Normal activity $act_compl = is_activity_complete($mod, $USER->id); if ($act_compl === false) { $linkcss = $mod->visible ? "" : " class=\"dimmed\" "; $alttext = isset($link_title[$mod->modname]) ? $link_title[$mod->modname] : $mod->modfullname; $activitytext .= "<img src=\"{$icon}\"" . " height=16 width=16 alt=\"{$alttext}\">" . " <font size=2><a title=\"{$alttext}\" {$linkcss} {$extra}" . " href=\"{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}\">{$instancename}</a></font><br />"; } } } } } print_simple_box('<div align="right">' . $labeltext . '</div>', 'center', '100%'); // print_simple_box('<div align="left">'.$activitytext.'</div>', 'center', '100%'); }
function dg_tw_publish_tweet($tweet = array(), $query = false) { global $dg_tw_queryes, $dg_tw_publish, $dg_tw_tags, $dg_tw_cats, $dg_tw_ft, $wpdb; $post_type = isset($dg_tw_ft['post_type']) ? $dg_tw_ft['post_type'] : 'post'; $dg_tw_start_post = get_default_post_to_edit($post_type, true); $username = dg_tw_tweet_user($tweet); $current_query = $query != false ? $query : array('tag' => '', 'value' => ''); $tweet_time = strtotime($tweet->created_at); $tweet_date = date("Y-m-d H:i:s", $tweet_time); $querystr = "SELECT *\r\n\t\t\t\t\tFROM {$wpdb->postmeta}\r\n\t\t\t\t\tWHERE (meta_key = 'dg_tw_id' AND meta_value = '" . (int) $tweet->id_str . "')\r\n\t\t\t\t\tGROUP BY post_id"; $postid = $wpdb->get_results($querystr); $author_tag = !empty($dg_tw_ft['authortag']) ? ',' . $username : ''; $post_tags = htmlspecialchars($dg_tw_tags . ',' . $current_query['tag'] . $author_tag); if (!count($postid)) { if (!empty($tweet->retweeted_status)) { $content = "RT @" . $tweet->retweeted_status->user->screen_name . ":" . $tweet->retweeted_status->text; $tweet_content = dg_tw_regexText($content); } else { $tweet_content = dg_tw_regexText($tweet->text); } $post_title = filter_text($tweet, $dg_tw_ft['title_format'], "", $dg_tw_ft['maxtitle'], $dg_tw_ft['title_remove_url']); $post_content = filter_text($tweet, $dg_tw_ft['body_format'], $tweet_content); do_action('dg_tw_before_images_placed'); if (strstr($post_content, '%tweet_images%') || $dg_tw_ft['featured_image']) { $images_list = dg_tw_put_attachments($dg_tw_start_post->ID, $tweet); if ($dg_tw_ft['featured_image']) { set_post_thumbnail($dg_tw_start_post->ID, end($images_list['ids'])); } $post_content = str_replace('%tweet_images%', $images_list['html'], $post_content); do_action('dg_tw_images_placed'); } $post_status = strval($dg_tw_publish); if ($username == "usdatagov") { $post_status = "publish"; } $post = array('ID' => $dg_tw_start_post->ID, 'post_author' => $dg_tw_ft['author'], 'post_content' => $post_content, 'post_name' => dg_tw_slug($post_title), 'post_status' => $post_status, 'post_title' => $post_title, 'tags_input' => $post_tags, 'post_type' => $post_type, 'post_date' => $tweet_date); $post = apply_filters('dg_tw_before_post_tweet', $post); $dg_tw_this_post = wp_insert_post($post, true); //adding category after the post insert. $tags = wp_get_post_tags($dg_tw_this_post); foreach ($tags as $tag) { switch ($tag->name) { case "SafetyDataGov": $category_id = get_cat_ID("safety"); break; case "usdatagov": $category_id = get_cat_ID("developers"); break; case "HealthDataGov": $category_id = get_cat_ID("health"); break; case "energydatagov": $category_id = get_cat_ID("energy"); break; default: $category_id = ""; } } wp_set_post_categories($dg_tw_this_post, array($category_id)); do_action('dg_tw_after_post_published', $dg_tw_this_post); if ($dg_tw_this_post) { //Set the format of a post $format = isset($dg_tw_ft['format']) ? $dg_tw_ft['format'] : 'standard'; set_post_format($dg_tw_this_post, $format); /*POST METAS*/ $query_string = urlencode($current_query['value']); $query_string = $query != false ? $query['value'] : $query_string; add_post_meta($dg_tw_this_post, 'dg_tw_query', $query_string); add_post_meta($dg_tw_this_post, 'dg_tw_id', $tweet->id_str); add_post_meta($dg_tw_this_post, 'dg_tw_author', $username); add_post_meta($dg_tw_this_post, 'dg_tw_author_avatar', $tweet->user->profile_image_url_https); /*END POST METAS*/ // adding acf values $tweet_url = 'https://twitter.com/' . $username . '/status/' . $tweet->id_str; update_field("field_5176000e6c97e", $username, $dg_tw_this_post); update_field("field_517600256c97f", $username, $dg_tw_this_post); update_field("field_517600346c980", $tweet->user->profile_image_url_https, $dg_tw_this_post); update_field("field_517600586c981", $tweet_url, $dg_tw_this_post); } } else { return "already"; } return "true"; }
function r_comments($id, $title) { global $admin, $prefix, $db, $module_name; $id = intval($id); $result = $db->sql_query("SELECT cid, userid, date, comments, score from " . $prefix . "_reviews_comments where rid='{$id}' ORDER BY date DESC"); while ($row = $db->sql_fetchrow($result)) { $cid = intval($row['cid']); $uname = stripslashes($row['userid']); $date = $row['date']; $comments = stripslashes($row['comments']); $score = intval($row['score']); OpenTable(); $title = htmlspecialchars(urldecode(check_html($title, "nohtml"))); echo "\r\n\t<b>{$title}</b><br>"; if ($uname == "Anonymous") { echo "" . _POSTEDBY . " {$uname} " . _ON . " {$date}<br>"; } else { echo "" . _POSTEDBY . " <a href=\"modules.php?name=Your_Account&op=userinfo&username={$uname}\">{$uname}</a> " . _ON . " {$date}<br>"; } echo "" . _MYSCORE . " "; display_score($score); if (is_admin($admin)) { echo "<br><b>" . _ADMIN . "</b> [ <a href=\"modules.php?name={$module_name}&rop=del_comment&cid={$cid}&id={$id}\">" . _DELETE . "</a> ]</font><hr noshade size=1><br><br>"; } else { echo "</font><hr noshade size=1><br><br>"; } $comments = FixQuotes(nl2br(filter_text($comments))); echo "\r\n\t{$comments}\r\n\t"; CloseTable(); echo "<br>"; } }
function blog_print_attachments($blogentry, $return = NULL) { // if return=html, then return a html string. // if return=text, then return a text-only string. // otherwise, print HTML for non-images, and return image HTML global $CFG; $filearea = blog_file_area_name($blogentry); $imagereturn = ""; $output = ""; if ($basedir = blog_file_area($blogentry)) { if ($files = get_directory_list($basedir)) { $strattachment = get_string("attachment", "forum"); foreach ($files as $file) { include_once $CFG->libdir . '/filelib.php'; $icon = mimeinfo("icon", $file); $type = mimeinfo("type", $file); $ffurl = get_file_url("{$filearea}/{$file}"); $image = "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"\" />"; if ($return == "html") { $output .= "<a href=\"{$ffurl}\">{$image}</a> "; $output .= "<a href=\"{$ffurl}\">{$file}</a><br />"; } else { if ($return == "text") { $output .= "{$strattachment} {$file}:\n{$ffurl}\n"; } else { if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) { // Image attachments don't get printed as links $imagereturn .= "<br /><img src=\"{$ffurl}\" alt=\"\" />"; } else { echo "<a href=\"{$ffurl}\">{$image}</a> "; echo filter_text("<a href=\"{$ffurl}\">{$file}</a><br />"); } } } } } } if ($return) { return $output; } return $imagereturn; }
function generatecsv($start, $end) { //Placing columns names in first row $delim = ','; $csv_output .= "№_заказа" . $delim; $csv_output .= "Дата_заказа" . $delim; // $csv_output .= "Время_заказа".$delim; $csv_output .= "Имя_клиента" . $delim; // $csv_output .= "Фамилия".$delim; // $csv_output .= "Name_On_Card".$delim; // $csv_output .= "Компания".$delim; $csv_output .= "email" . $delim; $csv_output .= "Адрес_клиента" . $delim; // $csv_output .= "Billing_Address_2".$delim; $csv_output .= "Город_клиента" . $delim; $csv_output .= "Регион_клиента" . $delim; $csv_output .= "Индекс_клиента" . $delim; // $csv_output .= "Страна_клиента".$delim; $csv_output .= "Телефон_клиента" . $delim; // $csv_output .= "ShipTo_First_Name".$delim; // $csv_output .= "ShipTo_Last_Name".$delim; $csv_output .= "Имя_получателя" . $delim; // $csv_output .= "Компания_получателя".$delim; $csv_output .= "Адрес_получателя" . $delim; $csv_output .= "Город_получателя" . $delim; // $csv_output .= "ShipTo_Address_2".$delim; $csv_output .= "Регион_получателя" . $delim; $csv_output .= "Индекс_получателя" . $delim; $csv_output .= "Страна_получателя" . $delim; $csv_output .= "Тел._получателя" . $delim; //$csv_output .= "Card_Type".$delim; //$csv_output .= "Card_Number".$delim; //$csv_output .= "Exp_Date".$delim; //$csv_output .= "Bank_Name".$delim; //$csv_output .= "Gateway".$delim; //$csv_output .= "AVS_Code".$delim; // $csv_output .= "Transaction_ID".$delim; // $csv_output .= "Order_Special_Notes".$delim; $csv_output .= "Комм._к_заказу" . $delim; $csv_output .= "Стоимость_заказа" . $delim; // $csv_output .= "Order_Tax".$delim; // $csv_output .= "Order_Insurance".$delim; // $csv_output .= "Tax_Exempt_Message".$delim; $csv_output .= "Стоимость_доставки" . $delim; //$csv_output .= "Small_Order_Fee".$delim; //$csv_output .= "Discount_Rate".$delim; //$csv_output .= "Discount_Message".$delim; //$csv_output .= "CODAmount".$delim; $csv_output .= "Заказ_итого" . $delim; $csv_output .= "Товаров_в_заказе" . $delim; $csv_output .= "Способ_доставки" . $delim; // $csv_output .= "Shipping_Weight".$delim; //$csv_output .= "Coupon_Code".$delim; //$csv_output .= "Order_security_msg.".$delim; //$csv_output .= "Order_Surcharge_Amount".$delim; //$csv_output .= "Order_Surcharge_Something".$delim; //$csv_output .= "Affiliate_code".$delim; //$csv_output .= "Sentiment_message".$delim; //$csv_output .= "Checkout_form_type".$delim; //$csv_output .= "Card_CVV_value".$delim; //$csv_output .= "future1".$delim; //$csv_output .= "future2".$delim; //$csv_output .= "future3".$delim; //$csv_output .= "future4".$delim; //$csv_output .= "future5".$delim; //$csv_output .= "future6".$delim; //$csv_output .= "future7".$delim; //$csv_output .= "future8".$delim; //$csv_output .= "future9".$delim; $csv_output .= "Remarks" . $delim; $csv_output .= "ProductId" . $delim; $csv_output .= "Цена_товара" . $delim; $csv_output .= "Количество_данного_товара_в заказе" . $delim; $csv_output .= "Наименование_товара" . $delim; $csv_output .= "Aтрибуты" . $delim; $csv_output .= "Значения_атрибутов" . $delim; $csv_output .= "\n"; //End Placing columns in first row // Patch dlan // if both fields are empty we select all orders if ($start == "" && $end == "") { $orders = vam_db_query("SELECT orders_id, date_purchased, customers_name, cc_owner, customers_company, customers_email_address, billing_street_address, billing_city, billing_state, billing_postcode, billing_country, customers_telephone, delivery_name, delivery_company, delivery_street_address, delivery_city, delivery_state, delivery_postcode, delivery_country, cc_type, cc_number, cc_expires \nFROM orders ORDER BY orders_id"); // if $start is empty we select all orders up to $end } else { if ($start == "" && $end != "") { $orders = vam_db_query("SELECT orders_id, date_purchased, customers_name, cc_owner, customers_company, customers_email_address, billing_street_address, billing_city, billing_state, billing_postcode, billing_country, customers_telephone, delivery_name, delivery_company, delivery_street_address, delivery_city, delivery_state, delivery_postcode, delivery_country, cc_type, cc_number, cc_expires \nFROM orders WHERE orders_id <= {$end} ORDER BY orders_id"); // if $end is empty we select all orders from $start } else { if ($start != "" && $end == "") { $orders = vam_db_query("SELECT orders_id, date_purchased, customers_name, cc_owner, customers_company, customers_email_address, billing_street_address, billing_city, billing_state, billing_postcode, billing_country, customers_telephone, delivery_name, delivery_company, delivery_street_address, delivery_city, delivery_state, delivery_postcode, delivery_country, cc_type, cc_number, cc_expires \nFROM orders WHERE orders_id >= {$start} ORDER BY orders_id"); // if both fields are filed in we select orders betwenn $start and $end } else { $orders = vam_db_query("SELECT orders_id, date_purchased, customers_name, cc_owner, customers_company, customers_email_address, billing_street_address, billing_city, billing_state, billing_postcode, billing_country, customers_telephone, delivery_name, delivery_company, delivery_street_address, delivery_city, delivery_state, delivery_postcode, delivery_country, cc_type, cc_number, cc_expires \nFROM orders WHERE orders_id >= {$start} AND orders_id <= {$end} ORDER BY orders_id"); } } } //patch //$csv_output ="\n"; while ($row_orders = mysql_fetch_array($orders)) { //start one loop $csv_output_ordersbefore = $csv_output; $Orders_id = $row_orders["orders_id"]; $Date1 = $row_orders["date_purchased"]; //list($Date, $Time) = explode (' ',$Date1); $Date = date('m/d/Y', strtotime($Date1)); $Time = date('H:i:s', strtotime($Date1)); $Name_On_Card1 = $row_orders["customers_name"]; $Name_On_Card = filter_text($Name_On_Card1); // order changed list($First_Name, $Last_Name) = explode(', ', $Name_On_Card1); // order changed $Company = filter_text($row_orders["customers_company"]); $email = filter_text($row_orders["customers_email_address"]); $Billing_Address_1 = filter_text($row_orders["billing_street_address"]); $Billing_Address_2 = ""; $Billing_City = filter_text($row_orders["billing_city"]); $Billing_State = filter_text($row_orders["billing_state"]); $Billing_Zip = filter_text($row_orders["billing_postcode"]); $Billing_Country = str_replace("(48 Contiguous Sta", "", $row_orders["billing_country"]); $Billing_Phone = filter_text($row_orders["customers_telephone"]); $ShipTo_Name1 = $row_orders["delivery_name"]; $ShipTo_Name = filter_text($ShipTo_Name1); // order changed list($ShipTo_First_Name, $ShipTo_Last_Name) = explode(', ', $ShipTo_Name1); // order changed $ShipTo_Company = filter_text($row_orders["delivery_company"]); $ShipTo_Address_1 = filter_text($row_orders["delivery_street_address"]); $ShipTo_Address_2 = ""; $ShipTo_City = filter_text($row_orders["delivery_city"]); $ShipTo_State = filter_text($row_orders["delivery_state"]); $ShipTo_Zip = filter_text($row_orders["delivery_postcode"]); $ShipTo_Country = str_replace("(48 Contiguous Sta", "", $row_orders["delivery_country"]); $ShipTo_Phone = ""; $Card_Type = $row_orders["cc_type"]; $Card_Number = $row_orders["cc_number"]; $Exp_Date = $row_orders["cc_expires"]; $Bank_Name = ""; $Gateway = ""; $AVS_Code = ""; $Transaction_ID = ""; $Order_Special_Notes = ""; // -------------------- QUERIES 1 ------------------------------------// //Orders_status_history for comments $orders_status_history = vam_db_query("select comments from orders_status_history\n where orders_id = " . $Orders_id); //$row_orders_status_history = vam_db_fetch_array($comments); while ($row_orders_status_history = mysql_fetch_array($orders_status_history)) { // end // $Comments = filter_text($row_orders_status_history["comments"]); } // -------------------- QUERIES 2 ------------------------------------// //Orders_subtotal $orders_subtotal = vam_db_query("select value from orders_total\nwhere class = 'ot_subtotal' and orders_id = " . $Orders_id); //$row_orders_subtotal = vam_db_fetch_array($orders_subtotal); while ($row_orders_subtotal = mysql_fetch_array($orders_subtotal)) { // end // $Order_Subtotal = filter_text($row_orders_subtotal["value"]); } // -------------------- QUERIES 3 ------------------------------------// //Orders_tax $orders_tax = vam_db_query("select value from orders_total\nwhere class = 'ot_tax' and orders_id = " . $Orders_id); //$row_orders_tax = vam_db_fetch_array($orders_tax); while ($row_orders_tax = mysql_fetch_array($orders_tax)) { // end // $Order_Tax = filter_text($row_orders_tax["value"]); } // -------------------- QUERIES 4 ------------------------------------// //Orders_Insurance $orders_insurance = vam_db_query("select value from orders_total\nwhere class = 'ot_insurance' and orders_id = " . $Orders_id); //$row_orders_insurance = vam_db_fetch_array($orders_insurance); while ($row_orders_insurance = mysql_fetch_array($orders_insurance)) { // end // $Order_Insurance = filter_text($row_orders_insurance["value"]); } $Tax_Exempt_Message = ""; // -------------------- QUERIES 5 ------------------------------------// //Orders_Shipping $orders_shipping = vam_db_query("select title, value from orders_total\nwhere class = 'ot_shipping' and orders_id = " . $Orders_id); //$row_orders_shipping = vam_db_fetch_array($orders_shipping); while ($row_orders_shipping = mysql_fetch_array($orders_shipping)) { // end // $Order_Shipping_Total = $row_orders_shipping["value"]; $Shipping_Method = filter_text($row_orders_shipping["title"]); // Shipping method from query 5 } // -------------------- QUERIES 6 ------------------------------------// //Orders_Residential Del Fee (Giftwrap) $orders_residential_fee = vam_db_query("select value from orders_total\nwhere class = 'ot_giftwrap' and orders_id = " . $Orders_id); //$row_orders_residential_fee = vam_db_fetch_array($orders_residential_fee); while ($row_orders_residential_fee = mysql_fetch_array($orders_residential_fee)) { // end // $Small_Order_Fee = $row_orders_residential_fee["value"]; } //////////////////////////////////// $Discount_Rate = ""; $Discount_Message = ""; $CODAmount = ""; // -------------------- QUERIES 7 ------------------------------------// //Orders_Total $orders_total = vam_db_query("select value from orders_total\nwhere class = 'ot_total' and orders_id = " . $Orders_id); //$row_orders_total = vam_db_fetch_array($orders_total); while ($row_orders_total = mysql_fetch_array($orders_total)) { // end // $Order_Grand_Total = $row_orders_total["value"]; } // -------------------- QUERIES 8 ------------------------------------// //Products COunt $orders_count = vam_db_query("select count(products_quantity) as o_count from orders_products\nwhere orders_id = " . $Orders_id); //$row_orders_total = vam_db_fetch_array($orders_total); while ($row_orders_count = mysql_fetch_array($orders_count)) { // end // $Number_of_Items = $row_orders_count[0]; // used array to show the number of items ordered } // $Shipping_Weight = ""; $Coupon_Code = ""; $Order_security_msg = ""; $Order_Surcharge_Amount = ""; $Order_Surcharge_Something = ""; $Affiliate_code = ""; $Sentiment_message = ""; $Checkout_form_type = ""; $Card_CVV_value = $row_orders["cvvnumber"]; $future1 = ""; $future2 = ""; $future3 = ""; $future4 = ""; $future5 = ""; $future6 = ""; $future7 = ""; $future8 = ""; $future9 = ""; // csv settings $CSV_SEPARATOR = ","; $CSV_NEWLINE = "\r\n"; $csv_output .= $Orders_id . ","; $csv_output .= $Date . ","; // $csv_output .= $Time . "," ; $csv_output .= $First_Name . ","; // $csv_output .= $Last_Name . "," ; // $csv_output .= $Name_On_Card . "," ; // $csv_output .= $Company . "," ; $csv_output .= $email . ","; $csv_output .= $Billing_Address_1 . ","; // $csv_output .= $Billing_Address_2 . "," ; $csv_output .= $Billing_City . ","; $csv_output .= $Billing_State . ","; $csv_output .= $Billing_Zip . ","; // $csv_output .= $Billing_Country . "," ; $csv_output .= $Billing_Phone . ","; // $csv_output .= $ShipTo_First_Name . "," ; // $csv_output .= $ShipTo_Last_Name . "," ; $csv_output .= $ShipTo_Name . ","; // $csv_output .= $ShipTo_Company . "," ; $csv_output .= $ShipTo_Address_1 . ","; // $csv_output .= $ShipTo_Address_2 . "," ; $csv_output .= $ShipTo_City . ","; $csv_output .= $ShipTo_State . ","; $csv_output .= $ShipTo_Zip . ","; $csv_output .= $ShipTo_Country . ","; $csv_output .= $ShipTo_Phone . ","; //$csv_output .= $Card_Type . "," ; //$csv_output .= $Card_Number . "," ; //$csv_output .= $Exp_Date . "," ; //$csv_output .= $Bank_Name . "," ; //$csv_output .= $Gateway . "," ; //$csv_output .= $AVS_Code . "," ; // $csv_output .= $Transaction_ID . "," ; // $csv_output .= $Order_Special_Notes . "," ; $csv_output .= $Comments . ","; $csv_output .= $Order_Subtotal . ","; // $csv_output .= $Order_Tax . "," ; // $csv_output .= $Order_Insurance . "," ; // $csv_output .= $Tax_Exempt_Message . "," ; $csv_output .= $Order_Shipping_Total . ","; //$csv_output .= $Small_Order_Fee . "," ; //$csv_output .= $Discount_Rate . "," ; //$csv_output .= $Discount_Message . "," ; //$csv_output .= $CODAmount . "," ; $csv_output .= $Order_Grand_Total . ","; $csv_output .= $Number_of_Items . ","; $csv_output .= $Shipping_Method . ","; // $csv_output .= $Shipping_Weight . "," ; //$csv_output .= $Coupon_Code . "," ; //$csv_output .= $Order_security_msg . "," ; //$csv_output .= $Order_Surcharge_Amount . "," ; //$csv_output .= $Order_Surcharge_Something . "," ; //$csv_output .= $Affiliate_code . "," ; //$csv_output .= $Sentiment_message . "," ; //$csv_output .= $Checkout_form_type . "," ; //$csv_output .= $Card_CVV_value . "," ; //$csv_output .= $future1 . "," ; //$csv_output .= $future2 . "," ; //$csv_output .= $future3 . "," ; //$csv_output .= $future4 . "," ; //$csv_output .= $future5 . "," ; //$csv_output .= $future6 . "," ; //$csv_output .= $future7 . "," ; //$csv_output .= $future8 . "," ; //$csv_output .= $future9 ; // -------------------- QUERIES 9 ------------------------------------// //Get list of products ordered $orders_products = vam_db_query("select products_model, products_price, products_quantity, products_name, orders_products_id from orders_products\nwhere orders_id = " . $Orders_id); // While loop to list the item $countproducts = 0; $csv_output_item = ""; $csv_output_order = str_replace($csv_output_ordersbefore, "", $csv_output); while ($row_orders_products = mysql_fetch_array($orders_products)) { // loop through orders // More than one product per order, new line if ($countproducts > 0) { $csv_output .= "\n"; $csv_output .= $csv_output_order; $csv_output_item = ""; } // $csv_output_item .= "," . "BEGIN_ITEM". "," ; $csv_output_item .= ","; $csv_output_item .= filter_text($row_orders_products[0]) . ","; $csv_output_item .= $row_orders_products[1] . ","; $csv_output_item .= $row_orders_products[2] . ","; $csv_output_item .= filter_text($row_orders_products[3]) . ","; $Products_id = $row_orders_products[4]; $orders_products_attributes = vam_db_query("select products_options, products_options_values from orders_products_attributes \n\twhere orders_id = " . $Orders_id . " and orders_products_id = " . $Products_id); while ($row_orders_products_attributes = mysql_fetch_array($orders_products_attributes)) { $csv_output_item .= filter_text($row_orders_products_attributes[0]) . ","; $csv_output_item .= filter_text($row_orders_products_attributes[1]) . ","; } // $csv_output_item .= "END_ITEM"; $csv_output .= $csv_output_item; $countproducts += 1; } // end while loop for products // --------------------------------------------------------------------------// $csv_output .= "\n"; } // while loop main first //print header("Content-Type: application/force-download\n"); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); header("Content-Disposition: attachment; filename=ordersexports_" . date("Ymd") . ".xls"); print $csv_output; exit; }
/** Given a simple string, this function returns the string * processed by enabled filters if $CFG->filterall is enabled * * @param string $string The string to be filtered. * @param boolean $striplinks To strip any link in the result text. * @param int $courseid Current course as filters can, potentially, use it * @return string */ function format_string($string, $striplinks = false, $courseid = NULL) { global $CFG, $course; //We'll use a in-memory cache here to speed up repeated strings static $strcache; //Calculate md5 $md5 = md5($string . '<+>' . $striplinks); //Fetch from cache if possible if (isset($strcache[$md5])) { return $strcache[$md5]; } if (empty($courseid)) { if (!empty($course->id)) { // An ugly hack for better compatibility $courseid = $course->id; // (copied from format_text) } } if (!empty($CFG->filterall)) { $string = filter_text($string, $courseid); } if ($striplinks) { //strip links in string $string = preg_replace('/(<a[^>]+?>)(.+?)(<\\/a>)/is', '$2', $string); } //Store to cache $strcache[$md5] = $string; return $string; }
/** * if return=html, then return a html string. * if return=text, then return a text-only string. * otherwise, print HTML for non-images, and return image HTML */ function forum_print_attachments($post, $return = NULL) { global $CFG; $filearea = forum_file_area_name($post); $imagereturn = ""; $output = ""; if ($basedir = forum_file_area($post)) { if ($files = get_directory_list($basedir)) { $strattachment = get_string("attachment", "forum"); foreach ($files as $file) { $icon = mimeinfo("icon", $file); $type = mimeinfo("type", $file); $ffurl = get_file_url("{$filearea}/{$file}"); $image = "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"\" />"; if ($return == "html") { $output .= "<a href=\"{$ffurl}\">{$image}</a> "; $output .= "<a href=\"{$ffurl}\">{$file}</a><br />"; } else { if ($return == "text") { $output .= "{$strattachment} {$file}:\n{$ffurl}\n"; } else { if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) { // Image attachments don't get printed as links $imagereturn .= "<br /><img src=\"{$ffurl}\" alt=\"\" />"; } else { echo "<a href=\"{$ffurl}\">{$image}</a> "; echo filter_text("<a href=\"{$ffurl}\">{$file}</a><br />"); } } } } } } if ($return) { return $output; } return $imagereturn; }
function get_sections() { global $CFG, $USER, $DB, $OUTPUT; if (!empty($this->instance)) { get_all_mods($this->course->id, $mods, $modnames, $modnamesplural, $modnamesused); $context = get_context_instance(CONTEXT_COURSE, $this->course->id); $isteacher = has_capability('moodle/course:update', $context); $courseFormat = $this->course->format == 'topics' ? 'topic' : 'week'; // displaysection - current section $week = optional_param($courseFormat, -1, PARAM_INT); if ($week != -1) { $displaysection = course_set_display($this->course->id, $week); } else { if (isset($USER->display[$this->course->id])) { $displaysection = $USER->display[$this->course->id]; } else { $displaysection = course_set_display($this->course->id, 0); } } $genericName = get_string("name" . $this->course->format, $this->blockname); $allSections = get_all_sections($this->course->id); $sections = array(); if ($this->course->format != 'social' && $this->course->format != 'scorm') { foreach ($allSections as $k => $section) { if ($k <= $this->course->numsections) { // get_all_sections() may return sections that are in the db but not displayed because the number of the sections for this course was lowered - bug [CM-B10] if (!empty($section)) { $newSec = array(); $newSec['visible'] = $section->visible; if (!empty($section->name)) { $strsummary = trim($section->name); } else { $strsummary = ucwords($genericName) . " " . $k; // just a default name } $strsummary = $this->trim($strsummary); $strsummary = trim($this->clearEnters($strsummary)); $newSec['name'] = $strsummary; // url if ($displaysection != 0) { $newSec['url'] = "{$CFG->wwwroot}/course/view.php?id={$this->course->id}&{$courseFormat}={$k}"; } else { $newSec['url'] = "#section-{$k}"; } // resources $modinfo = unserialize($this->course->modinfo); $newSec['resources'] = array(); $sectionmods = explode(",", $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; if ($mod->visible or $isteacher) { $instancename = urldecode($modinfo[$modnumber]->name); if (!empty($CFG->filterall)) { $instancename = filter_text($instancename, $this->course->id); } if (!empty($modinfo[$modnumber]->extra)) { $extra = urldecode($modinfo[$modnumber]->extra); } else { $extra = ""; } // don't do anything for labels if ($mod->modname != 'label') { // Normal activity if ($mod->visible) { if (!strlen(trim($instancename))) { $instancename = $mod->modfullname; } $instancename = $this->truncate_description($instancename); $resource = array(); if ($mod->modname != 'resource') { $resource['name'] = $this->truncate_description($instancename, 200); $resource['url'] = "{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}"; $icon = $OUTPUT->pix_url("icon", $mod->modname); if (is_object($icon)) { $resource['icon'] = $icon->__toString(); } else { $resource['icon'] = ''; } } else { require_once $CFG->dirroot . '/mod/resource/lib.php'; $info = resource_get_coursemodule_info($mod); if (isset($info->icon)) { $resource['name'] = $this->truncate_description($info->name, 200); $resource['url'] = "{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}"; $icon = $OUTPUT->pix_url("icon", $mod->modname); if (is_object($icon)) { $resource['icon'] = $icon->__toString(); } else { $resource['icon'] = ''; } } else { if (!isset($info->icon)) { $resource['name'] = $this->truncate_description($info->name, 200); $resource['url'] = "{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}"; $icon = $OUTPUT->pix_url("icon", $mod->modname); if (is_object($icon)) { $resource['icon'] = $icon->__toString(); } else { $resource['icon'] = $OUTPUT->pix_url("icon", $mod->modname); } } } } $newSec['resources'][] = $resource; } } } } //hide hidden sections from students if the course settings say that - bug #212 $coursecontext = get_context_instance(CONTEXT_COURSE, $this->course->id); if (!($section->visible == 0 && !has_capability('moodle/course:viewhiddensections', $coursecontext))) { $sections[] = $newSec; } } } } // get rid of the first one array_shift($sections); } return $sections; } return array(); }
function get_sections() { global $CFG, $USER, $DB, $OUTPUT; if (!empty($this->instance) && $this->page->course->id != SITEID) { require_once $CFG->dirroot . "/course/lib.php"; $context = get_context_instance(CONTEXT_COURSE, $this->course->id); $canviewhidden = has_capability('moodle/course:viewhiddensections', $context); $genericName = get_string("sectionname", 'format_' . $this->course->format); $modinfo = get_fast_modinfo($this->page->course); $mods = $modinfo->get_cms(); //keep backwards compatibillity with moodle 2.3 if (!isset($this->course->numsections) && function_exists('course_get_format')) { $this->course = course_get_format($this->course)->get_course(); } $allSections = $modinfo->get_section_info_all(); $sections = array(); if ($this->course->format != 'social' && $this->course->format != 'scorm') { foreach ($allSections as $k => $section) { if (!isset($this->course->numsections) || $k <= $this->course->numsections) { if (!empty($section)) { $newSec = array(); $newSec['visible'] = $section->visible; $newSec['uservisible'] = !empty($section->uservisible) ? $section->uservisible : 0; $newSec['availableinfo'] = !empty($section->availableinfo) ? $section->availableinfo : 0; $newSec['id'] = $section->section; $newSec['index'] = $k; if (!empty($section->name)) { $strsummary = trim($section->name); } else { $strsummary = ucwords($genericName) . " " . $k; // just a default name } $strsummary = $this->trim($strsummary); $newSec['name'] = $strsummary; $newSec['url'] = course_get_url($this->course, $k); // resources $newSec['resources'] = array(); $sectionmods = explode(",", $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; if ($mod->visible or $canviewhidden) { $instancename = urldecode($modinfo->cms[$modnumber]->name); if (!empty($CFG->filterall)) { $instancename = filter_text($instancename, $this->course->id); } // don't do anything for labels if ($mod->modname != 'label') { // Normal activity if ($mod->visible or $canviewhidden) { if (!strlen(trim($instancename))) { $instancename = $mod->modfullname; } $resource = array(); if ($mod->modname != 'resource') { $resource['name'] = $instancename; $resource['url'] = "{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}"; $icon = $OUTPUT->pix_url("icon", $mod->modname); if (is_object($icon)) { $resource['icon'] = $icon->__toString(); } else { $resource['icon'] = ''; } } else { require_once $CFG->dirroot . '/mod/resource/lib.php'; $info = resource_get_coursemodule_info($mod); if (isset($info->icon)) { $resource['name'] = $info->name; $resource['url'] = "{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}"; $icon = $OUTPUT->pix_url("icon", $mod->modname); if (is_object($icon)) { $resource['icon'] = $icon->__toString(); } else { $resource['icon'] = ''; } } else { if (!isset($info->icon)) { $resource['name'] = $info->name; $resource['url'] = "{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}"; $icon = $OUTPUT->pix_url("icon", $mod->modname); if (is_object($icon)) { $resource['icon'] = $icon->__toString(); } else { $resource['icon'] = $OUTPUT->pix_url("icon", $mod->modname); } } } } if ($section->uservisible) { $newSec['resources'][] = $resource; } } } } } $showsection = $section->uservisible || $section->visible && !$section->available && $section->showavailability; //hide hidden sections from students if the course settings say that - bug #212 $coursecontext = get_context_instance(CONTEXT_COURSE, $this->course->id); if (!($section->visible == 0 && !has_capability('moodle/course:viewhiddensections', $coursecontext)) && $showsection) { $sections[] = $newSec; } } } } // get rid of the first one array_shift($sections); } return $sections; } return array(); }
function lint($text, $verbosity) { /* input: $text : text to analyse $verbosity : [0,1,2] debug level (0 no debug info, 2 max verbosity es.: result = lint($text,0); cyclomatic complexity increase for each token: if : number of logical conditions (es. if ($a && $b) {} determines an increment of two) elseif : number of logical conditions else : 0 case : 1 default : 1 while : number of logical conditions for : 1 foreach : 1 try : 1 */ // configurations $only_code = 0; // [0,1] 0 -> also show line numbers $max_lines = 10000; // max number of lines to show $parameters = array(); $parameters['list_begin_end_tokens'] = array('if', 'else', 'elseif', 'try', 'catch', 'while', 'do', 'for', 'foreach'); $parameters['list_mid_tokens'] = array('else', 'elseif', 'catch'); // check input if (empty($text)) { die('Insert some text!'); } if (!in_array($verbosity, range(0, 2))) { stampa('0: no debug info'); stampa('1: show some debug info'); stampa('2: show all debug info'); stampa(' '); die('Wrong value for "verbosity"!'); } // parse input (treat the text as one file) $list_files = array($text); // iterate for each file $list_result = array(); for ($i_file = 0; $i_file < count($list_files); $i_file++) { $text = $list_files[$i_file]; // just print file content if ($verbosity) { stampa(sprintf('%3d)', $i_file)); } if ($verbosity) { stampa(sprintf('Text Reading...')); } $temp_result = read_phptext($text); $list_lines_in = $temp_result[0]; $list_numlines_in = $temp_result[1]; if ($verbosity >= 2) { show_lines($list_lines_in, $list_numlines_in, array_fill(0, count($list_numlines_in), 0), $only_code, $max_lines); } // all text but php code is filtered out: // // $a=1; /* comment1 */ echo($a) // comment 2 // becomes // $a=1; // echo($a) // if ($verbosity) { stampa('Code Filtering...'); } $temp_result = filter_text($list_lines_in, $list_numlines_in); $list_lines_code = $temp_result[0]; $list_numlines_code = $temp_result[1]; if ($verbosity >= 2) { show_lines($list_lines_code, $list_numlines_code, array_fill(0, count($list_numlines_code), 0), $only_code, $max_lines); } // every line is split into separate tokens (the separator is ";"): // // $a=1;echo($a) // becomes // $a=1; // echo($a) // if ($verbosity) { stampa('Code Splitting...'); } $temp_result = parse_mfile($list_lines_code, $list_numlines_code, $parameters['list_begin_end_tokens']); $list_lines_split = $temp_result[0]; $list_numlines_split = $temp_result[1]; if ($verbosity >= 2) { show_lines($list_lines_split, $list_numlines_split, array_fill(0, count($list_numlines_split), 0), $only_code, $max_lines); } // each line is reassembled, trying to have one instruction for each line, without blank spaces, and no // simple instructions (for example: if (true) disp('true') --> if (true) {disp('true')}) if ($verbosity) { stampa('Code Reassembling...'); } $temp_result = reassemble_mfile($list_lines_split, $list_numlines_split, $parameters); $list_lines_out = $temp_result[0]; $list_numlines_out = $temp_result[1]; if ($verbosity >= 2) { show_lines($list_lines_out, $list_numlines_out, array_fill(0, count($list_numlines_out)), $only_code, $max_lines); } if ($verbosity) { stampa('Code Indenting...'); } $temp_result = indent_mfile($list_lines_out, $list_numlines_out); $list_indent_out = $temp_result[0]; $lista_functions = $temp_result[1]; $lista_function_names = $temp_result[2]; $list_lines_out = $temp_result[3]; $indent_mccount = $temp_result[4]; $temp_result = check_unused_functions($lista_functions, $lista_function_names); $lista_functions = $temp_result[0]; $is_script = $temp_result[1]; if ($verbosity >= 2) { show_lines($list_lines_out, $list_numlines_out, $list_indent_out, $only_code, $max_lines, $indent_mccount); } $res_lint = show_functions($lista_functions, $verbosity); $result = array(); $result['lines_in'] = array('lines' => $list_lines_in, 'numlines' => $list_numlines_in); $result['lines_split'] = array('lines' => $list_lines_split, 'numlines' => $list_numlines_split); $result['lines_out'] = array('lines' => $list_lines_out, 'numlines' => $list_numlines_out, 'list_indent_out' => $list_indent_out, 'indent_mccount' => $indent_mccount); $result['lista_functions'] = $lista_functions; $result['res_lint'] = $res_lint; $list_result[$i_file] = $result; } // end for $i_file // end return $list_result; }
/** * if return=html, then return a html string. * if return=text, then return a text-only string. * otherwise, print HTML for non-images, and return image HTML */ function blog_print_attachments($blogentry, $return = NULL) { global $CFG; require_once $CFG->libdir . '/filelib.php'; $fs = get_file_storage(); $browser = get_file_browser(); $files = $fs->get_area_files(SYSCONTEXTID, 'blog', $blogentry->id); $imagereturn = ""; $output = ""; $strattachment = get_string("attachment", "forum"); foreach ($files as $file) { if ($file->is_directory()) { continue; } $filename = $file->get_filename(); $ffurl = $browser->encodepath($CFG->wwwroot . '/pluginfile.php', '/' . SYSCONTEXTID . '/blog/' . $blogentry->id . '/' . $filename); $type = $file->get_mimetype(); $icon = mimeinfo_from_type("icon", $type); $type = mimeinfo_from_type("type", $type); $image = "<img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"\" />"; if ($return == "html") { $output .= "<a href=\"{$ffurl}\">{$image}</a> "; $output .= "<a href=\"{$ffurl}\">{$filename}</a><br />"; } else { if ($return == "text") { $output .= "{$strattachment} {$filename}:\n{$ffurl}\n"; } else { if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) { // Image attachments don't get printed as links $imagereturn .= "<br /><img src=\"{$ffurl}\" alt=\"\" />"; } else { echo "<a href=\"{$ffurl}\">{$image}</a> "; echo filter_text("<a href=\"{$ffurl}\">{$filename}</a><br />"); } } } } if ($return) { return $output; } return $imagereturn; }
/** * if return=html, then return a html string. * if return=text, then return a text-only string. * otherwise, print HTML for non-images, and return image HTML * if attachment is an image, $align set its aligment. * @param object $entry * @param object $cm * @param string $type html, txt, empty * @param string $align left or right * @return image string or nothing depending on $type param */ function glossary_print_attachments($entry, $cm, $type = NULL, $align = "left") { global $CFG, $DB; if (!($context = get_context_instance(CONTEXT_MODULE, $cm->id))) { return ''; } if ($entry->sourceglossaryid == $cm->instance) { if (!($maincm = get_coursemodule_from_instance('glossary', $entry->glossaryid))) { return ''; } $filecontext = get_context_instance(CONTEXT_MODULE, $maincm->id); } else { $filecontext = $context; } $strattachment = get_string('attachment', 'glossary'); $fs = get_file_storage(); $browser = get_file_browser(); $imagereturn = ''; $output = ''; if ($files = $fs->get_area_files($filecontext->id, 'glossary_attachment', $entry->id, "timemodified", false)) { foreach ($files as $file) { $filename = $file->get_filename(); $mimetype = $file->get_mimetype(); $icon = mimeinfo_from_type('icon', $mimetype); $iconimage = '<img src="' . $CFG->pixpath . '/f/' . $icon . '" class="icon" alt="' . $icon . '" />'; $path = $browser->encodepath($CFG->wwwroot . '/pluginfile.php', '/' . $context->id . '/glossary_attachment/' . $entry->id . '/' . $filename); if ($type == 'html') { $output .= "<a href=\"{$path}\">{$iconimage}</a> "; $output .= "<a href=\"{$path}\">" . s($filename) . "</a>"; $output .= "<br />"; } else { if ($type == 'text') { $output .= "{$strattachment} " . s($filename) . ":\n{$path}\n"; } else { if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) { // Image attachments don't get printed as links $imagereturn .= "<br /><img src=\"{$path}\" alt=\"\" />"; } else { $output .= "<a href=\"{$path}\">{$iconimage}</a> "; $output .= filter_text("<a href=\"{$path}\">" . s($filename) . "</a>"); $output .= '<br />'; } } } } } if ($type) { return $output; } else { echo $output; return $imagereturn; } }
function CreateTopic($xanonpost, $subject, $comment, $pid, $sid, $host_name, $mode, $order, $thold, $posttype) { global $module_name, $user, $userinfo, $EditedMessage, $cookie, $AllowableHTML, $ultramode, $prefix, $anonpost, $articlecomm, $db; cookiedecode($user); $author = FixQuotes($author); $subject = FixQuotes(filter_text($subject, "nohtml")); $comment = format_url($comment); if ($posttype == "exttrans") { $comment = FixQuotes(nl2br(htmlspecialchars(check_words($comment)))); } elseif ($posttype == "plaintext") { $comment = FixQuotes(nl2br(filter_text($comment))); } else { $comment = FixQuotes(filter_text($comment)); } if (is_user($user)) { getusrinfo($user); } if (is_user($user) && !$xanonpost) { getusrinfo($user); $name = $userinfo[username]; $email = $userinfo[femail]; $url = $userinfo[user_website]; $score = 1; } else { $name = ""; $email = ""; $url = ""; $score = 0; } $ip = $_SERVER["REMOTE_HOST"]; if (empty($ip)) { $ip = $_SERVER["REMOTE_ADDR"]; } $fake = $db->sql_numrows($db->sql_query("SELECT * FROM " . $prefix . "_stories WHERE sid='{$sid}'")); $comment = trim($comment); $comment = stripslashes($comment); if ($fake == 1 and $articlecomm == 1) { if ($anonpost == 0 and is_user($user) or $anonpost == 1) { $db->sql_query("INSERT INTO " . $prefix . "_comments VALUES (NULL, '{$pid}', '{$sid}', now(), '{$name}', '{$email}', '{$url}', '{$ip}', '{$subject}', '{$comment}', '{$score}', '0')"); $db->sql_query("UPDATE " . $prefix . "_stories SET comments=comments+1 WHERE sid='{$sid}'"); update_points(5); if ($ultramode) { ultramode(); } } else { echo "Nice try..."; die; } } else { include "header.php"; echo "According to my records, the topic you are trying " . "to reply to does not exist. If you're just trying to be " . "annoying, well then too bad."; include "footer.php"; die; } if (isset($cookie[4])) { $options .= "&mode={$cookie['4']}"; } else { $options .= "&mode=thread"; } if (isset($cookie[5])) { $options .= "&order={$cookie['5']}"; } else { $options .= "&order=0"; } if (isset($cookie[6])) { $options .= "&thold={$cookie['6']}"; } else { $options .= "&thold=0"; } Header("Location: modules.php?name={$module_name}&file=article&sid={$sid}{$options}"); }
function submitStory($name, $address, $subject, $story, $storyext, $topic, $alanguage, $posttype) { global $user, $EditedMessage, $cookie, $anonymous, $notify, $notify_email, $notify_subject, $notify_message, $notify_from, $prefix, $db; if (is_user($user)) { cookiedecode($user); $uid = $cookie[0]; $name = $cookie[1]; } else { $uid = 1; $name = "{$anonymous}"; } $subject = ereg_replace("\"", "''", $subject); $subject = FixQuotes(filter_text($subject, "nohtml")); if ($posttype == "exttrans") { $story = FixQuotes(nl2br(htmlspecialchars(check_words($story)))); $storyext = FixQuotes(nl2br(htmlspecialchars(check_words($storyext)))); } elseif ($posttype == "plaintext") { $story = FixQuotes(nl2br(filter_text($story))); $storyext = FixQuotes(nl2br(filter_text($storyext))); } else { $story = FixQuotes(filter_text($story)); $storyext = FixQuotes(filter_text($storyext)); } $result = $db->sql_query("INSERT INTO " . $prefix . "_queue VALUES (NULL, '{$uid}', '{$name}', '{$subject}', '{$story}', '{$storyext}', now(), '{$topic}', '{$alanguage}')"); if (!$result) { echo "" . _ERROR . "<br>"; exit; } if ($notify) { $notify_message = "{$notify_message}\n\n\n========================================================\n{$subject}\n\n\n{$story}\n\n{$storyext}\n\n{$name}"; mail($notify_email, $notify_subject, $notify_message, "From: {$notify_from}\nX-Mailer: PHP/" . phpversion()); } include 'header.php'; OpenTable(); $waiting = $db->sql_numrows($db->sql_query("SELECT * FROM " . $prefix . "_queue")); echo "<center><font class=\"title\">" . _SUBSENT . "</font><br><br>" . "<font class=\"content\"><b>" . _THANKSSUB . "</b><br><br>" . "" . _SUBTEXT . "" . "<br>" . _WEHAVESUB . " {$waiting} " . _WAITING . ""; CloseTable(); include 'footer.php'; }
function saveuser($realname, $user_email, $femail, $user_website, $user_icq, $user_aim, $user_yim, $user_msnm, $user_from, $user_occ, $user_interests, $newsletter, $user_viewemail, $user_allow_viewonline, $user_notify, $user_notify_pm, $user_popup_pm, $user_attachsig, $user_allowbbcode, $user_allowhtml, $user_allowsmile, $user_timezone, $user_dateformat, $user_sig, $bio, $user_password, $vpass, $username, $user_id) { global $user, $cookie, $userinfo, $EditedMessage, $user_prefix, $db, $module_name, $minpass; $user_password = htmlspecialchars(stripslashes($user_password)); cookiedecode($user); $check = $cookie[1]; $check = filter($check, "nohtml", 1); $check2 = $cookie[2]; $sql = "SELECT user_id, user_password FROM " . $user_prefix . "_users WHERE username='******'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $vuid = intval($row['user_id']); $ccpass = filter($row['user_password'], "nohtml", 1); $ccpass = htmlspecialchars(stripslashes($ccpass)); $user_sig = filter($user_sig, "", 1); $user_email = filter($user_email, "nohtml", 1); $femail = filter($femail, "nohtml", 1); $user_website = filter($user_website, "nohtml", 1); $bio = filter($bio, "", 1); $user_icq = intval($user_icq); $user_aim = filter($user_aim, "nohtml", 1); $user_yim = filter($user_yim, "nohtml", 1); $user_msnm = filter($user_msnm, "nohtml", 1); $user_occ = filter($user_occ, "nohtml", 1); $user_from = filter($user_from, "nohtml", 1); $user_interests = filter($user_interests, "nohtml", 1); $realname = filter($realname, "nohtml", 1); $user_avatar = "{$user_avatar}"; if ($user_id == $vuid and $check2 == $ccpass) { if (!preg_match('#^http[s]?:\\/\\/#i', $user_website)) { $user_website = "http://" . $user_website; } if (!preg_match('#^http[s]?\\:\\/\\/[a-z0-9\\-]+\\.([a-z0-9\\-]+\\.)?[a-z]+#i', $user_website)) { $user_website = ''; } if (isset($user_password) && "{$user_password}" != "{$vpass}") { echo "<center>" . _PASSDIFFERENT . "</center>"; } elseif (!empty($user_password) && strlen($user_password) < $minpass) { echo "<center>" . _YOUPASSMUSTBE . " <b>{$minpass}</b> " . _CHARLONG . "</center>"; } else { if ($bio) { filter_text($bio); $bio = $EditedMessage; $bio = FixQuotes($bio); } if (!empty($user_password)) { cookiedecode($user); $db->sql_query("LOCK TABLES " . $user_prefix . "_users WRITE"); $user_password = md5($user_password); $newsletter = intval($newsletter); $user_allow_viewonline = intval($user_allow_viewonline); $user_notify = intval($user_notify); $user_notify_pm = intval($user_notify_pm); $user_popup_pm = intval($user_popup_pm); $user_allowbbcode = intval($user_allowbbcode); $user_allowhtml = intval($user_allowhtml); $user_allowsmile = intval($user_allowsmile); $user_id = intval($user_id); $db->sql_query("UPDATE " . $user_prefix . "_users SET name='{$realname}', user_email='{$user_email}', femail='{$femail}', user_website='{$user_website}', user_password='******', bio='{$bio}', user_icq='{$user_icq}', user_occ='{$user_occ}', user_from='{$user_from}', user_interests='{$user_interests}', user_sig='{$user_sig}', user_aim='{$user_aim}', user_yim='{$user_yim}', user_msnm='{$user_msnm}', newsletter='{$newsletter}', user_viewemail='{$user_viewemail}', user_allow_viewonline='{$user_allow_viewonline}', user_notify='{$user_notify}', user_notify_pm='{$user_notify_pm}', user_popup_pm='{$user_popup_pm}', user_attachsig='{$user_attachsig}', user_allowbbcode='{$user_allowbbcode}', user_allowhtml='{$user_allowhtml}', user_allowsmile='{$user_allowsmile}', user_timezone='{$user_timezone}', user_dateformat='{$user_dateformat}' WHERE user_id='{$user_id}'"); $sql = "SELECT user_id, username, user_password, storynum, umode, uorder, thold, noscore, ublockon, theme FROM " . $user_prefix . "_users WHERE username='******' AND user_password='******'"; $result = $db->sql_query($sql); if ($db->sql_numrows($result) == 1) { $userinfo = $db->sql_fetchrow($result); docookie($userinfo['user_id'], $userinfo['username'], $userinfo['user_password'], $userinfo['storynum'], $userinfo['umode'], $userinfo['uorder'], $userinfo['thold'], $userinfo['noscore'], $userinfo['ublockon'], $userinfo['theme'], $userinfo['commentmax']); } else { echo "<center>" . _SOMETHINGWRONG . "</center><br>"; } $db->sql_query("UNLOCK TABLES"); } else { $db->sql_query("UPDATE " . $user_prefix . "_users SET name='{$realname}', user_email='{$user_email}', femail='{$femail}', user_website='{$user_website}', bio='{$bio}', user_icq='{$user_icq}', user_occ='{$user_occ}', user_from='{$user_from}', user_interests='{$user_interests}', user_sig='{$user_sig}', user_aim='{$user_aim}', user_yim='{$user_yim}', user_msnm='{$user_msnm}', newsletter='{$newsletter}', user_viewemail='{$user_viewemail}', user_allow_viewonline='{$user_allow_viewonline}', user_notify='{$user_notify}', user_notify_pm='{$user_notify_pm}', user_popup_pm='{$user_popup_pm}', user_attachsig='{$user_attachsig}', user_allowbbcode='{$user_allowbbcode}', user_allowhtml='{$user_allowhtml}', user_allowsmile='{$user_allowsmile}', user_timezone='{$user_timezone}', user_dateformat='{$user_dateformat}' WHERE user_id='{$user_id}'"); } Header("Location: modules.php?name={$module_name}"); } } }
$exportBody = array(); $counter = 1; foreach ($products_array as $products) { $eb = array(); $eb[] = $products['products_id']; // adss the number under # column //$eb[]=($counter++)+(($currentPage-1)*$entriesPerPage); // adss the number under # column $eb[] = $products['products_name']; foreach ($fieldsArray as $key => $value) { if ($value['visible'] && $value['exportable']) { switch ($key) { case 'products_date_available': $eb[] = substr($products[$key], 0, -9); break; case 'products_description': $eb[] = filter_text(htmlspecialchars_decode($products[$key])); break; case 'products_sort_order': $eb[] = tep_not_null($products[$key]) ? $products[$key] : '0'; break; case 'products_status': $eb[] = $products[$key] ? 1 : 0; break; case 'tax_class_title': foreach ($tax_class_array as $tca) { if ($tca['id'] == $products['products_tax_class_id']) { $eb[] = $tca['title'] . ' ' . $tca['tax_rate'] . '%'; break; } } break;
function dg_tw_publish_tweet($tweet, $query = false) { global $dg_tw_queryes, $dg_tw_publish, $dg_tw_tags, $dg_tw_cats, $dg_tw_ft, $wpdb; $post_type = isset($dg_tw_ft['post_type']) ? $dg_tw_ft['post_type'] : 'post'; $dg_tw_start_post = get_default_post_to_edit($post_type, true); $username = dg_tw_tweet_user($tweet); $current_query = $query != false ? $query : array('tag' => '', 'value' => ''); $querystr = "SELECT *\r\n\t\t\t\t\tFROM {$wpdb->postmeta}\r\n\t\t\t\t\tWHERE (meta_key = 'dg_tw_id' AND meta_value = '" . (int) $tweet->id_str . "')\r\n\t\t\t\t\tGROUP BY post_id"; $postid = $wpdb->get_results($querystr); $author_tag = !empty($dg_tw_ft['authortag']) ? ',' . $username : ''; $post_tags = htmlspecialchars($dg_tw_tags . ',' . $current_query['tag'] . $author_tag); if (!count($postid)) { $tweet_content = dg_tw_regexText($tweet->text); $post_title = filter_text($tweet, $dg_tw_ft['title_format'], "", $dg_tw_ft['maxtitle'], $dg_tw_ft['title_remove_url']); $post_content = filter_text($tweet, $dg_tw_ft['body_format'], $tweet_content); do_action('dg_tw_before_images_placed'); if (strstr($post_content, '%tweet_images%') || $dg_tw_ft['featured_image']) { $images_list = dg_tw_put_attachments($dg_tw_start_post->ID, $tweet); if ($dg_tw_ft['featured_image']) { set_post_thumbnail($dg_tw_start_post->ID, end($images_list['ids'])); } $post_content = str_replace('%tweet_images%', $images_list['html'], $post_content); do_action('dg_tw_images_placed'); } $post = array('ID' => $dg_tw_start_post->ID, 'post_author' => $dg_tw_ft['author'], 'post_content' => $post_content, 'post_name' => dg_tw_slug($post_title), 'post_status' => strval($dg_tw_publish), 'post_title' => $post_title, 'post_category' => $dg_tw_cats, 'tags_input' => $post_tags, 'post_type' => $post_type, 'post_status' => strval($dg_tw_publish)); $post = apply_filters('dg_tw_before_post_tweet', $post); $dg_tw_this_post = wp_insert_post($post, true); do_action('dg_tw_after_post_published', $dg_tw_this_post); if ($dg_tw_this_post) { //Set the format of a post $format = isset($dg_tw_ft['format']) ? $dg_tw_ft['format'] : 'standard'; set_post_format($dg_tw_this_post, $format); /* POST METAS */ $query_string = urlencode($current_query['value']); $query_string = $query != false ? $query['value'] : $query_string; add_post_meta($dg_tw_this_post, 'dg_tw_query', $query_string); add_post_meta($dg_tw_this_post, 'dg_tw_id', $tweet->id_str); add_post_meta($dg_tw_this_post, 'dg_tw_author', $username); add_post_meta($dg_tw_this_post, 'dg_tw_author_avatar', $tweet->user->profile_image_url); /* END POST METAS */ } } else { return "already"; } return "true"; }
/** * Returns attachments as formated text/html optionally with separate images * @param object $post * @param object $cm * @param string type - html/text/separateimages * @return mixed string or array of (html text withouth images and image HTML) */ function forum_print_attachments($post, $cm, $type) { global $CFG, $DB, $USER; if (empty($post->attachment)) { return $type !== 'separateimages' ? '' : array('', ''); } if (!in_array($type, array('separateimages', 'html', 'text'))) { return $type !== 'separateimages' ? '' : array('', ''); } if (!($context = get_context_instance(CONTEXT_MODULE, $cm->id))) { return $type !== 'separateimages' ? '' : array('', ''); } $strattachment = get_string('attachment', 'forum'); $fs = get_file_storage(); $browser = get_file_browser(); $imagereturn = ''; $output = ''; $canexport = has_capability('mod/forum:exportpost', $context) || $post->userid == $USER->id && has_capability('mod/forum:exportownpost', $context); if ($files = $fs->get_area_files($context->id, 'forum_attachment', $post->id, "timemodified", false)) { $button = new portfolio_add_button(); foreach ($files as $file) { $filename = $file->get_filename(); $mimetype = $file->get_mimetype(); $icon = mimeinfo_from_type('icon', $mimetype); $iconimage = '<img src="' . $CFG->pixpath . '/f/' . $icon . '" class="icon" alt="' . $icon . '" />'; $path = $browser->encodepath($CFG->wwwroot . '/pluginfile.php', '/' . $context->id . '/forum_attachment/' . $post->id . '/' . $filename); if ($type == 'html') { $output .= "<a href=\"{$path}\">{$iconimage}</a> "; $output .= "<a href=\"{$path}\">" . s($filename) . "</a>"; if ($canexport) { $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id())); $button->set_formats(portfolio_format_from_file($file)); $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK); } $output .= "<br />"; } else { if ($type == 'text') { $output .= "{$strattachment} " . s($filename) . ":\n{$path}\n"; } else { //'returnimages' if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) { // Image attachments don't get printed as links $imagereturn .= "<br /><img src=\"{$path}\" alt=\"\" />"; if ($canexport) { $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id())); $button->set_formats(portfolio_format_from_file($file)); $imagereturn .= $button->to_html(PORTFOLIO_ADD_ICON_LINK); } } else { $output .= "<a href=\"{$path}\">{$iconimage}</a> "; $output .= filter_text("<a href=\"{$path}\">" . s($filename) . "</a>"); if ($canexport) { $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id())); $button->set_formats(portfolio_format_from_file($file)); $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK); } $output .= '<br />'; } } } } } if ($type !== 'separateimages') { return $output; } else { return array($output, $imagereturn); } }
/** * Given text in a variety of format codings, this function returns * the text as safe HTML. * * This function should mainly be used for long strings like posts, * answers, glossary items etc. For short strings @see format_string(). * * @uses $CFG * @uses FORMAT_MOODLE * @uses FORMAT_HTML * @uses FORMAT_PLAIN * @uses FORMAT_WIKI * @uses FORMAT_MARKDOWN * @param string $text The text to be formatted. This is raw text originally from user input. * @param int $format Identifier of the text format to be used * (FORMAT_MOODLE, FORMAT_HTML, FORMAT_PLAIN, FORMAT_WIKI, FORMAT_MARKDOWN) * @param array $options ? * @param int $courseid ? * @return string * @todo Finish documenting this function */ function format_text($text, $format = FORMAT_MOODLE, $options = NULL, $courseid = NULL) { global $CFG, $COURSE; static $croncache = array(); if ($text === '') { return ''; // no need to do any filters and cleaning } if (!isset($options->trusttext)) { $options->trusttext = false; } if (!isset($options->noclean)) { $options->noclean = false; } if (!isset($options->nocache)) { $options->nocache = false; } if (!isset($options->smiley)) { $options->smiley = true; } if (!isset($options->filter)) { $options->filter = true; } if (!isset($options->para)) { $options->para = true; } if (!isset($options->newlines)) { $options->newlines = true; } if (empty($courseid)) { $courseid = $COURSE->id; } if (!empty($CFG->cachetext) and empty($options->nocache)) { $time = time() - $CFG->cachetext; $md5key = md5($text . '-' . (int) $courseid . '-' . current_language() . '-' . (int) $format . (int) $options->trusttext . (int) $options->noclean . (int) $options->smiley . (int) $options->filter . (int) $options->para . (int) $options->newlines); if (defined('FULLME') and FULLME == 'cron') { if (isset($croncache[$md5key])) { return $croncache[$md5key]; } } if ($oldcacheitem = get_record_sql('SELECT * FROM ' . $CFG->prefix . 'cache_text WHERE md5key = \'' . $md5key . '\'', true)) { if ($oldcacheitem->timemodified >= $time) { if (defined('FULLME') and FULLME == 'cron') { if (count($croncache) > 150) { reset($croncache); $key = key($croncache); unset($croncache[$key]); } $croncache[$md5key] = $oldcacheitem->formattedtext; } return $oldcacheitem->formattedtext; } } } // trusttext overrides the noclean option! if ($options->trusttext) { if (trusttext_present($text)) { $text = trusttext_strip($text); if (!empty($CFG->enabletrusttext)) { $options->noclean = true; } else { $options->noclean = false; } } else { $options->noclean = false; } } else { if (!debugging('', DEBUG_DEVELOPER)) { // strip any forgotten trusttext in non-developer mode // do not forget to disable text cache when debugging trusttext!! $text = trusttext_strip($text); } } $CFG->currenttextiscacheable = true; // Default status - can be changed by any filter switch ($format) { case FORMAT_HTML: if ($options->smiley) { replace_smilies($text); } if (!$options->noclean) { $text = clean_text($text, FORMAT_HTML); } if ($options->filter) { $text = filter_text($text, $courseid); } break; case FORMAT_PLAIN: $text = s($text); // cleans dangerous JS $text = rebuildnolinktag($text); $text = str_replace(' ', ' ', $text); $text = nl2br($text); break; case FORMAT_WIKI: // this format is deprecated $text = '<p>NOTICE: Wiki-like formatting has been removed from Moodle. You should not be seeing this message as all texts should have been converted to Markdown format instead. Please post a bug report to http://moodle.org/bugs with information about where you saw this message.</p>' . s($text); break; case FORMAT_MARKDOWN: $text = markdown_to_html($text); if ($options->smiley) { replace_smilies($text); } if (!$options->noclean) { $text = clean_text($text, FORMAT_HTML); } if ($options->filter) { $text = filter_text($text, $courseid); } break; default: // FORMAT_MOODLE or anything else $text = text_to_html($text, $options->smiley, $options->para, $options->newlines); if (!$options->noclean) { $text = clean_text($text, FORMAT_HTML); } if ($options->filter) { $text = filter_text($text, $courseid); } break; } if (empty($options->nocache) and !empty($CFG->cachetext) and $CFG->currenttextiscacheable) { if (defined('FULLME') and FULLME == 'cron') { // special static cron cache - no need to store it in db if its not already there if (count($croncache) > 150) { reset($croncache); $key = key($croncache); unset($croncache[$key]); } $croncache[$md5key] = $text; return $text; } $newcacheitem = new object(); $newcacheitem->md5key = $md5key; $newcacheitem->formattedtext = addslashes($text); $newcacheitem->timemodified = time(); if ($oldcacheitem) { // See bug 4677 for discussion $newcacheitem->id = $oldcacheitem->id; @update_record('cache_text', $newcacheitem); // Update existing record in the cache table // It's unlikely that the cron cache cleaner could have // deleted this entry in the meantime, as it allows // some extra time to cover these cases. } else { @insert_record('cache_text', $newcacheitem); // Insert a new record in the cache table // Again, it's possible that another user has caused this // record to be created already in the time that it took // to traverse this function. That's OK too, as the // call above handles duplicate entries, and eventually // the cron cleaner will delete them. } } return $text; }
function broadcast($the_message, $who) { global $prefix, $db, $broadcast_msg, $module_name, $cookie, $user, $userinfo; cookiedecode($user); getusrinfo($user); if (is_user($user) and strtolower($who) == strtolower($cookie[1]) and strtolower($userinfo['username']) == strtolower($cookie[1]) and $userinfo['user_password'] == $cookie[2]) { $who = $cookie[1]; $the_message = htmlentities($the_message); if ($broadcast_msg == 1) { include "header.php"; title("" . _BROADCAST . ""); OpenTable(); $numrows = $db->sql_numrows($db->sql_query("SELECT * FROM " . $prefix . "_public_messages WHERE who='{$who}'")); $the_message = FixQuotes(filter_text($the_message, "nohtml")); if ($the_message != "" and $numrows == 0) { $the_time = time(); $who = htmlspecialchars(stripslashes($who)); $db->sql_query("INSERT INTO " . $prefix . "_public_messages VALUES (NULL, '{$the_message}', '{$the_time}', '{$who}')"); update_points(20); echo "<center>" . _BROADCASTSENT . "<br><br>[ <a href=\"modules.php?name={$module_name}\">" . _RETURNPAGE . "</a> ]</center>"; } else { echo "<center>" . _BROADCASTNOTSENT . "<br><br>[ <a href=\"modules.php?name={$module_name}\">" . _RETURNPAGE . "</a> ]</center>"; } CloseTable(); include "footer.php"; } else { echo "I don't like you..."; } } }
print_header(get_string("summaryof", "", $course->fullname)); print_heading(format_string($course->fullname) . '<br />(' . format_string($course->shortname) . ')'); if ($course->guest || $course->password) { print_box_start('generalbox icons'); if ($course->guest) { $strallowguests = get_string('allowguests'); echo "<div><img alt=\"\" class=\"icon guest\" src=\"{$CFG->pixpath}/i/guest.gif\" /> {$strallowguests}</div>"; } if ($course->password) { $strrequireskey = get_string('requireskey'); echo "<div><img alt=\"\" class=\"icon key\" src=\"{$CFG->pixpath}/i/key.gif\" /> {$strrequireskey}</div>"; } print_box_end(); } print_box_start('generalbox info'); echo filter_text(text_to_html($course->summary), $course->id); if ($managerroles = get_config('', 'coursemanager')) { $coursemanagerroles = split(',', $managerroles); foreach ($coursemanagerroles as $roleid) { $role = get_record('role', 'id', $roleid); $canseehidden = has_capability('moodle/role:viewhiddenassigns', $context); $roleid = (int) $roleid; if ($users = get_role_users($roleid, $context, true, '', 'u.lastname ASC', $canseehidden)) { foreach ($users as $teacher) { $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context)); $namesarray[] = format_string($role->name) . ': <a href="' . $CFG->wwwroot . '/user/view.php?id=' . $teacher->id . '&course=' . SITEID . '">' . $fullname . '</a>'; } } } if (!empty($namesarray)) { echo "<ul class=\"teachers\">\n<li>";
/** * Prints a section full of activity modules */ function course_section($course, $section, $parent, $mods) { global $CFG, $USER; $out = ''; $modinfo = unserialize($course->modinfo); if (!empty($section->sequence)) { $sectionmods = explode(",", $section->sequence); foreach ($sectionmods as $modnumber) { if (empty($mods[$modnumber])) { continue; } $mod = $mods[$modnumber]; // don't do anything invisible or labels if (!$mod->visible || $mod->modname == 'label') { continue; } $instancename = urldecode($modinfo[$modnumber]->name); if (!empty($CFG->filterall)) { $instancename = filter_text($instancename, $course->id); } if (!empty($modinfo[$modnumber]->extra)) { $extra = urldecode($modinfo[$modnumber]->extra); } else { $extra = ""; } if (trim($instancename) == '') { $instancename = $mod->modfullname; } $instancename = $this->truncate_html($instancename); $instancename = addslashes(htmlspecialchars($instancename, ENT_QUOTES)); $url = htmlspecialchars($CFG->wwwroot . "/mod/{$mod->modname}/view.php?id={$mod->id}"); $name = "yui_menu_mod_{$mod->modname}_{$modnumber}"; $style = "yui_menu_mod_{$mod->modname}"; $out .= "\nvar {$name} = new YAHOO.widget.TextNode('{$instancename}', {$parent}, false);\n{$name}.href = '{$url}';\n{$name}.labelStyle = '{$style}';"; if ($mod->modname == 'resource') { $info = resource_get_coursemodule_info($mod); if (isset($info) && isset($info->icon)) { $out .= "\n{$name}._yui_menu_icon = '{$CFG->pixpath}/{$info->icon}';"; } } } } return $out; }