Пример #1
0
 public function render()
 {
     $mime = $this->_getMimetype();
     $contents = $this->FS->read($this->path);
     $this->httpResponse->setCacheable();
     $this->httpResponse->addHeader("content-type: {$mime};charset=utf-8");
     $this->httpResponse->setContent($contents);
     $this->httpResponse->send();
 }
Пример #2
0
 function domanage()
 {
     if ($_FILES['Filedata']) {
         require_once iPATH . 'include/upload.class.php';
         $this->iCMS->config['iswatermark'] = false;
         $this->iCMS->config['isthumb'] = false;
         $ext = FS::getExt($_FILES['Filedata']['name']);
         $F = iUpload::FILES("Filedata", 0, '', 'avatar', 'tmp_' . member::$uId . '.' . strtolower($ext), 'avatar');
         //            echo FS::fp($F["FilePath"],'+http');
         echo '../' . $this->iCMS->config['uploadfiledir'] . '/' . $F["FilePath"];
     } else {
         $_dir = ceil(member::$uId / 500);
         $data = file_get_contents("php://input");
         $length = strlen($data);
         $lastIndex = 0;
         $sizeIndex = 0;
         $sizeArray = array(120, 48, 24);
         //同时上传3个尺寸的头像。 分割数据
         while ($lastIndex < $length) {
             $a = unpack('L', $data[$lastIndex + 3] . $data[$lastIndex + 2] . $data[$lastIndex + 1] . $data[$lastIndex]);
             $lastIndex += 4;
             $avatarData = substr($data, $lastIndex, $a[1]);
             $lastIndex += $a[1];
             $avatar = 'avatar/' . $_dir . '/' . member::$uId . '_' . $sizeArray[$sizeIndex] . '.gif';
             $fp = FS::fp($avatar, '+iPATH');
             @FS::mkdir(dirname($fp));
             @FS::write($fp, $avatarData);
             $sizeIndex++;
         }
         $rootpf = FS::fp('avatar/tmp_' . member::$uId, '+iPATH');
         foreach (glob($rootpf . "*") as $_fp) {
             file_exists($_fp) && FS::del($_fp);
         }
     }
 }
Пример #3
0
 function sql($name, $type = 'install')
 {
     $_file = self::path($name, $type . '.sql');
     if ($_file) {
         return FS::read($_file);
     }
 }
Пример #4
0
 /**
  * Runtime of Master process
  * @return void
  */
 public function run()
 {
     Daemon::$process = $this;
     $this->prepareSystemEnv();
     class_exists('Timer');
     // ensure loading this class
     gc_enable();
     $this->eventBase = event_base_new();
     $this->registerEventSignals();
     FS::initEvent();
     $this->fileWatcher = new FileWatcher();
     $this->workers = new ThreadCollection();
     $this->collections['workers'] = $this->workers;
     Daemon::$appResolver = (require Daemon::$config->path->value);
     $this->IPCManager = Daemon::$appResolver->getInstanceByAppName('IPCManager');
     Daemon::$appResolver->preload(true);
     $this->callbacks = new SplStack();
     $this->spawnWorkers(min(Daemon::$config->startworkers->value, Daemon::$config->maxworkers->value));
     Timer::add(function ($event) use(&$cbs) {
         $self = Daemon::$process;
         static $c = 0;
         ++$c;
         if ($c > 0xfffff) {
             $c = 1;
         }
         if ($c % 10 == 0) {
             $self->workers->removeTerminated(true);
             gc_collect_cycles();
         } else {
             $self->workers->removeTerminated();
         }
         if (isset(Daemon::$config->mpm->value) && is_callable(Daemon::$config->mpm->value)) {
             call_user_func(Daemon::$config->mpm->value);
         } else {
             // default MPM
             $state = Daemon::getStateOfWorkers($self);
             if ($state) {
                 $n = max(min(Daemon::$config->minspareworkers->value - $state['idle'], Daemon::$config->maxworkers->value - $state['alive']), Daemon::$config->minworkers->value - $state['alive']);
                 if ($n > 0) {
                     Daemon::log('Spawning ' . $n . ' worker(s).');
                     $self->spawnWorkers($n);
                     event_base_loopbreak($self->eventBase);
                 }
                 $n = min($state['idle'] - Daemon::$config->maxspareworkers->value, $state['alive'] - Daemon::$config->minworkers->value);
                 if ($n > 0) {
                     Daemon::log('Stopping ' . $n . ' worker(s).');
                     $self->stopWorkers($n);
                 }
             }
         }
         $event->timeout();
     }, 1000000.0 * Daemon::$config->mpmdelay->value, 'MPM');
     while (!$this->breakMainLoop) {
         while (!$this->callbacks->isEmpty()) {
             call_user_func($this->callbacks->shift(), $this);
         }
         event_base_loop($this->eventBase);
     }
 }
Пример #5
0
 /**
  * Called when worker is going to update configuration.
  * @return void
  */
 public function onConfigUpdated()
 {
     parent::onConfigUpdated();
     $app = $this;
     FS::readfile($this->config->file->value, function ($file, $data) use($app) {
         $app->policyData = $data;
         $app->enable();
     });
 }
Пример #6
0
 public function init()
 {
     $req = $this;
     $this->sleep(1, true);
     FS::readfile('/etc/filesystems', function ($file, $data) use($req) {
         $req->fileData = $data;
         $req->wakeup();
     });
 }
Пример #7
0
 function doDel()
 {
     foreach ($_POST['id'] as $id) {
         FS::del($this->create($id, true));
         iCMS_DB::query("delete from `#iCMS@__advertise` where `id`='{$id}'");
         $this->iCMS->iCache->delete('system/adm/' . md5($_POST['varname'][$id]));
     }
     javascript::dialog("操作完成!", 'url:1');
 }
Пример #8
0
 function doSave()
 {
     strpos($_POST['tplpath'], '..') !== false && javascript::alert("文件路径不能带有..");
     preg_match("/\\.([a-zA-Z0-9]{2,4})\$/", $_POST['tplpath'], $exts);
     $FileExt = strtolower($exts[1]);
     strstr($FileExt, 'ph') && javascript::alert("文件格式错误!");
     in_array($FileExt, array('cer', 'htr', 'cdx', 'asa', 'asp', 'jsp', 'aspx', 'cgi')) && javascript::alert("文件格式错误!");
     $FileData = stripslashes($_POST['html']);
     FS::write(iPATH . 'templates' . $_POST['tplpath'], $FileData);
     javascript::dialog('保存成功!', 'url:' . __SELF__ . $_POST['REFERER']);
 }
Пример #9
0
 function doFile($do = null)
 {
     $dir = trim($_GET["dir"]);
     $type = $_GET["type"];
     $click = $_GET["click"];
     $from = $_GET["from"];
     $Folder = $do == 'template' ? 'templates' : $this->iCMS->config['uploadfiledir'];
     $callback = $_GET["callback"];
     $L = FS::folder($dir, $Folder, $type);
     include admincp::tpl("files.manage.file");
 }
Пример #10
0
 function doUpdate()
 {
     include_once iPATH . 'include/forum.class.php';
     if ($_POST['forum']) {
         $forum = new forum();
         $forum->cache();
     }
     if ($_POST['adm']) {
         include_once iPATH . 'admin/advertise.mo.php';
         $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__advertise`", OBJECT);
         $_count = count($rs);
         for ($i = 0; $i < $_count; $i++) {
             adm($rs[$i]);
         }
     }
     $_POST['tpl'] && $this->iCMS->clear_compiled_tpl();
     $_POST['iCMS_list'] && FS::rmdir(iPATH . 'cache/list');
     $_POST['iCMS_forum'] && FS::rmdir(iPATH . 'cache/forum');
     $_POST['iCMS_tag'] && FS::rmdir(iPATH . 'cache/tags');
     if ($_POST['iCMS_ALL']) {
         FS::rmdir(iPATH . 'cache/list');
         FS::rmdir(iPATH . 'cache/forum');
         FS::rmdir(iPATH . 'cache/tags');
     }
     $_POST['keywords'] && keywords_cache();
     $_POST['tags'] && tags_cache();
     if ($_POST['model']) {
         include iPATH . 'include/model.class.php';
         model::cache();
     }
     $_POST['field'] && field_cache();
     $_POST['config'] && CreateConfigFile();
     if ($_POST['Re-Article-Count']) {
         $rs = iCMS_DB::getArray("SELECT fid FROM `#iCMS@__forum`");
         $_count = count($rs);
         for ($i = 0; $i < $_count; $i++) {
             $c = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__article where `fid`='" . $rs[$i]['fid'] . "' LIMIT 1 ");
             iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` ='{$c}' WHERE `fid` ='" . $rs[$i]['fid'] . "' LIMIT 1 ");
         }
     }
     if ($_POST['Re-Tag-Count']) {
         include_once iPATH . 'include/forum.class.php';
         $rs = iCMS_DB::getArray("SELECT id FROM `#iCMS@__tags`");
         $_count = count($rs);
         for ($i = 0; $i < $_count; $i++) {
             $_count = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__taglist` WHERE `tid`='" . $rs[$i]['id'] . "'");
             iCMS_DB::query("UPDATE `#iCMS@__tags` SET `count` = '{$_count}'  WHERE `id` ='" . $rs[$i]['id'] . "'");
             tags_cache($rs[$i]['id']);
         }
     }
     javascript::dialog("执行完毕!", 'url:1');
 }
 protected function build()
 {
     $this->btn_group('submit', 'back');
     for ($i = 0; $i < count($this->_files); $i++) {
         $file = $this->_files[$i];
         $this->markup('line');
         $element = $this->element('title', 'text', array('group' => TRUE));
         $this->markup('filename', array('file' => $file));
         $this->markup('/line');
         $element->value(ucfirst(FS::name_body($file)));
         $element->rule('not_empty');
     }
 }
Пример #12
0
 function doCrop()
 {
     $pFile = $_GET['pic'];
     $iFile = FS::fp($pFile, '+iPATH');
     $callback = $_GET['callback'];
     list($width, $height, $imagetype) = @getimagesize($iFile);
     $pw = $width > 500 ? 500 : $width;
     $tw = (int) $this->iCMS->config['thumbwidth'];
     $th = (int) $this->iCMS->config['thumbhight'];
     $rate = round($pw / $width, 2) * 100;
     $sliderMin = round($tw / $width, 2) * 100;
     include admincp::tpl();
 }
Пример #13
0
 function get_file($key, $method)
 {
     $dirPath = $this->_dirs . '/' . (strpos($key, '/') !== false ? dirname($key) : '');
     if ($this->_dir_level != -1) {
         $a = str_split(md5($key), $this->_dir_level);
         $dirPath .= '/' . implode('/', $a) . '/';
     }
     if (!file_exists($dirPath) && $method == 'add') {
         FS::mkdir($dirPath);
     }
     $strrchr = strrchr($key, '/');
     $strrchr !== false && ($key = $strrchr);
     return $dirPath . $key . '.php';
 }
Пример #14
0
 public function stat($cb, $pri = EIO_PRI_DEFAULT)
 {
     if (!FS::$supported) {
         call_user_func($cb, $this, FS::statPrepare(fstat($this->fd)));
         return;
     }
     if ($this->stat) {
         call_user_func($cb, $this, $this->stat);
     } else {
         eio_fstat($this->fd, $pri, function ($file, $stat) use($cb) {
             $stat = FS::statPrepare($stat);
             $file->stat = $stat;
             call_user_func($cb, $file, $stat);
         }, $this);
     }
 }
 /**
  * Recreate images for a certain size
  */
 public function action_recreate()
 {
     ini_set('max_execution_time', 3600);
     // check if allowed
     if (!Acl::instance()->allowed($this->_controller, 'recreate')) {
         throw HTTP_Exception::factory(403, 'Not allowed to recreate images');
     }
     // get size
     $size = $this->request->param('id', FALSE);
     if ($size !== FALSE) {
         // get settings
         if ($settings = $this->_settings->get('sizes.' . $size, FALSE)) {
             // get all images
             $images = ORM::factory($this->_controller)->find_all();
             foreach ($images as $image) {
                 // check if the original exists
                 if (file_exists($this->_settings->get('path_files') . $image->file) && is_file($this->_settings->get('path_files') . $image->file)) {
                     // delete the requested size
                     FS::delete($this->_settings->get('path_images') . $size . DIRECTORY_SEPARATOR . $image->file);
                     // get existing sizes
                     $sizes = $image->sizes;
                     // unset this size
                     unset($sizes[$size]);
                     // recreate the wanted size
                     try {
                         $image->create_sizes($this->_settings->get('path_files') . $image->file, array($size => $settings), $this->_settings->get('path_images'));
                         // merge the original sizes and the newly created
                         $sizes = array_merge($sizes, $image->sizes);
                         // save these sizes
                         $image->sizes = $sizes;
                         $image->save();
                         //some feedback
                         echo 'recreated ' . $image->file . ' in size: ' . $size . '<br />';
                     } catch (Exception $e) {
                     }
                 }
             }
         }
     }
 }
Пример #16
0
function iCMS_advertise($vars, &$iCMS)
{
    if (empty($vars['name'])) {
        echo $iCMS->language('empty:TPL_advName');
        return false;
    }
    $rs = $iCMS->getCache('system/adm/' . md5($vars['name']));
    if ($rs->status != '1') {
        return false;
    }
    $file = FS::path($iCMS->config['htmlURL'] . '/!adm') . '/';
    switch ($rs->load) {
        case "js":
            $file .= "{$rs->style}-{$rs->id}.js";
            echo "<script src=\"" . $file . "\" language=\"javascript\"></script>";
            break;
        case "iframe":
            $file .= "{$rs->style}-{$rs->id}.html";
            if ($rs->style == "image") {
                $rs->code['image']['width'] && ($width = " width=\"{$rs->code['image']['width']}\"");
                $rs->code['image']['height'] && ($height = " height=\"{$rs->code['image']['height']}\"");
            } elseif ($rs->style == "flash") {
                $rs->code['flash']['width'] && ($width = " width=\"{$rs->code['flash']['width']}\"");
                $rs->code['flash']['height'] && ($height = " height=\"{$rs->code['flash']['height']}\"");
            }
            echo '<iframe src="' . $file . '" name="' . $rs->style . '-id-' . $rs->id . '"' . $width . $height . ' frameborder="0"scrolling="no" style="overflow: visible;"></iframe>';
            break;
        case "shtml":
            $file .= "{$rs->style}-{$rs->id}.shtml";
            $uri = parse_url($file);
            echo '<!--#include virtual="' . $uri['path'] . '"-->';
            break;
        default:
            if (time() >= $rs->starttime && (time() <= $rs->endtime || empty($rs->endtime))) {
                echo adm($rs);
            }
    }
}
Пример #17
0
 public function applyConfig()
 {
     parent::applyConfig();
     $pool = $this;
     if (!isset($this->preloading)) {
         $this->preloading = new ComplexJob();
     }
     $job = $this->preloading;
     $job->addJob('resolvfile', function ($jobname, $job) use($pool) {
         FS::readfile($pool->config->resolvfile->value, function ($file, $data) use($pool, $job, $jobname) {
             if ($file) {
                 preg_match_all('~nameserver ([^\\r\\n;]+)~', $data, $m);
                 foreach ($m[1] as $s) {
                     $pool->addServer($s);
                 }
             }
             $job->setResult($jobname);
         });
     });
     $job->addJob('hostsfile', function ($jobname, $job) use($pool) {
         FS::readfile($pool->config->hostsfile->value, function ($file, $data) use($pool, $job, $jobname) {
             if ($file) {
                 preg_match_all('~^(\\S+)\\s+([^\\r\\n]+)\\s*~m', $data, $m, PREG_SET_ORDER);
                 $pool->hosts = array();
                 foreach ($m as $h) {
                     $hosts = preg_split('~\\s+~', $h[2]);
                     $ip = $h[1];
                     foreach ($hosts as $host) {
                         $host = rtrim($host, '.') . '.';
                         $pool->hosts[$host] = $ip;
                     }
                 }
             }
             $job->setResult($jobname);
         });
     });
     $job();
 }
Пример #18
0
 public function uploadFile($uploadDir, $filePropArr)
 {
     if (count($filePropArr) == 0) {
         return 0;
     }
     $fName = FS::validateString(basename($filePropArr[$this->_uFFN]['name']));
     $uploadfile = $uploadDir . "/" . $fName;
     //var_dump($filePropArr[$this->_uFFN]['tmp_name'], $uploadfile);
     // Копируем файл из каталога для временного хранения файлов:
     //die(var_dump($filePropArr[$this->_uFFN]));
     if ($filePropArr[$this->_uFFN]['size'] == 0) {
         throw new Exception("Размер файла превышает 2 мегабайта :(. <br /> \n\t\t\t\tБыло бы замечательно, если бы Вы чуточку уменьшили размер фотографии ;)");
     }
     if ($this->copyFile($filePropArr[$this->_uFFN]['tmp_name'], $uploadfile)) {
         $retArr['lastName'] = $filePropArr[$this->_uFFN]['name'];
         $retArr['Mime'] = $filePropArr[$this->_uFFN]['type'];
         $retArr['size'] = $filePropArr[$this->_uFFN]['size'];
         $retArr['tmp_name'] = $filePropArr[$this->_uFFN]['tmp_name'];
     } else {
         throw new Exception("Ошибка копирования: " . $filePropArr[$this->_uFFN]['tmp_name'] . " в " . $uploadfile);
     }
     return $retArr;
 }
Пример #19
0
 /**
  * Копирование папки
  * @param string $oldPath текущий <b>полный</b> путь к папке
  * @param string $newPath будущий <b>полный</b> путь к папке
  */
 public function copyDir($oldPath, $newPath, $cut = FALSE)
 {
     if (file_exists($oldPath)) {
         $tempArr = $this->getDirContent($oldPath);
         if (count($tempArr) < 3) {
             $r1 = $this->createPath($newPath);
             if ($r1 == TRUE && $cut == TRUE) {
                 $this->deleteDir($oldPath);
             }
         } else {
             $this->createPath($newPath);
             foreach ($tempArr as $key => $value) {
                 if ($value != "." && $value != "..") {
                     //die("ok");
                     FS::copyElement($oldPath . "/" . $value, $newPath . "/" . $value, $cut);
                 }
             }
             FS::deleteSmthg($oldPath);
         }
     } else {
         throw new Exception("Неправильный исходный путь для копирования");
     }
     return TRUE;
 }
Пример #20
0
 function dodel()
 {
     foreach ($_POST['delete'] as $key => $value) {
         if (eregi("\\.sql\$", $value)) {
             FS::del(iPATH . 'admin/backup/' . $value);
         }
     }
     javascript::dialog("备份文件已删除!!", 'url:1');
 }
Пример #21
0
function uploadpath($f, $m = '+http')
{
    global $iCMS;
    switch ($m) {
        case '+http':
            $fp = $iCMS->config['uploadURL'] . '/' . $f;
            break;
        case '-http':
            $fp = str_replace($iCMS->config['uploadURL'] . '/', '', $f);
            break;
        case 'http2iPATH':
            $f = str_replace($iCMS->config['uploadURL'] . '/', '', $f);
            $fp = FS::path_join(iPATH, $iCMS->config['uploadfiledir']) . '/' . $f;
            break;
        case 'iPATH2http':
            $f = str_replace(FS::path_join(iPATH, $iCMS->config['uploadfiledir']) . '/', '', $f);
            $fp = $iCMS->config['uploadURL'] . '/' . $f;
            break;
        case '+iPATH':
            $fp = FS::path_join(iPATH, $iCMS->config['uploadfiledir']) . '/' . $f;
            break;
        case '-iPATH':
            $fp = str_replace(FS::path_join(iPATH, $iCMS->config['uploadfiledir']) . '/', '', $f);
            break;
    }
    return $fp;
}
Пример #22
0
 function Content($mid, $id)
 {
     global $iCMS;
     if (empty($id) || !$iCMS->config['ishtm'] || strstr($iCMS->config['aRule'], '{PHP}')) {
         return false;
     }
     $iCMS->mode = 'CreateHtml';
     $iCMS->htmlConf = array('enable' => true, 'ext' => $rs['htmlext'] ? $rs['htmlext'] : $iCMS->config['htmlext']);
     $html = $iCMS->content($mid, $id);
     FS::mkdir($iCMS->result->iurl->dir);
     FS::write($iCMS->result->iurl->path, $html, false);
     return true;
 }
Пример #23
0
function CreateConfigFile()
{
    global $iCMS;
    $tmp = iCMS_DB::getArray("SELECT * FROM `#iCMS@__config`");
    $config_data = "<?php\n\t\$config=array(\n";
    for ($i = 0; $i < count($tmp); $i++) {
        $_config .= "\t\t\"" . $tmp[$i]['name'] . "\"=>\"" . $tmp[$i]['value'] . "\",\n";
    }
    $config_data .= substr($_config, 0, -2);
    $config_data .= "\t\n);?>";
    FS::write(iPATH . 'include/site.config.php', $config_data);
}
Пример #24
0
</td>
                        <td>评论总数</td>
                        <td><?php 
echo iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__comment");
?>
</td>
                    </tr>
                    <tr>
                        <td>数据库大小</td>
                        <td><?php 
echo FS::sizeUnit($datasize + $indexsize);
?>
</td>
                        <td>文章数据大小</td>
                        <td><?php 
echo FS::sizeUnit($content_datasize);
?>
</td>
                    </tr>
                </tbody>
            </table></td>
        <td style="width:30%;"><table class="adminlist border" cellspacing="0">
                <thead>
                    <tr>
                        <th>iCMS相关信息</th>
                    </tr>
                </thead>
                <tr>
                    <td><div class="license">授权信息:<span id="license">未获取授权</span></div><div id="cmsnews"></div></td>
                </tr>
            </table></td>
Пример #25
0
 function thumbnail($upfiledir, $src, $tName, $tw = '', $th = '', $scale = true, $tDir = "thumb")
 {
     global $iCMS;
     $R = array();
     $tw = empty($tw) ? $iCMS->config['thumbwidth'] : (int) $tw;
     $th = empty($th) ? $iCMS->config['thumbhight'] : (int) $th;
     if ($tw && $th) {
         list($width, $height, $type) = @getimagesize($src);
         if ($width < 1 && $height < 1) {
             $R['width'] = $tw;
             $R['height'] = $th;
             $R['src'] = $src;
             return $R;
         }
         if ($width > $tw || $height > $th) {
             $R['src'] = $upfiledir . $tDir . "/" . $tName . '_' . $tw . 'x' . $th . '.' . substr(strrchr($src, "."), 1);
             if (in_array('Gmagick', get_declared_classes())) {
                 $image = new Gmagick();
                 $image->readImage($src);
                 $im = self::scale(array("tw" => $tw, "th" => $th, "w" => $image->getImageWidth(), "h" => $image->getImageHeight()));
                 $image->resizeImage($im['w'], $im['h'], null, 1);
                 $image->cropImage($tw, $th, 0, 0);
                 //$image->thumbnailImage($gm_w,$gm_h);
                 FS::mkdir($upfiledir . $tDir);
                 $image->writeImage($R['src']);
                 $image->destroy();
             } else {
                 $im = self::scale(array("tw" => $tw, "th" => $th, "w" => $width, "h" => $height), $scale);
                 $R['width'] = $im['w'];
                 $R['height'] = $im['h'];
                 $res = self::imagecreate($type, $src);
                 if ($res) {
                     $thumb = imagecreatetruecolor($im['w'], $im['h']);
                     imagecopyresampled($thumb, $res, 0, 0, 0, 0, $im['w'], $im['h'], $width, $height);
                     //PHP_VERSION != '4.3.2' && self::UnsharpMask($thumb);
                     FS::mkdir($upfiledir . $tDir);
                     self::image($thumb, $type, $R['src']);
                 } else {
                     $R['src'] = $src;
                 }
             }
         } else {
             $R['width'] = $width;
             $R['height'] = $height;
             $R['src'] = $src;
         }
         return $R;
     }
 }
 /**
  * increment file id, or create file id, windows style
  * 
  * "file" will become "file(2)"
  * "file(2)" will become "file(3)" etc.
  *
  * @return string
  */
 public static function name_unique($name, $path)
 {
     $extension = FS::name_extension($name);
     $body = FS::name_body($name);
     while (file_exists($path . $name)) {
         if (substr($body, -1) == ')') {
             // if the body ends in ')'
             // strip the trailing ')' and explode on '('
             $bodyParts = explode('(', substr($body, 0, strlen($body) - 1));
             if (is_numeric($bodyParts[count($bodyParts) - 1])) {
                 // if the last part of the explode is numeric, it means
                 // the last part was '('numeric')'
                 // get the number as int
                 $number = (int) $bodyParts[count($bodyParts) - 1];
                 // increment
                 $number++;
                 //remove last part of the name bodyparts
                 array_pop($bodyParts);
                 // stick it back on
                 // implode on '(' because we explode on '(' before
                 // so this way we reinsert '(' elsewhere in the body name
                 $body = implode('(', $bodyParts) . '(' . $number . ')';
             } else {
                 // last part was not (numeric)
                 // just stick (2) on it
                 $body = $body . '(2)';
             }
         } else {
             // last part was not (numeric)
             // just stick (2) on it
             $body = $body . '(2)';
         }
         // reassemble name
         $name = $body . '.' . $extension;
     }
     return $name;
 }
Пример #27
0
    function dodelpic()
    {
        $id = (int) $_GET['id'];
        $mid = (int) $_GET['mid'];
        $table = model::tbn($_GET['table']);
        $field = $_GET['field'];
        $fp = $_GET['fp'];
        if (empty($fp)) {
            return;
        }
        !$id && javascript::alert("请选择要删除图片的内容");
        $thumbfilepath = gethumb($fp, '', '', false, true, true);
        FS::del(FS::fp($fp, '+iPATH'));
        if ($thumbfilepath) {
            foreach ($thumbfilepath as $wh => $tfp) {
                FS::del(FS::fp($tfp, '+iPATH'));
            }
        }
        $filename = FS::info($fp)->filename;
        iCMS_DB::query("DELETE FROM `#iCMS@__file` WHERE `filename` = '{$filename}'");
        iCMS_DB::query("UPDATE `#iCMS@__{$table}` SET `{$field}` = '' WHERE `id` ='{$id}'");
        echo '<script type="text/javascript">
	        parent.$("#' . $field . '2").hide();
	        parent.$("#c' . $field . '1").hide();
	        parent.$("#' . $field . '1").show();
	        parent.$("[name=' . $field . ']").val("");</script>';
    }
Пример #28
0
        <th>删</th>
        <th>ID</th>
        <th>文件名</th>
        <th>内容ID</th>
        <th>文件大小</th>
        <th>上传时间</th>
        <th>管理</th>
      </tr>
    </thead>
    <?php 
for ($i = 0; $i < $_count; $i++) {
    $filename = $rs[$i]['filename'] . '.' . $rs[$i]['ext'];
    $path = $rs[$i]['path'] . '/' . $filename;
    $rs[$i]['time'] = get_date($rs[$i]['time'], 'Y-m-d H:i');
    $rs[$i]['size'] = FS::sizeUnit($rs[$i]['size']);
    $rs[$i]['icon'] = FS::icon($filename);
    $rs[$i]['path'] = uploadpath($path);
    ?>
    <tr id="fid<?php 
    echo $rs[$i]['id'];
    ?>
">
      <td><input type="checkbox" class="checkbox" name="delete[]" value="<?php 
    echo $rs[$i]['id'];
    ?>
" /></td>
      <td><?php 
    echo $total - ($i + $this->firstcount);
    ?>
</td>
      <td><a href="<?php 
Пример #29
0
 /**
  * File Upload Requests
  */
 public static function FilePOST(APIRequest $req)
 {
     $result = false;
     $error = false;
     // FIXME: Frontend does not show error
     call_user_func_array(array(API::$Handler, 'checkPrivilege'), array(APIUser::GROUP_UPLOAD));
     try {
         if (isset($_POST['path']) && isset($_FILES['upload'])) {
             if (FS::upload($_POST['path'], $_FILES['upload'])) {
                 $result = true;
             } else {
                 $error = "File was not uploaded";
             }
         }
     } catch (Exception $e) {
         $error = "File upload failed: {$e->getMessage()}";
     }
     return new APIResponse(false, $result, $error);
 }
Пример #30
0
        iCMS_DB::query("INSERT INTO `#iCMS@__members` (`groupid`, `username`, `password`, `nickname`, `gender`, `info`, `power`, `cpower`, `regtime`, `lastip`, `lastlogintime`, `logintimes`, `post`, `type`, `status`) VALUES ('1', '{$admin}', '" . md5($password) . "', '管理员', '0', '', '', '', '" . time() . "', '', '0', '0', '0', '1', '1');");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$setupURL}' WHERE `name` ='setupURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$publicURL}' WHERE `name` ='publicURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$htmlURL}' WHERE `name` ='htmlURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$uploadURL}' WHERE `name` ='uploadURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$setupURL}' WHERE `name` ='tagURL'");
        iCMS_DB::query("UPDATE `#iCMS@__config` SET `value` = '{$usercpURL}' WHERE `name` ='usercpURL'");
        $tmp = iCMS_DB::getArray("SELECT * FROM `#iCMS@__config`");
        $config_data = "<?php\n\t\$config=array(\n";
        for ($i = 0; $i < count($tmp); $i++) {
            $_config .= "\t\t\"" . $tmp[$i]['name'] . "\"=>\"" . $tmp[$i]['value'] . "\",\n";
        }
        $config_data .= substr($_config, 0, -2);
        $config_data .= "\t\n);?>";
        FS::write(iPATH . 'include/site.config.php', $config_data);
        FS::write($lockfile, 'iCMS');
        ?>
    </p>
    <p>共创建了<?php 
        echo $tablenum;
        ?>
个数据表.</p>
    <hr size="1" noshade="noshade" />
    <p>安装程序已经顺利执行完毕,请尽快删除整个 install 目录,以免被他人恶意利用。</p>
    <p>&nbsp;</p>
    <p><a href="../">点击这里进入首页</a><br />
      <a href="../admincp.php">点击这里进入后台</a></p>
    <hr size="1" noshade="noshade" />
    <p align="right"><a href="http://www.idreamsoft.com" target="_blank">Welcome to iDreamSoft</a></p>
    <?php 
    }