コード例 #1
0
ファイル: dev2prod.php プロジェクト: philum/cms
function plug_dev2prod($p, $o)
{
    $r = explore('progb', 'files', 1);
    $old = '_old/' . date('ymd') . '/';
    mkdir_r($old);
    $olb = '_old/' . date('ym') . '/';
    mkdir_r($olb);
    foreach ($r as $k => $v) {
        if ($v != '_trash.php') {
            $fa = 'progb/' . $v;
            $da = filemtime($fa);
            $sa = filesize($fa);
            $fb = 'prog/' . $v;
            $db = filemtime($fb);
            $sb = filesize($fb);
            if (date('d') == '01') {
                copy($fb, $olb . $v);
            }
            if ($sa != $sb or $da > $db) {
                copy($fb, $old . $v);
                copy($fa, $fb);
                $ret .= strdeb($v, '.') . ' ';
            }
        }
    }
    return $ret;
}
コード例 #2
0
ファイル: log.class.php プロジェクト: codethics/proteoerp
 function run(&$xml_reponse, $p)
 {
     $cmdtocheck = array("send", "me", "notice");
     if (in_array($this->name, $cmdtocheck)) {
         $clientid = $p["clientid"];
         $param = $p["param"];
         $sender = $p["sender"];
         $recipient = $p["recipient"];
         $recipientid = $p["recipientid"];
         $c =& pfcGlobalConfig::Instance();
         $u =& pfcUserConfig::Instance();
         $logpath = $c->proxies_cfg[$this->proxyname]["path"] == "" ? $c->data_private_path . "/logs" : $c->proxies_cfg[$this->proxyname]["path"];
         $logpath .= "/" . $c->getId();
         if (!file_exists($logpath)) {
             @mkdir_r($logpath);
         }
         if (file_exists($logpath) && is_writable($logpath)) {
             $logfile = $logpath . "/chat.log";
             if (is_writable($logpath)) {
                 // @todo write logs in a cleaner structured language (xml, html ... ?)
                 $log = $recipient . "\t";
                 $log .= date("d/m/Y") . "\t";
                 $log .= date("H:i:s") . "\t";
                 $log .= $sender . "\t";
                 $log .= $param . "\n";
                 file_put_contents($logfile, $log, FILE_APPEND | LOCK_EX);
             }
         }
     }
     // forward the command to the next proxy or to the final command
     return $this->next->run($xml_reponse, $p);
 }
コード例 #3
0
ファイル: ifr.php プロジェクト: philum/cms
function ifrim($f, $ret)
{
    $dr = 'users/public/ifram/';
    mkdir_r($dr);
    write_file($dr . mkday('', 'ydmHis') . '.jpg', $ret);
    return image($f);
}
コード例 #4
0
ファイル: ifrm.php プロジェクト: philum/cms
function ifrim($f, $d)
{
    $dr = 'users/public/ifrm/';
    mkdir_r($dr);
    $fb = $dr . strrchr_b($f, '/');
    write_file($fb, $d);
    return image('/' . $fb);
}
コード例 #5
0
ファイル: Local.php プロジェクト: simplator/medialib
 function mkdir_r($path)
 {
     if (file_exists($path)) {
         return;
     }
     mkdir_r(dirname($path));
     mkdir($path);
 }
コード例 #6
0
 /**
  * Tests {@link mkdir_r()}
  */
 function test_mkdir_r()
 {
     if (!is_writable(TMPDIR)) {
         $this->my_skip_message('TMPDIR is not writable.');
         return;
     }
     $this->assertTrue(mkdir_r(TMPDIR . 'test/foo'));
     $this->assertTrue(is_dir(TMPDIR . 'test/foo'));
     $this->assertTrue(mkdir_r(TMPDIR . 'test/foo/bar/2'));
     $this->assertTrue(is_dir(TMPDIR . 'test/foo/bar/2'));
     $this->assertTrue(mkdir_r(TMPDIR . 'test//foo/bar///0'));
     $this->assertTrue(is_dir(TMPDIR . 'test//foo/bar///0'));
     // does not work (PHP does not allow it):
     // ini_set('open_basedir', TMPDIR.'test/bar');
 }
コード例 #7
0
ファイル: FileUtil.php プロジェクト: RasterCode/Torque3D
 static function prepareOutputDir($outdir)
 {
     if (!file_exists($outdir)) {
         echo " Directory " . $outdir . " doesn't exist, attempting to create it.\n";
         if (!mkdir_r($outdir, 0777)) {
             echo " Couldn't create directory.\n";
             return false;
         }
     }
     if (!chdir($outdir)) {
         echo "Couldn't change directory\n";
         return false;
     }
     return true;
 }
コード例 #8
0
ファイル: publish_site.php プロジェクト: philum/cms
function funcb($j, $k, $v, $io)
{
    $xt = substr($v ? $v : $j, -3);
    if (valid_ext($xt) or strpos($j, 'imgb/icons') !== false && $xt == '.gz') {
        if (substr($j, 0, 1) != '_' && substr($v, 0, 1) != '_' && substr($v, -8, 4) != '_sav' && strpos($j, '_notes/') === false or $v == '_admin.css' or $v == '_global.css' or $v == '_pictos.css' or $v == '_default.css') {
            $dir = '_public/' . $j;
            if (!is_dir($dir)) {
                mkdir_r($dir);
            }
            $f = $j;
            $fb = $dir;
            if ($v) {
                $f .= '/' . $v;
                $fb .= '/' . $v;
            }
            $t = copyif($f, $fb);
            echo $t . $fb . br();
        }
    }
}
コード例 #9
0
ファイル: gz.php プロジェクト: 469306621/Languages
 */
$compress = $compress && strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false;
if ($compress) {
    $gz_uri = "tmp/gzip/" . $src_uri . ".gz";
    if (file_exists($gz_uri)) {
        $src_last_modified = filemtime($src_uri);
        $dst_last_modified = filemtime($gz_uri);
        // The gzip version of the file exists, but it is older
        // than the source file. We need to recreate it...
        if ($src_last_modified > $dst_last_modified) {
            unlink($gz_uri);
        }
    }
    if (!file_exists($gz_uri)) {
        if (!file_exists("tmp/gzip/" . $uri_dir)) {
            mkdir_r("tmp/gzip/" . $uri_dir);
        }
        $error = false;
        if ($fp_out = gzopen($gz_uri, "wb")) {
            if ($fp_in = fopen($src_uri, "rb")) {
                while (!feof($fp_in)) {
                    gzwrite($fp_out, fread($fp_in, 1024 * 512));
                }
                fclose($fp_in);
            } else {
                $error = true;
            }
            gzclose($fp_out);
        } else {
            $error = true;
        }
コード例 #10
0
ファイル: _cls_form.php プロジェクト: dapfru/gladiators
 function runsql($noprint)
 {
     global $search, $auth, $idn, $id, $site_path, $im_array, $test, $i, $er, $lang, $_POST, $insertid, $r;
     if (!$this->checkPermission(1)) {
         return 0;
     }
     if ($this->act != "select") {
         $sql = $this->sql;
     } else {
         $sql = $this->action;
     }
     if ($sql) {
         if (!($numrows = $_POST['numrows'])) {
             $numrows = 1;
         }
         $tmpsql = $sql;
         for ($i = 0; $i < $numrows; $i++) {
             $sql = $tmpsql;
             $sql = str_replace("&lt;", "<", $sql);
             $sql = str_replace("&gt;", ">", $sql);
             $sqlar = explode("#", $sql);
             foreach ($sqlar as $sql) {
                 $j++;
                 $l = substr($sql, 0, 1);
                 if ($l == "^") {
                     eval($this->set_form_params(substr($sql, 1), $i));
                 } else {
                     if (($this->mode == 2 && ($this->attributes['field'] || $this->attributes['item']) || $this->mode == 1 && ($this->document->getElementsByTagName("fields") || $this->document->getElementsByTagName("header"))) && $this->name != "delete" && $this->name != "create" && $this->name != "drop") {
                         $sql = $this->set_form_params($sql, $i);
                     } else {
                         $sql = set_params($sql);
                     }
                     if ($er) {
                         break;
                     } else {
                         if (strstr($sql, "insert")) {
                             $c = 1;
                         }
                         //print $sql."<br>";
                         $sqlstr = str_replace(";", "", $sql);
                         $sqlstr = str_replace("#dot", ";", $sqlstr);
                         if ($res = runquery($sqlstr)) {
                             $str = set_params($this->success);
                         } else {
                             $er .= "<font color=black>Error<br> " . str_replace(";", "", $sql) . " <br></font>" . mysql_error();
                         }
                         if (substr($sql, 0, 6) == "select") {
                             $r = mysql_fetch_array($res);
                         }
                         if (!$er) {
                             if ($im_array) {
                                 foreach ($im_array as $v) {
                                     //print "<br>".$v['name']." ".$v['type'];
                                     $name = $this->table;
                                     if (!$name) {
                                         $name = "unfiled";
                                     }
                                     if ($auth->user == 455) {
                                         //print "$sql<br>";
                                     }
                                     //print $v['type'];
                                     $q = select("select @insertid");
                                     if ($q[0]) {
                                         $idn = $q[0];
                                     } else {
                                         $idn = $id;
                                     }
                                     if ($name && $v['image'] && $idn) {
                                         $path = $site_path . "images/" . $name . "/" . strtolower($v['name']) . "/";
                                         if (!file_exists($path)) {
                                             mkdir_r($path);
                                         }
                                         $file = fopen($path . $idn . ".jpg", "w");
                                         fputs($file, $v['image']);
                                     }
                                     if ($v['small'] && $name && $idn) {
                                         $path = $site_path . "images/" . $name . "/small/";
                                         if (!file_exists($path)) {
                                             mkdir_r($path);
                                         }
                                         $file = fopen($path . $idn . ".jpg", "w");
                                         fputs($file, $v['small']);
                                     }
                                     fclose($file);
                                 }
                             }
                             unset($im_array);
                         }
                     }
                 }
                 $r1 = select("select @error");
                 if ($r1[0]) {
                     if (strstr($r1[0], "#")) {
                         if (substr($r1[0], strlen($r1[0]) - 1, 1) == "#") {
                             $r1[0] = substr($r1[0], 0, strlen($r1[0]) - 1);
                         }
                         $ar = explode("#", $r1[0]);
                         foreach ($ar as $a) {
                             $er .= message($a) . "<br>";
                         }
                     } else {
                         $er .= message($r1[0]);
                     }
                     break;
                 }
                 //поиск----------------------------------
                 if ($this->act == "insert" || substr($sql, 0, 6) == "insert") {
                     $q = select("select SearchID from en_search where TableName='{$this->table}'");
                     if ($q[0] && $search) {
                         $insert = select("@insertid");
                         $search = str_replace("\n\r", " ", $search);
                         $search = str_replace("Є", "е", $search);
                         $search = downstr(addslashes($search));
                         $ar = explode(" ", $search);
                         $position = 1;
                         foreach ($ar as $word) {
                             if ($word) {
                                 mysql_query("insert into en_searchindex(Word,SearchID,RecordID,Position) values('{$word}','{$q['0']}','{$insert['0']}','{$position}')");
                                 $position++;
                             }
                         }
                     }
                     unset($search);
                 }
                 if ($this->act == "update" || substr($sql, 0, 6) == "update") {
                     $q = select("select SearchID from en_search where TableName='{$this->table}'");
                     if ($q[0] && $search) {
                         mysql_query("delete from en_searchindex where SearchID='{$q['0']}' and RecordID='{$id}'");
                         $search = str_replace("\n\r", " ", $search);
                         $search = str_replace("Є", "е", $search);
                         $search = cut_end_word(downstr(addslashes($search)));
                         $ar = explode(" ", $search);
                         $position = 1;
                         foreach ($ar as $word) {
                             if ($word) {
                                 runsql("insert into en_searchindex(Word,SearchID,RecordID,Position) values('{$word}','{$q['0']}','{$id}','{$position}')");
                                 $position++;
                             }
                         }
                     }
                     unset($search);
                 }
                 if ($this->act == "delete" || substr($sql, 0, 6) == "delete") {
                     $q = select("select SearchID from en_search where TableName='{$this->table}'");
                     if ($q[0]) {
                         mysql_query("delete from en_searchindex where SearchID='{$q['0']}' and RecordID='{$id}'");
                     }
                 }
                 //поиск-----------------------------------
             }
             if ($er) {
                 break;
             }
         }
         //if($auth->user==455)
         //{
         //	exit;
         //}
         if ($er) {
             $retstr = icon('error', "<font color=red>{$er}</font>") . "<br>";
         } elseif ($str) {
             $retstr = icon('ok', "{$str}") . "<br>";
         } else {
             $retstr = "";
         }
         if (!$noprint) {
             print $retstr;
         } else {
             return $retstr;
         }
     }
 }
コード例 #11
0
/**
 * Unpack ZIP archive to destination directory
 *
 * @param string source file path
 * @param string destination directory path
 * @param boolean true if create destination directory
 * @param string Zip file name
 * @return boolean results
 */
function unpack_archive($src_file, $dest_dir, $mk_dest_dir = false, $src_file_name = '')
{
    if (!file_exists($dest_dir)) {
        // We can create directory
        if (!mkdir_r($dest_dir)) {
            echo '<p style="color:red">' . sprintf(T_('Unable to create &laquo;%s&raquo; directory to extract files from ZIP archive.'), $dest_dir) . '</p>';
            evo_flush();
            return false;
        }
    }
    if (function_exists('gzopen')) {
        // Unpack using 'zlib' extension and PclZip wrapper
        // Load PclZip class (PHP4):
        load_class('_ext/pclzip/pclzip.lib.php', 'PclZip');
        $PclZip = new PclZip($src_file);
        if ($PclZip->extract(PCLZIP_OPT_PATH, $dest_dir) == 0) {
            if (empty($src_file_name)) {
                // Set zip file name
                $src_file_name = $src_file;
            }
            echo '<p style="color:red">' . sprintf(T_('Unable to decompress &laquo;%s&raquo; ZIP archive.'), $src_file_name) . '<br />' . sprintf(T_('Error: %s'), $PclZip->errorInfo(true)) . '</p>';
            evo_flush();
            return false;
        }
    } else {
        debug_die('Unable to decompress the file because there is no \'zip\' or \'zlib\' extension installed in your PHP!');
    }
    return true;
}
コード例 #12
0
ファイル: index.php プロジェクト: dapfru/gladiators
    fclose($file);
    if (strstr($str, "message[" . $id . "]")) {
        $str = substr($str, 0, strpos($str, "\$message[" . $id)) . "\$message[" . $id . "] = '" . $_POST[$lang] . "';\r\n" . substr($str, strpos($str, "\$message", 1 + strpos($str, "\$message[" . $id)));
        $file = fopen($fname, "w");
        fputs($file, $str);
        fclose($file);
    }
}
if ($type == "engine/templates" && $step) {
    if ($id) {
        $_POST['TemplateID'] = $id;
    } else {
        $_POST['TemplateID'] = $insertid;
    }
    if (!file_exists($site_path . "templates/")) {
        mkdir_r($site_path . "templates/");
    }
    function recTemplate($id)
    {
        global $_POST;
        $q = select("select TemplateID,Header,Footer,ParentID from en_templates where TemplateID='{$id}'");
        if ($q[0]) {
            $_POST['Header'] = $q[Header] . $_POST['Header'];
            $_POST['Footer'] = $_POST['Footer'] . $q[Footer];
            if ($q[ParentID]) {
                recTemplate($q[ParentID]);
            }
        }
    }
    function makeTemplate($id)
    {
コード例 #13
0
ファイル: Project.php プロジェクト: tainer32/Torque3D
 public function generate($tpl, $platform, $base_dir)
 {
     // Alright, for each project scan and generate the file list.
     $projectFiles = array();
     $rootPhpBuildDir = getcwd();
     // Iterate over this project's outputs.
     foreach ($this->outputs as $outputName => $output) {
         $saved_includes = $this->includes;
         $saved_lib_dirs = $this->lib_dirs;
         //print_r( $output );
         // Supported platform?
         if (!$output->supportsPlatform($platform)) {
             //echo( "      # Skipping output: '$outputName'.\n" );
             continue;
         }
         // Get to the right working directory (first go back to root, then to relative)
         chdir($base_dir);
         //echo( "      - Changing CWD to " . $output->output_dir . "\n" );
         // echo("        (From: " . getcwd() . ")\n");
         if (!FileUtil::prepareOutputDir($output->output_dir)) {
             continue;
         }
         //echo( "      - Scanning directory for output  '.$outputName.'...\n" );
         if (!$this->generateFileList($projectFiles, $outputName, $output)) {
             echo "File list generation failed. Giving up on this project.\n";
             continue;
         }
         // Do any special work on the include/lib directories that we need
         $this->conditionDirectories($output, $projectFiles[$this->name]);
         $this->projectFileExt = $output->output_ext;
         if ($this->isCSProject()) {
             $this->projectFileExt = ".csproj";
         }
         // always csproj C# project under VS/MonoDevelop
         $outfile = $output->project_dir . $this->name . $this->projectFileExt;
         echo "      o Writing project file " . $outfile . "\n";
         $this->setTemplateParams($tpl, $output, $projectFiles[$this->name]);
         // To put a bandaid on the tools/player output dir problem
         // CodeReview: This should be in the template. -- BJG, 3/13/2007
         // Moved into templates -- neo
         // Write file
         $outdir = dirname($outfile);
         if (!file_exists($outdir)) {
             mkdir_r($outdir, 0777);
         }
         if ($hdl = fopen($outfile, 'w')) {
             if ($this->isApp()) {
                 $template = $output->template_app;
             } else {
                 if ($this->isLib()) {
                     $template = $output->template_lib;
                 } else {
                     if ($this->isSharedLib()) {
                         $template = $output->template_shared_lib;
                     } else {
                         if ($this->isSharedApp()) {
                             $template = $output->template_shared_app;
                         } else {
                             if ($this->isActiveX()) {
                                 $template = $output->template_activex;
                             } else {
                                 if ($this->isSafari()) {
                                     $template = $output->template_activex;
                                 } else {
                                     if ($this->isCSProject()) {
                                         $template = $output->template_csproj;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             fputs($hdl, $tpl->fetch($template));
             fclose($hdl);
         } else {
             trigger_error("Could not write output file: " . $output->outputFile, E_USER_ERROR);
         }
         if ($output->template_user) {
             $outfile = $output->project_dir . $this->name . $this->projectFileExt . '.' . getenv("COMPUTERNAME") . '.' . getenv("USERNAME") . '.user';
             if (!file_exists($outfile)) {
                 if ($hdl = fopen($outfile, 'w')) {
                     $template = $output->template_user;
                     fputs($hdl, $tpl->fetch($template));
                     fclose($hdl);
                 } else {
                     trigger_error("Could not write output file: " . $outfile, E_USER_ERROR);
                 }
             }
         }
         // Build the .filters file used by VS2010.
         if ($output->template_filter) {
             $filterData = new FilterData();
             array_walk($projectFiles[$this->name], array($filterData, 'callback'), '');
             $tpl->assign_by_ref('Folders', $filterData->folders);
             $tpl->assign_by_ref('SrcFiles', $filterData->srcFiles);
             $tpl->assign_by_ref('IncFiles', $filterData->incFiles);
             $tpl->assign_by_ref('OtherFiles', $filterData->otherFiles);
             $tpl->register_function('gen_uuid', 'gen_uuid');
             $outfile = $output->project_dir . $this->name . $this->projectFileExt . '.filters';
             if ($hdl = fopen($outfile, 'w')) {
                 fputs($hdl, $tpl->fetch($output->template_filter));
                 fclose($hdl);
             }
         }
         $this->includes = $saved_includes;
         $this->lib_dirs = $saved_lib_dirs;
     }
     // Copy any files into the project
     foreach ($this->fileCopyPaths as $paths) {
         $source = $paths[0];
         $dest = $paths[1];
         // We need forward slashes for paths.
         $source = str_replace("\\", "/", $source);
         $dest = str_replace("\\", "/", $dest);
         // Remove trailing slashes.
         $source = rtrim($source, " /");
         $dest = rtrim($dest, " /");
         // Remove any beginning slash from the destination
         $dest = ltrim($dest, " /");
         // Build full destination path
         $fullDest = $base_dir . "/" . $dest;
         echo "      o Copying file " . $source . " to " . $fullDest . "\n";
         if (!copy($source, $fullDest)) {
             trigger_error("\n*******************************************************************" . "\n" . "\n  Unable to copy required file for project!" . "\n" . "Source file: " . $source . "\n" . "Destination file: " . $fullDest . "\n" . "\n" . "\n*******************************************************************" . "\n", E_USER_ERROR);
         }
     }
 }
コード例 #14
0
ファイル: Wakka.class.php プロジェクト: freebasic/fbwikka
 function CheckUploadedFiles()
 {
     $upload_path = $this->config['upload_path'] . '/' . $this->GetPageTag();
     $max_upload_size = $this->config['max_upload_size'];
     if (!is_dir($upload_path)) {
         mkdir_r($upload_path);
     }
     // upload action
     $uploaded = $_FILES['file'];
     switch ($_FILES['file']['error']) {
         case 0:
             if ($_FILES["file"]["size"] > $max_upload_size) {
                 echo sprintf(ERROR_MAX_FILESIZE_EXCEEDED, bytesToHumanReadableUsage($max_upload_size));
                 unlink($uploaded['tmp_name']);
             } else {
                 $strippedname = str_replace("'", '', $uploaded['name']);
                 $strippedname = stripslashes($strippedname);
                 $destfile = $upload_path . '/' . $strippedname;
                 if (!file_exists($destfile)) {
                     if (!move_uploaded_file($uploaded['tmp_name'], $destfile)) {
                         echo ERROR_DURING_FILE_UPLOAD . "<br />\n";
                     }
                 } else {
                     echo sprintf(ERROR_FILE_EXISTS, $strippedname);
                 }
             }
             break;
         case 1:
         case 2:
             // File was too big.... as reported by the browser, respecting MAX_FILE_SIZE
             echo sprintf(ERROR_MAX_FILESIZE_EXCEEDED, bytesToHumanReadableUsage($max_upload_size));
             break;
         case 3:
             echo ERROR_DURING_FILE_UPLOAD;
             break;
         case 4:
             echo NO_FILE_UPLOADED;
             break;
     }
 }
コード例 #15
0
ファイル: file.class.php プロジェクト: danielheyman/EazySubs
 function incMeta($group, $subgroup, $leaf)
 {
     $c =& pfcGlobalConfig::Instance();
     // create directories
     $dir_base = $c->container_cfg_server_dir;
     $dir = $dir_base . '/' . $group . '/' . $subgroup;
     if (!is_dir($dir)) {
         mkdir_r($dir);
     }
     // create or replace metadata file
     $leaffilename = $dir . "/" . $leaf;
     // create return array
     $ret = array();
     $ret["timestamp"] = array();
     $ret["value"] = array();
     // read and increment data from metadata file
     clearstatcache();
     if (file_exists($leaffilename)) {
         $fh = fopen($leaffilename, 'r+');
         for ($i = 0; $i < 10; $i++) {
             if (flock($fh, LOCK_EX)) {
                 $leafvalue = chop(fread($fh, filesize($leaffilename)));
                 $leafvalue++;
                 rewind($fh);
                 fwrite($fh, $leafvalue);
                 fflush($fh);
                 ftruncate($fh, ftell($fh));
                 flock($fh, LOCK_UN);
                 break;
             }
             // If flock is working properly, this will never be reached
             $delay = rand(0, pow(2, $i + 1) - 1) * 5000;
             // Exponential backoff
             usleep($delay);
         }
         fclose($fh);
     } else {
         $leafvalue = "1";
         file_put_contents($leaffilename, $leafvalue, LOCK_EX);
     }
     $ret["value"][] = $leafvalue;
     $ret["timestamp"][] = filemtime($leaffilename);
     return $ret;
 }
コード例 #16
0
ファイル: _cls_form.php プロジェクト: dapfru/gladiators
 function runsql($noprint)
 {
     global $id, $site_path, $im_array, $test, $i, $er, $lang, $_POST, $insertid, $r;
     if (!$this->checkPermission(1)) {
         return 0;
     }
     if ($this->act != "select") {
         $sql = $this->sql;
     } else {
         $sql = $this->action;
     }
     if ($sql) {
         if (!($numrows = $_POST['numrows'])) {
             $numrows = 1;
         }
         $tmpsql = $sql;
         for ($i = 0; $i < $numrows; $i++) {
             $sql = $tmpsql;
             $sqlar = explode("#", $sql);
             foreach ($sqlar as $sql) {
                 //if($test) print "<br>$sql";
                 $l = substr($sql, 0, 1);
                 if ($l == "^") {
                     eval($this->set_form_params(substr($sql, 1), $i));
                 } else {
                     if (($this->mode == 2 && ($this->attributes['field'] || $this->attributes['item']) || $this->mode == 1 && ($this->document->getElementsByTagName("fields") || $this->document->getElementsByTagName("header"))) && $this->name != "delete" && $this->name != "create" && $this->name != "drop") {
                         $sql = $this->set_form_params($sql, $i);
                     } else {
                         $sql = set_params($sql);
                     }
                     if ($er) {
                         break;
                     } else {
                         if (strstr($sql, "insert")) {
                             $c = 1;
                         }
                         //print $sql."<br>";
                         $sqlstr = str_replace(";", "", $sql);
                         $sqlstr = str_replace("#dot", ";", $sqlstr);
                         if ($res = runquery($sqlstr)) {
                             $str = set_params($this->success);
                         } else {
                             $er .= "<font color=black>Error<br> " . str_replace(";", "", $sql) . " <br></font>" . mysql_error();
                         }
                         if (substr($sql, 0, 6) == "select") {
                             $r = mysql_fetch_array($res);
                         }
                         if (!$er) {
                             if ($im_array) {
                                 foreach ($im_array as $v) {
                                     print "<br>" . $v['name'] . " " . $v['type'];
                                     $name = $this->table;
                                     if (!$name) {
                                         $name = "unfiled";
                                     }
                                     print $v['type'];
                                     $q = select("select @insertid");
                                     if ($q[0]) {
                                         $idn = $q[0];
                                     } else {
                                         $idn = $id;
                                     }
                                     if ($name && $v['image'] && $idn) {
                                         $path = $site_path . "images/" . $name . "/" . strtolower($v['name']) . "/";
                                         if (!file_exists($path)) {
                                             mkdir_r($path);
                                         }
                                         $file = fopen($path . $idn . ".jpg", "w");
                                         fputs($file, $v['image']);
                                     }
                                     if ($v['small'] && $name && $idn) {
                                         $path = $site_path . "images/" . $name . "/small/";
                                         if (!file_exists($path)) {
                                             mkdir_r($path);
                                         }
                                         $file = fopen($path . $idn . ".jpg", "w");
                                         fputs($file, $v['small']);
                                     }
                                     fclose($file);
                                 }
                             }
                         }
                     }
                 }
                 $r1 = select("select @error");
                 if ($r1[0]) {
                     if (strstr($r1[0], "#")) {
                         if (substr($r1[0], strlen($r1[0]) - 1, 1) == "#") {
                             $r1[0] = substr($r1[0], 0, strlen($r1[0]) - 1);
                         }
                         $ar = explode("#", $r1[0]);
                         foreach ($ar as $a) {
                             $er .= message($a) . "<br>";
                         }
                     } else {
                         $er .= message($r1[0]);
                     }
                     break;
                 }
             }
             if ($er) {
                 break;
             }
         }
         //exit;
         if ($er) {
             $retstr = icon('error', "<font color=red>{$er}</font>") . "<br>";
         } elseif ($str) {
             $retstr = icon('ok', "{$str}") . "<br>";
         } else {
             $retstr = "";
         }
         if (!$noprint) {
             print $retstr;
         } else {
             return $retstr;
         }
     }
 }
コード例 #17
0
 /**
  * @return boolean true if cache has been successfully created
  */
 function cache_create($clear = true)
 {
     global $cache_path;
     // Create by using the filemanager's default chmod. TODO> we may not want to make these publicly readable
     if (!mkdir_r($this->ads_collcache_path, NULL)) {
         return false;
     }
     if ($clear) {
         // Clear contents of folder, if any:
         cleardir_r($this->ads_collcache_path);
     }
     // Create htaccess file with deny rules
     if (!create_htaccess_deny($cache_path)) {
         return false;
     }
     return true;
 }
コード例 #18
0
/**
 * Unpack ZIP archive to destination directory
 *
 * @param string source file path
 * @param string destination directory path
 * @param boolean true if create destination directory
 * @return boolean results
 */
function unpack_archive($src_file, $dest_dir, $mk_dest_dir = false)
{
    global $inc_path;
    if (!file_exists($dest_dir)) {
        // We can create directory
        if (!mkdir_r($dest_dir)) {
            echo '<p style="color:red">' . sprintf(T_('Unable to create &laquo;%s&raquo; directory.'), $dest_dir) . '</p>';
            evo_flush();
            return false;
        }
    }
    if (function_exists('gzopen')) {
        // Unpack using 'zlib' extension and PclZip wrapper
        // Load PclZip class (PHP4):
        load_class('_ext/pclzip/pclzip.lib.php', 'PclZip');
        $PclZip = new PclZip($src_file);
        if ($PclZip->extract(PCLZIP_OPT_PATH, $dest_dir) == 0) {
            echo '<p style="color:red">' . sprintf(T_('Unable to unpack &laquo;%s&raquo; ZIP archive.'), $src_file) . '</p>';
            evo_flush();
            return false;
        }
    } else {
        debug_die('There is no \'zip\' or \'zlib\' extension installed!');
    }
    return true;
}
コード例 #19
0
ファイル: _cls_image.php プロジェクト: dapfru/gladiators
 function imageResize()
 {
     global $engine_path, $ImageTrimX, $ImageTrimY;
     $source = $this->image;
     $newWidth = $this->newWidth;
     $newHeight = $this->newHeight;
     $imType = $this->type;
     if (!$imType || $imType == "jpeg" || $imType == "pjpeg") {
         $srcImage = ImageCreateFromJPEG($source);
     } elseif ($imType == "gif") {
         $srcImage = LoadGif($source);
     } else {
         $srcImage = ImageCreateFromPNG($source);
     }
     $srcWidth = ImageSX($srcImage);
     $srcHeight = ImageSY($srcImage);
     $ratioWidth = $srcWidth / $newWidth;
     $ratioHeight = $srcHeight / $newHeight;
     if ($ratioWidth < 1 && $this->fix == "width" || $ratioHeight < 1 && $this->fix == "height") {
         $destWidth = $srcWidth;
         $destHeight = $srcHeight;
         $mode = 1;
     } elseif ($ratioWidth > $ratioHeight && $newHeight != 120 || $ratioWidth < $ratioHeight && $this->fix != "width" || $this->fix == "height") {
         $destWidth = $srcWidth / $ratioHeight;
         $destHeight = $newHeight;
         $mode = 2;
     } else {
         $destWidth = $newWidth;
         $destHeight = $srcHeight / $ratioWidth;
         $mode = 3;
     }
     //print "$ratioWidth > $ratioHeight) || ( $ratioWidth < $ratioHeight && $this->fix ".$mode;
     //exit;
     if ($newWidth != $srcWidth && $newHeight != $srcHeight && $newWidth != 160 && $mode != 1 && $newHeight != 120) {
         if (!strlen($ImageTrim)) {
             $ImageTrim = 2;
         }
         if ($newy) {
             $y = $newy;
         } elseif ($ImageTrimY == 0) {
             $y = 0;
         } elseif ($ImageTrimY == 1) {
             $y = ($newHeight - $destHeight) / 4;
         } elseif ($ImageTrimY == 2) {
             $y = ($newHeight - $destHeight) / 2;
         } elseif ($ImageTrimY == 3) {
             $y = 3 * ($newHeight - $destHeight) / 2;
         } elseif ($ImageTrimY == 4) {
             $y = 5 * ($newHeight - $destHeight) / 2;
         }
         if ($newx) {
             $x = $newx;
         } elseif ($ImageTrimX == 0) {
             $x = 0;
         } elseif ($ImageTrimX == 1) {
             $x = ($newWidth - $destWidth) / 4;
         } elseif ($ImageTrimX == 2) {
             $x = ($newWidth - $destWidth) / 2;
         } elseif ($ImageTrimX == 3) {
             $x = 3 * ($newWidth - $destWidth) / 2;
         } elseif ($ImageTrimX == 4) {
             $x = 5 * ($newWidth - $destWidth) / 2;
         }
         $destImage = imagecreatetruecolor($newWidth, $newHeight);
         imagecopyresampled($destImage, $srcImage, $x, $y, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
     } else {
         $destImage = imagecreatetruecolor($destWidth, $destHeight);
         imagecopyresampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
     }
     $this->newWidth = $destWidth;
     $this->newHeight = $destHeight;
     if ($this->mix) {
         $destImage = $this->mix($destImage);
     }
     $name = $engine_path . "tmp/" . $this->name;
     if (!file_exists($engine_path . "tmp/")) {
         mkdir_r($engine_path . "tmp/");
     }
     if ($imType == "jpeg" || $imType == "pjpeg") {
         Imagejpeg($destImage, $name);
     } elseif ($imType == "gif") {
         Imagegif($destImage, $name);
     } else {
         Imagepng($destImage, $name);
     }
     $file['tmp_name'] = $name;
     ImageDestroy($srcImage);
     ImageDestroy($destImage);
     return $file;
 }
コード例 #20
0
ファイル: tarim.php プロジェクト: philum/cms
function tarim_copy($rc)
{
    $dr = 'imgd/';
    rmdir_r('imgd');
    mkdir_r($dr);
    foreach ($rc as $v) {
        copy($v, $dr . substr($v, 4));
    }
}
コード例 #21
0
ファイル: pop.php プロジェクト: philum/cms
function makenew($qb, $restore = '')
{
    $qdu = ses('qdu');
    require 'styl.php';
    if (!auth(4)) {
        $_SESSION['auth'] = 4;
    }
    msq_copy("system", "default_css_1", 'design', $qb . '_design_1');
    msq_copy("system", "default_clr_1", 'design', $qb . '_clrset_1');
    msq_copy("system", "default_css_2", 'design', $qb . '_design_2');
    msq_copy("system", "default_clr_2", 'design', $qb . '_clrset_2');
    msq_copy("system", "default_mods", 'users', $qb . '_mods_1');
    msq_copy("system", "default_rstr", 'users', $qb . '_rstr');
    msq_copy("system", "default_apps", 'users', $qb . '_apps');
    if ($restore) {
        list($rstr, $config) = ndprms_defaults();
        update('qdu', 'rstr', $rstr, 'name', ses('qb'));
        update('qdu', 'config', $config, 'name', ses('qb'));
    }
    $clr = msql_read('system', 'default_clr_1', '');
    $css = 'css/' . $qb . '_design_1.css';
    build_css($css, css_default(1), $clr);
    $clr = msql_read('system', 'default_clr_2', '');
    $css = 'css/' . $qb . '_design_2.css';
    build_css($css, css_default(), $clr);
    update('qdu', 'menus', ses('dayx'), 'name', $qb);
    if (!is_dir('users/' . $qb)) {
        mkdir_r('users/' . $qb);
    }
    return $qb;
}
コード例 #22
0
ファイル: finder.php プロジェクト: philum/cms
function fi_download($d, $id, $res)
{
    $dr = 'users/';
    $drd = fi_droot();
    if (!$res) {
        $nnm = $_SESSION['qb'] . '/downoalds/' . strrchr_b($d, '/');
        $j = $id . 'fidwn_fifunc___fi*download_' . ajx($d) . '_' . $id . '__' . $id . 'fdwn';
        $ret = btn('txtsmall', 'target:') . input(1, $id . 'fdwn', $nnm) . ' ' . lj('txtbox', $j, 'ok');
    } elseif (auth(3)) {
        $res = ajxg($res);
        $ra = explode('/', $res);
        if ($ra[0] == $_SESSION['qb']) {
            mkdir_r($dr . $res);
            copy($drd . $d, $dr . $res);
        } else {
            $not = 'not_';
        }
        $ret = fi_parent($d, $id . 'fidwn', $not . 'saved', 1);
    }
    return $ret;
}
コード例 #23
0
ファイル: _xmlrpcs.funcs.php プロジェクト: ldanielz/uesp.blog
/**
 * metaWeblog.newMediaObject image upload
 * wp.uploadFile
 *
 * Supplied image is encoded into the struct as bits
 *
 * @see http://www.xmlrpc.com/metaWeblogApi#metaweblognewmediaobject
 * @see http://codex.wordpress.org/XML-RPC_wp#wp.uploadFile
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 blogid (string): Unique identifier of the blog the post will be added to.
 *						Currently ignored in b2evo, in favor of the category.
 *					1 username (string): Login for a Blogger user who has permission to edit the given
 *						post (either the user who originally created it or an admin of the blog).
 *					2 password (string): Password for said username.
 *					3 struct (struct)
 * 							- name : filename
 * 							- type : mimetype
 * 							- bits : base64 encoded file
 * @return xmlrpcresp XML-RPC Response
 */
function _wp_mw_newmediaobject($m)
{
    global $Settings, $Plugins, $force_upload_forbiddenext;
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 1, 2))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET BLOG:
    /**
     * @var Blog
     */
    if (!($Blog =& xmlrpcs_get_Blog($m, 0))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // CHECK PERMISSION:
    if (!$current_User->check_perm('files', 'add', false, $Blog->ID)) {
        // Permission denied
        return xmlrpcs_resperror(3);
        // User error 3
    }
    logIO('Permission granted.');
    if (!$Settings->get('upload_enabled')) {
        return xmlrpcs_resperror(2, 'Object upload not allowed');
    }
    $xcontent = $m->getParam(3);
    // Get the main data - and decode it properly for the image - sorry, binary object
    logIO('Decoding content...');
    $contentstruct = xmlrpc_decode_recurse($xcontent);
    $data = $contentstruct['bits'];
    $file_mimetype = isset($contentstruct['type']) ? $contentstruct['type'] : '(none)';
    logIO('Received MIME type: ' . $file_mimetype);
    $overwrite = false;
    if (isset($contentstruct['overwrite'])) {
        $overwrite = (bool) $contentstruct['overwrite'];
    }
    logIO('Overwrite if exists: ' . ($overwrite ? 'yes' : 'no'));
    load_funcs('files/model/_file.funcs.php');
    $filesize = evo_bytes($data);
    if (($maxfilesize = $Settings->get('upload_maxkb') * 1024) && $filesize > $maxfilesize) {
        return xmlrpcs_resperror(4, sprintf(T_('The file is too large: %s but the maximum allowed is %s.'), bytesreadable($filesize, false), bytesreadable($maxfilesize, false)));
    }
    logIO('File size is OK: ' . bytesreadable($filesize, false));
    $FileRootCache =& get_FileRootCache();
    $fm_FileRoot =& $FileRootCache->get_by_type_and_ID('collection', $Blog->ID, true);
    if (!$fm_FileRoot) {
        // fileRoot not found:
        return xmlrpcs_resperror(14, 'File root not found');
    }
    $rf_filepath = $contentstruct['name'];
    logIO('Received filepath: ' . $rf_filepath);
    // Split into path + name:
    $filepath_parts = explode('/', $rf_filepath);
    $filename = array_pop($filepath_parts);
    logIO('Original file name: ' . $filename);
    // Validate and sanitize filename
    if ($error_filename = process_filename($filename, true)) {
        return xmlrpcs_resperror(5, $error_filename);
    }
    logIO('Sanitized file name: ' . $filename);
    // Check valid path parts:
    $rds_subpath = '';
    foreach ($filepath_parts as $filepath_part) {
        if (empty($filepath_part) || $filepath_part == '.') {
            // self ref not useful
            continue;
        }
        if ($error = validate_dirname($filepath_part)) {
            // invalid relative path:
            logIO($error);
            return xmlrpcs_resperror(6, $error);
        }
        $rds_subpath .= $filepath_part . '/';
    }
    logIO('Subpath: ' . $rds_subpath);
    // Create temporary file and insert contents into it.
    $tmpfile_name = tempnam(sys_get_temp_dir(), 'fmupload');
    if ($tmpfile_name) {
        if (save_to_file($data, $tmpfile_name, 'wb')) {
            $image_info = @getimagesize($tmpfile_name);
        } else {
            return xmlrpcs_resperror(13, 'Error while writing to temp file.');
        }
    }
    if (!empty($image_info)) {
        // This is an image file, let's check mimetype and correct extension
        if ($image_info['mime'] != $file_mimetype) {
            // Invalid file type
            $FiletypeCache =& get_FiletypeCache();
            // Get correct file type based on mime type
            $correct_Filetype = $FiletypeCache->get_by_mimetype($image_info['mime'], false, false);
            $file_mimetype = $image_info['mime'];
            // Check if file type is known by us, and if it is allowed for upload.
            // If we don't know this file type or if it isn't allowed we don't change the extension! The current extension is allowed for sure.
            if ($correct_Filetype && $correct_Filetype->is_allowed()) {
                // A FileType with the given mime type exists in database and it is an allowed file type for current User
                // The "correct" extension is a plausible one, proceed...
                $correct_extension = array_shift($correct_Filetype->get_extensions());
                $path_info = pathinfo($filename);
                $current_extension = $path_info['extension'];
                // change file extension to the correct extension, but only if the correct extension is not restricted, this is an extra security check!
                if (strtolower($current_extension) != strtolower($correct_extension) && !in_array($correct_extension, $force_upload_forbiddenext)) {
                    // change the file extension to the correct extension
                    $old_filename = $filename;
                    $filename = $path_info['filename'] . '.' . $correct_extension;
                }
            }
        }
    }
    // Get File object for requested target location:
    $FileCache =& get_FileCache();
    $newFile =& $FileCache->get_by_root_and_path($fm_FileRoot->type, $fm_FileRoot->in_type_ID, trailing_slash($rds_subpath) . $filename, true);
    if ($newFile->exists()) {
        if ($overwrite && $newFile->unlink()) {
            // OK, file deleted
            // Delete thumb caches from old location:
            logIO('Old file deleted');
            $newFile->rm_cache();
        } else {
            return xmlrpcs_resperror(8, sprintf(T_('The file &laquo;%s&raquo; already exists.'), $filename));
        }
    }
    // Trigger plugin event
    if ($Plugins->trigger_event_first_false('AfterFileUpload', array('File' => &$newFile, 'name' => &$filename, 'type' => &$file_mimetype, 'tmp_name' => &$tmpfile_name, 'size' => &$filesize))) {
        // Plugin returned 'false'.
        // Abort upload for this file:
        @unlink($tmpfile_name);
        return xmlrpcs_resperror(16, 'File upload aborted by a plugin.');
    }
    if (!mkdir_r($newFile->get_dir())) {
        // Dir didn't already exist and could not be created
        return xmlrpcs_resperror(9, 'Error creating sub directories: ' . $newFile->get_rdfs_rel_path());
    }
    if (!@rename($tmpfile_name, $newFile->get_full_path())) {
        return xmlrpcs_resperror(13, 'Error while writing to file.');
    }
    // chmod the file
    $newFile->chmod();
    // Initializes file properties (type, size, perms...)
    $newFile->load_properties();
    // Load meta data AND MAKE SURE IT IS CREATED IN DB:
    $newFile->meta == 'unknown';
    $newFile->load_meta(true);
    // Resize and rotate
    logIO('Running file post-processing (resize and rotate)...');
    prepare_uploaded_files(array($newFile));
    logIO('Done');
    $url = $newFile->get_url();
    logIO('URL of new file: ' . $url);
    $struct = new xmlrpcval(array('file' => new xmlrpcval($filename, 'string'), 'url' => new xmlrpcval($url, 'string'), 'type' => new xmlrpcval($file_mimetype, 'string')), 'struct');
    logIO('OK.');
    return new xmlrpcresp($struct);
}
コード例 #24
0
ファイル: icons.php プロジェクト: philum/cms
function icons_build($k)
{
    $nm = 'imgb/icons/system/philum/16/' . $k . '.png';
    mkdir_r($nm);
    $d = msql_read('system', 'program_icons', $k);
    if ($d) {
        $r = str_split($d);
    }
    icons_graphics($r, 16, 16, $nm);
    return pictosys($k);
}
コード例 #25
0
ファイル: _system.funcs.php プロジェクト: ldanielz/uesp.blog
/**
 * Create cache/ and  /cache/plugins/ folders
 *
 * @return boolean false if cache/ folder not exists or has limited editing permission, true otherwise
 */
function system_create_cache_folder()
{
    global $cache_path;
    // create /cache folder
    mkdir_r($cache_path);
    // check /cache folder
    if (system_check_dir('cache') > 0) {
        return false;
    }
    // create /cache/plugins/ folder
    mkdir_r($cache_path . 'plugins/');
    return true;
}
コード例 #26
0
 /**
  * Constructor
  *
  * Will fail if non existent User or Blog is requested.
  * But specific access permissions on (threfore existence of) this User or Blog should have been tested before anyway.
  *
  * @param string Root type: 'user', 'group' or 'collection'
  * @param integer ID of the user, the group or the collection the file belongs to...
  * @param boolean Create the directory, if it does not exist yet?
  */
 function FileRoot($root_type, $root_in_type_ID, $create = true)
 {
     /**
      * @var User
      */
     global $current_User;
     global $Messages;
     global $Settings, $Debuglog;
     global $Blog;
     // Store type:
     $this->type = $root_type;
     // Store ID in type:
     $this->in_type_ID = $root_in_type_ID;
     // Generate unique ID:
     $this->ID = FileRoot::gen_ID($root_type, $root_in_type_ID);
     switch ($root_type) {
         case 'user':
             $UserCache =& get_UserCache();
             if (!($User =& $UserCache->get_by_ID($root_in_type_ID, false, false))) {
                 // User not found
                 return false;
             }
             $this->name = $User->get('login');
             //.' ('. /* TRANS: short for "user" */ T_('u').')';
             $this->ads_path = $User->get_media_dir($create);
             $this->ads_url = $User->get_media_url();
             return;
         case 'collection':
             $BlogCache =& get_BlogCache();
             if (!($Blog =& $BlogCache->get_by_ID($root_in_type_ID, false, false))) {
                 // Blog not found
                 return false;
             }
             $this->name = $Blog->get('shortname');
             //.' ('. /* TRANS: short for "blog" */ T_('b').')';
             $this->ads_path = $Blog->get_media_dir($create);
             $this->ads_url = $Blog->get_media_url();
             return;
         case 'shared':
             // fp> TODO: handle multiple shared directories
             global $media_path, $media_url;
             $rds_shared_subdir = 'shared/global/';
             $ads_shared_dir = $media_path . $rds_shared_subdir;
             if (!$Settings->get('fm_enable_roots_shared')) {
                 // Shared dir is disabled:
                 $Debuglog->add('Attempt to access shared dir, but this feature is globally disabled', 'files');
             } elseif (!mkdir_r($ads_shared_dir)) {
                 // Only display error on an admin page:
                 if (is_admin_page()) {
                     $Messages->add(sprintf(T_('The directory &laquo;%s&raquo; could not be created.'), $rds_shared_subdir) . get_manual_link('directory_creation_error'), 'error');
                 }
             } else {
                 $this->name = T_('Shared');
                 $this->ads_path = $ads_shared_dir;
                 if (isset($Blog)) {
                     // (for now) Let's make shared files appear as being part of the currently displayed blog:
                     $this->ads_url = $Blog->get_local_media_url() . 'shared/global/';
                 } else {
                     $this->ads_url = $media_url . 'shared/global/';
                 }
             }
             return;
         case 'skins':
             // fp> some stuff here should go out of here... but I don't know where to put it yet. I'll see after the Skin refactoring.
             if (!$Settings->get('fm_enable_roots_skins')) {
                 // Skins root is disabled:
                 $Debuglog->add('Attempt to access skins dir, but this feature is globally disabled', 'files');
             } elseif (empty($current_User) || !$current_User->check_perm('templates')) {
                 // No perm to access templates:
                 $Debuglog->add('Attempt to access skins dir, but no permission', 'files');
             } else {
                 global $skins_path, $skins_url;
                 $this->name = T_('Skins');
                 $this->ads_path = $skins_path;
                 if (isset($Blog)) {
                     // (for now) Let's make skin files appear as being part of the currently displayed blog:
                     $this->ads_url = $Blog->get_local_skins_url();
                 } else {
                     $this->ads_url = $skins_url;
                 }
             }
             return;
     }
     debug_die("Invalid root type");
 }
コード例 #27
0
 /**
  * Initialize the phpfreechat configuration
  * this initialisation is done once at startup then it is stored into a session cache
  */
 function init()
 {
     $ok = true;
     // check the parameters types
     $array_params = $this->_params_type["array"];
     foreach ($array_params as $ap) {
         if (!is_array($this->{$ap})) {
             $this->errors[] = _pfc("'%s' parameter must be an array", $ap);
         }
     }
     $numerical_positive_params = $this->_params_type["positivenumeric"];
     foreach ($numerical_positive_params as $npp) {
         if (!is_int($this->{$npp}) || $this->{$npp} < 0) {
             $this->errors[] = _pfc("'%s' parameter must be a positive number", $npp);
         }
     }
     $boolean_params = $this->_params_type["bool"];
     foreach ($boolean_params as $bp) {
         if (!is_bool($this->{$bp})) {
             $this->errors[] = _pfc("'%s' parameter must be a boolean", $bp);
         }
     }
     $string_params = $this->_params_type["string"];
     foreach ($string_params as $sp) {
         if (!is_string($this->{$sp})) {
             $this->errors[] = _pfc("'%s' parameter must be a charatere string", $sp);
         }
     }
     if ($this->title == "") {
         $this->title = _pfc("My Chat");
     }
     // first of all, check the used functions
     $f_list["file_get_contents"] = _pfc("You need %s", "PHP 4 >= 4.3.0 or PHP 5");
     $err_session_x = "You need PHP 4 or PHP 5";
     $f_list["session_start"] = $err_session_x;
     $f_list["session_destroy"] = $err_session_x;
     $f_list["session_id"] = $err_session_x;
     $f_list["session_name"] = $err_session_x;
     $err_preg_x = _pfc("You need %s", "PHP 3 >= 3.0.9 or PHP 4 or PHP 5");
     $f_list["preg_match"] = $err_preg_x;
     $f_list["preg_replace"] = $err_preg_x;
     $f_list["preg_split"] = $err_preg_x;
     $err_ob_x = _pfc("You need %s", "PHP 4 or PHP 5");
     $f_list["ob_start"] = $err_ob_x;
     $f_list["ob_get_contents"] = $err_ob_x;
     $f_list["ob_end_clean"] = $err_ob_x;
     $f_list["get_object_vars"] = _pfc("You need %s", "PHP 4 or PHP 5");
     $this->errors = array_merge($this->errors, check_functions_exist($f_list));
     //    $this->errors = array_merge($this->errors, @test_writable_dir($this->data_public_path, "data_public_path"));
     $this->errors = array_merge($this->errors, @test_writable_dir($this->data_private_path, "data_private_path"));
     $this->errors = array_merge($this->errors, @test_writable_dir($this->data_private_path . "/cache", "data_private_path/cache"));
     // install the public directory content
     $dir = dirname(__FILE__) . "/../data/public/js";
     $dh = opendir($dir);
     while (false !== ($file = readdir($dh))) {
         $f_src = $dir . '/' . $file;
         $f_dst = $this->data_public_path . '/js/' . $file;
         if ($file == "." || $file == ".." || !is_file($f_src)) {
             continue;
         }
         // skip . and .. generic files
         // install js files only if the destination doesn't exists or if the destination timestamp is older than the source timestamp
         if (!file_exists($f_dst) || filemtime($f_dst) < filemtime($f_src)) {
             mkdir_r($this->data_public_path . '/js/');
             copy($f_src, $f_dst);
         }
         if (!file_exists($f_dst)) {
             $this->errors[] = _pfc("%s doesn't exist, data_public_path cannot be installed", $f_dst);
         }
     }
     closedir($dh);
     // ---
     // test client script
     // try to find the path into server configuration
     if ($this->client_script_path == '') {
         $this->client_script_path = pfc_GetScriptFilename();
     }
     if ($this->server_script_url == '' && $this->server_script_path == '') {
         $filetotest = $this->client_script_path;
         // do not take into account the url parameters
         if (preg_match("/(.*)\\?(.*)/", $filetotest, $res)) {
             $filetotest = $res[1];
         }
         if (!file_exists($filetotest)) {
             $this->errors[] = _pfc("%s doesn't exist", $filetotest);
         }
         $this->server_script_url = './' . basename($filetotest) . $this->_query_string;
     }
     // calculate datapublic url
     if ($this->data_public_url == "") {
         $this->data_public_url = pfc_RelativePath($this->client_script_path, $this->data_public_path);
     }
     if ($this->server_script_path == '') {
         $this->server_script_path = $this->client_script_path;
     }
     // ---
     // test server script
     if ($this->server_script_url == '') {
         $filetotest = $this->server_script_path;
         // do not take into account the url parameters
         if (preg_match("/(.*)\\?(.*)/", $this->server_script_path, $res)) {
             $filetotest = $res[1];
         }
         if (!file_exists($filetotest)) {
             $this->errors[] = _pfc("%s doesn't exist", $filetotest);
         }
         $this->server_script_url = pfc_RelativePath($this->client_script_path, $this->server_script_path) . '/' . basename($filetotest) . $this->_query_string;
     }
     // check if the theme_path parameter are correctly setup
     if ($this->theme_default_path == '' || !is_dir($this->theme_default_path)) {
         $this->theme_default_path = dirname(__FILE__) . '/../themes';
     }
     if ($this->theme_path == '' || !is_dir($this->theme_path)) {
         $this->theme_path = $this->theme_default_path;
     }
     // If the user didn't give any theme_default_url value,
     // copy the default theme resources in a public directory
     if ($this->theme_default_url == '') {
         mkdir_r($this->data_public_path . '/themes/default');
         if (!is_dir($this->data_public_path . '/themes/default')) {
             $this->errors[] = _pfc("cannot create %s", $this->data_public_path . '/themes/default');
         } else {
             $ret = copy_r(dirname(__FILE__) . '/../themes/default', $this->data_public_path . '/themes/default');
             if (!$ret) {
                 $this->errors[] = _pfc("cannot copy %s in %s", dirname(__FILE__) . '/../themes/default', $this->data_public_path . '/themes/default');
             }
         }
         $this->theme_default_url = $this->data_public_url . '/themes';
     }
     if ($this->theme_url == '') {
         mkdir_r($this->data_public_path . '/themes/' . $this->theme);
         if (!is_dir($this->data_public_path . '/themes/' . $this->theme)) {
             $this->errors[] = _pfc("cannot create %s", $this->data_public_path . '/themes/' . $this->theme);
         } else {
             $ret = copy_r($this->theme_path . '/' . $this->theme, $this->data_public_path . '/themes/' . $this->theme);
             if (!$ret) {
                 $this->errors[] = _pfc("cannot copy %s in %s", $this->theme_path . '/' . $this->theme, $this->data_public_path . '/themes/' . $this->theme);
             }
         }
         $this->theme_url = $this->theme_default_url;
     }
     // if the user do not have an existing prototype.js library, we use the embeded one
     if ($this->prototypejs_url == '') {
         $this->prototypejs_url = $this->data_public_url . '/js/prototype.js';
     }
     // ---
     // run specific container initialisation
     $ct =& pfcContainer::Instance();
     $ct_errors = $ct->init($this);
     $this->errors = array_merge($this->errors, $ct_errors);
     // check the language is known
     $lg_list = pfcI18N::GetAcceptedLanguage();
     if ($this->language != "" && !in_array($this->language, $lg_list)) {
         $this->errors[] = _pfc("'%s' parameter is not valid. Available values are : '%s'", "language", implode(", ", $lg_list));
     }
     // calculate the proxies chaine
     $this->proxies = array();
     foreach ($this->pre_proxies as $px) {
         if (!in_array($px, $this->skip_proxies) && !in_array($px, $this->proxies)) {
             $this->proxies[] = $px;
         }
     }
     foreach ($this->_sys_proxies as $px) {
         if (!in_array($px, $this->skip_proxies) && !in_array($px, $this->proxies)) {
             $this->proxies[] = $px;
         }
     }
     foreach ($this->post_proxies as $px) {
         if (!in_array($px, $this->skip_proxies) && !in_array($px, $this->proxies)) {
             $this->proxies[] = $px;
         }
     }
     // save the proxies path
     $this->proxies_path_default = dirname(__FILE__) . '/proxies';
     // check the customized proxies path
     if ($this->proxies_path != '' && !is_dir($this->proxies_path)) {
         $this->errors[] = _pfc("'%s' directory doesn't exist", $this->proxies_path);
     }
     if ($this->proxies_path == '') {
         $this->proxies_path = $this->proxies_path_default;
     }
     // save the commands path
     $this->cmd_path_default = dirname(__FILE__) . '/commands';
     if ($this->cmd_path == '') {
         $this->cmd_path = $this->cmd_path_default;
     }
     // load smileys from file
     $this->loadSmileyTheme();
     // load version number from file
     $this->version = trim(file_get_contents(dirname(__FILE__) . "/../version.txt"));
     $this->is_init = count($this->errors) == 0;
 }
コード例 #28
0
ファイル: sav.php プロジェクト: philum/cms
function save_img()
{
    $qb = $_SESSION['qb'];
    $read = $_SESSION['read'];
    $fich = $_FILES['fichier']['name'];
    $fich_tmp = $_FILES['fichier']['tmp_name'];
    $xt = xt($fich);
    $fich = normalize($fich);
    $fich = str_replace("-", "", $fich);
    if ($fich == "") {
        $exp_out .= "no file uploaded ";
    } else {
        $goodxt = ".mp4.m4a.mov.mpg.mp3.wav.wmv.asf.rmv.ram.rm.swf.flv.jpg.png.gif.pdf.txt.rar.zip.tar.gz";
        $goodxt .= $_SESSION['prmb'][23];
        $goodext = str_replace(array(".php", ".js"), "", $goodxt);
        if (stristr($goodxt, $xt) === false) {
            $exp_out .= $xt . '=forbidden ; authorized=' . $goodxt . br();
        }
        $poids = $_FILES['fichier']['size'] / 1024;
        $uplimit = prms('uplimit') * 1000;
        if ($poids >= $uplimit || $poids == 0) {
            $exp_out .= "{$poids} > 250Mo ";
        }
        if ($xt == ".rm") {
            $fich .= "v";
        }
        $rep = 'img/';
        if (stristr(".m4a.mpg.mp4.asf.rmv.wmv.flv", $xt) !== false) {
            $rep = 'video/';
        } elseif (stristr(".rar.swf.txt.pdf", $xt) !== false) {
            $rep = 'docs/';
        } elseif (stristr(".mp3", $xt) !== false) {
            $rep = 'mp3/';
        }
        if (stristr(".txt.mp3.pdf.swf", $xt) !== false) {
            $rep = 'users/' . $qb . '/' . $rep;
        } elseif (stristr(".jpg.png.gif", $xt) === false) {
            $rep = 'users/' . $qb . '/' . $rep;
        }
        if (stristr(".jpg.png.gif.mp3.mp4.pmg.swf.wmv.flv.pdf", $xt) === false) {
            $w = ':w';
        }
        if (stristr(".txt", $xt) !== false) {
            $w = ':scrut';
        }
        if ($_GET['mode'] == "banim") {
            $mg = 'ban_' . $qb . '.jpg';
        } elseif ($_GET['avnim'] == "ok") {
            $mg = 'avatar_' . $_SESSION['USE'] . '.gif';
            $rep = 'imgb/';
        } elseif ($_GET['edit_css']) {
            $mg = 'css_' . $qb . '_' . $fich;
            $rep = 'imgb/';
        } elseif ($_GET['bkgim'] == "ok") {
            $mg = 'bkg_' . $qb . '.jpg';
            $rep = 'imgb/';
        } elseif ($_GET["mode"] == "disk") {
            $rep = 'users/' . ajx($_GET['opdir'], 1) . '/';
            $mg = $fich;
            if ($_GET['opdir'] != $qb) {
                mkdir_r($rep);
            }
        } else {
            $mg = $qb . '_' . $read . '_' . $fich;
        }
        if (!is_dir($rep)) {
            mkdir($rep, 0777);
        }
        if (is_uploaded_file($fich_tmp) && !$exp_out) {
            if (!move_uploaded_file($fich_tmp, $rep . $mg)) {
                $exp_out .= " not saved";
            }
            if ($xt == '.tar' or $xt == '.gz') {
                unpack_gz($rep . $mg, $rep);
            }
            if ($read && !$_GET["mode"]) {
                add_im_img($mg);
                if (!$_POST["imnot"]) {
                    add_im_msg("", $rep . $mg . $w);
                }
            }
        } else {
            $exp_out .= "upload refused: {$rep}{$mg}";
        }
    }
    //end_no_file
    if ($exp_out) {
        alert($exp_out);
    }
    return $rep . $mg;
}
コード例 #29
0
ファイル: picture_process.php プロジェクト: nong053/condo
function resizeImages($loop, $image, $max_width, $max_height, $max_width2, $max_height2, $images_path)
{
    $images_thumbnail_path = $images_path . "/thumbnail";
    if (!is_dir($images_path)) {
        umask(0);
        mkdir_r($images_path, 0777);
    }
    /*else{
    			umask (0);
    			chmod_r($images_path,0777);
    		}*/
    if (!is_dir($images_thumbnail_path)) {
        umask(0);
        mkdir_r($images_thumbnail_path, 0777);
    }
    /*else{
    			umask (0);
    			chmod_r($images_thumbnail_path,0777);
    		}*/
    $allowedtypes = array("image/x-png", "image/png", "image/jpeg", "image/pjpeg", "image/gif");
    $datename = date("YdmHis");
    if (is_file($image['tmp_name']) && $image['error'] == '0' && in_array($image['type'], $allowedtypes)) {
        $imageSize = getimagesize($image['tmp_name']);
        $width = $imageSize[0];
        $height = $imageSize[1];
        $x_ratio = $max_width / $width;
        $y_ratio = $max_height / $height;
        if ($width <= $max_width && $height <= $max_height) {
            $tn_width = $width;
            $tn_height = $height;
        } elseif ($x_ratio * $height < $max_height) {
            $tn_height = ceil($x_ratio * $height);
            $tn_width = $max_width;
        } else {
            $tn_width = ceil($y_ratio * $width);
            $tn_height = $max_height;
        }
        $x_ratio = $max_width2 / $width;
        $y_ratio = $max_height2 / $height;
        if ($width <= $max_width2 && $height <= $max_height2) {
            $tn_width2 = $width;
            $tn_height2 = $height;
        } elseif ($x_ratio * $height < $max_height2) {
            $tn_height2 = ceil($x_ratio * $height);
            $tn_width2 = $max_width2;
        } else {
            $tn_width2 = ceil($y_ratio * $width);
            $tn_height2 = $max_height2;
        }
        ini_set('memory_limit', '64M');
        $max_width_center = ceil($max_width2 / 2);
        $max_height_center = ceil($max_height2 / 2);
        $tn_width_center = ceil($tn_width2 / 2);
        $tn_height_center = ceil($tn_height2 / 2);
        $x = $max_width_center - $tn_width_center;
        $y = $max_height_center - $tn_height_center;
        $dst = ImageCreateTrueColor($tn_width, $tn_height);
        if ($image['type'] == "image/x-png" || $image['type'] == "image/png") {
            imagesavealpha($dst, true);
            $trans_colour = imagecolorallocatealpha($dst, 0, 0, 0, 127);
            imagefill($dst, 0, 0, $trans_colour);
        } else {
            $white = imagecolorallocate($dst, 255, 255, 255);
            imagefill($dst, 0, 0, $white);
        }
        $dst2 = ImageCreateTrueColor($max_width2, $max_height2);
        if ($image['type'] == "image/x-png" || $image['type'] == "image/png") {
            imagesavealpha($dst2, true);
            $trans_colour = imagecolorallocatealpha($dst2, 0, 0, 0, 127);
            imagefill($dst2, 0, 0, $trans_colour);
        } else {
            $white = imagecolorallocate($dst2, 255, 255, 255);
            imagefill($dst2, 0, 0, $white);
        }
        if ($image['type'] == "image/x-png" || $image['type'] == "image/png") {
            $src = imagecreatefrompng($image['tmp_name']);
            imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
            $fileName = $images_path . "/" . $datename . $loop . ".png";
            imagepng($dst, $fileName);
            imagecopyresampled($dst2, $src, $x, $y, 0, 0, $tn_width2, $tn_height2, $width, $height);
            $fileName = $images_thumbnail_path . "/" . $datename . $loop . ".png";
            imagepng($dst2, $fileName);
        } elseif ($image['type'] == "image/jpeg" || $image['type'] == "image/pjpeg") {
            $src = imagecreatefromjpeg($image['tmp_name']);
            imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
            $fileName = $images_path . "/" . $datename . $loop . ".jpg";
            imagejpeg($dst, $fileName, 100);
            imagecopyresampled($dst2, $src, $x, $y, 0, 0, $tn_width2, $tn_height2, $width, $height);
            $fileName = $images_thumbnail_path . "/" . $datename . $loop . ".jpg";
            imagejpeg($dst2, $fileName, 100);
        } else {
            $src = imagecreatefromgif($image['tmp_name']);
            imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
            $fileName = $images_path . "/" . $datename . $loop . ".gif";
            imagegif($dst, $fileName);
            imagecopyresampled($dst2, $src, $x, $y, 0, 0, $tn_width2, $tn_height2, $width, $height);
            $fileName = $images_thumbnail_path . "/" . $datename . $loop . ".gif";
            imagegif($dst2, $fileName);
        }
        ImageDestroy($src);
        ImageDestroy($dst);
        ImageDestroy($dst2);
        return true;
    }
}
コード例 #30
0
ファイル: cls_image.php プロジェクト: dapfru/gladiators
 function imageMix($mix)
 {
     global $engine_path, $ImageTrimX, $ImageTrimY;
     $source = $this->image;
     $imType = $this->type;
     if (!$imType || $imType == "jpeg" || $imType == "pjpeg") {
         $srcImage = ImageCreateFromJPEG($source);
     } elseif ($imType == "gif") {
         $srcImage = LoadGif($source);
     } else {
         $srcImage = ImageCreateFromPNG($source);
     }
     if ($mix) {
         $srcImage = $this->mix($srcImage, $mix);
     }
     $name = $engine_path . "tmp/" . "mix" . $this->name;
     if (!file_exists($engine_path . "tmp/")) {
         mkdir_r($engine_path . "tmp/");
     }
     if ($imType == "jpeg" || $imType == "pjpeg") {
         Imagejpeg($srcImage, $name);
     } elseif ($imType == "gif") {
         Imagegif($srcImage, $name);
     } else {
         Imagepng($srcImage, $name);
     }
     $file['tmp_name'] = $name;
     ImageDestroy($srcImage);
     return $file;
 }