Example #1
0
void end_transaction(int cid, ATerm sid) {
  EM_Session session = getSession(sid);

  if (session != NULL) {
    int referenceCount = EM_getSessionReferenceCount(session);
    assert(referenceCount > 0);

    referenceCount--;
    session = EM_setSessionReferenceCount(session, referenceCount);
    putSession(session);

    if (referenceCount == 0) {
      EM_SessionStatus status = EM_getSessionStatus(session);
      if (EM_isSessionStatusZombie(status)) {
	ATtableRemove(sessions, sid);
      }
    }
  }
  else {
    ATabort("editor-manager.c:end_transaction: no such session %t\n", sid);
  }
}
Example #2
0
static int cancel_article(char *board, char *file)
{
    struct fileheader header;
    char dirname[MAXPATHLEN];
    char *basename;
    time_t time;
    int fd, ent;
    char old_path[255];

    if (file == NULL || strlen(file) < 3)
        return 0;
    basename = (file[1]=='/') ? (file + 2) : file;
    if (basename[0] != 'M' || basename[1] != '.' || (time = atoi(basename + 2)) <= 0)
        return 0;

    getcwd(old_path, 255);
    chdir(BBSHOME);
    setbdir(DIR_MODE_NORMAL,dirname,board);
    if ((fd = open(dirname, O_RDWR)) == -1) {
        chdir(old_path);
        return 0;
    }

    ent = search_record_back(fd, sizeof(struct fileheader),0,cmp_filename, file, &header,1);
    if (ent) {
        struct write_dir_arg delarg;
        struct userec user;
        init_write_dir_arg(&delarg);
        delarg.fd=fd;
        delarg.ent=ent;
        getCurrentUser() = &user;
        strcpy(user.userid, "<innd>");
        do_del_post(getCurrentUser(),&delarg,&header,board,DIR_MODE_NORMAL,0,getSession());
        free_write_dir_arg(&delarg);
    }
    close(fd);
    chdir(old_path);
    return 0;
}
Example #3
0
void PostHightScore::generateResponse(Poco::Net::HTTPServerRequest& inRequest,
                                      Poco::Net::HTTPServerResponse& outResponse)
{
    std::string requestBody;
    inRequest.stream() >> requestBody;

    Args args;
    GetArgs(requestBody, args);

    std::string name = URIDecode(GetArg(args, "name"));
    const std::string & score = GetArg(args, "score");

    Statement insert(getSession());
    insert << "INSERT INTO HighScores VALUES(NULL, strftime('%s', 'now'), ?, ?)", use(name), use(score);
    insert.execute();

    // Return an URL instead of a HTML page.
    // This is because the client is the JavaScript application in this case.
    std::string body = ResourceManager::Instance().getResourceLocation(GetResourceId());
    outResponse.setContentLength(body.size());
    outResponse.send() << body;
}
Example #4
0
__private_extern__
kern_return_t
_notifyremove(mach_port_t		server,
	      xmlData_t			keyRef,		/* raw XML bytes */
	      mach_msg_type_number_t	keyLen,
	      int			isRegex,
	      int			*sc_status
)
{
	CFStringRef		key		= NULL;		/* key  (un-serialized) */
	serverSessionRef	mySession;

	/* un-serialize the key */
	if (!_SCUnserializeString(&key, NULL, (void *)keyRef, keyLen)) {
		*sc_status = kSCStatusFailed;
		goto done;
	}

	if (!isA_CFString(key)) {
		*sc_status = kSCStatusInvalidArgument;
		goto done;
	}

	mySession = getSession(server);
	if (mySession == NULL) {
		*sc_status = kSCStatusNoStoreSession;	/* you must have an open session to play */
		goto done;
	}

	*sc_status = __SCDynamicStoreRemoveWatchedKey(mySession->store,
						      key,
						      isRegex != 0,
						      FALSE);

    done :

	if (key)	CFRelease(key);
	return KERN_SUCCESS;
}
Example #5
0
void RecadoController::list(Request &request, StreamResponse &response)
{
    Json::Value item;
    Json::Value result;
    result["operation"] = "recado_list";
    UsuarioPtr usuario = getSession(request, response).get<UsuarioPtr>("usuario");
    if(usuario){
        const string& materia_id = request.get("materia_id");
        auto list = model.list(materia_id);
        for(RecadoHasMateriaPtr rm: list){
            item["texto"] = rm->getRecado()->getTexto();
            item["data"] = to_string(rm->getRecado()->getData());
            item["remetente"] = rm->getUsuario()->getNome();
            result["recados"].append(item);
        }
        result["success"] = true;
    }else{
        result["success"] = false;
        result["erro_msg"] = "Não permitido";
    }

    response << result;
}
bool AmSessionContainer::postEvent(const string& local_tag,
				   AmEvent* event) 
{
  //     DBG("postEvent: local_tag = %s\n",local_tag.c_str());
  as_mut.lock();
  AmSession* s = getSession(local_tag);
  as_mut.unlock();

  if (s  != NULL) {
    s->postEvent(event);
    return true;
  }    
	
  // try session factories
  AmSessionFactory* sf = AmPlugIn::instance()->getFactory4App(local_tag);
  if (sf != NULL) {
    sf->postEvent(event);
    return true;
  }

  delete event;
  return false;
}
Example #7
0
void DeleteHighScore::generateResponse(Poco::Net::HTTPServerRequest& inRequest,
                                       Poco::Net::HTTPServerResponse& outResponse)
{
    std::string requestBody;
    inRequest.stream() >> requestBody;

    GetLogger().information("Request body is: " + requestBody);

    std::string sql = Poco::replace<std::string>("DELETE FROM HighScores WHERE {{args}}",
                                                 "{{args}}",
                                                 Args2String(GetArgs(requestBody)));

    GetLogger().information("SQL statement is: " + sql);

    Statement insert(getSession());
    insert << sql;
    insert.execute();

    // Return a message indicating success.
    std::string body = "Succesfully performed the following SQL statement: " + sql;
    outResponse.setContentLength(body.size());
    outResponse.send() << body;
}
Status WiredTigerRecoveryUnit::setTimestamp(Timestamp timestamp) {
    _ensureSession();
    LOG(3) << "WT set timestamp of future write operations to " << timestamp;
    WT_SESSION* session = _session->getSession();
    invariant(_inUnitOfWork(), toString(_state));
    invariant(_prepareTimestamp.isNull());
    invariant(_commitTimestamp.isNull(),
              str::stream() << "Commit timestamp set to " << _commitTimestamp.toString()
                            << " and trying to set WUOW timestamp to "
                            << timestamp.toString());

    _lastTimestampSet = timestamp;

    // Starts the WT transaction associated with this session.
    getSession();

    const std::string conf = "commit_timestamp=" + integerToHex(timestamp.asULL());
    auto rc = session->timestamp_transaction(session, conf.c_str());
    if (rc == 0) {
        _isTimestamped = true;
    }
    return wtRCToStatus(rc, "timestamp_transaction");
}
vector<pair<ClassificationObjectPtr, LabelPtr> >
DatabaseSubsystem::getClassificationObjectsAndLabelsForResponse(ResponsePtr r)
{
    RWLock::ScopedLock lock(_dbLock);

    vector<pair<ClassificationObjectPtr, LabelPtr> > result;
    Session session = getSession();
    session.begin();
    for (map<int, int>::const_iterator it = r->labels.begin();
        it != r->labels.end(); it++) {
        ClassificationObjectPtr clo;
        LabelPtr label;
        session << "SELECT * FROM classification_object WHERE object_id = ?",
                   use(it->first), into(clo), now;
        getClassificationObjectDescrIDs(session, clo);
        getClassificationObjectLabelIDs(session, clo);
        session << "SELECT * FROM label where label_id = ?",
                   use(it->second), into(label), now;
        result.push_back(pair<ClassificationObjectPtr, LabelPtr>(clo, label));
    }
    session.commit();
    return result;
}
vector<ClassificationObjectPtr>
DatabaseSubsystem::getClassificationObjectsForLabel(int labelID)
{
    RWLock::ScopedLock lock(_dbLock);

    vector<ClassificationObjectPtr> result;
    Session session = getSession();
    session.begin();
    session << "SELECT * FROM classification_object WHERE object_id "
               "IN (SELECT object_id FROM classification_object_label WHERE "
               "label_id = ?)",
               use(labelID),
               into(result),
               now;
    for (vector<ClassificationObjectPtr>::iterator it = result.begin();
        it != result.end(); ++it)
    {
        getClassificationObjectDescrIDs(session, *it);
        getClassificationObjectLabelIDs(session, *it);
    }
    session.commit();
    return result;
}
Example #11
0
File: newio.c Project: zhouqt/kbs
void oflush()
{
    if (obufsize) {
        if (convcode) {
            char *out;

            out = gb2big(outbuf, &obufsize, 0, getSession());
#ifdef SSHBBS
            if (ssh_write(0, out, obufsize) < 0)
#else
            if (write(0, out, obufsize) < 0)
#endif
                abort_bbs(0);
        } else
#ifdef SSHBBS
            if (ssh_write(0, outbuf, obufsize) < 0)
#else
            if (write(0, outbuf, obufsize) < 0)
#endif
                abort_bbs(0);
    }
    obufsize = 0;
}
Example #12
0
void
LoginProcess::onGotToken()
{
    lastfm::XmlQuery lfm;

    if ( lfm.parse( static_cast<QNetworkReply*>( sender() )->readAll() ) )
    {
        getSession( lfm["token"].text() );
    }
    else
    {
        qWarning() << lfm.parseError().message() << lfm.parseError().enumValue();

        m_lastError = lfm.parseError();

        if ( m_lastError.enumValue() == lastfm::ws::UnknownError )
        {
           m_lastNetworkError = static_cast<QNetworkReply*>( sender() )->error();
        }

        emit gotSession( 0 );
    }
}
void X11Device::shutdown() {
    X11Session *session = static_cast<X11Session *>(getSession());
    Log(EDebug, "Shutting down X11 device");
    Device::shutdown();
    setVisible(false);
    XDestroyWindow(session->m_display, m_window);
    XFree(m_visinfo);

    if (m_fullscreen) {
        /* Switch back to the previous screen resolution */
        XF86VidModeSwitchToMode(session->m_display, session->m_screen, &m_previousMode);
        XF86VidModeSetViewPort(session->m_display, session->m_screen, 0, 0);
    }

    /* In case auto_repeat was left on */
    XKeyboardState xkbs;
    XAutoRepeatOn(session->m_display);
    XGetKeyboardControl(session->m_display, &xkbs);

    if (!xkbs.global_auto_repeat)
        Log(EWarn, "Unable to restore the keyboard auto-repeat flag");

    m_initialized = false;
}
Example #14
0
ChatSession *ChatLayer::getSession(Account *acc, const QString &id, bool create)
{
	return (acc && !id.isEmpty()) ? getSession(acc->getUnit(id, create)) : 0;
}
Example #15
0
/* process post write */
static int bbspost_write_post(int fh, char *board, char *filename)
{
    char *fptr, *ptr;
    FILE *fhfd;
    char conv_buf[256];

    fhfd = fdopen(fh, "w");
    if (fhfd == NULL) {
        innbbsdlog("can't fdopen, maybe disk full\n");
        return -1;
    }
    if (strlen(SUBJECT) > 256)
        FAILED;
    str_decode((unsigned char*)conv_buf, (unsigned char*)SUBJECT);
    /* big 标题转码,original patch by dgwang @ 笔山书院 */
    if(strstr(SUBJECT,"=?big5?") || strstr(SUBJECT,"=?Big5?") ||
       strstr(SUBJECT,"=?BIG5?") ){
       int len;
       len = strlen(conv_buf);
       big2gb(conv_buf,&len,0,getSession());
    }

    if (fprintf(fhfd, "%s%s, %s%s\n", FromTxt, FROM, BoardTxt, board) == EOF
        || fprintf(fhfd, "%s%.70s\n", SubjectTxt, conv_buf) == EOF || fprintf(fhfd, "%s%.43s (%s)\n", OrganizationTxt, SITE, DATE) == EOF || fprintf(fhfd, "%s%s\n", PathTxt, PATH) == EOF)
        FAILED;

    if (POSTHOST != NULL) {
        if (fprintf(fhfd, "出  处: %.70s\n", POSTHOST) == EOF)
            FAILED;
    }
    if (fprintf(fhfd, "\n") == EOF)
        FAILED;
    for (fptr = BODY, ptr = strchr(fptr, '\r'); ptr != NULL && *ptr != '\0'; fptr = ptr + 1, ptr = strchr(fptr, '\r')) {
        int ch = *ptr;

        *ptr = '\0';
        /*
         * 990530.edwardc 这里应该要处理,采用留住单一 "." 的方式 
         */
        if (fptr[0] == '.' && fptr[1] == '.')
            fptr++;
        if (fputs(fptr, fhfd) == EOF)
            FAILED;
        *ptr = ch;
    }

    /*
     * 990530.edwardc 这里也是 
     */
    if (fptr[0] == '.' && fptr[1] == '.')
        fptr++;

    if (fputs(fptr, fhfd) == EOF)
        FAILED;

    fflush(fhfd);
    fclose(fhfd);
    return 0;
  failed:
    fclose(fhfd);
    return -1;
}
Example #16
0
 __int64 Codec::Seek(__int64 iSeekTime) {
   Logger::printOut("trying to seek");
   sp_session_player_seek(getSession(), iSeekTime);
   m_bufferPos = 0;
   return iSeekTime;
 }
void WiredTigerRecoveryUnit::preallocateSnapshot() {
    // Begin a new transaction, if one is not already started.
    getSession();
}
Example #18
0
const QDomNode &SVT_Fcml::fcmlReqWithRefreshSession(const QString &to
                                                    , const QString &model, const QString &func
                                                    , const QMap<QString, QString> &para
                                                    , int *error)
{
    bool sessionRegeted=false;
    mNode.clear();
    bool sessionOk=mSession.contains(to);
    mMutex.lock();
    bool authOk=mSavedAuth.contains(to);
    mMutex.unlock();
    if(!sessionOk && !authOk)
    {
        if(error)
        {
            *error=FE_WRONG_USER_OR_PWD;
        }
        return mNode;
    }

    //step1 get sessionId
    QString sessionId;
    if(!sessionOk)
    {
        Q_ASSERT(authOk);
        mMutex.lock();
        const QPair<QString,QString> pair=mSavedAuth[to];
        mMutex.unlock();
        int itemp;
        sessionId=getSession(to,pair.first,pair.second,&itemp);
        if(sessionId.isEmpty())
        {
            //有两种可能,1.用户名密码错    2.不在线
            if(error)
            {
                *error=itemp;
            }
            return mNode;
        }
        sessionRegeted=true;

    }
    else
    {
        sessionId=mSession[to];
    }

    //step2 get data
    QDomElement elem;
    QDomDocument doc;
    elem=doc.createElement(QString("%1.%2").arg(model,func));
    elem.setAttribute("_sessionId",sessionId);

    QMap<QString, QString>::const_iterator i = para.constBegin();
    while (i != para.constEnd()) {
        elem.setAttribute(i.key(),i.value());
        ++i;
    }

    doc.appendChild(elem);
//    QString req="<%1.%2 _sessionId=\"%3\"/>";
//    req=req.arg(model,func,sessionId);

    QString req=doc.toString();

    bool needStartFinish=isSetApi(model,func);

    if(needStartFinish)sendStart(to,sessionId);
    elem=fcmlRequest(QString("netrouter@")+to,req).firstChild().toElement();
    if(needStartFinish)sendFinish(to,sessionId);

    if(0==elem.tagName().compare("error"))
    {
        int retvalue=elem.attribute("code").toInt();
        if(retvalue==FE_SESSION_NOTOK && !sessionRegeted && authOk)
        {
            const QPair<QString,QString> pair=mSavedAuth[to];
            sessionId=getSession(to,pair.first,pair.second);
            sessionRegeted=true;
            if(!sessionId.isEmpty())
            {
                elem=fcmlRequest(QString("netrouter@")+to,req).firstChild().toElement();
            }
        }
    }

    if(error)
    {
        if(0==elem.tagName().compare("error"))
        {
            *error=elem.attribute("code").toInt();
        }
        else
        {
            *error=0;
        }
    }
    return mNode;
}
Example #19
0
void Window::triggerAction(int identifier, const QVariantMap &parameters)
{
	switch (identifier)
	{
		case ActionsManager::CloneTabAction:
			if (canClone())
			{
				m_mainWindow->addWindow(clone(true, m_mainWindow));
			}

			break;
		case ActionsManager::PinTabAction:
			setPinned(!isPinned());

			break;
		case ActionsManager::DetachTabAction:
			if (m_mainWindow->getWindowCount() > 1)
			{
				m_mainWindow->moveWindow(this);
			}

			break;
		case ActionsManager::SuspendTabAction:
			if (!m_contentsWidget || m_contentsWidget->close())
			{
				m_session = getSession();

				setContentsWidget(nullptr);
			}

			break;
		case ActionsManager::CloseTabAction:
			if (!isPinned())
			{
				requestClose();
			}

			break;
		case ActionsManager::GoAction:
		case ActionsManager::ActivateAddressFieldAction:
		case ActionsManager::ActivateSearchFieldAction:
			{
				AddressWidget *addressWidget(findAddressWidget());
				SearchWidget *searchWidget(nullptr);

				for (int i = 0; i < m_searchWidgets.count(); ++i)
				{
					if (m_searchWidgets.at(i) && m_searchWidgets.at(i)->isVisible())
					{
						searchWidget = m_searchWidgets.at(i);

						break;
					}
				}

				if (identifier == ActionsManager::ActivateSearchFieldAction && searchWidget)
				{
					searchWidget->activate(Qt::ShortcutFocusReason);
				}
				else if (addressWidget)
				{
					if (identifier == ActionsManager::ActivateAddressFieldAction)
					{
						addressWidget->activate(Qt::ShortcutFocusReason);
					}
					else if (identifier == ActionsManager::ActivateSearchFieldAction)
					{
						addressWidget->setText(QLatin1String("? "));
						addressWidget->activate(Qt::OtherFocusReason);
					}
					else if (identifier == ActionsManager::GoAction)
					{
						addressWidget->handleUserInput(addressWidget->text(), SessionsManager::CurrentTabOpen);

						return;
					}
				}
				else if (identifier == ActionsManager::ActivateAddressFieldAction || identifier == ActionsManager::ActivateSearchFieldAction)
				{
					OpenAddressDialog dialog(this);

					if (identifier == ActionsManager::ActivateSearchFieldAction)
					{
						dialog.setText(QLatin1String("? "));
					}

					connect(&dialog, SIGNAL(requestedLoadUrl(QUrl,SessionsManager::OpenHints)), this, SLOT(handleOpenUrlRequest(QUrl,SessionsManager::OpenHints)));
					connect(&dialog, SIGNAL(requestedOpenBookmark(BookmarksItem*,SessionsManager::OpenHints)), this, SIGNAL(requestedOpenBookmark(BookmarksItem*,SessionsManager::OpenHints)));
					connect(&dialog, SIGNAL(requestedSearch(QString,QString,SessionsManager::OpenHints)), this, SLOT(handleSearchRequest(QString,QString,SessionsManager::OpenHints)));

					dialog.exec();
				}
			}

			break;
		case ActionsManager::PrintAction:
			{
				QPrinter printer;
				printer.setCreator(QStringLiteral("Otter Browser %1").arg(Application::getFullVersion()));

				QPrintDialog printDialog(&printer, this);
				printDialog.setWindowTitle(tr("Print Page"));

				if (printDialog.exec() != QDialog::Accepted)
				{
					break;
				}

				getContentsWidget()->print(&printer);
			}

			break;
		case ActionsManager::PrintPreviewAction:
			{
				QPrintPreviewDialog printPreviewDialog(this);
				printPreviewDialog.printer()->setCreator(QStringLiteral("Otter Browser %1").arg(Application::getFullVersion()));
				printPreviewDialog.setWindowFlags(printPreviewDialog.windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint);
				printPreviewDialog.setWindowTitle(tr("Print Preview"));

				if (QApplication::activeWindow())
				{
					printPreviewDialog.resize(QApplication::activeWindow()->size());
				}

				connect(&printPreviewDialog, SIGNAL(paintRequested(QPrinter*)), getContentsWidget(), SLOT(print(QPrinter*)));

				printPreviewDialog.exec();
			}

			break;
		case ActionsManager::BookmarkPageAction:
			{
				const QUrl url((parameters.contains(QLatin1String("url")) ? parameters[QLatin1String("url")].toUrl() : getUrl()).adjusted(QUrl::RemovePassword));

				if (url.isEmpty())
				{
					break;
				}

				const QVector<BookmarksItem*> bookmarks(BookmarksManager::getModel()->getBookmarks(url));

				if (bookmarks.isEmpty())
				{
					BookmarkPropertiesDialog dialog(url, (parameters.contains(QLatin1String("title")) ? parameters[QLatin1String("title")].toString() : getTitle()), parameters[QLatin1String("description")].toString(), nullptr, -1, true, this);
					dialog.exec();
				}
				else
				{
					BookmarkPropertiesDialog dialog(bookmarks.at(0), this);
					dialog.exec();
				}
			}

			break;
		case ActionsManager::FullScreenAction:
			if (m_addressBar)
			{
				m_addressBar->setVisible(m_addressBar->shouldBeVisible(m_mainWindow->isFullScreen()));
			}

			if (m_contentsWidget)
			{
				m_contentsWidget->triggerAction(identifier, parameters);
			}

			break;
		default:
			getContentsWidget()->triggerAction(identifier, parameters);

			break;
	}
Example #20
0
inline void setcurrentuser(struct userec *user, int usernum)
{
	setCurrentUser(user);
    getSession()->currentuid = usernum;
}
Example #21
0
inline void setcurrentuinfo(struct user_info *uinfo, int uinfonum)
{
    getSession()->currentuinfo = uinfo;
    getSession()->utmpent = uinfonum;
}
Example #22
0
int main(int argc, char* argv[])
{
	static int idx;
	int flag;
	int ex_score = 0;	
	int num_of_users = 0;
	int is_update = 0;
	FILE* top50_fd;
	char fname[STRLEN];
	//FILE* top100ex_fd;

#ifdef CA_LOG
	char* log_file_name = (char *)malloc(sizeof(char) * 20);
#endif

    if(setgid(BBSGID)==-1)
        exit(8);
    if(setuid(BBSUID)==-1)
        exit(8);

	curtime = time(NULL);
	local_time = localtime(&curtime);
	is_first_init = 0;

	count = 0;
	if(chdir(BBSHOME)==-1)
		return -1;
	if (init_all()) {
		printf("init data fail\n");
		return -2; 
	}
	apply_users(create_userlist,NULL);

	if( argc == 2)
	{
		if ( strncmp(argv[1], "--init", 6) == 0 ) 
			is_first_init = 1; 
		if ( strncmp( argv[1], "--update", 8 ) == 0 )
			is_update = 1;
	}


#ifdef CA_LOG
	sprintf( log_file_name, "scores.log.%d%02d%02d", 
			1900+local_time->tm_year, 1+local_time->tm_mon, local_time->tm_mday);
	logfd = fopen( log_file_name, "r" );
	if (logfd > 0)
	{
		fclose(logfd);
		logfd = fopen( log_file_name, "a+" );
		fprintf(logfd, "[%02u/%02u %02u:%02u]:\t\tCan't caculate scores second time a day\n", 
				local_time->tm_mon+1, local_time->tm_mday, local_time->tm_hour, local_time->tm_min);
		fclose(logfd);
		exit(1);
	}
	logfd = fopen( log_file_name, "a+" );
#endif

	flag = read_userscore_from_file(".SCORES", scorelist);
	/*读积分操作文件,对用户进行相应的积分增减*/
	if ( score_update_from_file("score_update.txt") == 0 )
	{
#ifdef CA_LOG
		fprintf( logfd, "No score update today\n" );
#endif
	}
	if ( is_update )
	{
		exit(1);
	}
	/*读文件结束*/
	
	for(idx=0;idx<count;idx++)
	{
		if(userlist[idx]->userid[0])
		{
			
#ifdef CA_DEBUG
			printf("------------------------\n");
			printf("[%s]\n", userlist[idx]->userid);
			printf("[%s]\n", userlist[idx]->username);
			printf("初始积分:%d\n", scorelist[idx].base_score);
#endif
			
			ex_score = 0;
			if(is_first_init)
			{
				//第一次创建文件的时候,把对应的用户ID拷贝过去
				strncpy(scorelist[idx].userid, userlist[idx]->userid, sizeof(scorelist[idx].userid) - 1);
				scorelist[idx].userid[sizeof(scorelist[idx].userid) - 1] = '\0';
				//计算基础积分了
				scorelist[idx].base_score = calculate_base_score(idx, userlist[idx]);
				scorelist[idx].ex_score = 0;
			}
			else 
			{
				if( scorelist[idx].userid[0] ){
					if( strcmp(userlist[idx]->userid, scorelist[idx].userid) != 0 )
					{
					//这部分用来验证用户的ID是否符合
#ifdef CA_DEBUG
						printf("user id error\n");
#endif
						strncpy(scorelist[idx].userid, userlist[idx]->userid, sizeof(scorelist[idx].userid) - 1);
						scorelist[idx].userid[sizeof(scorelist[idx].userid) - 1] = '\0';
						scorelist[idx].base_score = 0;
						scorelist[idx].ex_score = 0;
						continue;
					}
				}
				else
				{
					//说明遇到了新注册用户,需要拷贝用户ID
					strncpy(scorelist[idx].userid, userlist[idx]->userid, sizeof(scorelist[idx].userid) - 1);
					scorelist[idx].userid[sizeof(scorelist[idx].userid) - 1] = '\0';
					scorelist[idx].base_score = 0;
					scorelist[idx].ex_score = 0;
					continue;//新用户不用再计算积分了
				}
				//不是第一次创建文件,而且是老用户,计算积分增量
				if( strcmp("guest",scorelist[idx].userid)==0 )
				{
					scorelist[idx].base_score = 0;
					scorelist[idx].ex_score = 0;
					continue;
				}
				scorelist[idx].base_score = userlist[idx]->score;
				ex_score = calculate_ex_score(idx, userlist[idx]);
				scorelist[idx].base_score += ex_score;
				scorelist[idx].ex_score = ex_score;
			}
#ifdef CA_DEBUG
			printf("增加积分: %d\n", scorelist[idx].ex_score);
			printf("总积分: %d\n", scorelist[idx].base_score);
#endif
			p_scorelist[num_of_users].s = &scorelist[idx];
			p_scorelist[num_of_users].i = idx;
			num_of_users ++;
		}
		else
		{
			if(is_first_init)
			{
				scorelist[idx].base_score = 0;
				scorelist[idx].ex_score = 0;
				userlist[idx]->score_rank = 0;
				userlist[idx]->score = 0;
			}
		}
	}


/*******************************************************
 *  下面使用库函数qsort对积分进行排序
 *  同时输出日志
 *  将每日Top50总量排名和增量排名发文到ScoreRecords版
 ******************************************************/

	// 总量排名
	qsort(p_scorelist, num_of_users, sizeof(struct score_sort), cmp_base_score);
	//输出日志
	flag = write_userscore(".SCORES", scorelist);
	for(idx=0; idx<num_of_users; idx++)
	{
		p_scorelist[idx].s->rank = idx;
#ifdef CA_LOG
		fprintf(logfd, "[%02u/%02u %02u:%02u]:\t",
				local_time->tm_mon+1, local_time->tm_mday, 
				local_time->tm_hour, local_time->tm_min);
		fprintf(logfd,"%-16s", p_scorelist[idx].s->userid);
		fprintf(logfd,"=%-10d",p_scorelist[idx].s->base_score);
		fprintf(logfd,"+%-10d",p_scorelist[idx].s->ex_score);
		fprintf(logfd,"rank=%-6d",p_scorelist[idx].s->rank);
		userlist[ p_scorelist[idx].i ]->score_rank = (num_of_users-idx)*100000/num_of_users;
		fprintf(logfd,"%d.%d%%\n", userlist[ p_scorelist[idx].i ]->score_rank/1000, userlist[ p_scorelist[idx].i ]->score_rank%1000);
		userlist[ p_scorelist[idx].i ]->score = p_scorelist[idx].s->base_score;
#endif
	}
#ifdef CA_DEBUG
	if(flag<=0)
		printf("write error\n");
#endif
#ifdef CA_LOG
	fflush(logfd);
	fclose(logfd);
#endif
	//发文至ScoreRecords
	top50_fd = fopen("etc/posts/top50score","w+");
	fprintf(top50_fd, "名次 代号            昵称                                     积分      \n");
	fprintf(top50_fd, "==== ======================================================== ==========\n");
	for(idx=0; idx<50; idx++)
		fprintf(top50_fd, "[%2d] %-16s%-40s %-10d\n", 
				idx+1, p_scorelist[idx].s->userid, 
				userlist[ p_scorelist[idx].i ]->username,
				p_scorelist[idx].s->base_score);
	fflush(top50_fd);
	fclose(logfd);
	sprintf(fname, "%d年%2d月%2d日积分总量排名Top 50", local_time->tm_year+1900, local_time->tm_mon+1, local_time->tm_mday);
//	post_file(NULL, "", "etc/posts/top50score", "BBSLists", fname, 0, 1, getSession());
	post_file(NULL, "", "etc/posts/top50score", "ScoreRecords", fname, 0, 1, getSession());

	//增量排名
	qsort(p_scorelist, num_of_users, sizeof(struct score_sort), cmp_ex_socre);
	//发文至ScoreRecords
	top50_fd = fopen("etc/posts/top50exscore","w+");
	fprintf(top50_fd, "名次 代号            昵称                                     积分      \n");
	fprintf(top50_fd, "==== ======================================================== ==========\n");
	for(idx=0; idx<50; idx++)
		fprintf(top50_fd, "[%2d] %-16s%-40s %-10d\n", 
				idx+1, p_scorelist[idx].s->userid, 
				userlist[ p_scorelist[idx].i ]->username,
				p_scorelist[idx].s->ex_score);
	fflush(top50_fd);
	fclose(logfd);
	sprintf(fname, "%d年%2d月%2d日积分增量排名Top 50", local_time->tm_year+1900, local_time->tm_mon+1, local_time->tm_mday);
//	post_file(NULL, "", "etc/posts/top50exscore", "BBSLists", fname, 0, 1, getSession());
	post_file(NULL, "", "etc/posts/top50exscore", "ScoreRecords", fname, 0, 1, getSession());

	return 0;
}
Example #23
0
int score_update_from_file( const char* filename )
{
	FILE* fd = fopen(filename,"r");
	FILE* update_fd;
	char  uid[IDLEN+2];
	char  reason[400];
	char  fname[STRLEN];
	int   score;
	int   flag;

	if ( fd == NULL )
	{
		printf("Cannot read file %s", filename);
		return 0;
	}

#ifdef CA_LOG
	fprintf( logfd, "------------------------------------------\n" );
#endif
	while ( fgets( reason, 400, fd ) )
	{
		update_fd = fopen("etc/posts/update_score","w+");
		sscanf( reason, "%s %d", uid, &score );
		if ( fgets( reason, 400, fd ) == NULL )
		{
			return 0;
		}
		if ( score > 0)
		{
#ifdef CA_LOG
			fprintf( logfd, "%s  +%d \n", uid, score );
#endif
			sprintf( fname, "[公告] 增加 %s 积分 %d 分", uid, score );
		}
		else
		{
#ifdef CA_LOG
			fprintf( logfd, "%s  %d \n", uid, score );
#endif
			sprintf( fname, "[公告] 扣除 %s 积分 %d 分", uid, score );

		}
			update_user_score( (const char*)uid, score );
		fprintf( update_fd, "说明:\n");
		fprintf( update_fd, "        %s\n", reason);
		fclose(update_fd);
		post_file(NULL, "", "etc/posts/update_score", "ScoreRecords", fname, 0, 1, getSession());
	}
#ifdef CA_LOG
	fprintf( logfd, "------------------------------------------\n" );
#endif
	fclose(fd);
	sprintf( fname, "%s.%04u%02u%02u.bak", 
			filename, local_time->tm_year + 1900,
			local_time->tm_mon + 1,
			local_time->tm_mday
			);
	flag = rename( filename, fname );
	if ( flag < 0 )
	{
		perror( "rename successfully\n" );
	}
	return 1;
}
Example #24
0
void MaterialNode::createFragment(VNMFragmentID ID, VNMFragmentType type, const VMatFrag& value)
{
  getSession().push();
  verse_send_m_fragment_create(getID(), ID, type, &value);
  getSession().pop();
}
Example #25
0
File: register.c Project: wyat/kbs
void new_register()
{
    struct userec newuser;
    int allocid, do_try, flag;
    char buf[STRLEN];

    /* temp !!!!!*/

#ifdef SECONDSITE
    prints("不接受新帐号注册!!!\n");
    oflush();
    sleep(2);
    exit(-1);
#else

    /*    prints("Sorry, we don't accept newusers due to system problem, we'll fixit ASAP\n");
        oflush();
        sleep(2);
        exit(-1);
    */
    memset(&newuser, 0, sizeof(newuser));
    getdata(0, 0, "使用GB编码阅读?(\xa8\xcf\xa5\xce BIG5\xbd\x58\xbe\x5c\xc5\xaa\xbd\xd0\xbf\xefN)(Y/N)? [Y]: ", buf, 4, DOECHO, NULL, true);
    if (*buf == 'n' || *buf == 'N')
        if (!convcode)
            switch_code();

    ansimore("etc/register", false);
    do_try = 0;
    while (1) {
        if (++do_try >= 10) {
            prints("\n掰掰,按太多下  <Enter> 了...\n");
            refresh();
            longjmp(byebye, -1);
        }
        getdata(0, 0, "请输入代号: ", newuser.userid, IDLEN + 1, DOECHO, NULL, true);
        flag = 1;
        if (id_invalid(newuser.userid) == 1) {
            prints("帐号必须由英文字母或数字组成,并且第一个字符必须是英文字母!\n");
            /*                prints("帐号必须由英文字母或数字,而且帐号第一个字是英文字母!\n"); */
            flag = 0;
        }
        if (flag) {
            if (strlen(newuser.userid) < 2) {
                prints("代号至少需有两个英文字母!\n");
            } else if ((strcasecmp(newuser.userid, "SYSOP") == 0) && (strcmp(newuser.userid, "SYSOP") != 0) && searchuser("SYSOP") == 0) {
                prints("抱歉,本站只允许注册*全部*大写的SYSOP用户ID。\n");
            } else if (!strcasecmp(newuser.userid, "guest") && strcmp(newuser.userid, "guest") && !searchuser("guest")) {
                prints("抱歉,本站只允许注册*全部*小写的guest用户ID。\n");
            } else if ((*newuser.userid == '\0') || bad_user_id(newuser.userid) || (strcasecmp(newuser.userid, "SYSOPS") == 0) || (strcasecmp(newuser.userid, "BMS") == 0)) {
                prints("抱歉,本站暂不提供此帐号注册。\n");
            } else if (searchuser(newuser.userid) != 0) {   /*( dosearchuser( newuser.userid ) ) midified by dong , 1998.12.2, change getuser -> searchuser , 1999.10.26 */
                prints("此帐号已经有人使用\n");
            } else {
                /*--- ---*/
                struct stat lst;
                time_t lnow;

                lnow = time(NULL);
                sethomepath(genbuf, newuser.userid);
                if (!stat(genbuf, &lst) && S_ISDIR(lst.st_mode)
                        && (lnow - lst.st_ctime < SEC_DELETED_OLDHOME /* 3600*24*30 */)) {
                    prints("目前无法注册帐号%s,请与系统管理人员联系。\n", newuser.userid);
                    sprintf(genbuf, "IP %s new id %s failed[home changed in past 30 days]", getSession()->fromhost, newuser.userid);
                    bbslog("user","%s",genbuf);
                } else {
                    /* etnlegend, 2006.10.14, 新用户可能继承原有同名用户信件... */
                    sethomepath(genbuf,newuser.userid);
                    my_f_rm(genbuf);
                    setmailpath(genbuf,newuser.userid);
                    my_f_rm(genbuf);
                    break;
                }
            }
        }
    }

    newuser.firstlogin = newuser.lastlogin = time(NULL) - 13 * 60 * 24;
    do_try = 0;
    while (1) {
        char passbuf[STRLEN], passbuf2[STRLEN];

        if (++do_try >= 10) {
            prints("\n掰掰,按太多下  <Enter> 了...\n");
            refresh();
            longjmp(byebye, -1);
        }
        getdata(0, 0, "请设定您的密码: ", passbuf, 39, NOECHO, NULL, true);
        if (strlen(passbuf) < 4 || !strcmp(passbuf, newuser.userid)) {
            prints("密码太短或与使用者代号相同, 请重新输入\n");
            continue;
        }
        getdata(0, 0, "请再输入一次你的密码: ", passbuf2, 39, NOECHO, NULL, true);
        if (strcmp(passbuf, passbuf2) != 0) {
            prints("密码输入错误, 请重新输入密码.\n");
            continue;
        }

        setpasswd(passbuf, &newuser);
#ifdef NEWSMTH
        strcpy(getSession()->passwd, passbuf);
#endif
        break;
    }

    if (searchuser(newuser.userid) != 0) {
        prints("此帐号已经有人使用\n");
        refresh();
        longjmp(byebye, -1);
    }

    newuser.userlevel = PERM_BASIC;
    newuser.userdefine[0] = -1;
    newuser.userdefine[1] = -1;
    /*   newuser.userdefine&=~DEF_MAILMSG;
        newuser.userdefine&=~DEF_EDITMSG; */
    SET_UNDEFINE(&newuser, DEF_NOTMSGFRIEND);
    if (convcode)
        SET_UNDEFINE(&newuser, DEF_USEGB);

    SET_UNDEFINE(&newuser, DEF_SHOWREALUSERDATA);

    newuser.exittime = time(NULL) - 100;
    /*newuser.unuse2 = -1;*/
    newuser.flags |= PAGER_FLAG;
    newuser.title = 0;
    newuser.firstlogin = newuser.lastlogin = time(NULL);

    allocid = getnewuserid2(newuser.userid);
    if (allocid > MAXUSERS || allocid <= 0) {
        prints("抱歉, 由于某些系统原因, 无法注册新的帐号.\n\r");
        oflush();
        sleep(2);
        exit(1);
    }
    newbbslog(BBSLOG_USIES, "APPLY: %s uid %d from %s", newuser.userid, allocid, getSession()->fromhost);

    update_user(&newuser, allocid, 1);

    if (!dosearchuser(newuser.userid)) {
        /* change by KCN 1999.09.08
           fprintf(stderr,"User failed to create\n") ;
         */
        prints("User failed to create %d-%s\n", allocid, newuser.userid);
        oflush();
        exit(1);
    }
    bbslog("user","%s","new account");
#endif /* SECONDSITE */
}
Example #26
0
void EIoFilterEvent::fire() {
    sp<EIoSession> session = getSession();
    EIoEventType type = getType();

    LOGGER->debug__(__FILE__, __LINE__, "Firing a %s event for session %d", GetIoEventTypeName(type), session->getId());

    switch (type) {
    case MESSAGE_RECEIVED:
    {
        sp<EObject> parameter = getParameter();
        nextFilter->messageReceived(session, parameter);
        break;
    }
    case MESSAGE_SENT:
    {
        sp<EWriteRequest> writeRequest = dynamic_pointer_cast<EWriteRequest>(getParameter());
        nextFilter->messageSent(session, writeRequest);
        break;
    }
    case WRITE:
    {
        sp<EWriteRequest> writeRequest = dynamic_pointer_cast<EWriteRequest>(getParameter());
        nextFilter->filterWrite(session, writeRequest);
        break;
    }
    case CLOSE:
        nextFilter->filterClose(session);
        break;

    case EXCEPTION_CAUGHT:
    {
        sp<EThrowableType> throwable = dynamic_pointer_cast<EThrowableType>(getParameter());
        nextFilter->exceptionCaught(session, throwable);
        break;
    }
    case SESSION_IDLE:
    {
        sp<EInteger> parameter = dynamic_pointer_cast<EInteger>(getParameter());
        nextFilter->sessionIdle(session, (EIdleStatus)parameter->intValue());
        break;
    }
    case SESSION_OPENED:
        nextFilter->sessionOpened(session);
        break;

    case SESSION_CREATED:
        nextFilter->sessionCreated(session);
        break;

    case SESSION_CLOSED:
        nextFilter->sessionClosed(session);
        break;

    default:
    {
        EString msg("Unknown event type: ");
        msg << type;
        throw EIllegalArgumentException(__FILE__, __LINE__, msg.c_str());
    }
    }

    LOGGER->debug__(__FILE__, __LINE__, "Event %s has been fired for session  %d", GetIoEventTypeName(type), session->getId());
}
Example #27
0
static int set_smsg_getdata(struct _select_def *conf,int pos,int len)
{
    int i;

    for (i=0; i<sm_num; i++) {
        if (s_m[i].context) free(s_m[i].context);
    }
    bzero(s_m, sizeof(struct smsmsg) * BBS_PAGESIZE);

    if (conf->item_count - conf->page_pos < BBS_PAGESIZE)
        conf->item_count = count_sql_smsmsg(getCurrentUser()->userid, sm_dest, 0, 0, sm_type, 0, sm_msgtxt, getSession());

    i = get_sql_smsmsg(s_m, getCurrentUser()->userid, sm_dest, 0, 0, sm_type, 0, conf->page_pos-1, BBS_PAGESIZE,sm_msgtxt,sm_desc, getSession());

    if (i <= 0) {

        conf->page_pos = 0;
        sm_dest[0]=0;
        sm_type = -1;
        sm_msgtxt[0]=0;

        i = get_sql_smsmsg(s_m, getCurrentUser()->userid, sm_dest, 0, 0, sm_type, 0, conf->page_pos-1, BBS_PAGESIZE,sm_msgtxt,sm_desc, getSession());

        if (i <= 0)
            return SHOW_QUIT;
    }

    return SHOW_CONTINUE;
}
Example #28
0
void
LoginProcess::cancel()
{
    disconnect( m_webServer, SIGNAL( gotToken( QString ) ), this, SLOT( getSession( QString ) ) );
    qDeleteAll( findChildren<QNetworkReply*>() );
}
Example #29
0
static int set_smsg_key(struct _select_def *conf, int key)
{
    switch (key) {
        case 'd': {
            char sql[100];
            MYSQL s;
            char ans[4];

            move(2,0);
            clrtoeol();
            ans[0]=0;
            getdata(2, 0, "删除这条消息(Y/N) [N]: ", ans, 3, DOECHO, NULL, true);
            if (ans[0] != 'y' && ans[0]!='Y')
                return SHOW_REFRESH;

            mysql_init(&s);
            if (! my_connect_mysql(&s)) {
                clear();
                prints("%s\n",mysql_error(&s));
                pressanykey();
                mysql_close(&s);
                return SHOW_REFRESH;
            }

            sprintf(sql,"DELETE FROM smsmsg WHERE id=%d;",s_m[conf->pos-conf->page_pos].id);


            if (mysql_real_query(&s, sql, strlen(sql))) {
                clear();
                prints("%s\n",mysql_error(&s));
                pressanykey();
                mysql_close(&s);
                return SHOW_REFRESH;
            }

            mysql_close(&s);

            return SHOW_DIRCHANGE;
        }
        case 's': {
            char ans[40];

            clear();
            move(0,0);
            ans[0]=0;
            prints("                                 超级短信选择\n");
            prints("\033[1;31m------------------------------------------------------------------------\033[m\n");
            getdata(2, 0, "选择全部短信请按\033[1;32m1\033[m,输入条件选择请按\033[1;32m2\033[m,取消直接回车(1/2/0) [0]: ", ans, 3, DOECHO, NULL, true);
            if (ans[0] == '1') {
                conf->page_pos = 0;
                sm_dest[0]=0;
                sm_type = -1;
                sm_msgtxt[0]=0;
                return SHOW_DIRCHANGE;
            } else if (ans[0] == '2') {
                move(3,0);
                getdata(3,0,"请输入要选择的短信来源(回车选择所有):",ans,15, DOECHO,NULL,true);
                strncpy(sm_dest, ans, 13);
                sm_dest[12]=0;

                move(4,0);
                getdata(4,0,"请输入要选择的短信类别(1表示发,2表示收,回车所有) [0]:",ans,3, DOECHO,NULL,true);
                if (ans[0] == '1')
                    sm_type = 1;
                else if (ans[0] == '2')
                    sm_type = 0;
                else sm_type = -1;

                move(5,0);
                getdata(5,0,"请输入开始显示的短信序号 [0]:",ans,5, DOECHO,NULL,true);
                conf->page_pos = atoi(ans);
                if (conf->page_pos <= 0) conf->page_pos=1;
                conf->pos=conf->page_pos;

                move(6,0);
                getdata(6,0,"请输入要短信内容包含文字(回车选择所有):",ans,21, DOECHO,NULL,true);
                strncpy(sm_msgtxt, ans, 21);
                sm_msgtxt[20]=0;

                return SHOW_DIRCHANGE;
            } else {
                return SHOW_REFRESH;
            }
            break;
        }
        case 'a': {
            conf->page_pos = 0;
            sm_dest[0]=0;
            sm_type = -1;
            sm_msgtxt[0]=0;
            return SHOW_DIRCHANGE;
        }
        case 'S': {
            if (! isdigit(s_m[conf->pos-conf->page_pos].dest[0]))
                return SHOW_CONTINUE;
            clear();
            do_send_sms_func(s_m[conf->pos-conf->page_pos].dest, NULL);
            pressanykey();
            return SHOW_REFRESH;
        }
        case 'r': {
            sm_desc = ! sm_desc;
            return SHOW_DIRCHANGE;
        }
        case 'z': {
            char ans[42];

            clear();
            prints("修改短消息前缀/后缀,这些会在发送的短消息内容前/后显示,占短消息字节");

            if (getSession()->currentmemo->ud.smsprefix[0])
                strcpy(ans, getSession()->currentmemo->ud.smsprefix);
            else
                ans[0]=0;
            move(2,0);
            prints("请输入新的前缀:");
            multi_getdata(3, 0, 79, NULL, ans, 41, 6, false, 0);
            if (ans[0]) {
                strncpy(getSession()->currentmemo->ud.smsprefix, ans, 40);
                getSession()->currentmemo->ud.smsprefix[40]=0;
            } else
                getSession()->currentmemo->ud.smsprefix[0]=0;

            if (getSession()->currentmemo->ud.smsend[0])
                strcpy(ans, getSession()->currentmemo->ud.smsend);
            else
                ans[0]=0;
            move(10,0);
            prints("请输入新的后缀:");
            multi_getdata(11, 0, 79, NULL, ans, 41, 6, false, 0);
            if (ans[0]) {
                strncpy(getSession()->currentmemo->ud.smsend, ans, 40);
                getSession()->currentmemo->ud.smsend[40]=0;
            } else
                getSession()->currentmemo->ud.smsend[0]=0;

            write_userdata(getCurrentUser()->userid, &(getSession()->currentmemo->ud));

            move(18,0);
            prints("修改成功");
            pressreturn();

            return SHOW_REFRESH;
        }
        case 'h': {
            clear();
            prints("           短信管理器帮助\n\n");
            prints("   d   删除短信\n");
            prints("   s   超级选择\n");
            prints("   a   显示所有短信\n");
            prints("   S   回复短信\n");
            prints("   r   倒序排列\n");
            prints("   z   更改短信前/后缀\n");
            pressreturn();

            return SHOW_REFRESH;
        }
        default:
            break;
    }
    return SHOW_CONTINUE;
}
Example #30
0
static char *post_article(char *homepath, char *userid, char *board, int (*writebody)(), char *pathname, char *firstpath)
{
    struct fileheader header;
    struct fileheader threadfh;

/*    char        *subject = SUBJECT;  */
    char index[MAXPATHLEN];
    static char name[MAXPATHLEN];
    char article[MAXPATHLEN];
    FILE *fidx;
    int fh;
    int ret;
    int linkflag;
    char conv_buf[256];
    char old_path[255];

    getcwd(old_path, 255);
    sprintf(index, "%s/.DIR", homepath);
    if ((fidx = fopen(index, "r")) == NULL) {
        if ((fidx = fopen(index, "w")) == NULL) {
            innbbsdlog(":Err: Unable to post in %s.\n", homepath);
            return NULL;
        }
    }
    fclose(fidx);

    if (GET_POSTFILENAME(name, homepath) < 0)
	{
		innbbslog(" Err: can't get a postfile name\n");
		return NULL;
	}
	sprintf(article, "%s/%s", homepath, name);
	fh = open(article, O_WRONLY, 0644);

#ifdef DEBUG
    printf("post to %s\n", article);
#endif

    linkflag = 1;
    if (firstpath && *firstpath) {
        close(fh);
        unlink(article);
#ifdef DEBUGLINK
        innbbsdlog("try to link %s to %s", firstpath, article);
#endif
        linkflag = link(firstpath, article);
        if (linkflag) {
            fh = open(article, O_CREAT | O_EXCL | O_WRONLY, 0644);
        }
    }
    if (linkflag != 0) {
        if (writebody) {
            if ((*writebody) (fh, board, pathname) < 0)
                return NULL;
        } else {
            if (bbspost_write_post(fh, board, pathname) < 0)
                return NULL;
        }
        close(fh);
    }
    bzero((void *) &header, sizeof(header));
    strcpy(header.filename, name);
    strncpy(header.owner, userid, OWNER_LEN);
    header.owner[OWNER_LEN - 1] = 0;

    str_decode((unsigned char*)conv_buf, (unsigned char*)SUBJECT);
    /* big 标题转码,original patch by dgwang @ 笔山书院 */
    if(strstr(SUBJECT,"=?big5?") || strstr(SUBJECT,"=?Big5?") ||
       strstr(SUBJECT,"=?BIG5?") ){
       int len;
       len = strlen(conv_buf);
       big2gb(conv_buf,&len,0,getSession());
    }

    strnzhcpy(header.title, conv_buf, ARTICLE_TITLE_LEN);
    header.innflag[1] = 'M';
	set_posttime(&header);
    /*
     * if append record record, should return fail message 
     */
    chdir(BBSHOME);
    resolve_boards();
    linkflag = find_thread(&threadfh, board, header.title);
    header.eff_size = get_effsize(article);
    ret = after_post(NULL, &header, board, linkflag ? &threadfh : NULL, 0, getSession());
    if ((ret < 0) && (ret != -2)) {
        innbbslog(":Err:after_post Unable to post.\n");
        chdir(old_path);
        return NULL;
    }
    chdir(old_path);
    return name;
}