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


PHP CLISetup::fileExists方法代码示例

本文整理汇总了PHP中CLISetup::fileExists方法的典型用法代码示例。如果您正苦于以下问题:PHP CLISetup::fileExists方法的具体用法?PHP CLISetup::fileExists怎么用?PHP CLISetup::fileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLISetup的用法示例。


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

示例1: simpleImg

function simpleImg()
{
    // prefer manually converted PNG files (as the imagecreatefromblp-script has issues with some formats)
    // see: https://github.com/Kanma/BLPConverter
    $loadImageFile = function ($path) {
        $result = null;
        if (in_array(mb_substr($path, -4, 4), ['.png', '.blp', '.BLP', '.PNG'])) {
            $path = mb_substr($path, 0, mb_strlen($path) - 4);
        }
        $file = $path . '.png';
        if (CLISetup::fileExists($file)) {
            CLISetup::log('manually converted png file present for ' . $path . '.', CLISetup::LOG_INFO);
            $result = imagecreatefrompng($file);
        }
        if (!$result) {
            $file = $path . '.blp';
            if (CLISetup::fileExists($file)) {
                $result = imagecreatefromblp($file);
            }
        }
        return $result;
    };
    if (isset(FileGen::$cliOpts['help'])) {
        echo "\n";
        echo "available options for subScript 'simpleImg':\n";
        echo " --icons          (generates square icons that are used for basicly everything)\n";
        echo " --glyphs         (decorative tidbit displayed on Infobox for Glyph Spells)\n";
        echo " --pagetexts      (imagery contained in PageTexts on readable GameObjects or Items)\n";
        echo " --loadingscreens (loading screens (not used, skipped by default))\n";
        return true;
    }
    $locStr = null;
    $groups = [];
    $dbcPath = CLISetup::$srcDir . '%sDBFilesClient/';
    $imgPath = CLISetup::$srcDir . '%sInterface/';
    $destDir = 'static/images/wow/';
    $success = true;
    $iconDirs = array(['icons/large/', 'jpg', 0, 56, 4], ['icons/medium/', 'jpg', 0, 36, 4], ['icons/small/', 'jpg', 0, 18, 4], ['icons/tiny/', 'gif', 0, 15, 4]);
    $calendarDirs = array(['icons/large/', 'jpg', 90, 56, 4], ['icons/medium/', 'jpg', 90, 36, 4], ['icons/small/', 'jpg', 90, 18, 4], ['icons/tiny/', 'gif', 90, 15, 4]);
    $loadScreenDirs = array(['loadingscreens/large/', 'jpg', 0, 1024, 0], ['loadingscreens/medium/', 'jpg', 0, 488, 0], ['loadingscreens/original/', 'png', 0, 0, 0], ['loadingscreens/small/', 'jpg', 0, 244, 0]);
    $paths = array(0 => ['Icons/', $iconDirs, '/*.[bB][lL][pP]', true, 0], 1 => ['Spellbook/', [['Interface/Spellbook/', 'png', 0, 0, 0]], '/UI-Glyph-Rune*.blp', true, 0], 2 => ['PaperDoll/', array_slice($iconDirs, 0, 3), '/UI-{Backpack,PaperDoll}-*.blp', true, 0], 3 => ['GLUES/CHARACTERCREATE/UI-CharacterCreate-Races.blp', $iconDirs, '', true, 64], 4 => ['GLUES/CHARACTERCREATE/UI-CharacterCreate-CLASSES.blp', $iconDirs, '', true, 64], 5 => ['GLUES/CHARACTERCREATE/UI-CharacterCreate-Factions.blp', $iconDirs, '', true, 64], 7 => ['FlavorImages/', [['Interface/FlavorImages/', 'png', 0, 0, 0]], '/*.[bB][lL][pP]', false, 0], 8 => ['Pictures/', [['Interface/Pictures/', 'png', 0, 0, 0]], '/*.[bB][lL][pP]', false, 0], 9 => ['PvPRankBadges/', [['Interface/PvPRankBadges/', 'png', 0, 0, 0]], '/*.[bB][lL][pP]', false, 0], 10 => ['Calendar/Holidays/', $calendarDirs, '/*{rt,a,y,h,s}.[bB][lL][pP]', true, 0], 11 => ['GLUES/LOADINGSCREENS/', $loadScreenDirs, '/[lL][oO]*.[bB][lL][pP]', false, 0]);
    // textures are composed of 64x64 icons
    // numeric indexed arrays mimick the position on the texture
    $cuNames = array(2 => array('ui-paperdoll-slot-chest' => 'inventoryslot_chest', 'ui-backpack-emptyslot' => 'inventoryslot_empty', 'ui-paperdoll-slot-feet' => 'inventoryslot_feet', 'ui-paperdoll-slot-finger' => 'inventoryslot_finger', 'ui-paperdoll-slot-hands' => 'inventoryslot_hands', 'ui-paperdoll-slot-head' => 'inventoryslot_head', 'ui-paperdoll-slot-legs' => 'inventoryslot_legs', 'ui-paperdoll-slot-mainhand' => 'inventoryslot_mainhand', 'ui-paperdoll-slot-neck' => 'inventoryslot_neck', 'ui-paperdoll-slot-secondaryhand' => 'inventoryslot_offhand', 'ui-paperdoll-slot-ranged' => 'inventoryslot_ranged', 'ui-paperdoll-slot-relic' => 'inventoryslot_relic', 'ui-paperdoll-slot-shirt' => 'inventoryslot_shirt', 'ui-paperdoll-slot-shoulder' => 'inventoryslot_shoulder', 'ui-paperdoll-slot-tabard' => 'inventoryslot_tabard', 'ui-paperdoll-slot-trinket' => 'inventoryslot_trinket', 'ui-paperdoll-slot-waist' => 'inventoryslot_waist', 'ui-paperdoll-slot-wrists' => 'inventoryslot_wrists'), 3 => array(['race_human_male', 'race_dwarf_male', 'race_gnome_male', 'race_nightelf_male', 'race_draenei_male'], ['race_tauren_male', 'race_scourge_male', 'race_troll_male', 'race_orc_male', 'race_bloodelf_male'], ['race_human_female', 'race_dwarf_female', 'race_gnome_female', 'race_nightelf_female', 'race_draenei_female'], ['race_tauren_female', 'race_scourge_female', 'race_troll_female', 'race_orc_female', 'race_bloodelf_female']), 4 => array(['class_warrior', 'class_mage', 'class_rogue', 'class_druid'], ['class_hunter', 'class_shaman', 'class_priest', 'class_warlock'], ['class_paladin', 'class_deathknight']), 5 => array(['faction_alliance', 'faction_horde']), 6 => array([], [null, 'quest_start', 'quest_end', 'quest_start_daily', 'quest_end_daily']), 10 => array('calendar_winterveilstart' => 'calendar_winterveilstart', 'calendar_noblegardenstart' => 'calendar_noblegardenstart', 'calendar_childrensweekstart' => 'calendar_childrensweekstart', 'calendar_fishingextravaganza' => 'calendar_fishingextravaganzastart', 'calendar_harvestfestivalstart' => 'calendar_harvestfestivalstart', 'calendar_hallowsendstart' => 'calendar_hallowsendstart', 'calendar_lunarfestivalstart' => 'calendar_lunarfestivalstart', 'calendar_loveintheairstart' => 'calendar_loveintheairstart', 'calendar_midsummerstart' => 'calendar_midsummerstart', 'calendar_brewfeststart' => 'calendar_brewfeststart', 'calendar_darkmoonfaireelwynnstart' => 'calendar_darkmoonfaireelwynnstart', 'calendar_darkmoonfairemulgorestart' => 'calendar_darkmoonfairemulgorestart', 'calendar_darkmoonfaireterokkarstart' => 'calendar_darkmoonfaireterokkarstart', 'calendar_piratesday' => 'calendar_piratesdaystart', 'calendar_wotlklaunch' => 'calendar_wotlklaunchstart', 'calendar_dayofthedeadstart' => 'calendar_dayofthedeadstart', 'calendar_fireworks' => 'calendar_fireworksstart'));
    $writeImage = function ($name, $ext, $src, $srcDims, $destDims, $done) {
        $ok = false;
        $dest = imagecreatetruecolor($destDims['w'], $destDims['h']);
        imagesavealpha($dest, true);
        if ($ext == 'png') {
            imagealphablending($dest, false);
        }
        imagecopyresampled($dest, $src, $destDims['x'], $destDims['x'], $srcDims['x'], $srcDims['y'], $destDims['w'], $destDims['h'], $srcDims['w'], $srcDims['h']);
        switch ($ext) {
            case 'jpg':
                $ok = imagejpeg($dest, $name . '.' . $ext, 85);
                break;
            case 'gif':
                $ok = imagegif($dest, $name . '.' . $ext);
                break;
            case 'png':
                $ok = imagepng($dest, $name . '.' . $ext);
                break;
            default:
                CLISetup::log($done . ' - unsupported file fromat: ' . $ext, CLISetup::LOG_WARN);
        }
        imagedestroy($dest);
        if ($ok) {
            chmod($name . '.' . $ext, Util::FILE_ACCESS);
            CLISetup::log($done . ' - image ' . $name . '.' . $ext . ' written', CLISetup::LOG_OK);
        } else {
            CLISetup::log($done . ' - could not create image ' . $name . '.' . $ext, CLISetup::LOG_ERROR);
        }
        return $ok;
    };
    $checkSourceDirs = function ($sub, &$missing = []) use($imgPath, $dbcPath, $paths) {
        $hasMissing = false;
        foreach (array_column($paths, 0) as $subDir) {
            $p = sprintf($imgPath, $sub) . $subDir;
            if (!CLISetup::fileExists($p)) {
                $hasMissing = true;
                $missing[] = $p;
            }
        }
        $p = sprintf($dbcPath, $sub);
        if (!CLISetup::fileExists($p)) {
            $hasMissing = true;
            $missing[] = $p;
        }
        return !$hasMissing;
    };
    if (isset(FileGen::$cliOpts['icons'])) {
        array_push($groups, 0, 2, 3, 4, 5, 10);
    }
    if (isset(FileGen::$cliOpts['glyphs'])) {
        $groups[] = 1;
    }
    if (isset(FileGen::$cliOpts['pagetexts'])) {
        array_push($groups, 7, 8, 9);
    }
    if (isset(FileGen::$cliOpts['loadingscreens'])) {
//.........这里部分代码省略.........
开发者ID:saqar,项目名称:aowow,代码行数:101,代码来源:simpleImg.func.php

示例2: complexImg

function complexImg()
{
    if (isset(FileGen::$cliOpts['help'])) {
        echo "\n";
        echo "available options for subScript 'complexImg':\n";
        // modeMask
        echo "--talentbgs  (backgrounds for talent calculator)\n";
        // 0x01
        echo "--maps       (generates worldmaps)\n";
        // 0x02
        echo "--spawn-maps (creates alphaMasks of each zone to check spawns against)\n";
        // 0x04
        echo "--artwork    (optional: imagery from /glues/credits (not used, skipped by default))\n";
        // 0x08
        echo "--area-maps  (optional: renders maps with highlighted subZones for each area)\n";
        // 0x10
        return true;
    }
    $mapWidth = 1002;
    $mapHeight = 668;
    $threshold = 95;
    // alpha threshold to define subZones: set it too low and you have unspawnable areas inside a zone; set it too high and the border regions overlap
    $runTime = ini_get('max_execution_time');
    $locStr = null;
    $dbcPath = CLISetup::$srcDir . '%sDBFilesClient/';
    $imgPath = CLISetup::$srcDir . '%sInterface/';
    $destDir = 'static/images/wow/';
    $success = true;
    $paths = ['WorldMap/', 'TalentFrame/', 'Glues/Credits/'];
    $modeMask = 0x7;
    // talentBGs, regular maps, spawn-related alphaMaps
    $createAlphaImage = function ($w, $h) {
        $img = imagecreatetruecolor($w, $h);
        imagesavealpha($img, true);
        imagealphablending($img, false);
        $bgColor = imagecolorallocatealpha($img, 0, 0, 0, 127);
        imagefilledrectangle($img, 0, 0, imagesx($img) - 1, imagesy($img) - 1, $bgColor);
        imagecolortransparent($img, $bgColor);
        imagealphablending($img, true);
        imagecolordeallocate($img, $bgColor);
        return $img;
    };
    // prefer manually converted PNG files (as the imagecreatefromblp-script has issues with some formats)
    // alpha channel issues observed with locale deDE Hilsbrad and Elwynn - maps
    // see: https://github.com/Kanma/BLPConverter
    $loadImageFile = function ($path) {
        $result = null;
        $file = $path . '.png';
        if (CLISetup::fileExists($file)) {
            CLISetup::log('manually converted png file present for ' . $path . '.', CLISetup::LOG_WARN);
            $result = imagecreatefrompng($file);
        }
        if (!$result) {
            $file = $path . '.blp';
            if (CLISetup::fileExists($file)) {
                $result = imagecreatefromblp($file);
            }
        }
        return $result;
    };
    $assembleImage = function ($baseName, $order, $w, $h) use($loadImageFile) {
        $dest = imagecreatetruecolor($w, $h);
        imagesavealpha($dest, true);
        imagealphablending($dest, false);
        $_h = $h;
        foreach ($order as $y => $row) {
            $_w = $w;
            foreach ($row as $x => $suffix) {
                $src = $loadImageFile($baseName . $suffix);
                if (!$src) {
                    CLISetup::log(' - complexImg: tile ' . $baseName . $suffix . '.blp missing.', CLISetup::LOG_ERROR);
                    unset($dest);
                    return null;
                }
                imagecopyresampled($dest, $src, 256 * $x, 256 * $y, 0, 0, min($_w, 256), min($_h, 256), min($_w, 256), min($_h, 256));
                $_w -= 256;
                unset($src);
            }
            $_h -= 256;
        }
        return $dest;
    };
    $writeImage = function ($name, $ext, $src, $w, $h, $done) {
        $ok = false;
        $dest = imagecreatetruecolor($w, $h);
        imagesavealpha($dest, true);
        imagealphablending($dest, false);
        imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $h, imagesx($src), imagesy($src));
        switch ($ext) {
            case 'jpg':
                $ok = imagejpeg($dest, $name . '.' . $ext, 85);
                break;
            case 'png':
                $ok = imagepng($dest, $name . '.' . $ext);
                break;
            default:
                CLISetup::log($done . ' - unsupported file fromat: ' . $ext, CLISetup::LOG_WARN);
        }
        imagedestroy($dest);
        if ($ok) {
//.........这里部分代码省略.........
开发者ID:Carbenium,项目名称:aowow,代码行数:101,代码来源:complexImg.func.php

示例3: imagecreatefromblp

function imagecreatefromblp($fileName, $imgId = 0)
{
    if (!CLISetup::fileExists($fileName)) {
        CLISetup::log('file ' . $fileName . ' could not be found', CLISetup::LOG_ERROR);
        return;
    }
    $file = fopen($fileName, 'rb');
    if (!$file) {
        CLISetup::log('could not open file ' . $fileName, CLISetup::LOG_ERROR);
        return;
    }
    $fileSize = fileSize($fileName);
    if ($fileSize < 16) {
        CLISetup::log('file ' . $fileName . ' is too small for a BLP file', CLISetup::LOG_ERROR);
        return;
    }
    $data = fread($file, $fileSize);
    fclose($file);
    // predict replacement patch files
    // ref: http://www.zezula.net/en/mpq/patchfiles.html
    if (substr($data, 0x0, 0x4) == "PTCH") {
        // strip patch header
        if (substr($data, 0x40, 0x43) == "COPY") {
            $data = substr($data, 0x44);
        } else {
            CLISetup::log('file ' . $fileName . ' is an incremental patch file and cannot be used by this script.', CLISetup::LOG_ERROR);
            return;
        }
    }
    if (substr($data, 0, 4) != "BLP2") {
        CLISetup::log('file ' . $fileName . ' has incorrect/unsupported magic bytes', CLISetup::LOG_ERROR);
        return;
    }
    $header = unpack("Vformat/Ctype/CalphaBits/CalphaType/Cmips/Vwidth/Vheight", substr($data, 4, 16));
    $header['mipsOffs'] = unpack("V16", substr($data, 20, 64));
    $header['mipsSize'] = unpack("V16", substr($data, 84, 64));
    $debugStr = ' header = ' . print_r($header, true);
    if ($header['format'] != 1) {
        CLISetup::log('file ' . $fileName . ' has unsupported format' . $debugStr, CLISetup::LOG_ERROR);
        return;
    }
    $offs = $header['mipsOffs'][$imgId + 1];
    $size = $header['mipsSize'][$imgId + 1];
    while ($imgId > 0) {
        $header['width'] /= 2;
        $header['height'] /= 2;
        $imgId--;
    }
    if ($size == 0) {
        CLISetup::log('file ' . $fileName . ' contains zeroes in a mips table' . $debugStr, CLISetup::LOG_ERROR);
        return;
    }
    if ($offs + $size > $fileSize) {
        CLISetup::log('file ' . $fileName . ' is corrupted/incomplete' . $debugStr, CLISetup::LOG_ERROR);
        return;
    }
    if ($header['type'] == 1) {
        $img = icfb1($header['width'], $header['height'], substr($data, 148, 1024), substr($data, $offs, $size));
    } else {
        if ($header['type'] == 2) {
            $img = icfb2($header['width'], $header['height'], substr($data, $offs, $size), $header['alphaBits'], $header['alphaType']);
        } else {
            if ($header['type'] == 3) {
                $img = icfb3($header['width'], $header['height'], substr($data, $offs, $size));
            } else {
                CLISetup::log('file ' . $fileName . ' has unsupported type' . $debugStr, CLISetup::LOG_ERROR);
                return;
            }
        }
    }
    return $img;
}
开发者ID:saqar,项目名称:aowow,代码行数:72,代码来源:imagecreatefromblp.func.php

示例4: emotes

function emotes()
{
    $globStrPath = CLISetup::$srcDir . '%sInterface/FrameXML/GlobalStrings.lua';
    $allOK = true;
    $locPath = [];
    DB::Aowow()->query('TRUNCATE ?_emotes_aliasses');
    foreach (CLISetup::$localeIds as $lId) {
        foreach (CLISetup::$expectedPaths as $xp => $locId) {
            if ($lId != $locId) {
                continue;
            }
            if ($xp) {
                // if in subDir add trailing slash
                $xp .= '/';
            }
            $path = sprintf($globStrPath, $xp);
            if (CLISetup::fileExists($path)) {
                $locPath[$lId] = $path;
                continue 2;
            }
        }
        CLISetup::log('GlobalStrings.lua not found for selected locale ' . CLISetup::bold(Util::$localeStrings[$lId]), CLISetup::LOG_WARN);
        $allOK = false;
    }
    $_ = DB::Aowow()->query('REPLACE INTO ?_emotes SELECT
            et.Id,
            LOWER(et.command),
            IF(e.animationId, 1, 0),
            0,                                              -- cuFlags
            etdT.text_loc0,  etdT.text_loc2,  etdT.text_loc3,  etdT.text_loc6,  etdT.text_loc8,
            etdNT.text_loc0, etdNT.text_loc2, etdNT.text_loc3, etdNT.text_loc6, etdNT.text_loc8,
            etdS.text_loc0,  etdS.text_loc2,  etdS.text_loc3,  etdS.text_loc6,  etdS.text_loc8
        FROM
            dbc_emotestext et
        LEFT JOIN
            dbc_emotes e ON e.Id = et.emoteId
        LEFT JOIN
            dbc_emotestextdata etdT  ON etdT.Id  = et.targetId
        LEFT JOIN
            dbc_emotestextdata etdNT ON etdNT.Id = et.noTargetId
        LEFT JOIN
            dbc_emotestextdata etdS  ON etdS.Id  = et.selfId');
    if (!$_) {
        $allOK = false;
    }
    // i have no idea, how the indexing in this file works.
    // sometimes the \d+ after EMOTE is the emoteTextId, but not nearly often enough
    $aliasses = [];
    foreach ($locPath as $lId => $path) {
        foreach (file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
            if (preg_match('/^EMOTE(\\d+)_CMD\\d+\\s=\\s\\"\\/([^"]+)\\";$/', $line, $m)) {
                $aliasses[$m[1]][] = [$lId, $m[2]];
            }
        }
    }
    $emotes = DB::Aowow()->selectCol('SELECT id AS ARRAY_KEY, cmd FROM ?_emotes');
    foreach ($emotes as $eId => $cmd) {
        foreach ($aliasses as $gsId => $data) {
            if (in_array($cmd, array_column($data, 1))) {
                foreach ($data as $d) {
                    DB::Aowow()->query('INSERT IGNORE INTO ?_emotes_aliasses VALUES (?d, ?d, ?) ON DUPLICATE KEY UPDATE locales = locales | ?d', $eId, 1 << $d[0], strtolower($d[1]), 1 << $d[0]);
                }
                break;
            }
        }
    }
    return $allOK;
}
开发者ID:TrinityCore,项目名称:aowow,代码行数:68,代码来源:emotes.func.php

示例5: readFromFile

 public function readFromFile()
 {
     if (!$this->file || $this->error) {
         return [];
     }
     $foundMask = 0x0;
     foreach (CLISetup::$expectedPaths as $locStr => $locId) {
         if (!in_array($locId, CLISetup::$localeIds)) {
             continue;
         }
         if ($foundMask & 1 << $locId) {
             continue;
         }
         $fullpath = CLISetup::$srcDir . ($locStr ? $locStr . '/' : '') . 'DBFilesClient/' . $this->file . '.dbc';
         if (!CLISetup::fileExists($fullpath)) {
             continue;
         }
         CLISetup::log(' - reading ' . ($this->localized ? 'and merging ' : '') . 'data from ' . $fullpath);
         if (!$this->read($fullpath)) {
             CLISetup::log(' - DBC::read() returned with error', CLISetup::LOG_ERROR);
         } else {
             $foundMask |= 1 << $locId;
         }
         if (!$this->localized) {
             // one match is enough
             break;
         }
     }
     return $this->getIndexed();
 }
开发者ID:dobrMAN,项目名称:aowow,代码行数:30,代码来源:dbc.class.php


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