当前位置: 首页>>代码示例>>PHP>>正文


PHP clean_filename函数代码示例

本文整理汇总了PHP中clean_filename函数的典型用法代码示例。如果您正苦于以下问题:PHP clean_filename函数的具体用法?PHP clean_filename怎么用?PHP clean_filename使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了clean_filename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rm

 function rm($name = '')
 {
     $clear = false;
     if ($name) {
         $this->cur_query = "cache->rm('{$name}')";
         $this->debug('start');
         $filename = $this->dir . clean_filename($this->prefix . $name) . '.php';
         if (file_exists($filename)) {
             $clear = (bool) unlink($filename);
         }
         $this->debug('stop');
         $this->cur_query = null;
         $this->num_queries++;
     } else {
         if (is_dir($this->dir)) {
             if ($dh = opendir($this->dir)) {
                 while (($file = readdir($dh)) !== false) {
                     if ($file != "." && $file != "..") {
                         $filename = $this->dir . $file;
                         unlink($filename);
                         $clear = true;
                     }
                 }
                 closedir($dh);
             }
         }
     }
     return $clear;
 }
开发者ID:forummaks,项目名称:forum_maks,代码行数:29,代码来源:file.php

示例2: print_grades

 public function print_grades()
 {
     global $CFG;
     $export_tracking = $this->track_exports();
     $strgrades = get_string('grades');
     switch ($this->separator) {
         case 'comma':
             $separator = ",";
             break;
         case 'tab':
         default:
             $separator = "\t";
     }
     /// Print header to force download
     if (strpos($CFG->wwwroot, 'https://') === 0) {
         //https sites - watch out for IE! KB812935 and KB316431
         @header('Cache-Control: max-age=10');
         @header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
         @header('Pragma: ');
     } else {
         //normal http - prevent caching at all cost
         @header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
         @header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
         @header('Pragma: no-cache');
     }
     header("Content-Type: application/download\n");
     $downloadfilename = clean_filename("{$this->course->shortname} {$strgrades}");
     header("Content-Disposition: attachment; filename=\"{$downloadfilename}.txt\"");
     /// Print names of all the fields
     echo get_string("firstname") . $separator . get_string("lastname") . $separator . get_string("idnumber") . $separator . get_string("institution") . $separator . get_string("department") . $separator . get_string("email");
     foreach ($this->columns as $grade_item) {
         echo $separator . $this->format_column_name($grade_item);
         /// add a feedback column
         if ($this->export_feedback) {
             echo $separator . $this->format_column_name($grade_item, true);
         }
     }
     echo "\n";
     /// Print all the lines of data.
     $geub = new grade_export_update_buffer();
     $gui = new graded_users_iterator($this->course, $this->columns, $this->groupid);
     $gui->init();
     while ($userdata = $gui->next_user()) {
         $user = $userdata->user;
         echo $user->firstname . $separator . $user->lastname . $separator . $user->idnumber . $separator . $user->institution . $separator . $user->department . $separator . $user->email;
         foreach ($userdata->grades as $itemid => $grade) {
             if ($export_tracking) {
                 $status = $geub->track($grade);
             }
             echo $separator . $this->format_grade($grade);
             if ($this->export_feedback) {
                 echo $separator . $this->format_feedback($userdata->feedbacks[$itemid]);
             }
         }
         echo "\n";
     }
     $gui->close();
     $geub->close();
     exit;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:60,代码来源:grade_export_txt.php

示例3: print_grades

 public function print_grades()
 {
     global $CFG;
     $export_tracking = $this->track_exports();
     $strgrades = get_string('grades');
     $profilefields = grade_helper::get_user_profile_fields($this->course->id, $this->usercustomfields);
     $shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id)));
     $downloadfilename = clean_filename("{$shortname} {$strgrades}");
     $csvexport = new csv_export_writer($this->separator);
     $csvexport->set_filename($downloadfilename);
     // Print names of all the fields
     $exporttitle = array();
     foreach ($profilefields as $field) {
         $exporttitle[] = $field->fullname;
     }
     if (!$this->onlyactive) {
         $exporttitle[] = get_string("suspended");
     }
     // Add a feedback column.
     foreach ($this->columns as $grade_item) {
         $exporttitle[] = $this->format_column_name($grade_item);
         if ($this->export_feedback) {
             $exporttitle[] = $this->format_column_name($grade_item, true);
         }
     }
     $csvexport->add_data($exporttitle);
     // Print all the lines of data.
     $geub = new grade_export_update_buffer();
     $gui = new graded_users_iterator($this->course, $this->columns, $this->groupid);
     $gui->require_active_enrolment($this->onlyactive);
     $gui->allow_user_custom_fields($this->usercustomfields);
     $gui->init();
     while ($userdata = $gui->next_user()) {
         $exportdata = array();
         $user = $userdata->user;
         foreach ($profilefields as $field) {
             $fieldvalue = grade_helper::get_user_field_value($user, $field);
             $exportdata[] = $fieldvalue;
         }
         if (!$this->onlyactive) {
             $issuspended = $user->suspendedenrolment ? get_string('yes') : '';
             $exportdata[] = $issuspended;
         }
         foreach ($userdata->grades as $itemid => $grade) {
             if ($export_tracking) {
                 $status = $geub->track($grade);
             }
             $exportdata[] = $this->format_grade($grade);
             if ($this->export_feedback) {
                 $exportdata[] = $this->format_feedback($userdata->feedbacks[$itemid]);
             }
         }
         $csvexport->add_data($exportdata);
     }
     $gui->close();
     $geub->close();
     $csvexport->download_file();
     exit;
 }
开发者ID:abhilash1994,项目名称:moodle,代码行数:59,代码来源:grade_export_txt.php

示例4: msg_die

function msg_die($msg)
{
    if (DBG_LOG) {
        dbg_log(' ', '!die-' . clean_filename($msg));
    }
    $output = bencode(array('min interval' => (int) 1800, 'failure reason' => (string) $msg, 'warning message' => (string) $msg));
    die($output);
}
开发者ID:ErR163,项目名称:torrentpier,代码行数:8,代码来源:scrape.php

示例5: send_message

 /**
  * Processes the message (sends by email).
  * @param object $eventdata the event data submitted by the message sender plus $eventdata->savedmessageid
  */
 function send_message($eventdata)
 {
     global $CFG;
     // Ignore $CFG->noemailever here because we want to test this code,
     // the message sending fails later in email_to_user().
     // skip any messaging suspended and deleted users
     if ($eventdata->userto->auth === 'nologin' or $eventdata->userto->suspended or $eventdata->userto->deleted) {
         return true;
     }
     //the user the email is going to
     $recipient = null;
     //check if the recipient has a different email address specified in their messaging preferences Vs their user profile
     $emailmessagingpreference = get_user_preferences('message_processor_email_email', null, $eventdata->userto);
     $emailmessagingpreference = clean_param($emailmessagingpreference, PARAM_EMAIL);
     // If the recipient has set an email address in their preferences use that instead of the one in their profile
     // but only if overriding the notification email address is allowed
     if (!empty($emailmessagingpreference) && !empty($CFG->messagingallowemailoverride)) {
         //clone to avoid altering the actual user object
         $recipient = clone $eventdata->userto;
         $recipient->email = $emailmessagingpreference;
     } else {
         $recipient = $eventdata->userto;
     }
     // Check if we have attachments to send.
     $attachment = '';
     $attachname = '';
     if (!empty($CFG->allowattachments) && !empty($eventdata->attachment)) {
         if (empty($eventdata->attachname)) {
             // Attachment needs a file name.
             debugging('Attachments should have a file name. No attachments have been sent.', DEBUG_DEVELOPER);
         } else {
             if (!$eventdata->attachment instanceof stored_file) {
                 // Attachment should be of a type stored_file.
                 debugging('Attachments should be of type stored_file. No attachments have been sent.', DEBUG_DEVELOPER);
             } else {
                 // Copy attachment file to a temporary directory and get the file path.
                 $attachment = $eventdata->attachment->copy_content_to_temp();
                 // Get attachment file name.
                 $attachname = clean_filename($eventdata->attachname);
             }
         }
     }
     // Configure mail replies - this is used for incoming mail replies.
     $replyto = '';
     $replytoname = '';
     if (isset($eventdata->replyto)) {
         $replyto = $eventdata->replyto;
         if (isset($eventdata->replytoname)) {
             $replytoname = $eventdata->replytoname;
         }
     }
     $result = email_to_user($recipient, $eventdata->userfrom, $eventdata->subject, $eventdata->fullmessage, $eventdata->fullmessagehtml, $attachment, $attachname, true, $replyto, $replytoname);
     // Remove an attachment file if any.
     if (!empty($attachment) && file_exists($attachment)) {
         unlink($attachment);
     }
     return $result;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:62,代码来源:message_output_email.php

示例6: error_exit

function error_exit($msg = '')
{
    if (DBG_LOG) {
        dbg_log(' ', '!err-' . clean_filename($msg));
    }
    silent_exit();
    echo bencode(array('failure reason' => str_compact($msg)));
    tracker_exit();
}
开发者ID:ErR163,项目名称:torrentpier,代码行数:9,代码来源:init_tr.php

示例7: report_download_csv

 function report_download_csv($fields, $data, $reportname = 'reportincsv')
 {
     $filename = clean_filename($reportname);
     $csvexport = new csv_export_writer();
     $csvexport->set_filename($filename);
     $csvexport->add_data($fields);
     foreach ($data as $eachrow) {
         $csvexport->add_data($eachrow);
     }
     $csvexport->download_file();
 }
开发者ID:kmahesh541,项目名称:mitclone,代码行数:11,代码来源:export_reports.php

示例8: user_download_csv

function user_download_csv($fields) {
    global $CFG;
    require_once($CFG->libdir . '/csvlib.class.php');
    $filename = clean_filename(get_string('course', 'local_cobaltcourses'));
    $csvexport = new csv_export_writer();
    $csvexport->set_filename($filename);
    $csvexport->add_data($fields);
    $userprofiledata = array();
    $csvexport->add_data($userprofiledata);
    $csvexport->download_file();
    die;
}
开发者ID:anilch,项目名称:Personel,代码行数:12,代码来源:sample.php

示例9: user_download_csv

function user_download_csv($fields) {
    global $CFG;
    require_once($CFG->libdir . '/csvlib.class.php');
    $filename = clean_filename('Departments');
    $csvexport = new csv_export_writer();
    $csvexport->set_filename($filename);
    $csvexport->add_data($fields);
    $userprofiledata = array();
    $csvexport->add_data($userprofiledata);
    $csvexport->download_file();
    die;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:12,代码来源:sample.php

示例10: user_download_csv

function user_download_csv($fields) {
    global $CFG;
    require_once($CFG->libdir . '/csvlib.class.php');
    $filename = clean_filename('Users sample');
    $csvexport = new csv_export_writer();
    $csvexport->set_filename($filename);
    $csvexport->add_data($fields);
    $userprofiledata = array('lp_shortname','testuser');
    $csvexport->add_data($userprofiledata);
    $csvexport->download_file();
    die;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:12,代码来源:sample.php

示例11: user_download_xls

function user_download_xls($fields) {

    global $CFG, $DB;
    require_once("$CFG->libdir/excellib.class.php");
    $filename = clean_filename(get_string('course', 'local_cobaltcourses') . '.xls');
    $workbook = new MoodleExcelWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] = $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }


    $hierarchy = new hierarchy();
    $schoollist = $hierarchy->get_assignedschools();
    if (is_siteadmin()) {
        $schoollist = $hierarchy->get_school_items();
    }

    $sheetrow = 1;
    foreach ($schoollist as $school) {
        $courses = $DB->get_records('local_cobaltcourses', array('schoolid' => $school->id));
        foreach ($courses as $course) {
            $post = new stdclass();

            $post->fullname = $course->fullname;
            $post->shortname = $course->shortname;
            $departmentname = $DB->get_field('local_department', 'fullname', array('id' => $course->departmentid));
            $post->courselibraryname = $departmentname;
            $schoolname = $DB->get_field('local_school', 'fullname', array('id' => $course->schoolid));
            $post->organizationname = $schoolname;
            $post->summary = $course->summary;
            $post->coursetype = ($course->coursetype == 0) ? 'General' : 'Elective';
            $post->credithours = $course->credithours;
            $post->coursecost = $course->coursecost;
            $col = 0;
            foreach ($fields as $fieldname) {
                $worksheet[0]->write($sheetrow, $col, $post->$fieldname);
                $col++;
            }
            $sheetrow++;
        }
    }

    $workbook->close();
    die;
}
开发者ID:anilch,项目名称:Personel,代码行数:50,代码来源:download_all.php

示例12: local_mail_downloadall

function local_mail_downloadall($message) {
    $attachments = local_mail_attachments($message);
    if (count($attachments) > 1) {
        foreach ($attachments as $attach) {
            $filename = clean_filename($attach->get_filename());
            $filesforzipping[$filename] = $attach;
        }
        $filename = clean_filename(fullname($message->sender()) . '-' .
                                   $message->subject() . '.zip');
        if ($zipfile = pack_files($filesforzipping)) {
            send_temp_file($zipfile, $filename);
        }
    }
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:14,代码来源:locallib.php

示例13: moodle_binary_get_path

function moodle_binary_get_path($id, $meta, $course, $wiki, $userid, $groupid)
{
    global $CFG;
    $entry = wiki_get_entry($wiki, $course, $userid, $groupid);
    if (!$entry) {
        print_error('cannotgetentry', 'wiki');
    }
    $dir = make_upload_directory("{$course->id}/{$CFG->moddata}/wiki/{$wiki->id}/{$entry->id}/" . $meta["section"]);
    if (substr($id, 0, strlen(EWIKI_IDF_INTERNAL)) != EWIKI_IDF_INTERNAL) {
        print_error('cannotstartwith', 'wiki', '', EWIKI_IDF_INTERNAL . substr($id, 0, strlen(EWIKI_IDF_INTERNAL)));
    }
    $id = substr($id, strlen(EWIKI_IDF_INTERNAL));
    $id = clean_filename($id);
    return "{$dir}/{$id}";
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:15,代码来源:moodle_binary_store.php

示例14: store

 function store($title, $var)
 {
     $this->cur_query = "cache->set('{$title}')";
     $this->debug('start');
     $this->data[$title] = $var;
     $filename = $this->dir . clean_filename($this->prefix . $title) . '.php';
     $filecache = "<?php\n";
     $filecache .= "if (!defined('FT_ROOT')) die(basename(__FILE__));\n";
     $filecache .= '$filecache = ' . var_export($var, true) . ";\n";
     $filecache .= '?>';
     $this->debug('stop');
     $this->cur_query = null;
     $this->num_queries++;
     return (bool) file_write($filecache, $filename, false, true, true);
 }
开发者ID:forummaks,项目名称:forum_maks,代码行数:15,代码来源:file.php

示例15: user_download_xls

function user_download_xls($fields) {

    global $CFG, $DB;
    require_once("$CFG->libdir/excellib.class.php");
    $filename = clean_filename(get_string('department', 'local_departments') . '.xls');
    $workbook = new MoodleExcelWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] = $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }

    $hierarchy = new hierarchy();
    /*   Bug report #260 
     * Edited by hemalatha c arun <hemalatha@eabyas.in>
     * resolved- If loggedin user is admin, downloading all the department   
     */
    if (is_siteadmin()) {
        $sql = "SELECT distinct(s.id),s.* FROM {local_school} s ORDER BY s.sortorder";
        $schoollist = $DB->get_records_sql($sql);
    } else
        $schoollist = $hierarchy->get_assignedschools();

    $sheetrow = 1;
    foreach ($schoollist as $school) {
        $departments = $DB->get_records('local_department', array('schoolid' => $school->id));
        foreach ($departments as $department) {
            $post = new stdclass();
            $post->shortname = $department->shortname;
            $post->fullname = $department->fullname;
            $schoolname = $DB->get_field('local_school', 'fullname', array('id' => $department->schoolid));
            $post->schoolname = $schoolname;
            $post->summary = $department->description;
            $col = 0;
            foreach ($fields as $fieldname) {
                $worksheet[0]->write($sheetrow, $col, $post->$fieldname);
                $col++;
            }
            $sheetrow++;
        }
    }
    $workbook->close();
    die;
}
开发者ID:anilch,项目名称:Personel,代码行数:47,代码来源:download_all.php


注:本文中的clean_filename函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。