Ejemplo n.º 1
0
 /**
  * 添加用户
  * Enter description here ...
  */
 public function add()
 {
     $cmd = $this->input->post('cmd');
     if ($cmd && $cmd == 'submit') {
         $user = $this->user;
         $tel = $this->input->post('tel');
         $password = $this->input->post('password');
         $member = $this->MemberModel->getModel("tel='" . $tel . "'");
         if (!$member) {
             $dataArray = array('nick_name' => $this->input->post('nick_name'), 'tel' => $tel, 'password' => md5($password), 'token' => md5(create_random(32)), 'create_id' => $user['id'], 'create_time' => now());
             $result = $this->MemberModel->add($dataArray);
             if ($result) {
                 show_error('index.php/EditorMember/index', 500, '提示信息:会员添加成功!');
             } else {
                 show_error('index.php/EditorMember/add', 500, '提示信息:会员添加失败!');
             }
         } else {
             show_error('index.php/EditorMember/add', 500, '提示信息:手机号码已被占用!');
         }
     } else {
         $this->load->view('EditorMember/add');
     }
 }
Ejemplo n.º 2
0
if (isset($attachment) and $attachment == 'yes' and !empty($_FILES) and is_dir($configuration['temp_folder'])) {
    $upload = new Upload($_FILES);
    if (!isset($attachment_size) or empty($attachment_size) or !is_numeric($attachment_size)) {
        $attachment_size = $attach_size;
    }
    $upload->maxupload_size = $attachment_size;
    $allowed_files = explode(',', $attachment_files);
    array_walk($allowed_files, 'array_trim');
    while (list($field, $values) = each($_FILES)) {
        ${$field} = '';
        if ($upload->getFilename($field) == '') {
            continue;
        }
        $file_name = $upload->getFilename($field);
        ${$field} = $file_name;
        $upload_suffix = create_random(20);
        $file_extension = trim(substr($file_name, strrpos($file_name, '.') + 1));
        reset($allowed_files);
        while (list($ext_key, $ext_val) = each($allowed_files)) {
            if (preg_match('#' . preg_quote($ext_val) . '#i', $file_extension) <= 0) {
                continue;
            }
            if ($upload->saveAs($file_name . '_' . $upload_suffix, $configuration['temp_folder'], $field, true)) {
                $attachment_file_names[] = array('new' => $configuration['temp_folder'] . $file_name . '_' . $upload_suffix, 'old' => $file_name);
                $form_output_file_names[$field] = $file_name;
                $form_output_suffix[$field] = $upload_suffix;
            }
        }
    }
    // debug_mode($upload->errors, 'Upload');
    // print_a($attachment_file_names);