require_once "/home/bkinney/includes/mysessions.php"; mysession_start(); include_once "/www/canvas/canvasapi.php"; if (array_key_exists('csv', $_REQUEST)) { //download header("content-disposition:attachment;filename=rubric_scores_" . $_REQUEST['aid'] . ".csv"); header("content-type:text/csv"); echo $_REQUEST['csv']; exit; } $token = $_SESSION['token']; $access_key = $_SESSION['token']; $domain = $_SESSION['_basic_lti_context']['custom_domain_url']; $api = new CanvasAPI($access_key, $domain); if (get_val($_GET, 'endpoint')) { $endpoint = str_replace('https://' . $domain, '', $_GET['endpoint']); //echo $endpoint; $queueStatus = $api->get_canvas($endpoint, false); echo '<p>status: ' . $queueStatus['workflow_state']; echo '</p><p>percent completed: ' . $queueStatus['completion'] . '</p>'; if ($queueStatus['completion'] * 1 < 100) { echo '<a href="#" onclick="$(\'#success\').load(\'putgrades-beta.php?endpoint=' . $endpoint . '\')">Check again</a>'; } exit; } $endpoint = '/api/v1/courses/' . $_SESSION['_basic_lti_context']['custom_canvas_course_id'] . '/assignments/' . $_POST['aid'] . '/submissions/update_grades?as_user_id=' . $_SESSION['_basic_lti_context']['custom_canvas_user_id']; $args = array(); foreach ($_POST['grades'] as $grade) { //grade //echo "Student,ID,SIS User ID,SIS Login ID,Section,peer" . $projectid . "\r\n";
function do_the_import_stuff($feed) { global $db, $dblang, $RSSImport; $RSSImport = new RSSImport(); $added_one = false; $url = $feed->feed_url; $rss = fetch_rss($url); if ($_GET['override'] == $feed->feed_id) { $canIhaveAccess = 0; $canIhaveAccess = $canIhaveAccess + checklevel('god'); if (!$canIhaveAccess == 1) { die('You are not authorized to override.'); } } $MyArray = array(); $Feed_Links = $RSSImport->get_feed_field_links($feed->feed_id); if (count($Feed_Links) > 0) { foreach ($Feed_Links as $link) { if ($link->pligg_field == 'link_title') { $MyArray['title'] = $link->feed_field; } if ($link->pligg_field == 'link_content') { $MyArray['content'] = $link->feed_field; } if ($link->pligg_field == 'link_url') { $MyArray['link_url'] = $link->feed_field; } if ($link->pligg_field == 'link_tags') { $MyArray['link_tags'] = $link->feed_field; } if ($link->pligg_field == 'link_field1') { $MyArray['link_field1'] = $link->feed_field; } if ($link->pligg_field == 'link_field2') { $MyArray['link_field2'] = $link->feed_field; } if ($link->pligg_field == 'link_field3') { $MyArray['link_field3'] = $link->feed_field; } if ($link->pligg_field == 'link_field4') { $MyArray['link_field4'] = $link->feed_field; } if ($link->pligg_field == 'link_field5') { $MyArray['link_field5'] = $link->feed_field; } if ($link->pligg_field == 'link_field6') { $MyArray['link_field6'] = $link->feed_field; } if ($link->pligg_field == 'link_field7') { $MyArray['link_field7'] = $link->feed_field; } if ($link->pligg_field == 'link_field8') { $MyArray['link_field8'] = $link->feed_field; } if ($link->pligg_field == 'link_field9') { $MyArray['link_field9'] = $link->feed_field; } if ($link->pligg_field == 'link_field10') { $MyArray['link_field10'] = $link->feed_field; } if ($link->pligg_field == 'link_field11') { $MyArray['link_field11'] = $link->feed_field; } if ($link->pligg_field == 'link_field12') { $MyArray['link_field12'] = $link->feed_field; } if ($link->pligg_field == 'link_field13') { $MyArray['link_field13'] = $link->feed_field; } if ($link->pligg_field == 'link_field14') { $MyArray['link_field14'] = $link->feed_field; } if ($link->pligg_field == 'link_field15') { $MyArray['link_field15'] = $link->feed_field; } } $thecount = 0; if ($feed->feed_last_item_first == 0) { $the_items = array_reverse($rss->items); } else { $the_items = $rss->items; } foreach ($the_items as $item) { echo "<strong>Title: " . get_val($item, $MyArray['title']) . "</strong><br/>"; echo "<strong>Content:</strong> " . strip_tags(substr(get_val($item, $MyArray['content']), 0, 256)) . "...<br>"; echo "<strong>URL:</strong> " . get_val($item, $MyArray['link_url']) . "<br/>"; $skipthis = 0; $linkres = new Link(); $linkres->randkey = rand(10000, 10000000); $linkres->status = $feed->feed_status; $linkres->author = $feed->feed_submitter; $linkres->title = get_val($item, $MyArray['title']); $linkres->title = strip_tags($linkres->title); $linkres->tags = get_val($item, $MyArray['link_tags']); // MJE: MOD to include title words as tags ---------------------------- if (trim($linkres->tags) == '') { $temp1 = strtolower($linkres->title); $stopwords = file(mnmpath . '/modules/rss_import/templates/stopwords.txt'); for ($zz = 0; $zz < count($stopwords); $zz++) { $pos = strpos($temp1, $stopwords[$zz] . ' '); if ($pos !== false && $pos == 0) { $temp1 = str_replace(trim($stopwords[$zz]) . ' ', ' ', $temp1); } $temp1 = str_replace(' ' . trim($stopwords[$zz]) . ' ', ' ', $temp1); } $pos = strpos($temp1, ' '); while ($pos !== false) { $temp1 = str_replace(' ', ' ', $temp1); $pos = strpos($temp1, ' '); } $temp1 = str_replace(' ', ", ", $temp1); // $out = ereg_replace("[^[:alpha:]]", "", $in); // strip all except letters and spaces and commas $linkres->tags = preg_replace('/[^a-z A-Z,]+/i', '', $temp1); } //---------------------------------------------------------------------- if (checklevel('god')) { $Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_God; } elseif (checklevel('admin')) { $Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_Admin; } else { $Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_Normal; } $linkres->title_url = makeUrlFriendly($linkres->title); $linkres->url = get_val($item, $MyArray['link_url']); $linkres->url_title = $linkres->title; $linkres->content = get_val($item, $MyArray['content']); $linkres->content = strip_tags($linkres->content, $Story_Content_Tags_To_Allow); $linkres->content = str_replace("\n", "<br />", $linkres->content); $linkres->link_field1 = get_val($item, $MyArray['link_field1']); $linkres->link_field2 = get_val($item, $MyArray['link_field2']); $linkres->link_field3 = get_val($item, $MyArray['link_field3']); $linkres->link_field4 = get_val($item, $MyArray['link_field4']); $linkres->link_field5 = get_val($item, $MyArray['link_field5']); $linkres->link_field6 = get_val($item, $MyArray['link_field6']); $linkres->link_field7 = get_val($item, $MyArray['link_field7']); $linkres->link_field8 = get_val($item, $MyArray['link_field8']); $linkres->link_field9 = get_val($item, $MyArray['link_field9']); $linkres->link_field10 = get_val($item, $MyArray['link_field10']); $linkres->link_field11 = get_val($item, $MyArray['link_field11']); $linkres->link_field12 = get_val($item, $MyArray['link_field12']); $linkres->link_field13 = get_val($item, $MyArray['link_field13']); $linkres->link_field14 = get_val($item, $MyArray['link_field14']); $linkres->link_field15 = get_val($item, $MyArray['link_field15']); $linkres->category = $feed->feed_category; //MJE: MOD $linkres->link_summary = utf8_substr(strip_tags($linkres->content), 0, StorySummary_ContentTruncate - 1); //--------- if ($thecount >= $feed->feed_item_limit && $skipthis == 0) { echo "Reached import limit, skipping<HR>"; $skipthis = 1; } if ($feed->feed_title_dupe == 0 && $skipthis == 0) { // 0 means don't allow, 1 means allow if ($linkres->duplicates_title($linkres->title) > 0) { //echo "Title Match, skipping: " . $linkres->title . "<HR>"; echo '<span style="color:#fc0000;">Title Match, skipping</span> <hr>'; $skipthis = 1; } } if ($feed->feed_url_dupe == 0 && $linkres->url != "" && $skipthis == 0) { // 0 means don't allow, 1 means allow if ($linkres->duplicates($linkres->url) > 0) { //echo "URL Match, skipping: " . $linkres->title . "<HR>"; echo '<span style="color:#fc0000;">URL Match, skipping</span> <hr>'; $skipthis = 1; } } if ($skipthis == 0) { echo "Importing <hr>"; $added_one = true; $linkres->store(); totals_adjust_count($linkres->status, 1); tags_insert_string($linkres->id, $dblang, $linkres->tags); require_once mnminclude . 'votes.php'; if ($feed->feed_random_vote_enable == 1) { $feed->feed_votes = rand($feed->feed_random_vote_min, $feed->feed_random_vote_max); } $votes = 0; for ($i = 1; $i <= $feed->feed_votes; $i++) { $value = 1; $vote = new Vote(); $vote->type = 'links'; $vote->user = 0; $vote->link = $linkres->id; $vote->ip = '0.0.0.' . $i; $vote->value = $value; $vote->insert(); $vote = ""; $votes += $value; // $vote = new Vote; // $vote->type='links'; // $vote->link=$linkres->id; } $linkres->votes = $votes; $linkres->store_basic(); $linkres->check_should_publish(); $thecount = $thecount + 1; } } $sql = "UPDATE `" . table_feeds . "` SET `feed_last_check` = FROM_UNIXTIME(" . (time() - 300) . ") WHERE `feed_id` = {$feed->feed_id};"; //echo $sql; $db->query($sql); } else { echo "Feed not fully setup, skipping <hr>"; } if ($added_one) { return true; } else { return false; } }
function panel_heading($name, $input, $methode, $default, $documentName) { //$obj, 'getLabel', 'Create new page')) $val = get_val($input, $methode, $name); if (!$val) { $val = '<i>' . $default . '</i>'; } return ' <h1 class="lead-heading">' . $documentName . ': ' . $val . '</h1> '; }
$linkres->content = str_replace("\n", "<br />", $linkres->content); $linkres->link_field1 = get_val($item, $MyArray['link_field1']); $linkres->link_field2 = get_val($item, $MyArray['link_field2']); $linkres->link_field3 = get_val($item, $MyArray['link_field3']); $linkres->link_field4 = get_val($item, $MyArray['link_field4']); $linkres->link_field5 = get_val($item, $MyArray['link_field5']); $linkres->link_field6 = get_val($item, $MyArray['link_field6']); $linkres->link_field7 = get_val($item, $MyArray['link_field7']); $linkres->link_field8 = get_val($item, $MyArray['link_field8']); $linkres->link_field9 = get_val($item, $MyArray['link_field9']); $linkres->link_field10 = get_val($item, $MyArray['link_field10']); $linkres->link_field11 = get_val($item, $MyArray['link_field11']); $linkres->link_field12 = get_val($item, $MyArray['link_field12']); $linkres->link_field13 = get_val($item, $MyArray['link_field13']); $linkres->link_field14 = get_val($item, $MyArray['link_field14']); $linkres->link_field15 = get_val($item, $MyArray['link_field15']); $linkres->category = $feed->feed_category; $linkres->link_summary = utf8_substr($linkres->content, 0, StorySummary_ContentTruncate - 1); if ($thecount >= $feed->feed_item_limit && $skipthis == 0) { echo "Reached import limit, skipping<HR>"; $skipthis = 1; } if ($feed->feed_title_dupe == 0 && $skipthis == 0) { // 0 means don't allow, 1 means allow if ($linkres->duplicates_title($linkres->title) > 0) { echo "Title Match, skipping: " . $linkres->title . "<HR>"; $skipthis = 1; } } if ($feed->feed_url_dupe == 0 && $linkres->url != "" && $skipthis == 0) { // 0 means don't allow, 1 means allow
function contentflexfilelist($file = '', $tpl_head = '', $tpl_dir_start = '', $tpl_row = '', $tpl_between_row = '', $tpl_dir_end = '', $tpl_foot = '', $frontendsubfolders = 'false', $modconfsubfolders = 'true', $modconfavailfolders = '', $modconfavailfiletypes = '', $modconftplbetweenrowcounter = '1', $modconftplbetweenrowcounterreset = '', $modconfdirtplon1stlevel = 'true', $modconflabelselection = '', $modconflabelsubfolders = '', $modconfslashreplacement = '/', $modconfdatetimeformat = 'Y-m-d', $modconfcomplfolderstring = 'true', $modconftreemode = 'false', $modconffiletypeiconpath = '', $modconfselectmode = '', $modconflistselectedfile = 'true', $modconfselectrights = '', $modconffilelimit = '', $modconffilesort = 'filename > ASC', $modv) { global $db; $cfg = sf_api('LIB', 'Config'); $modinfo = sf_api('LIB', 'Modinfo'); $req = sf_api('LIB', 'WebRequest'); $pi = sf_api('LIB', 'Pageinfos'); $idcatside = $cfg->env('idcatside'); $lang = $cfg->env('idlang'); $client = $cfg->env('idclient'); $view = $cfg->env('view'); $sess = $cfg->sess(); $modconffilelimit = (int) $modconffilelimit; $modconftplbetweenrowcounter = (int) $modconftplbetweenrowcounter; // // sorting preperation // if (empty($modconffilesort)) { $modconffilesort = 'filename > ASC'; } $filelist_filesort['array'] = array(); $filelist_filesort['raw'] = trim(str_replace(' > ', '>', $modconffilesort)); $filelist_filesort['raw_vals'] = explode("\n", $filelist_filesort['raw']); foreach ($filelist_filesort['raw_vals'] as $v) { $filelist_filesort['sorting_pieces'] = explode('>', trim($v)); $filelist_filesort['array'][] = $filelist_filesort['sorting_pieces']['0'] . ' ' . $filelist_filesort['sorting_pieces']['1']; } // get content id $sql = "SELECT\r\n\t\t\t\t\tidcontent\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . $cfg->db('content') . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tidsidelang='" . $pi->getIdsidelang($idcatside) . "'\r\n\t\t\t\t\tAND container='" . $modinfo->getIdContainer() . "'\r\n\t\t\t\t\tAND number='" . $modinfo->getEntryNr() . "'"; $db->query($sql); $db->next_record(); $entry_content_id = "id" . $db->f('idcontent'); $filelist_output = ''; if ($modconfselectmode == 'fsb') { $file = ''; $mod['cf_fl_dir'] = get_val('cf_fl_folder_' . $entry_content_id); $mod['cf_fl_subdirs'] = get_val('cf_fl_show_subfolders_' . $entry_content_id); if ($modconfsubfolders != 'true') { $mod['cf_fl_subdirs'] = 0; } } $filelist_dirs_all = array(); $sql = "SELECT \r\n\t\t\t\t\t*\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . $cfg->db('directory') . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tidclient=" . $client . "\r\n\t\t\t\t\tAND status=0 "; $db->query($sql); while ($db->next_record()) { $filelist_dirs_all[$db->f('iddirectory')] = $db->f('dirname'); } if (!empty($file) && $modconfselectmode == 'rb') { $selected_file = basename($file); } // get base-path if (!empty($file)) { $filelist_path = str_replace($cfg->env('path_frontend_fm'), '', dirname($file)) . "/"; } if (empty($file) || $modconfselectmode == 'fsb') { $sql = "SELECT * FROM " . $cfg->db('directory') . " WHERE idclient=" . $client . " AND status=0 "; } elseif ($frontendsubfolders == "true") { $sql = "SELECT * FROM " . $cfg->db('directory') . " WHERE idclient=" . $client . " AND dirname like '{$filelist_path}%' AND status=0 "; } else { $sql = "SELECT * FROM " . $cfg->db('directory') . " WHERE idclient=" . $client . " AND dirname like '{$filelist_path}' AND status=0 "; } // filter modulconfig selected pathes if ($modconfavailfolders != '' && $modconfavailfolders != 'true') { $thisdirsonly = array(); $thisdirsonly = explode(',', $modconfavailfolders); $sql_addondirs = array(); foreach ($thisdirsonly as $k => $v) { $sql_addondirs[] = " dirname like '" . $filelist_dirs_all[$v] . ($modconfsubfolders == 'true' ? '%' : '') . "' "; } $sql_addon = implode('OR', $sql_addondirs); } else { $sql_addon = ''; } // get dir(s) $filelist_dirs = array(); // filter modulconfig selected pathes if (!empty($sql_addon)) { $sql .= " AND (" . $sql_addon . ")"; } $db->query($sql); while ($db->next_record()) { $filelist_dirs[$db->f('iddirectory')] = $db->f('dirname'); } natsort($filelist_dirs); // frontendselectbox if ($modconfselectmode == 'fsb') { if ($sess->name == 'sefrengo' && $view == 'edit' && _type_check_editable($modconfselectrights)) { $cf_fl_subdirs = $req->post($entry_content_id . 'cf_fl_subdirs'); $cf_fl_dir = $req->post($entry_content_id . 'cf_fl_dir'); if ($cf_fl_dir != '' && $mod['cf_fl_dir'] != $cf_fl_dir) { set_val('cf_fl_folder_' . $entry_content_id, $cf_fl_dir); $mod['cf_fl_dir'] = $cf_fl_dir; } if ($req->post($entry_content_id . 'cf_fl_dir') != '' && !$cf_fl_subdirs && $mod['cf_fl_subdirs'] != 0) { set_val('cf_fl_show_subfolders_' . $entry_content_id, 0); $mod['cf_fl_subdirs'] = 0; } else { if ($req->post($entry_content_id . 'cf_fl_dir') != '' && $cf_fl_subdirs != '' && $mod['cf_fl_subdirs'] != 1) { set_val('cf_fl_show_subfolders_' . $entry_content_id, 1); $mod['cf_fl_subdirs'] = 1; } } // form $fsb_out = "\n" . '<form style="font-size:8pt;" class="contentflex_fl_form" method="post" name="' . $entry_content_id . '" action="' . $con_side[$idcatside]['link'] . '">' . "\n"; $fsb_out .= '<label class="contentflex_fl_select_label" for="' . $entry_content_id . 'cf_fl_dir">' . $modconflabelselection . '</label>' . "\n" . ' <select id="' . $entry_content_id . 'cf_fl_dir" class="contentflex_fl_select" name="' . $entry_content_id . 'cf_fl_dir" size="1" onchange="document.' . $entry_content_id . '.submit();">' . "\n"; if ($mod['cf_fl_dir'] == '0') { $fsb_out .= '<option value="0" selected>----------------</option>' . "\n"; } else { $fsb_out .= '<option value="0">----------------</option>' . "\n"; } foreach ($filelist_dirs as $k => $v) { if ($v == $mod['cf_fl_dir']) { $fsb_out .= '<option value="' . $v . '" selected>' . htmlentities($v, ENT_COMPAT, 'UTF-8') . '</option>' . "\n"; } else { $fsb_out .= '<option value="' . $v . '">' . htmlentities($v, ENT_COMPAT, 'UTF-8') . '</option>' . "\n"; } } $fsb_out .= '</select>' . "\n"; if ($modconfsubfolders == 'true') { $fsb_out .= '<input id="' . $entry_content_id . 'cf_fl_subdirs" class="contentflex_fl_checkbox" type="checkbox" name="' . $entry_content_id . 'cf_fl_subdirs" value="checkbox" ' . ($mod['cf_fl_subdirs'] == 1 ? 'checked="checked"' : '') . ' onclick="document.' . $entry_content_id . '.submit();"/>' . "\n" . '<label class="contentflex_fl_checkbox_label" for="' . $entry_content_id . 'cf_fl_subdirs">' . $modconflabelsubfolders . '</label>' . "\n"; } $fsb_out .= '</form>' . "\n"; } } if (empty($mod['cf_fl_dir']) && $modconfselectmode == 'fsb') { return $fsb_out; } elseif (empty($file) && $modconfselectmode != 'fsb') { return; } // get files if (!empty($filelist_dirs)) { if (count($filelist_dirs) > 0) { $sql_addon = " U.iddirectory IN (" . implode(',', array_keys($filelist_dirs)) . ")"; } $sql = "SELECT\r\n U.*,\r\n UNIX_TIMESTAMP(U.lastmodified) AS lastmodified,\r\n UNIX_TIMESTAMP(U.created) AS created,\r\n UL.*\r\n FROM\r\n " . $cfg->db('upl') . " U\r\n LEFT JOIN\r\n " . $cfg->db('upl_lang') . " UL\r\n USING(idupl)\r\n WHERE " . $sql_addon . "\r\n ORDER BY\r\n " . implode(',', $filelist_filesort['array']); $db->query($sql); while ($db->next_record()) { $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['filename'] = $db->f('filename'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['title'] = $db->f('title'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['description'] = $db->f('description'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['filesize'] = $db->f('filesize'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['pictwidth'] = $db->f('pictwidth'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['pictheight'] = $db->f('pictheight'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['pictthumbwidth'] = $db->f('pictthumbwidth'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['pictthumbheight'] = $db->f('pictthumbheight'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['iddirectory'] = $db->f('iddirectory'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['idfiletype'] = $db->f('idfiletype'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['idfile'] = $db->f('idupl'); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['created'] = date($modconfdatetimeformat, $db->f('created')); $filelist_files[$db->f('iddirectory')][$db->f('idupl')]['lastmodified'] = date($modconfdatetimeformat, $db->f('lastmodified')); } // get filetypes $sql = "SELECT * FROM " . $cfg->db('filetype'); $db->query($sql); $filelist_filetypes = array(); while ($db->next_record()) { $filelist_filetypes[$db->f('idfiletype')]['filetype'] = $db->f('filetype'); $filelist_filetypes[$db->f('idfiletype')]['filetypepict'] = $db->f('filetypepict'); $filelist_filetypes[$db->f('idfiletype')]['filetypedesc'] = $db->f('description'); $filelist_filetypes[$db->f('idfiletype')]['filemimetype'] = $db->f('mimetype'); } // ouput creation $filelist_output = $fsb_out . $tpl_head; $tpl_dir_end_collected = ''; $dir_count = 0; $file_count = 0; $filelist_dir_level_mem = 0; $all_count = 0; $all_file_count = 0; $dirname_mem = ''; $new_dir_name = ''; if (strpos($modconfavailfiletypes, ',') !== false) { $filetypes = explode(',', strtolower($modconfavailfiletypes)); } // list creation foreach ($filelist_dirs as $k => $v) { // filtering if (strpos($v, $mod['cf_fl_dir']) !== false && $modconfselectmode == 'fsb' && $mod['cf_fl_subdirs'] == 1 || $modconfselectmode == 'fsb' && $mod['cf_fl_subdirs'] == 0 && strpos($v, $mod['cf_fl_dir']) !== false && strlen($v) == strlen($mod['cf_fl_dir']) || !empty($file)) { $dir_count++; $all_count++; if ($dir_count > 1 || $modconfdirtplon1stlevel != 'false') { $tpl_dir_output = str_replace('{dir_no}', $dir_count, $tpl_dir_start); $tpl_dir_output = str_replace('{all_no}', $all_count, $tpl_dir_output); if ($modconfcomplfolderstring == "false" && substr_count($filelist_dirs[$k], '/') > 1) { $new_dir_name = substr(strrchr(substr($filelist_dirs[$k], 0, -1), "/"), 1) . '/'; } else { $new_dir_name = $filelist_dirs[$k]; } $filelist_output .= str_replace('{dirname}', str_replace('/', $modv['MOD_VALUE_2005'], $new_dir_name), $tpl_dir_output); } if (is_array($filelist_files[$k])) { foreach ($filelist_files[$k] as $v1) { $mod['thumbfile_ext'] = substr(strrchr($v1['filename'], "."), 1); if ((strpos($modconfavailfiletypes, strtolower($mod['thumbfile_ext'])) !== false || $modconfavailfiletypes == "true" || empty($modconfavailfiletypes)) && ($modconfselectmode != 'rb' || $modconflistselectedfile != 'false' || $modconflistselectedfile == 'false' && strpos($v1['filename'], $selected_file) === false)) { $file_count++; $all_file_count++; $all_count++; if ($all_file_count <= $modconffilelimit || $modconffilelimit == 0) { $filelist_output_row = $tpl_row; $filelist_output_row_array = array(); $filelist_output_row_array['all_no'] = $all_count; $filelist_output_row_array['file_no'] = $file_count; $filelist_output_row_array['file_no_rev'] = count($filelist_files[$k]) - $file_count; $filelist_output_row_array['all_file_no'] = $all_file_count; $filelist_output_row_array['dir_no'] = $dir_count; $filelist_output_row_array['dirname'] = str_replace($dirname_mem, '', str_replace('/', $modv['MOD_VALUE_2005'], $new_dir_name)); $filelist_output_row_array['filepath'] = $cfg->env('path_frontend_fm_http') . $filelist_dirs[$k]; $filelist_output_row_array['filename'] = $v1['filename']; $filelist_output_row_array['fileurl'] = 'cms://idfile=' . $v1['idfile']; $filelist_output_row_array['file'] = '<a href="cms://idfile=' . $v1['idfile'] . '">cms://idfile=' . $v1['idfile'] . '</a>'; $filelist_output_row_array['filefmtitle'] = $v1['title']; $filelist_output_row_array['filefmdesc'] = $v1['description']; $filelist_output_row_array['filecreated'] = $v1['created']; $filelist_output_row_array['filemodified'] = $v1['lastmodified']; // filesize if ($v1['filesize'] > 1048576) { $v1['filesize'] = sprintf("%01." . $modv['val_fsplaces'] . "f", $v1['filesize'] / 1048576) . ' ' . $modv['str_megabyte']; } else { $v1['filesize'] = $v1['filesize'] > 1024 ? sprintf("%01." . $modv['val_fsplaces'] . "f", $v1['filesize'] / 1024) . ' ' . $modv['str_kilobyte'] : $v1['filesize'] . ' ' . $modv['str_byte']; } $filelist_output_row_array['filesize'] = $v1['filesize']; //thumburl $mod['thumbfile'] = substr($v1['filename'], 0, -strlen($mod['thumbfile_ext']) - 1) . $cfg->client('thumbext') . '.' . $mod["thumbfile_ext"]; $filelist_output_row_array['imagethumb'] = '<img src="' . $cfg->env('path_frontend_fm_http') . $filelist_dirs[$k] . $mod['thumbfile'] . '" height="' . $v1['pictthumbheight'] . '" width="' . $v1['pictthumbwidth'] . '"/>'; $filelist_output_row_array['imagethumburl'] = $cfg->env('path_frontend_fm_http') . $filelist_dirs[$k] . $mod['thumbfile']; $filelist_output_row_array['imagewidth'] = $v1['pictwidth']; $filelist_output_row_array['imageheight'] = $v1['pictheight']; $filelist_output_row_array['imagethumbwidth'] = $v1['pictthumbwidth']; $filelist_output_row_array['imagethumbheight'] = $v1['pictthumbheight']; $filelist_output_row_array['imagethumbhalfwidth'] = round($v1['pictthumbwidth'] / 2); $filelist_output_row_array['imagethumbhalfheight'] = round($v1['pictthumbheight'] / 2); $filelist_output_row_array['iddirectory'] = $v1['iddirectory']; $filelist_output_row_array['filetypeicon'] = '<img src="' . $modconffiletypeiconpath . $filelist_filetypes[$v1['idfiletype']]['filetypepict'] . '" alt=""/>'; $filelist_output_row_array['filetypeiconurl'] = $modconffiletypeiconpath . $filelist_filetypes[$v1['idfiletype']]['filetypepict']; $filelist_output_row_array['filetype'] = $filelist_filetypes[$v1['idfiletype']]['filetype']; $filelist_output_row_array['filetypeiconname'] = $filelist_filetypes[$v1['idfiletype']]['filetypepict']; $filelist_output_row_array['filetypedesc'] = $filelist_filetypes[$v1['idfiletype']]['filetypedesc']; $filelist_output_row_array['filemimetype'] = $filelist_filetypes[$v1['idfiletype']]['filemimetype']; foreach ($filelist_output_row_array as $k2 => $v2) { // global if-statement if (strpos($filelist_output_row, '{if_' . $k2 . '}') !== false) { if (empty($v2)) { $filelist_output_row = preg_replace('#\\{if_' . $k2 . '\\}(.*)\\{/if_' . $k2 . '\\}#sU', '', $filelist_output_row); } else { $filelist_output_row = str_replace(array('{if_' . $k2 . '}', '{/if_' . $k2 . '}'), array('', ''), $filelist_output_row); } } // global if-not-statement if (strpos($filelist_output_row, '{if_not_' . $k2 . '}') !== false) { if (empty($v2)) { $filelist_output_row = str_replace(array('{if_not_' . $k2 . '}', '{/if_not_' . $k2 . '}'), array('', ''), $filelist_output_row); } else { $filelist_output_row = preg_replace('#\\{if_not_' . $k2 . '\\}(.*)\\{/if_not_' . $k2 . '\\}#sU', '', $filelist_output_row); } } // global if-statement if (strpos($filelist_output_row, '{if_' . $k2 . '=') !== false) { preg_match_all('/\\{if_' . $k2 . '=(.*?)\\}/', $filelist_output_row, $modv['temp_results']); foreach ($modv['temp_results'][0] as $ek => $ev) { if ($v2 != $modv['temp_results'][1][$ek]) { $filelist_output_row = preg_replace('#\\{if_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '\\}(.*)\\{/if_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '\\}#sU', '', $filelist_output_row); } else { $filelist_output_row = str_replace(array('{if_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '}', '{/if_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '}'), array('', ''), $filelist_output_row); } } } // global if-not-statement if (strpos($filelist_output_row, '{if_not_' . $k2 . '=') !== false) { preg_match_all('/\\{if_not_' . $k2 . '=(.*?)\\}/', $filelist_output_row, $modv['temp_results']); foreach ($modv['temp_results'][0] as $ek => $ev) { if ($v2 != $modv['temp_results'][1][$ek]) { $filelist_output_row = str_replace(array('{if_not_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '}', '{/if_not_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '}'), array('', ''), $filelist_output_row); } else { $filelist_output_row = preg_replace('#\\{if_not_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '\\}(.*)\\{/if_not_' . $k2 . '=' . $modv['temp_results'][1][$ek] . '\\}#sU', '', $filelist_output_row); } } } $filelist_output_row = str_replace('{' . $k2 . '}', $v2, $filelist_output_row); } $filelist_output .= $filelist_output_row; if ($modconftplbetweenrowcounter > 0) { if ($modconftplbetweenrowcounterreset == 1) { if ($file_count % $modconftplbetweenrowcounter == 0) { $filelist_output .= $tpl_between_row; } } else { if ($all_file_count % $modconftplbetweenrowcounter == 0) { $filelist_output .= $tpl_between_row; } } } } } } } $filelist_output = str_replace('{file_count}', $file_count, $filelist_output); $file_count = 0; // tree mode? if ($dir_count > ($modconftreemode == 'false' ? 1 : 0) || $modconfdirtplon1stlevel != 'false') { if ($modconftreemode != "false") { if (substr_count($filelist_dirs[$k], '/') - $filelist_dir_level_mem != 0 && $filelist_dir_level_mem != 0) { $filelist_output .= $tpl_dir_end; } else { $tpl_dir_end_collected .= $tpl_dir_end; } } else { $filelist_output .= $tpl_dir_end; } $filelist_dir_level_mem = substr_count($filelist_dirs[$k], '/'); } unset($mod['thumbfile_ext'], $mod['thumbfile']); } } $filelist_output .= $tpl_dir_end_collected; $filelist_output .= $tpl_foot; } return $filelist_output; }
<html> <head> <meta charset="utf-8"/> <?php $val = get_val("input", 0); $unit = get_val("unit", "sec"); function get_val($pname, $defVal) { global $_POST; if (array_key_exists($pname, $_POST)) { return $_POST[$pname]; } return $defVal; } ?> </head> <body> <h3>时间可读化工具</h3> <form method="POST"> 输入:<input type="text" name="input" value="<?php echo $val; ?> " placeholder="<?php echo "最大值" . PHP_INT_MAX; ?> " /> <select name="unit"> <?php $timeArray = array("milli" => "毫秒", "sec" => "秒", "min" => "分钟", "hour" => "小时");