if (empty($series)) {
    $series = 0;
}
$filepath = $_GET['filepath'];
$wa = new WechatArticle($wa_id, $a_id, $_POST['title'], $_POST['brief'], $_POST['address'], $type, $series, $_POST['deleted']);
$update_attachemnt = false;
if ($a_id) {
    $attachment_row = $aDao->getById($a_id);
    if ($attachment_row['filepath'] != $filepath) {
        // 更新了图片
        $update_attachemnt = true;
    }
} else {
    // 无图片
    $update_attachemnt = true;
}
if ($update_attachemnt) {
    $a_id = $aDao->addSimple($filepath);
    if (!$a_id) {
        echo '数据库添加图片失败!' . '</br>' . mysql_error();
        exit;
    } else {
        $wa->attachment_id = $a_id;
    }
}
if ($waDao->addOrUpdate($wa)) {
    header('Location:../backstage/success.php?info=' . '添加成功!' . '&type=wechat_article_' . $type);
} else {
    echo '添加/更新失败!' . '</br>' . mysql_error();
    exit;
}
예제 #2
0
$openid = $_POST["openid"];
$nickname = $_POST["nickname"];
$gender = $_POST["gender"];
$filepath = $_POST["filepath"];
$access_token = $_POST["access_token"];
$userDao = new UserDao();
$attachmentDao = new AttachmentDao();
$sessionController = new SessionController();
$user_row = $userDao->getByQQOpenid($openid);
// 用户第一次登陆
if (empty($user_row)) {
    $userId = $userDao->addQQUser($openid, $nickname, $gender);
    if (!$userId) {
        db_error("储存QQ用户信息失败!");
    }
    $attachmentId = $attachmentDao->addSimple($filepath);
    if (!$attachmentId) {
        db_error("存储图片附件失败!");
    }
    if (!$userDao->addPhoto($userId, $attachmentId)) {
        db_error("存储用户头像失败!");
    }
    $userInSession = new UserInSession($userId, $nickname, UserDao::TYPE_QQ, $openid, $access_token);
    $sessionController->addUserJson(json_encode($userInSession));
    output("New user, add user success.");
} else {
    $userInSession = new UserInSession($user_row['id'], $user_row['name'], $user_row['type'], $user_row['qq_openid'], $access_token);
    $sessionController->addUserJson(json_encode($userInSession));
    output("Old user, login success.");
}
function output($msg)
예제 #3
0
    }
} else {
    header('Location:../../website/backstage/error.php?info=添加失败,民宿信息不全!&type=casa');
    exit;
}
/** 2.添加民宿默认图 */
if (!empty($casa->main_photo)) {
    $casa_row = $casaDao->getById($casa_id);
    if (!empty($casa_row['attachment_id'])) {
        $attachment_row = $attachmentDao->getById($casa_row['attachment_id']);
        // 更新了图片
        if (!($attachment_row['filepath'] == $casa->main_photo)) {
            if (!$casaService->delAttachment($casa_id, $attachment_row['id'])) {
                db_error("删除默认图片失败!");
            }
            $mainAttachmentId = $attachmentDao->addSimple($casa->main_photo);
            if (!$mainAttachmentId) {
                db_error("添加默认图片失败!");
            }
            if (!$casaDao->addPhoto($casa_id, $mainAttachmentId)) {
                db_error("关联民宿和默认图片失败!");
            }
        }
        // else 跟之前的图片一样,不需要update
    } else {
        // 新的民宿无图片
        $mainAttachmentId = $attachmentDao->addSimple($casa->main_photo);
        if (!$mainAttachmentId) {
            db_error("添加默认图片失败!");
        }
        if (!$casaDao->addPhoto($casa_id, $mainAttachmentId)) {