コード例 #1
0
ファイル: tagpatch.php プロジェクト: philum/cms
function tagpatch_u($p, $o, $res = '')
{
    //$p='type';
    $p = utf8_decode($p);
    $r = sql('ib,msg', 'qdd', 'kv', 'val="' . $p . '"');
    //id>'.$p.' limit 10000
    foreach ($r as $k => $v) {
        $r[$k] = tri_tag($v);
        foreach ($r[$k] as $ka => $va) {
            if ($va) {
                $ra[$va] += 1;
                $rb[$k][] = $va;
            }
        }
    }
    //p($rb);
    foreach ($ra as $k => $v) {
        $idtag = sql('id', 'qdt', 'v', 'cat="' . $p . '" and tag="' . $k . '"');
        if (!$idtag) {
            $idtag = insert('qdt', '("","' . $p . '","' . $k . '")');
        }
        $rtag[$k] = $idtag;
    }
    foreach ($rb as $k => $v) {
        foreach ($v as $ka => $va) {
            $idtag = $rtag[$va];
            $ex = sql('id', 'qdta', 'v', 'idart="' . $k . '" and idtag="' . $idtag . '"');
            if (!$ex) {
                insert('qdta', '("","' . $k . '","' . $idtag . '")');
            }
        }
    }
    $ret = $p . ':' . sql('count(id)', 'qdt', 'v', '') . '-' . sql('count(id)', 'qdta', 'v', '');
    return $ret;
}
コード例 #2
0
ファイル: user.inc.php プロジェクト: BigeyeDestroyer/biogas
function addUser()
{
    $arr = $_POST;
    $arr['pubTime'] = time();
    $path = "../uploads";
    $uploadFiles = uploadFile($path);
    $totalCap = $arr['capacity'] + getCityCapById($arr['cId']);
    $sql = "update biogas_city set totalCap=" . $totalCap . " where id=" . $arr['cId'];
    mysql_query($sql);
    //更新城市的总池容
    $res = insert("biogas_user", $arr);
    $uid = getInsertId();
    if ($res && $uid) {
        if ($uploadFiles && is_array($uploadFiles)) {
            foreach ($uploadFiles as $uploadFile) {
                $arr1['uid'] = $uid;
                $arr1['albumPath'] = $uploadFile['name'];
                addAlbum($arr1);
            }
        }
        $mes = "<p>添加成功!</p><a href='addUser.php' target='mainFrame'>继续添加</a>|<a href='listUser.php' target='mainFrame'>查看用户列表</a>";
    } else {
        $mes = "<p>添加失败!</p><a href='addUser.php' target='mainFrame'>重新添加</a>";
    }
    return $mes;
}
コード例 #3
0
function emailcheck()
{
    $dbc = connectToDB("leeawg");
    $join_name = $_POST['name'];
    $join_email = $_POST['email'];
    $join_username = $_POST['username'];
    $join_password = $_POST['password'];
    $join_securepw = sha1($join_password);
    $join_age = $_POST['age'];
    $q_emailCheck = "SELECT email FROM account WHERE email = '{$join_email}';";
    $q_usernameCheck = "SELECT user_id FROM account WHERE user_id = '{$join_username}';";
    $emailCheck_result = performQuery($dbc, $q_emailCheck);
    $emailCheck_duplicate = mysqli_fetch_array($emailCheck_result, MYSQLI_ASSOC);
    $usernameCheck_result = performQuery($dbc, $q_usernameCheck);
    $usernameCheck_duplicate = mysqli_fetch_array($usernameCheck_result, MYSQLI_ASSOC);
    if (mysqli_num_rows($usernameCheck_result) == 0 && mysqli_num_rows($emailCheck_result) == 0) {
        //echo "no duplicate :)";
        $query = "INSERT INTO account (user_id,password,name,age,email)\n\t\tVALUES ( '{$join_username}', '{$join_securepw}', '{$join_name}', '{$join_age}', '{$join_email}' )";
        insert($dbc, $query);
    }
    if (mysqli_num_rows($emailCheck_result) > 0) {
        errorform('email');
    }
    if (mysqli_num_rows($usernameCheck_result) > 0) {
        errorform('username');
    }
}
コード例 #4
0
ファイル: city.inc.php プロジェクト: BigeyeDestroyer/biogas
function addCity()
{
    $arr = $_POST;
    $city_get = getTemp($arr['city']);
    $city_info['city'] = $arr['city'];
    $city_info['pinyin'] = $city_get['pinyin'];
    $city_info['pubDate'] = $city_get['date'];
    $city_info['longitude'] = $city_get['longitude'];
    $city_info['latitude'] = $city_get['latitude'];
    $city_info['altitude'] = $city_get['altitude'];
    $city_info['pId'] = $arr['pId'];
    $city_info['totalCap'] = 0;
    $cName = $city_info['city'];
    $pinyin = $city_info['pinyin'];
    $str = "<?php" . "\r\n" . "require_once '../lib/mysql.func.php';\r\n" . "require_once '../lib/temp.func.php';\r\n" . "\r\n" . "mysql_connect(\"localhost:/tmp/mysql.sock\",\"root\",\"\");\r\n" . "mysql_set_charset(\"utf8\");\r\n" . "mysql_select_db(\"biogas\");\r\n" . "\r\n" . "\$res = getItem('" . $cName . "');\r\n" . "\$res_insert = array();\r\n" . "\$res_insert['date'] = \$res['date'];\r\n" . "\$res_insert['l_tmp'] = \$res['l_tmp'];\r\n" . "\$res_insert['h_tmp'] = \$res['h_tmp'];\r\n" . "insert(\$res['pinyin'].\"_tmp\", \$res_insert);";
    $filename = '../tmp_update/' . $pinyin . '_update.php';
    if (insert("biogas_city", $city_info)) {
        createTable($city_info['pinyin']);
        //(1) 创建城市温度表
        file_put_contents($filename, $str);
        //(2) 创建温度更新脚本
        chmod($filename, 0777);
        $mes = "添加成功!<br/><a href='addCity.php'>继续添加!</a>|<a href='listCity.php'>查看列表!</a>";
    } else {
        $mes = "添加失败!<br/><a href='addCity.php'>重新添加!</a>|<a href='listCity.php'>查看列表!</a>";
    }
    return $mes;
}
コード例 #5
0
ファイル: comment.inc.php プロジェクト: JimmyVV/TuhaoWeb
/**
 *添加评论
 */
function addComm()
{
    $mes = array();
    $parent_id = addslashes($_POST['parent_id']);
    $pro_id = addslashes($_POST['pro_id']);
    $sender_id = $_SESSION['id'];
    $receiver_id = addslashes($_POST['receiver_id']);
    if ($receiver_id == '') {
        $receiver_id = 0;
    }
    $content = addslashes($_POST['text']);
    $comm = array('parent_id' => $parent_id, 'pro_id' => $pro_id, 'sender_id' => $sender_id, 'receiver_id' => $receiver_id, 'content' => $content, 'status' => 0, 'reg_time' => time());
    if (insert("tuhao_comm", $comm)) {
        $id = getInsertId();
        $sql = "select * from tuhao_comm where id={$id}";
        $row = fetchOne($sql);
        $sql1 = "select pro_name from tuhao_pro where id={$row['pro_id']}";
        $sql2 = "select head_photo from tuhao_info where user_id={$row['sender_id']}";
        $sql3 = "select username from tuhao_user where id={$row['sender_id']}";
        $sql4 = "select username from tuhao_user where id={$row['receiver_id']}";
        $sender = fetchOne($sql3);
        $receiver = fetchOne($sql4);
        $proName = fetchOne($sql1);
        $src = fetchOne($sql2);
        $row['sender_author'] = $sender['username'];
        $row['receiver_author'] = $receiver['username'];
        $row['goods_name'] = $proName['pro_name'];
        $row['src'] = "uploads/" . $src['head_photo'];
        $row['comments'] = array();
        $mes = array('mes' => '评论成功', 'code' => 1, 'data' => $row);
    } else {
        $mes = array('mes' => '评论失败', 'code' => 0);
    }
    echo json_encode($mes);
}
コード例 #6
0
function register($name, $username, $password)
{
    $message = [];
    if (empty($name) || empty($username) || empty($password)) {
        $message[] = "Please all fields are required";
    } else {
        $passlength = strlen($password);
        if ($passlength >= 5 && $passlength <= 20) {
            $query_run = mysql_query("SELECT * FROM `users` WHERE \n\t                  \t`username`='{$username}'");
            if (mysql_num_rows($query_run) >= 1) {
                $message[] = "Username already exists!";
            }
            if (count($message) == 0) {
                // no errors
                $password = md5($password);
                if (insert('users', ['name' => $name, 'username' => $username, 'password' => $password])) {
                    $message[] = "Thank you for joining! <a href='login.php'>Click here to log in</a>";
                }
            }
        } else {
            $message[] = "Password characters out of required range( 5 - 20 )";
        }
    }
    return $message;
}
コード例 #7
0
ファイル: replyFunc.php プロジェクト: jesus143/fs-dev
function insert_reply_flagged($plcrno, $mno, $flag_note, $cboxes, $date_time)
{
    $res = insert('fs_plcm_rflag', array('plcrno', 'mno', 'rflag_option', 'rflag_note', 'rflag_date'), array($plcrno, $mno, $flag_note, $cboxes, $date_time), 'rflagno');
    if ($res) {
        echo "reply comment flag successfully added!";
    }
}
コード例 #8
0
ファイル: function.create.php プロジェクト: nubix/cms
/**
 * Zeigt ein Formular zum erstellen einer Seite an
*/
function create()
{
    global $msg, $mysql;
    if (isset($_POST['content'])) {
        if (!insert($_POST['title'], $_POST['content'], $_POST['firstpage'], $_POST['files'])) {
            return;
        }
        $msg->error("Bitte füllen Sie alle Felder aus.");
    }
    $q = $mysql->query("SELECT * FROM " . _PREFIX_ . "files");
    while ($o = mysql_fetch_object($q)) {
        $files .= "<option value=" . $o->id . ">" . $o->name . "</option>";
    }
    $qFirstPage = $mysql->query("SELECT * FROM " . _PREFIX_ . "pages WHERE firstpage=1");
    if ($o = @mysql_fetch_object($qFirstPage)) {
        $curFirstPage = 'Die momentane Startseite ist: ' . $o->title;
    }
    /**
     * Die Bilderliste auslesen und erstellen
     */
    $qImages = $mysql->query("SELECT * FROM " . _PREFIX_ . "images");
    $imageTpl = @file_get_contents(dirname(__FILE__) . "/../template/editor.images.tpl");
    while ($o = mysql_fetch_object($qImages)) {
        $images .= str_replace(array("%name%", "%fullurl%", "%thumburl%"), array($o->name, IMAGE_DIR . $o->file, IMAGE_DIR . $o->file_t), $imageTpl);
    }
    // Template ausfüllen -->
    $template = @file_get_contents(dirname(__FILE__) . "/../template/editor.tpl");
    $template = str_replace(array("%cur_firstpage%", "%title%", "%content%", "%file%", "%images%"), array($curFirstPage, $_POST['title'], $_POST['content'], $files, $images), $template);
    // <-- Template ausfüllen
    return $template;
}
コード例 #9
0
function month_total_fee($month)
{
    $year = explode('-', $month)[0];
    $mon = explode('-', $month)[1];
    //获取需要的月份相应交费记录并计算总费用
    $sql = "select fee,date,dueDate from hh_fee";
    $rows = fetchAll($sql);
    $total = 0;
    foreach ($rows as $row) {
        $day1 = $row['date'];
        $day2 = $row['dueDate'];
        $fee = $row['fee'];
        $T = ceil($fee / days_dis($day1, $day2));
        //$T为 该笔学费每天的收入
        $days = month_days($day1, $day2, $month);
        if ($days) {
            $total = $days * $T + $total;
        }
    }
    $arr = array('year' => $year, 'month' => $mon, 'total' => $total);
    //如果已存在相应日期记录,则进行更新操作,否则进行插入
    $sql = "select count(total) from hh_totalFee where year={$year} and month={$mon}";
    $result = fetchOne($sql)['count(total)'];
    if ($result >= 1) {
        update('hh_totalFee', $arr, "year={$year} and month={$mon}");
    } else {
        insert('hh_totalFee', $arr);
    }
}
コード例 #10
0
ファイル: posts.php プロジェクト: ramonp233/blog
 function view_post()
 {
     $data = $_POST['data'];
     $data['post_id'] = $this->params[0];
     $data['comment_author'] = 'Gunnar';
     insert('comment', $data);
 }
コード例 #11
0
ファイル: BL.php プロジェクト: juggernautt/lines
function add_new_score($name, $score)
{
    $name = addslashes($name);
    $score = addslashes($score);
    $sql = "insert into scores(name, score) values ('{$name}', '{$score}')";
    insert($sql);
}
コード例 #12
0
ファイル: Company.php プロジェクト: virendrapatel99/surat
 public function add()
 {
     $this->form_validation->set_rules('name', 'Company Name', 'trim|required');
     if ($this->form_validation->run() == FALSE) {
         $this->template->load('admin', 'admin/company/add');
     } else {
         $config['upload_path'] = './uploads/company/';
         $config['allowed_types'] = 'gif|jpg|png';
         $config['remove_spaces'] = TRUE;
         $this->upload->initialize($config);
         if (!$this->upload->do_upload('image')) {
             $error = array('error' => $this->upload->display_errors());
             if (strip_tags($error['error'], '') != 'You did not select a file to upload.') {
                 $this->session->set_flashdata('error', $error['error']);
                 redirect('admin/company/add');
             }
         } else {
             $data = array('upload_data' => $this->upload->data());
             $image = $data['upload_data']['file_name'];
         }
         $name = $this->input->post('name');
         $about_company = htmlentities($this->input->post('about_company'));
         if (!empty($image)) {
             $file_path = 'uploads/company/' . $image;
         } else {
             $file_path = 'uploads/defaults/test.jpg';
         }
         $data_add = array('company_name' => $name, 'about_company' => $about_company, 'logo' => $file_path, 'is_delete' => 0);
         insert('company_mst', $data_add);
         $this->session->set_flashdata('success', 'Company has been Successfully Created.');
         redirect('admin/company');
     }
 }
コード例 #13
0
ファイル: imageReview.php プロジェクト: Tjorriemorrie/app
function importSlice($wikiIdstart, $wikiIdEnd, $start, $slice)
{
    global $dbs, $startFrom;
    $res = $dbs->select(array('pages'), array('page_id', 'page_wikia_id', 'page_last_edited', 'UNIX_TIMESTAMP(page_last_edited) as page_last_edited_unix'), array("page_namespace = " . NS_FILE, "page_wikia_id BETWEEN {$wikiIdstart} and {$wikiIdEnd}", "page_last_edited BETWEEN FROM_UNIXTIME({$startFrom}) and NOW()"), __METHOD__, array('ORDER BY' => 'page_latest ASC', 'OFFSET' => $start, 'LIMIT' => $slice));
    while ($row = $dbs->fetchRow($res)) {
        insert($row);
    }
}
コード例 #14
0
ファイル: article.fun.php プロジェクト: knight-zhou/PHP-HTML
function addarticle($table,$arr){
	if(insert("dw_article",$arr)){
		echo "添加文章成功,你可以<a href='add_article.php'>继续添加</a>|<a href='list_article.php'>查看文章列表</a";
		}
	else{
		echo "添加失败<a href='list_article.php'>查看文章列表</a";
		}
	}
コード例 #15
0
ファイル: users.php プロジェクト: PindsterY/Meliss
 function edit_post()
 {
     $data = $_POST['data'];
     $data['user_id'] = $this->params[0];
     $data['active'] = isset($data['active']) ? 1 : 0;
     insert('user', $data);
     header('Location: ' . BASE_URL . 'users/view/' . $this->params[0]);
 }
コード例 #16
0
ファイル: halo.php プロジェクト: DataKeyt/meliss
 function POST_index()
 {
     // Check if the controller's table already exists in the database
     // $table_names_are_singular = true; # currently plural names are not supported
     $name_plural = $_POST['name_plural'];
     $name_singular = $_POST['name_singular'];
     $table_name = $name_plural;
     $table_prefix = $name_singular;
     if (q("SHOW TABLES LIKE '{$table_name}'")) {
         // Show error
         echo '<div class="alert alert-danger">' . "The table {$name_plural} already existed. Aborting." . '</div>';
     } else {
         // SQL injection protection
         global $db;
         $table_name_escaped = mysqli_real_escape_string($db, $table_name);
         $table_prefix_escaped = mysqli_real_escape_string($db, $table_prefix);
         // Add table to database
         q("CREATE TABLE `{$table_name_escaped}` (\n             `{$table_prefix_escaped}_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autocreated',\n             `{$table_prefix_escaped}_name` varchar(50) NOT NULL COMMENT 'Autocreated',\n             PRIMARY KEY (`{$table_prefix_escaped}_id`)\n           ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
         // Print banner
         // Add 2 rows to database
         insert($table_name, array($table_prefix . '_name' => $name_singular . " #1"));
         insert($table_name, array($table_prefix . '_name' => $name_singular . " #2"));
         // Add controller from template (substituting module for controller's name)
         $content = file_get_contents('system/scaffolding/controller_template.php');
         $content = $this->replace_preserving_case("modules", $name_plural, $content);
         $content = $this->replace_preserving_case("module", $name_singular, $content);
         $controller_file = "controllers/{$name_plural}.php";
         $fp = fopen($controller_file, "wb");
         fwrite($fp, $content);
         fclose($fp);
         chmod($controller_file, 0666);
         /** Add views **/
         $views = ['index', 'view', 'edit'];
         // Create views directory
         $dirname = "views/{$name_plural}";
         if (!is_dir($dirname)) {
             mkdir($dirname, 0755);
         }
         // Create each view
         foreach ($views as $view) {
             $content = file_get_contents("system/scaffolding/view_{$view}_template.php");
             $content = $this->replace_preserving_case("modules", $name_plural, $content);
             $content = $this->replace_preserving_case("module", $name_singular, $content);
             $view_file = "views/{$name_plural}/{$name_plural}_{$view}.php";
             $fp = fopen($view_file, "wb");
             fwrite($fp, $content);
             fclose($fp);
             chmod($view_file, 0666);
         }
         // Add files to git
         exec("git add controllers/*");
         exec("git add views/*");
         // Prevent git running under developer's user account having permission issues when commiting this file
         exec("chmod -R a+rwX *");
         echo '<div class="alert alert-success">' . 'The module <a href="' . BASE_URL . $table_name . '">' . $table_name . '</a> was created.</div>';
     }
 }
コード例 #17
0
ファイル: img_save.php プロジェクト: jesus143/fs-dev
function insert_ads_info($client_name, $company_name, $link, $file_ext)
{
    $q = insert('ads', array('admin_no', 'client_name', 'company_name', 'link', 'ext', 'date_uploaded'), array(1, $client_name, $company_name, $link, $file_ext, "2012-01-01"), 'ano');
    if ($q) {
        return true;
    } else {
        return false;
    }
}
コード例 #18
0
ファイル: api.function.php プロジェクト: Flyu/voting4wechat
function insert_vote($openId, $workId)
{
    $dataArr = array();
    $dataArr['openId'] = $openId;
    $dataArr['workId'] = $workId;
    $dataArr["creatTime"] = date("Y-m-d H:i:s");
    $bRusult = insert(LOG_TABLE, $dataArr);
    return $bRusult ? true : false;
}
コード例 #19
0
ファイル: nav.fun.php プロジェクト: knight-zhou/PHP-HTML
function addnav(){
	$arr=$_POST;
	if(insert("dw_nav",$arr)){
		echo "添加成功,你可以<a href='nav_config.php'>马上查看</a>";
		}
		else{
		echo "添加失败<a href='='nav_config.php'>查看分类</a";
		}
	}
コード例 #20
0
ファイル: users.php プロジェクト: hillam/bookmarks
 protected static function delete()
 {
     global $current_user;
     if ($current_user['is_admin']) {
         insert('DELETE FROM user WHERE id=' . $_POST['id']);
     } else {
         self::$failure = 'you are not admin';
     }
 }
コード例 #21
0
ファイル: save_comment.php プロジェクト: jesus143/fs-dev
function save_comment($plno, $mno, $comment, $dtime)
{
    if (strlen($comment) > 0) {
        insert('posted_looks_comments', array('plno', 'mno', 'date_', 'msg'), array($plno, $mno, $dtime, tcleaner($comment)), 'plcno');
        // echo "<span style='color:green'> succesfully post comment </span>";
    } else {
        // echo " <span  style='color:red' > failled to post comment </span>" ;
    }
}
コード例 #22
0
ファイル: flag_save.php プロジェクト: jesus143/fs-dev
function insert_flagged_info()
{
    $plcno = $_GET['plcno'];
    $mno = $_SESSION['mno'];
    $flag_date = date("Y-m-d h:m:s");
    $flag_option = $_GET['cbox'];
    $flag_note = $_GET['flag_note'];
    insert('fs_cflag', array('mno', 'plcno', 'flag_option', 'flag_note', 'flag_date'), array($mno, $plcno, $flag_option, tcleaner($flag_note), $flag_date), 'flagno');
}
コード例 #23
0
ファイル: class.fun.php プロジェクト: knight-zhou/PHP-HTML
function addclass(){
	$arr=$_POST;
	if(insert("dw_class",$arr)){
		echo "添加成功,你可以<a href='add_class.html'>继续添加</a>|<a href='class.php'>查看分类</a";
		}
		else{
		echo "添加失败<a href='class.php'>查看分类</a";
		}
		//return $mes;
	}
コード例 #24
0
function edit1($word)
{
    $list1 = delete($word);
    $list2 = insert($word);
    $list3 = transpose($word);
    $list4 = replace($word);
    $union = array_merge($list1, $list2, $list3, $list4);
    $union = array_unique($union);
    return $union;
}
コード例 #25
0
ファイル: modify.php プロジェクト: loopzy/my
function pupdate($arg)
{
    mysql_select_db('nutrition');
    $sql = "delete from nutri0 where barcode='{$arg['oldbarcode']}'";
    mysql_query($sql);
    $sql = "delete from nutri1 where barcode='{$arg['oldbarcode']}'";
    mysql_query($sql);
    $p = array($arg['type'], $arg['description'], $arg['barcode'], $arg['per'], $arg['energykj'], $arg['energykc'], $arg['protein'], $arg['carb'], $arg['sugar'], $arg['fat'], $arg['saturates'], $arg['fibre'], $arg['sodium'], $arg['hydrodised']);
    insert($p);
}
コード例 #26
0
ファイル: cate.inc.php プロジェクト: juedaiyuer/codeworkplace
/**
 * 添加分类的操作
 * @return string
 */
function addCate()
{
    $arr = $_POST;
    if (insert("imooc_cate", $arr)) {
        $mes = "分类添加成功!<br/><a href='addCate.php'>继续添加</a>|<a href='listCate.php'>查看分类</a>";
    } else {
        $mes = "分类添加失败!<br/><a href='addCate.php'>重新添加</a>|<a href='listCate.php'>查看分类</a>";
    }
    return $mes;
}
コード例 #27
0
ファイル: cate.inc.php プロジェクト: win87/homarget2
/**
 * 添加分类的操作
* @return string
*/
function addCate()
{
    $arr = $_POST;
    if (insert("tigris_user_type", $arr)) {
        $mes = "Add success!<br/><a href='addCate.php'>Add more</a>|<a href='listCate.php'>View list</a>";
    } else {
        $mes = "Add failed!<br/><a href='addCate.php'>Add again</a>|<a href='listCate.php'>View list</a>";
    }
    return $mes;
}
コード例 #28
0
ファイル: prov.inc.php プロジェクト: BigeyeDestroyer/biogas
function addProv()
{
    $arr = $_POST;
    if (insert("biogas_prov", $arr)) {
        $mes = "添加成功!<br/><a href='addProv.php'>继续添加!</a>|<a href='listProv.php'>查看列表!</a>";
    } else {
        $mes = "添加失败!<br/><a href='addProv.php'>重新添加!</a>|<a href='listProv.php'>查看列表!</a>";
    }
    return $mes;
}
コード例 #29
0
/**
 * 添加商品
 * @return string
 */
function addPro()
{
    //POST来信息存储在$arr数组中
    $arr = $_POST;
    //发布时间,定义为当前时间
    $arr['pubTime'] = time();
    //存储路径为uploads
    $path = "./uploads";
    //调用上传文件函数
    $uploadFiles = uploadFile($path);
    //判断是否有值
    if (is_array($uploadFiles) && $uploadFiles) {
        //遍历数组产生缩略图并存储进各目录中,这里../image_50代表根目录下的image_50文件夹
        foreach ($uploadFiles as $key => $uploadFile) {
            thumb($path . "/" . $uploadFile['name'], "../image_50/" . $uploadFile['name'], 50, 50);
            thumb($path . "/" . $uploadFile['name'], "../image_220/" . $uploadFile['name'], 220, 220);
            thumb($path . "/" . $uploadFile['name'], "../image_350/" . $uploadFile['name'], 350, 350);
            thumb($path . "/" . $uploadFile['name'], "../image_800/" . $uploadFile['name'], 800, 800);
        }
    }
    //调用插入函数
    $res = insert("imooc_pro", $arr);
    //得到刚刚执行的insert操作产生的ID
    $pid = getInsertId();
    //判断是否insert成功
    if ($res && $pid) {
        //循环uploadFiles里的值,获得id、albumPath并插入数据库中
        foreach ($uploadFiles as $uploadFile) {
            $arr1['pid'] = $pid;
            $arr1['albumPath'] = $uploadFile['name'];
            //调用album.inc.php里的addAlbum函数
            addAlbum($arr1);
        }
        $mes = "<p>添加成功!</p><a href='addPro.php' target='mainFrame'>继续添加</a>|<a href='listPro.php' target='mainFrame'>查看商品列表</a>";
    } else {
        //若不成功,删除对应文件
        foreach ($uploadFiles as $uploadFile) {
            if (file_exists("../image_800/" . $uploadFile['name'])) {
                //若不成功,删除对应文件
                unlink("../image_800/" . $uploadFile['name']);
            }
            if (file_exists("../image_50/" . $uploadFile['name'])) {
                unlink("../image_50/" . $uploadFile['name']);
            }
            if (file_exists("../image_220/" . $uploadFile['name'])) {
                unlink("../image_220/" . $uploadFile['name']);
            }
            if (file_exists("../image_350/" . $uploadFile['name'])) {
                unlink("../image_350/" . $uploadFile['name']);
            }
        }
        $mes = "<p>添加失败!</p><a href='addPro.php' target='mainFrame'>重新添加</a>";
    }
    return $mes;
}
コード例 #30
0
ファイル: admin.inc.php プロジェクト: denson7/phpstudy
function addAdmin()
{
    $arr = $_POST;
    $arr['password'] = md5($_POST['password']);
    if (insert("imooc_admin", $arr)) {
        $mes = "添加成功! <br /><a href='addAdmin.php'>继续添加</a>| <a href='listAdmin.php'>查看管理员列表</a>";
    } else {
        $mes = "添加失败!<br /><a href='addAdmin.php'>重新添加</a>";
    }
    return $mes;
}