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


PHP my_chmod函数代码示例

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


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

示例1: check_attachments_dir_perms

 public function check_attachments_dir_perms()
 {
     global $import_session, $output;
     if ($import_session['total_attachments'] <= 0) {
         return;
     }
     $this->debug->log->trace0("Checking attachment directory permissions again");
     if ($import_session['uploads_test'] != 1) {
         // Check upload directory is writable
         $uploadswritable = @fopen(MYBB_ROOT . 'uploads/test.write', 'w');
         if (!$uploadswritable) {
             $this->debug->log->error("Uploads directory is not writable");
             $this->errors[] = 'The uploads directory (uploads/) is not writable. Please adjust the <a href="http://wiki.mybb.com/index.php/CHMOD%20Files" target="_blank">chmod</a> permissions to allow it to be written to.';
             @fclose($uploadswritable);
             $output->print_error_page();
         } else {
             @fclose($uploadswritable);
             @my_chmod(MYBB_ROOT . 'uploads', '0777');
             @my_chmod(MYBB_ROOT . 'uploads/test.write', '0777');
             @unlink(MYBB_ROOT . 'uploads/test.write');
             $import_session['uploads_test'] = 1;
             $this->debug->log->trace1("Uploads directory is writable");
         }
     }
 }
开发者ID:dgrp,项目名称:merge-system,代码行数:25,代码来源:attachments.php

示例2: upgrade3_dbchanges

function upgrade3_dbchanges()
{
    global $db, $output;
    $output->print_header("Attachment Conversion to Files");
    $contents = "<p>The first step of the upgrade process from RC4 is to move your attachments and avatars to the file system.</p>";
    if (!@is_dir("../uploads/")) {
        $errors = "<p>../uploads/ Does not exist in your forums' directory. Please create this directory.";
    } else {
        if (!@is_writable("../uploads/")) {
            @my_chmod("../uploads", '0777');
            if (!@is_writable("../uploads/")) {
                $errors = "<p>../uploads/ is not writable! Please chmod this directory so it's writable (766 or 777).";
            }
        }
    }
    if (!@is_dir("../uploads/avatars/")) {
        $errors .= "<p>../uploads/avatars/ Does not exist. Please create this directory.";
    } else {
        if (!@is_writable("../uploads/avatars/")) {
            @my_chmod("../uploads/avatars/", '0777');
            if (!is_writable("../uploads/avatars/")) {
                $errors = "<p>../uploads/avatars/ is not writable! Please chmod this directory so it's writable (766 or 777).";
            }
        }
    }
    if ($errors) {
        $output->print_contents($contents . "<p><font color=\"red\">To be able to do this you must perform the following:</font></p>{$errors}");
        $output->print_footer("3_dbchanges");
        exit;
    }
    $contents .= "<p>Okay, we've determined that the specified directory settings have been met.</p>If you wish to change the number of attachments to process per page then you can do so below.</p>";
    $contents .= "<p><strong>Attachments Per Page:</strong> <input type=\"text\" size=\"3\" value=\"50\" name=\"attachmentspage\" /></p>";
    $contents .= "<p>Once you're ready, press next to begin the conversion.</p>";
    $output->print_contents($contents);
    $output->print_footer("3_convertattachments");
}
开发者ID:GeorgeLVP,项目名称:mybb,代码行数:36,代码来源:upgrade3.php

示例3: upgrade3_dbchanges

function upgrade3_dbchanges()
{
    global $db, $output;
    $output->print_header("Konwersja załączników na pliki");
    $contents = "<p>Pierwszym krokiem w aktualizacji z wersji RC4 jest przeniesienie załączników i awatarów do systemu plików.</p>";
    if (!@is_dir("../uploads/")) {
        $errors = "<p>Katalog /uploads nie istnieje w katalogu, w którym znajduje się forum. Utwórz ten katalog przed kontynuowaniem.";
    } else {
        if (!@is_writable("../uploads/")) {
            @my_chmod("../uploads", '0777');
            if (!@is_writable("../uploads/")) {
                $errors = "<p>Nie można zapisywać do katalogu /uploads. Sprawdź uprawnienia dla tego katalogu i spróbuj ponownie (CHMOD 766 lub 777).";
            }
        }
    }
    if (!@is_dir("../uploads/avatars/")) {
        $errors .= "<p>Katalog /uploads/avatars/ nie istnieje. Utwórz ten katalog przed kontynuowaniem.";
    } else {
        if (!@is_writable("../uploads/avatars/")) {
            @my_chmod("../uploads/avatars/", '0777');
            if (!is_writable("../uploads/avatars/")) {
                $errors = "<p>Nie można zapisywać do katalogu /uploads/avatars. Sprawdź uprawnienia dla tego katalogu i spróbuj ponownie (CHMOD 766 lub 777).";
            }
        }
    }
    if ($errors) {
        $output->print_contents($contents . "<p><font color=\"red\">Aby wykonać ten krok musisz naprawić poniższe błędy:</font></p>{$errors}");
        $output->print_footer("3_dbchanges");
        exit;
    }
    $contents .= "<p>Wymagania co do folderów zostały spełnione.</p>Jeżeli chcesz zmienić liczbę załączników do przetworzenia na stronę, możesz to zrobić poniżej.</p>";
    $contents .= "<p><strong>Ilość wpisów na stronę:</strong> <input type=\"text\" size=\"3\" value=\"50\" name=\"attachmentspage\" /></p>";
    $contents .= "<p>Aby rozpocząć konwersję naciśnij dalej.</p>";
    $output->print_contents($contents);
    $output->print_footer("3_convertattachments");
}
开发者ID:Nidrax,项目名称:ppm-1.6,代码行数:36,代码来源:upgrade3.php

示例4: requirements_check

/**
 * Check our requirements
 */
function requirements_check()
{
    global $output, $mybb, $dboptions, $lang;
    $mybb->input['action'] = "requirements_check";
    $output->print_header($lang->req_check, 'requirements');
    echo $lang->req_step_top;
    $errors = array();
    $showerror = 0;
    if (!file_exists(MYBB_ROOT . "/inc/config.php")) {
        if (!@rename(MYBB_ROOT . "/inc/config.default.php", MYBB_ROOT . "/inc/config.php")) {
            if (!$configwritable) {
                $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_configdefaultfile);
                $configstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable);
                $showerror = 1;
            }
        }
    }
    // Check PHP Version
    if (version_compare(PHP_VERSION, '5.2.0', "<")) {
        $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->sprintf($lang->req_step_error_phpversion, PHP_VERSION));
        $phpversion = $lang->sprintf($lang->req_step_span_fail, PHP_VERSION);
        $showerror = 1;
    } else {
        $phpversion = $lang->sprintf($lang->req_step_span_pass, PHP_VERSION);
    }
    $mboptions = array();
    if (function_exists('mb_detect_encoding')) {
        $mboptions[] = $lang->multi_byte;
    }
    if (function_exists('iconv')) {
        $mboptions[] = 'iconv';
    }
    // Check Multibyte extensions
    if (count($mboptions) < 1) {
        $mbstatus = $lang->sprintf($lang->req_step_span_fail, $lang->none);
    } else {
        $mbstatus = implode(', ', $mboptions);
    }
    // Check database engines
    if (count($dboptions) < 1) {
        $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_dboptions);
        $dbsupportlist = $lang->sprintf($lang->req_step_span_fail, $lang->none);
        $showerror = 1;
    } else {
        foreach ($dboptions as $dboption) {
            $dbsupportlist[] = $dboption['title'];
        }
        $dbsupportlist = implode(', ', $dbsupportlist);
    }
    // Check XML parser is installed
    if (!function_exists('xml_parser_create')) {
        $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_xmlsupport);
        $xmlstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_installed);
        $showerror = 1;
    } else {
        $xmlstatus = $lang->sprintf($lang->req_step_span_pass, $lang->installed);
    }
    // Check config file is writable
    $configwritable = @fopen(MYBB_ROOT . 'inc/config.php', 'w');
    if (!$configwritable) {
        $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_configfile);
        $configstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable);
        $showerror = 1;
    } else {
        $configstatus = $lang->sprintf($lang->req_step_span_pass, $lang->writable);
    }
    @fclose($configwritable);
    // Check settings file is writable
    $settingswritable = @fopen(MYBB_ROOT . 'inc/settings.php', 'w');
    if (!$settingswritable) {
        $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_settingsfile);
        $settingsstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable);
        $showerror = 1;
    } else {
        $settingsstatus = $lang->sprintf($lang->req_step_span_pass, $lang->writable);
    }
    @fclose($settingswritable);
    // Check cache directory is writable
    $cachewritable = @fopen(MYBB_ROOT . 'cache/test.write', 'w');
    if (!$cachewritable) {
        $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_cachedir);
        $cachestatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable);
        $showerror = 1;
        @fclose($cachewritable);
    } else {
        $cachestatus = $lang->sprintf($lang->req_step_span_pass, $lang->writable);
        @fclose($cachewritable);
        @my_chmod(MYBB_ROOT . 'cache', '0777');
        @my_chmod(MYBB_ROOT . 'cache/test.write', '0777');
        @unlink(MYBB_ROOT . 'cache/test.write');
    }
    // Check upload directory is writable
    $uploadswritable = @fopen(MYBB_ROOT . 'uploads/test.write', 'w');
    if (!$uploadswritable) {
        $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_uploaddir);
        $uploadsstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable);
        $showerror = 1;
//.........这里部分代码省略.........
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:101,代码来源:index.php

示例5: generate_thumbnail

/**
 * Generates a thumbnail based on specified dimensions (supports png, jpg, and gif)
 * 
 * @param string the full path to the original image
 * @param string the directory path to where to save the new image
 * @param string the filename to save the new image as
 * @param integer maximum hight dimension
 * @param integer maximum width dimension
 * @return array thumbnail on success, error code 4 on failure
 */
function generate_thumbnail($file, $path, $filename, $maxheight, $maxwidth)
{
    if (!function_exists("imagecreate")) {
        $thumb['code'] = 3;
        return $thumb;
    }
    $imgdesc = getimagesize($file);
    $imgwidth = $imgdesc[0];
    $imgheight = $imgdesc[1];
    $imgtype = $imgdesc[2];
    $imgattr = $imgdesc[3];
    $imgbits = $imgdesc['bits'];
    $imgchan = $imdesc['channels'];
    if ($imgwidth == 0 || $imgheight == 0) {
        $thumb['code'] = 3;
        return $thumb;
    }
    if ($imgwidth >= $maxwidth || $imgheight >= $maxheight) {
        check_thumbnail_memory($imgwidth, $imgheight, $imgtype, $imgbits, $imgchan);
        if ($imgtype == 3) {
            if (@function_exists("imagecreatefrompng")) {
                $im = @imagecreatefrompng($file);
            }
        } elseif ($imgtype == 2) {
            if (@function_exists("imagecreatefromjpeg")) {
                $im = @imagecreatefromjpeg($file);
            }
        } elseif ($imgtype == 1) {
            if (@function_exists("imagecreatefromgif")) {
                $im = @imagecreatefromgif($file);
            }
        } else {
            $thumb['code'] = 3;
            return $thumb;
        }
        if (!$im) {
            $thumb['code'] = 3;
            return $thumb;
        }
        $scale = scale_image($imgwidth, $imgheight, $maxwidth, $maxheight);
        $thumbwidth = $scale['width'];
        $thumbheight = $scale['height'];
        $thumbim = @imagecreatetruecolor($thumbwidth, $thumbheight);
        if (!$thumbim) {
            $thumbim = @imagecreate($thumbwidth, $thumbheight);
            $resized = true;
        }
        // Attempt to preserve the transparency if there is any
        $trans_color = imagecolortransparent($im);
        if ($trans_color >= 0 && $trans_color < imagecolorstotal($im)) {
            $trans = imagecolorsforindex($im, $trans_colors);
            $new_trans_color = imagecolorallocate($thumbim, $trans['red'], $trans['blue'], $trans['green']);
            imagefill($thumbim, 0, 0, $new_trans_color);
            imagecolortransparent($thumbim, $new_trans_color);
        }
        if (!isset($resized)) {
            @imagecopyresampled($thumbim, $im, 0, 0, 0, 0, $thumbwidth, $thumbheight, $imgwidth, $imgheight);
        } else {
            @imagecopyresized($thumbim, $im, 0, 0, 0, 0, $thumbwidth, $thumbheight, $imgwidth, $imgheight);
        }
        @imagedestroy($im);
        if (!function_exists("imagegif") && $imgtype == 1) {
            $filename = str_replace(".gif", ".jpg", $filename);
        }
        switch ($imgtype) {
            case 1:
                if (function_exists("imagegif")) {
                    @imagegif($thumbim, $path . "/" . $filename);
                } else {
                    @imagejpeg($thumbim, $path . "/" . $filename);
                }
                break;
            case 2:
                @imagejpeg($thumbim, $path . "/" . $filename);
                break;
            case 3:
                @imagepng($thumbim, $path . "/" . $filename);
                break;
        }
        @my_chmod($path . "/" . $filename, '0666');
        @imagedestroy($thumbim);
        $thumb['code'] = 1;
        $thumb['filename'] = $filename;
        return $thumb;
    } else {
        return array("code" => 4);
    }
}
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:98,代码来源:functions_image.php

示例6: after_insert

 function after_insert($data, $insert_data, $aid)
 {
     global $mybb, $db, $import_session;
     // Transfer attachment
     $attachment_file = merge_fetch_remote_file($import_session['uploadspath'] . '/' . $data['physical_filename']);
     if (!empty($attachment_file)) {
         $attachrs = @fopen($mybb->settings['uploadspath'] . '/' . $insert_data['attachname'], 'w');
         if ($attachrs) {
             @fwrite($attachrs, $attachment_file);
         } else {
             $this->board->set_error_notice_in_progress("Error transfering the attachment (ID: {$aid})");
         }
         @fclose($attachrs);
         @my_chmod($mybb->settings['uploadspath'] . '/' . $insert_data['attachname'], '0777');
     } else {
         $this->board->set_error_notice_in_progress("Could not find the attachment (ID: {$aid})");
     }
     if (!$posthash) {
         // Restore connection
         $db->update_query("posts", array('posthash' => $insert_data['posthash']), "pid = '{$insert_data['pid']}'");
     }
     $posthash = $this->get_import->post_attachment_details($data['post_msg_id']);
     $db->write_query("UPDATE " . TABLE_PREFIX . "threads SET attachmentcount = attachmentcount + 1 WHERE tid = '" . $posthash['tid'] . "'");
 }
开发者ID:dgrp,项目名称:merge-system,代码行数:24,代码来源:attachments.php

示例7: upload_file

/**
 * Actually move a file to the uploads directory
 *
 * @param array $file The PHP $_FILE array for the file
 * @param string $path The path to save the file in
 * @param string $filename The filename for the file (if blank, current is used)
 * @return array The uploaded file
 */
function upload_file($file, $path, $filename = "")
{
    global $plugins, $mybb;
    $upload = array();
    if (empty($file['name']) || $file['name'] == "none" || $file['size'] < 1) {
        $upload['error'] = 1;
        return $upload;
    }
    if (!$filename) {
        $filename = $file['name'];
    }
    $upload['original_filename'] = preg_replace("#/\$#", "", $file['name']);
    // Make the filename safe
    $filename = preg_replace("#/\$#", "", $filename);
    // Make the filename safe
    $moved = @move_uploaded_file($file['tmp_name'], $path . "/" . $filename);
    $cdn_path = '';
    $moved_cdn = copy_file_to_cdn($path . "/" . $filename, $cdn_path);
    if (!$moved) {
        $upload['error'] = 2;
        return $upload;
    }
    @my_chmod($path . "/" . $filename, '0644');
    $upload['filename'] = $filename;
    $upload['path'] = $path;
    $upload['type'] = $file['type'];
    $upload['size'] = $file['size'];
    $upload = $plugins->run_hooks("upload_file_end", $upload);
    if ($moved_cdn) {
        $upload['cdn_path'] = $cdn_path;
    }
    return $upload;
}
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:41,代码来源:functions_upload.php

示例8: upgrade12_redothemes

function upgrade12_redothemes()
{
    global $db, $output, $config, $mybb;
    $output->print_header("Converting themes");
    if (!@is_dir(MYBB_ROOT . 'cache/')) {
        @mkdir(MYBB_ROOT . 'cache/', 077);
        // Add in empty index.html!
        $fp = @fopen(MYBB_ROOT . "cache/index.html", "w");
        @fwrite($fp, "");
        @fclose($fp);
    }
    $cachewritable = @fopen(MYBB_ROOT . 'cache/test.write', 'w');
    if (!$cachewritable) {
        $not_writable = true;
        @fclose($cachewritable);
    } else {
        @fclose($cachewritable);
        @my_chmod(MYBB_ROOT . 'cache', '0777');
        @my_chmod(MYBB_ROOT . 'cache/test.write', '0777');
        @unlink(MYBB_ROOT . 'cache/test.write');
    }
    if ($not_writable) {
        echo "<p><span style=\"color: red; font-weight: bold;\">Unable to write to the cache/ directory.</span><br />Before the upgrade process can continue you need to make sure this directory exists and is writable (chmod 777)</p>";
        $output->print_footer("12_redothemes");
        exit;
    }
    $not_writable = false;
    if (!@is_dir(MYBB_ROOT . 'cache/themes/')) {
        @mkdir(MYBB_ROOT . 'cache/themes/', 077);
        // Add in empty index.html!
        $fp = @fopen(MYBB_ROOT . "cache/themes/index.html", "w");
        @fwrite($fp, "");
        @fclose($fp);
    }
    $themewritable = @fopen(MYBB_ROOT . 'cache/themes/test.write', 'w');
    if (!$themewritable) {
        $not_writable = true;
        @fclose($themewritable);
    } else {
        @fclose($themewritable);
        @my_chmod(MYBB_ROOT . 'cache/themes', '0777');
        @my_chmod(MYBB_ROOT . 'cache/themes/test.write', '0777');
        @unlink(MYBB_ROOT . 'cache/themes/test.write');
    }
    if ($not_writable) {
        echo "<p><span style=\"color: red; font-weight: bold;\">Unable to write to the cache/themes/ directory.</span><br />Before the upgrade process can continue you need to make sure this directory exists and is writable (chmod 777)</p>";
        $output->print_footer("12_redothemes");
        exit;
    }
    if ($db->field_exists('themebits', "themes") && !$db->field_exists('properties', "themes")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes CHANGE themebits properties text NOT NULL");
    }
    if ($db->field_exists('cssbits', "themes")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes DROP cssbits");
    }
    if ($db->field_exists('csscached', "themes")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes DROP csscached");
    }
    if ($db->field_exists('stylesheets', "themes")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes DROP stylesheets");
    }
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes ADD stylesheets text NOT NULL AFTER properties");
    if ($db->table_exists("themestylesheets")) {
        $db->drop_table("themestylesheets");
    }
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "themestylesheets(\n\t\tsid int unsigned NOT NULL auto_increment,\n\t\tname varchar(30) NOT NULL default '',\n\t\ttid int unsigned NOT NULL default '0',\n\t\tattachedto text NOT NULL,\n\t\tstylesheet text NOT NULL,\n\t\tcachefile varchar(100) NOT NULL default '',\n\t\tlastmodified bigint(30) NOT NULL default '0',\n\t\tPRIMARY KEY(sid)\n\t) ENGINE=MyISAM{$collation};");
    // Define our default stylesheets - MyBB 1.4 contains additional stylesheets that our converted themes will also need
    $contents = @file_get_contents(INSTALL_ROOT . 'resources/mybb_theme.xml');
    if (file_exists(MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php")) {
        require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php";
    } else {
        if (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) {
            require_once MYBB_ROOT . "admin/inc/functions_themes.php";
        } else {
            $output->print_error("Please make sure your admin directory is uploaded correctly.");
        }
    }
    // Import master theme
    if (import_theme_xml($contents, array("tid" => 1, "no_templates" => 1, "version_compat" => 1)) === -1) {
        $output->print_error("Please make sure your install/resources/mybb_theme.xml file is uploaded correctly.");
    }
    // Fetch out default stylesheets from master
    $query = $db->simple_select("themes", "*", "tid=1");
    $master_theme = $db->fetch_array($query);
    $master_stylesheets = unserialize($master_theme['stylesheets']);
    if (is_array($master_stylesheets)) {
        // Note: 1.4 only ships with one global|global stylesheet
        foreach ($master_stylesheets as $location => $sheets) {
            foreach ($sheets as $action => $sheets) {
                foreach ($sheets as $stylesheet) {
                    if ($location == "global" && $action == "global") {
                        continue;
                        // Skip global
                    }
                    $default_stylesheets[$location][$action][] = $stylesheet;
                    $default_stylesheets['inherited']["{$location}_{$action}"][$stylesheet] = 1;
                    // This stylesheet is inherited from the master
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:slothly,项目名称:mybb,代码行数:101,代码来源:upgrade12.php

示例9: do_upload_xtattachment


//.........这里部分代码省略.........
        if (!$prevattach['aid']) {
            $update_attachment = false;
        }
    }
    /* else {
    		// Check if attachment already uploaded
    		// TODO: this is actually a little problematic - perhaps verify that this is attached to this field (or maybe rely on checks in xt_updatehooks file)
    		if(isset($file_md5))
    			$md5check = ' OR md5hash='.xthreads_db_escape_binary($file_md5);
    		else
    			$md5check = '';
    		$prevattach = $db->fetch_array($db->simple_select('xtattachments', 'aid', 'filename="'.$db->escape_string($attachment['name']).'" AND (md5hash IS NULL'.$md5check.') AND filesize='.$file_size.' AND (posthash="'.$posthash.'" OR (tid='.$tid.' AND tid!=0))'));
    		if($prevattach['aid']) {
    			@unlink($attachment['tmp_name']);
    			// TODO: maybe return aid instead?
    			return array('error' => $lang->error_alreadyuploaded);
    		}
    	} */
    // We won't use MyBB's nice monthly directories, instead, we'll use a more confusing system based on the timestamps
    // note, one month = 2592000 seconds, so if we split up by 1mil, it'll be approx 11.5 days
    // If safe_mode is enabled, don't attempt to use the monthly directories as it won't work
    if (ini_get('safe_mode') == 1 || strtolower(ini_get('safe_mode')) == 'on') {
        $month_dir = '';
    } else {
        $month_dir = 'ts_' . floor(TIME_NOW / 1000000) . '/';
        if (!@is_dir($path . $month_dir)) {
            @mkdir($path . $month_dir);
            // Still doesn't exist - oh well, throw it in the main directory
            if (@is_dir($path . $month_dir)) {
                // write index file
                if ($index = fopen($path . $month_dir . 'index.html', 'w')) {
                    fwrite($index, '<html><body></body></html>');
                    fclose($index);
                    @my_chmod($path . $month_dir . 'index.html', 0644);
                }
                @my_chmod($path . $month_dir, 0755);
            } else {
                $month_dir = '';
            }
        }
    }
    // All seems to be good, lets move the attachment!
    $basename = substr(md5(uniqid(mt_rand(), true) . substr($mybb->post_code, 16)), 12, 8) . '_' . preg_replace('~[^a-zA-Z0-9_\\-%]~', '', str_replace(array(' ', '.', '+'), '_', $attachment['name'])) . '.upload';
    $filename = 'file_' . ($prevattach['aid'] ? $prevattach['aid'] : 't' . TIME_NOW) . '_' . $basename;
    @ignore_user_abort(true);
    // don't let the user break this integrity between file system and DB
    if (isset($GLOBALS['xtfurl_tmpfiles'])) {
        // if using url fetch, remove this from list of temp files
        unset($GLOBALS['xtfurl_tmpfiles'][$attachment['tmp_name']]);
    }
    while (!@$movefunc($attachment['tmp_name'], $path . $month_dir . $filename)) {
        if ($month_dir) {
            // try doing it again without the month_dir
            $month_dir = '';
        } else {
            // failed
            @ignore_user_abort(false);
            return array('error' => $lang->error_uploadfailed . $lang->error_uploadfailed_detail . $lang->error_uploadfailed_movefailed);
        }
    }
    // Lets just double check that it exists
    if (!file_exists($path . $month_dir . $filename)) {
        @ignore_user_abort(false);
        return array('error' => $lang->error_uploadfailed . $lang->error_uploadfailed_detail . $lang->error_uploadfailed_lost);
    }
    // Generate the array for the insert_query
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:67,代码来源:xt_upload.php

示例10: directory

        if (!$contents || !$latest_code) {
            $checks['version_check_status'] = '<span class="pass"><i>Unable to Check</i></span>';
            $debug->log->warning("Unable to check version status against mybb.com version server");
        }
        // Check upload directory is writable
        $attachmentswritable = @fopen(MYBB_ROOT . 'uploads/test.write', 'w');
        if (!$attachmentswritable) {
            $errors['attachments_check'] = 'The attachments directory (/uploads/) is not writable. Please adjust the <a href="http://wiki.mybb.com/index.php/CHMOD%20Files" target="_blank">chmod</a> permissions to allow it to be written to.';
            $checks['attachments_check_status'] = '<span class="fail"><strong>Not Writable</strong></span>';
            @fclose($attachmentswritable);
            $debug->log->trace0("Attachments directory not writable");
        } else {
            $checks['attachments_check_status'] = '<span class="pass">Writable</span>';
            @fclose($attachmentswritable);
            @my_chmod(MYBB_ROOT . 'uploads', '0777');
            @my_chmod(MYBB_ROOT . 'uploads/test.write', '0777');
            @unlink(MYBB_ROOT . 'uploads/test.write');
            $debug->log->trace0("Attachments directory writable");
        }
        if (!empty($errors)) {
            $output->print_warning(error_list($errors), "The MyBB Merge System Requirements check failed:");
        }
        echo '<p><div class="border_wrapper">
			<div class="title">Requirements Check</div>
		<table class="general" cellspacing="0">
		<thead>
			<tr>
				<th colspan="2" class="first last">Requirements</th>
			</tr>
		</thead>
		<tbody>
开发者ID:dgrp,项目名称:merge-system,代码行数:31,代码来源:index.php

示例11: upload_file

/**
 * Actually move a file to the uploads directory
 *
 * @param array The PHP $_FILE array for the file
 * @param string The path to save the file in
 * @param string The filename for the file (if blank, current is used)
 */
function upload_file($file, $path, $filename = "")
{
    global $plugins;
    if (empty($file['name']) || $file['name'] == "none" || $file['size'] < 1) {
        $upload['error'] = 1;
        return $upload;
    }
    if (!$filename) {
        $filename = $file['name'];
    }
    $upload['original_filename'] = preg_replace("#/\$#", "", $file['name']);
    // Make the filename safe
    $upload['original_filename'] = utf8_handle_4byte_string($upload['original_filename']);
    $filename = preg_replace("#/\$#", "", $filename);
    // Make the filename safe
    $moved = @move_uploaded_file($file['tmp_name'], $path . "/" . $filename);
    if (!$moved) {
        $upload['error'] = 2;
        return $upload;
    }
    @my_chmod($path . "/" . $filename, '0644');
    $upload['filename'] = $filename;
    $upload['path'] = $path;
    $upload['type'] = $file['type'];
    $upload['size'] = $file['size'];
    $upload = $plugins->run_hooks("upload_file_end", $upload);
    return $upload;
}
开发者ID:ThinhNguyenVB,项目名称:Gradient-Studios-Website,代码行数:35,代码来源:functions_upload.php


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