Example #1
0
 /**
  * 远程下载文件
  * @param  array  $urlfrom 	下载文件路径		   
  * @param  string $urlto	保存文件地址
  * @param  string $checksum	下载权限码
  * @param  string $timeout	超时时间
  * @return string			下载成功返回1,失败返回报错信息。 
  */
 public function dlfile($urlfrom, $urlto, $checksum = '', $timeout = 30)
 {
     global $_M;
     $post_data = array('urlfrom' => $urlfrom, 'checknum' => $checksum, 'cmsver' => $_M['config']['metcms_v']);
     $result = $this->curl_post($post_data, $timeout);
     $link = $this->error_no($result);
     if ($link != 1) {
         return $link;
     }
     if (substr($result, -7) == 'metinfo') {
         $result = substr($result, 0, -7);
         $link = $this->error_no($result);
         if ($link == 1) {
             if ($urlto) {
                 if (!file_exists($urlto)) {
                     makefile($urlto);
                 }
                 $return = file_put_contents($urlto, $result);
                 if (!$return) {
                     return $this->error_no('No filepower');
                 } else {
                     return 1;
                 }
             } else {
                 return $result;
             }
         } else {
             return $link;
         }
     } else {
         return $this->error_no('Timeout');
     }
 }
Example #2
0
 public function checkfilepower($file)
 {
     global $_M;
     if (makefile($file, false)) {
         return getfilepower($file);
     } else {
         return false;
     }
 }
Example #3
0
 public static function put($file, $data, $type = 'php')
 {
     global $_M;
     load::sys_func('file');
     $save = PATH_CACHE . $file . '.' . $type;
     makefile($save);
     $data = str_replace(array("\"", "\\"), array("\\\"", "\\\\"), $data);
     if (!is_array($data)) {
         file_put_contents($save, "<?php\ndefined('IN_MET') or exit('No permission');\n\$cache=\"{$data}\";\n?>");
     } else {
         $info = var_export($data, true);
         $info = "<?php\ndefined('IN_MET') or exit('No permission');\n\$cache = {$info};\n?>";
         file_put_contents($save, $info);
     }
 }
Example #4
0
 public function dosetsave()
 {
     global $_M;
     $list = explode(",", $_M[form][allid]);
     $type = $_M[form][submit_type];
     $i = 0;
     foreach ($list as $id) {
         if ($id) {
             $i++;
             if ($type == 'save' || !$type) {
                 $name = $_M['form']['name-' . $id];
                 $defaultvalue = $_M['form']['defaultvalue-' . $id];
                 $valueinfo = $_M['form']['valueinfo-' . $id];
                 $type1 = $_M['form']['type-' . $id];
                 $tips = $_M['form']['tips-' . $id];
                 $selectd = $_M['form']['selectd-' . $id];
                 $style = $_M['form']['style-' . $id];
                 $no = $_M['form']['no'];
                 $pos = $_M['form']['pos-' . $id];
                 $no_order = $i;
                 if ($pos != $_M['form']['pos']) {
                     $counter = DB::counter($_M['table']['templates'], " WHERE no='{$_M['form']['no']}' and pos='{$pos}'  and lang='{$_M['form']['lang']}'", '*');
                     $no_order = $no_order + $counter;
                 }
                 $query = "\n\t\t\t\t\t\tno           = '{$no}',\n\t\t\t\t\t\tpos          = '{$pos}',\n\t\t\t\t\t\tno_order     = '{$no_order}',\n\t\t\t\t\t\tname         = '{$name}',\n\t\t\t\t\t\tdefaultvalue = '{$defaultvalue}',\n\t\t\t\t\t\tvalueinfo    = '{$valueinfo}',\n\t\t\t\t\t\ttype\t     = '{$type1}',\n\t\t\t\t\t\ttips\t     = '{$tips}',\n\t\t\t\t\t\tselectd\t     = '{$selectd}',\n\t\t\t\t\t\tstyle\t     = '{$style}',\n\t\t\t\t\t\tlang         = '{$_M['form']['lang']}'\n\t\t\t\t\t";
                 if (is_number($id)) {
                     //修改
                     $query = "UPDATE {$_M['table']['templates']} SET {$query} WHERE id = '{$id}' ";
                 } else {
                     //新增
                     $query = "INSERT INTO {$_M['table']['templates']} SET value = '{$defaultvalue}', {$query} ";
                 }
             } elseif ($type == 'del') {
                 //删除
                 if (is_number($id)) {
                     $query = "DELETE FROM {$_M['table']['templates']} WHERE id='{$id}' and pos = '{$_M['form']['pos']}' and lang='{$_M['form']['lang']}' ";
                 }
             }
             DB::query($query);
         }
     }
     /*同步到其它语言*/
     $query = "SELECT * FROM {$_M['table']['templates']} where no='{$_M['form']['no']}' AND lang='{$_M['form']['lang']}' ORDER BY no_order,id";
     $tems = DB::get_all($query);
     foreach ($_M['langlist']['web'] as $key => $val) {
         if ($key != $_M['form']['lang']) {
             $query = "DELETE FROM {$_M['table']['templates']} WHERE no='{$_M['form']['no']}' AND lang='{$key}'";
             DB::query($query);
             foreach ($tems as $keytems => $valtems) {
                 $query = "INSERT INTO {$_M['table']['templates']} SET no='{$valtems['no']}',pos ='{$valtems['pos']}',no_order='{$valtems['no_order']}',type='{$valtems['type']}',style='{$valtems['style']}',selectd='{$valtems['selectd']}',name ='{$valtems['name']}',value='{$valtems['value']}',defaultvalue='{$valtems['defaultvalue']}',valueinfo ='{$valtems['valueinfo']}',tips='{$valtems['tips']}',lang='{$key}'";
                 DB::query($query);
             }
         }
     }
     /*生成安装文件*/
     load::sys_func('file');
     $file = "templates/{$_M['form']['no']}/install/install.class.php";
     makefile($file);
     $query = "SELECT * FROM {$_M['table']['skin_table']} where skin_file='{$_M['form']['no']}'";
     $tem = DB::get_one($query);
     $query = "SELECT * FROM {$_M['table']['templates']} where no='{$_M['form']['no']}' AND lang='{$_M['form']['lang']}' ORDER BY no_order,id";
     $tems = DB::get_all($query);
     foreach ($tems as $keytems => $valtems) {
         $sql[] = "pos ='{$valtems['pos']}',no_order='{$valtems['no_order']}',type='{$valtems['type']}',style='{$valtems['style']}',selectd='{$valtems['selectd']}',name ='{$valtems['name']}',value='{$valtems['defaultvalue']}',defaultvalue='{$valtems['defaultvalue']}',valueinfo ='{$valtems['valueinfo']}',tips='{$valtems['tips']}'";
     }
     $sql_info = var_export($sql, true);
     $info .= "\n\$sql = {$sql_info};\n\$no='{$_M['form']['no']}';\n\$devices='{$tem['devices']}';";
     $str = file_get_contents(PATH_OWN_FILE . 'file/install.class.php');
     $str = str_replace('/*<!--sql-->*/', $info, $str);
     file_put_contents(PATH_WEB . $file, $str);
     turnover("{$_M[url][own_form]}a=doset&no={$_M['form']['no']}&pos={$_M['form']['pos']}", '操作成功');
 }
Example #5
0
//Experimental MemoryMap export for the geograph project
require_once 'geograph/global.inc.php';
require_once 'geograph/gridimage.class.php';
require_once 'geograph/gridsquare.class.php';
require_once 'geograph/imagelist.class.php';
init_session();
$smarty = new GeographPage();
$square = new GridSquare();
if (isset($_POST['gridsquare']) || isset($_POST['getall'])) {
    if (!isset($_POST['getall'])) {
        $prefix = $_POST['gridsquare'];
    } else {
        $prefix = '';
    }
    if (strlen($prefix) == 2 || strlen($prefix) == 1) {
        if (!($error = makefile($prefix))) {
            //Let the browser know what to expect
            $csvfilename = "geograph" . $prefix . ".csv";
            $len = (int) filesize("memorymap/{$csvfilename}");
            header("Content-type: text/plain");
            header("Content-Disposition: attachment; filename=\"{$csvfilename}\"");
            header("Content-length: {$len}");
            @readfile("memorymap/{$csvfilename}");
            die;
        } else {
            $smarty->assign('errormsg', $error);
        }
    } else {
        $smarty->assign('errormsg', "Please choose a grid square");
    }
}
Example #6
0
$uid = $authorizer->isLogged();
require_once '../func/admin.class.php';
require_once '../inc/vars.php';
function makefile($file, $table)
{
    $fh = fopen($file, 'w') or die("Error opening file!");
    fwrite($fh, "<?php define(MT_TABLE,'" . $table . "'); ?>");
    fclose($fh);
}
if ($_POST['_table']) {
    $file = '../inc/vars.php';
    if (!is_writable($file)) {
        if (chmod($file, 0777)) {
            makefile($file, $_POST['_table']);
        } else {
            echo '<div id="error">Your inc/vars.php file is not writable! (hint: chmod 0777)</div>';
        }
    } else {
        makefile($file, $_POST['_table']);
    }
    die("The table: " . $_POST['_table'] . " has been correctly selected.");
}
$admin = new Table(MT_TABLE);
?>
<div id="form-small">
    <select id="gruppo" name="gruppo" onchange="table = this.options[this.selectedIndex].value; return select_table(table);"><option value="0">Choose one..</option>
    <?php 
$admin->select();
?>
    </select>
</div>