コード例 #1
0
ファイル: product.inc.php プロジェクト: JimmyVV/TuhaoWeb
/**
 * Created by PhpStorm.
 * User: administrator
 * Date: 2015/7/17
 * Time: 15:47
 */
function issue()
{
    $arr = $_POST;
    $arr['username'] = $_SESSION['username'];
    $arr['is_send'] = 0;
    $arr['hot'] = 0;
    $arr['reg_time'] = time();
    $arr['status'] = 0;
    $path = "./uploads";
    $uploadFiles = uploadFile($path);
    $result = insert("tuhao_pro", $arr);
    $pid = getInsertId();
    if ($result && $pid) {
        if ($uploadFiles) {
            foreach ($uploadFiles as $uploadFile) {
                $arr1['pid'] = $pid;
                $arr1['album_path'] = $uploadFile['name'];
                insert("tuhao_album", $arr1);
            }
        }
        $message = array('success' => true, 'mes' => "发布成功", 'pro_id' => $pid);
    } else {
        $message = array('success' => false, 'mes' => "发布失败");
    }
    return json_encode($message);
}
コード例 #2
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);
}
コード例 #3
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;
}
コード例 #4
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;
}
コード例 #5
0
function add_member()
{
    $arr = $_POST;
    // return print_r($arr);
    if (empty($arr['name'])) {
        $msg = "成员姓名是必填项哦!<meta http-equiv='refresh' content='1;url=" . $_SERVER['HTTP_REFERER'] . "'/>";
        return $msg;
        exit;
    }
    //头像不是必填项,检测是否上传成员头像,若没有(error=4)则不处理头像
    if ($_FILES['avatar']['error'] != 4) {
        // 上传头像,并生成80*80和150*150的两张缩略图
        $uploadFile = uploadFile('images/uploads/avatar/');
        if ($uploadFile && is_array($uploadFile)) {
            $arr['avatar'] = $uploadFile[0]['name'];
        } else {
            return "添加成员失败<meta http-equiv='refresh' content='1;url=" . $_SERVER['HTTP_REFERER'] . "'/>";
        }
        thumb("images/uploads/avatar/" . $uploadFile[0]['name'], "images/uploads/avatar_150/" . $uploadFile[0]['name'], 150, 150);
        thumb("images/uploads/avatar/" . $uploadFile[0]['name'], "images/uploads/avatar_80/" . $uploadFile[0]['name'], 80, 80);
    }
    //电话号不是必填项,检测是否输入,若没有则不创建$arr_phone数组
    if (!empty($arr['phone'])) {
        $arr_phone['phone'] = $arr['phone'];
        $arr_phone['owner'] = $arr['owner'];
    }
    //推荐人不是必填项,检测是否有值,若不为false则创建$arr_father数组
    if ($arr['father_mid'] !== 'false') {
        $arr_father['mid'] = $arr['father_mid'];
    }
    unset($arr['father_mid']);
    unset($arr['phone']);
    unset($arr['owner']);
    // print_r($arr);
    // print_r($arr_phone);
    // 向数据库插入数据
    insert('hh_member', $arr);
    $mid = getInsertId();
    //若$arr_phone数组不存在(用户没有输入电话号),则不进行写入hh_phone数据库的操作
    if (isset($arr_phone)) {
        $arr_phone['mid'] = $mid;
        insert('hh_phone', $arr_phone);
    }
    //若$arr_father数组不存在(用户没有推荐人),则不进行写入hh_son数据库的操作
    if (isset($arr_father)) {
        $arr_father['child'] = $mid;
        insert('hh_son', $arr_father);
    }
    $msg = "成功添加 " . $arr['name'] . " 为快乐学习营成员!<br/>2秒钟后跳转到成员信息页面!<meta http-equiv='refresh' content='2;url=member.php?mid=" . $mid . "'/>";
    return $msg;
}
コード例 #6
0
ファイル: house.inc.php プロジェクト: win87/homarget2
/**
 * ��������Ա�˺�ͨ��user_id�����Ϣ
 * @return string
 */
function addHouse()
{
    $arr = $_POST;
    $arr['pub_time'] = date('Y-m-d H:i:s');
    //$path="../uploads";
    //��������һ��user_id����Ϊ�ù���Աװ�Ź������û���
    $user_id = $arr['user_id'];
    print_r($user_id);
    exit;
    $path = "uploads/house_images/user_id_" . $user_id;
    $uploadFiles = uploadFile($path);
    if (is_array($uploadFiles) && $uploadFiles) {
        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("tigris_house_info", $arr);
    //print_r($res);exit;
    //����õ�����tigris_user_profile���primary key(house_id), �Դ������������?��ÿһ��house����Ψһalbum
    $album_id = getInsertId();
    //print_r($album_id);exit;
    if ($res && $album_id) {
        foreach ($uploadFiles as $uploadFile) {
            $arr1['album_id'] = $album_id;
            $arr1['img_path'] = $uploadFile['name'];
            addAlbum($arr1);
        }
        $mes = "<p>Add success!</p><a href='addHouse.php' target='mainFrame'>Add more</a>|<a href='listHouse.php' target='mainFrame'>View house list</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>Failed!</p><a href='addHouse.php' target='mainFrame'>Add</a>";
    }
    return $mes;
}
コード例 #7
0
function insertNote($noteContent)
{
    // Make connection to the database.
    $dbInfo = initialize_db_info();
    $dbLink = db_connect($dbInfo);
    db_select($dbLink, $dbInfo);
    $insertNoteSql = generateInsertNoteSql($noteContent);
    $result = mysql_query($insertNoteSql, $dbLink);
    if (!$result) {
        echo $insertNoteSql;
        throw new Exception('Insert Note Failed: ' . $insertNoteSql);
    }
    $noteId = getInsertId();
    return $noteId;
}
コード例 #8
0
ファイル: test.php プロジェクト: juedaiyuer/codeworkplace
/**
 * 添加商品
 * @return string
 */
function addPro()
{
    $arr = $_POST;
    $arr['pubTime'] = time();
    $path = "./uploads";
    $uploadFiles = uploadFile($path);
    if (is_array($uploadFiles) && $uploadFiles) {
        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);
    $pid = getInsertId();
    if ($res && $pid) {
        foreach ($uploadFiles as $uploadFile) {
            $arr1['pid'] = $pid;
            $arr1['albumPath'] = $uploadFile['name'];
            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;
}
コード例 #9
0
ファイル: post.inc.php プロジェクト: hardihuang/zihuaxiang
/**
 * 添加记录
 * @return string
 */
function post()
{
    if (getPostNumByUid($_SESSION['uid']) >= maxPost) {
        $msg = "你的记录总数达到上限 (" . maxPost . "条),已不能继续发布记录. <br>若有疑问请联系管理员:huang_hao521@163.com";
        return $msg;
    }
    $arr = $_POST;
    array_splice($arr, 1, 1);
    //删除数组中注册不需要用到的submit和verify元素
    $arr['date'] = date("Y-m-j" . " " . "H:i:s");
    //匹配数据库中的datetime时间格式
    $arr['uid'] = $_SESSION['uid'];
    // 判断是否有记录图片都没有
    if (empty($arr['post']) && empty($_FILES['postImage']['name'])) {
        $msg = "填写内容或添加图片后再添加!<meta http-equiv='refresh' content='1;url=user.php'/>";
        return $msg;
        exit;
    }
    $res = insert("zhx_post", $arr);
    if ($res) {
        $pmsg = "记录发布成功!";
    }
    $pid = getInsertId();
    //获取记录pid用来插入图片
    // return print_r($arr);
    //若有图片添加,则上传图片
    if (!empty($_FILES['postImage']['name'])) {
        // print_r($uploadFile);exit;
        $uploadFile = uploadFile("images/uploads/postImage/");
        if ($uploadFile && is_array($uploadFile)) {
            $album['image'] = $uploadFile[0]['name'];
            thumb("images/uploads/postImage/" . $album['image'], "images/uploads/postImage_500/" . $album['image'], 500);
            $album['pid'] = $pid;
            insert("zhx_album", $album);
            $imsg = "添加图片成功!";
        } else {
            $imsg = "添加图片失败!";
        }
    }
    $msg = $pmsg . " " . @$imsg . "<meta http-equiv='refresh' content='1;url=user.php'/>";
    return $msg;
}
コード例 #10
0
ファイル: user.inc.php プロジェクト: JimmyVV/TuhaoWeb
function register()
{
    $username = addslashes($_POST['nickname']);
    $email = addslashes($_POST['email']);
    $password = addslashes($_POST['password']);
    $reg_time = time();
    $token = md5($username . $password . $reg_time);
    //创建用于激活识别码
    $token_exptime = time() + 7 * 60 * 60 * 24;
    //过期时间为7天
    $sex = addslashes($_POST['sex']);
    $college = addslashes($_POST['college']);
    $enroll_year = addslashes($_POST['enroll_year']);
    $address = addslashes($_POST['address']);
    $user = array('username' => $username, 'password' => md5($password), 'email' => $email, 'token' => $token, 'token_exptime' => $token_exptime, 'reg_time' => $reg_time);
    insert('tuhao_user', $user);
    $id = getInsertId();
    $sql = "select * from tuhao_user where id={$id}";
    $user = fetchOne($sql);
    $toMail = $user['email'];
    $subject = '账户激活';
    $username = $user['username'];
    $token = $user['token'];
    $head = array('header1.jpg', 'header2.jpg', 'header3.jpg');
    $rand = rand(0, 2);
    $src = $head[$rand];
    $body = "亲爱的" . $username . ":<br/>感谢您在我站注册了新帐号。<br/>请点击链接激活您的帐号。<br/>\n    <a href='http://tuhao.hustonline.net/doAction.php?action=active&verify=" . $token . "' target=\n'_blank'>http://tuhao.hustonline.net/doAction.php?action=active&verify=" . $token . "</a><br/>\n    如果以上链接无法点击,请将它复制到你的当前浏览器地址栏中进入访问,该链接24小时内有效。";
    $info = array('user_id' => $id, 'sex' => $sex, 'college' => $college, 'enroll_year' => $enroll_year, 'address' => $address, 'head_photo' => $src, 'levell' => 1, 'score' => 0, 'week_score' => 0, 'inc_score' => 0);
    if (insert('tuhao_info', $info)) {
        $res = sendMail($toMail, $subject, $body);
        if ($res == 1) {
            $message = array('success' => true, 'mes' => '邮件发送成功');
        }
    } else {
        $message = array('success' => false);
    }
    return json_encode($message);
}
コード例 #11
0
ファイル: requests.php プロジェクト: jrgsf/giggity
function gigs_saveGig($request)
{
    $gig_id = dbEscape(isset($request['gig_id']) ? $request['gig_id'] : '');
    $fields = array();
    $gig = $request['data'];
    foreach (array('title', 'description', 'date', 'start_time', 'end_time', 'meet_time', 'band_start', 'band_end', 'location', 'who', 'contact', 'details', 'tactical', 'musical', 'approved', 'public_description', 'notes', 'colors', 'type', 'url') as $key) {
        if (isset($gig[$key])) {
            if (in_array($key, array('start_time', 'end_time', 'meet_time', 'band_start', 'band_end'))) {
                $gig[$key] = date('H:i', strtotime($gig[$key]));
            } elseif ($key == 'date') {
                $date = str_replace('/', '-', $gig[$key]);
                $date = date_create_from_format('m-d-Y', $date) ?: date_create_from_format('Y-m-d', $date);
                //$date = date_create_from_format('Y-m-d', $gig[$key]);
                $gig[$key] = date_format($date, 'Y-m-d');
            }
            array_push($fields, "{$key}='" . dbEscape($gig[$key]) . "'");
        }
    }
    if (!isset($gig['details'])) {
        $details = "";
        foreach (array('cause', 'event_history', 'arrestable', 'has_permit', 'cops', 'people_of_color', 'relevant_communities', 'blo_role', 'other_groups', 'sound', 'other') as $key) {
            $details .= strtoupper($key) . ": " . (isset($gig[$key]) ? $gig[$key] : '') . "\n\n";
        }
        array_push($fields, "details='" . dbEscape($details) . "'");
    }
    if (isset($gig['setlist'])) {
        array_push($fields, "setlist='" . dbEscape(implode(",", $gig['setlist'])) . "'");
    }
    //$title = dbEscape($gig['title']);
    $new_gig = 0;
    if ($gig_id) {
        $res = dbWrite("update gigs set " . implode(",", $fields) . " where gig_id={$gig_id}");
    } else {
        $res = dbwrite("insert into gigs set " . implode(",", $fields));
        $new_gig = 1;
        $gig_id = getInsertId();
        $gig['gig_id'] = $gig_id;
    }
    $gig = gigs_fetchGig($gig);
    saveToCalendar($gig);
    if ($gig['approved'] == 1) {
        saveToCalendar($gig, 'public');
    } elseif ($gig['approved'] == -1) {
        deleteFromCalendar($gig, 'public');
    }
    if ($new_gig && $gig['type'] == 'gig') {
        sendEmails($gig);
    }
    return $gig;
}
コード例 #12
0
function bagCheckSaveHarvestInformation($oneBirdGroup)
{
    // Make connection to the database.
    $dbInfo = initialize_db_info();
    $dbLink = db_connect($dbInfo);
    db_select($dbLink, $dbInfo);
    $speciesList = $oneBirdGroup->getSpeciesList();
    $birdGroupId = $oneBirdGroup->getId();
    $speciesSeq = 0;
    foreach ($speciesList as $oneSpecies) {
        $speciesId = $oneSpecies->getId();
        if ($speciesId == -1) {
            // Insert new
            $insertSql = generateBCSpeciesInsertSql($oneSpecies, $birdGroupId, $speciesSeq);
            $result = mysql_query($insertSql, $dbLink);
            if (!$result) {
                echo $insertSql;
                throw new Exception('Save Insert Species Info Failed: ' . $insertSql);
            }
            $speciesId = getInsertId();
            $oneSpecies->setId($speciesId);
        } else {
            // Update existing
            $updateSql = generateBCSpeciesUpdateSql($oneSpecies, $birdGroupId, $speciesSeq);
            $result = mysql_query($updateSql, $dbLink);
            if (!$result) {
                echo $updateSql;
                throw new Exception('Save Update Species Info Failed: ' . $updateSql);
            }
        }
        $speciesSeq++;
    }
}