Commit 1e2c2f71 authored by Jan Koester's avatar Jan Koester
Browse files

libdbpp api change

parent c73aca27
Loading
Loading
Loading
Loading
+1 −1
Changes for editor/src/webedit_api.cpp: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -5138,7 +5138,7 @@ void webedit::Api::autoPublishSurveysForDocument(const std::string &docXml,

        std::string sname2 = res[0][1];
        std::string stitle = res[0][2];
        std::string sxml   = res[0][3] ? res[0][3] : "";
        std::string sxml   = res[0][3];

        json_object *jsurvey = surveyXmlToJson(sname2, stitle, sxml);

+38 −37
Changes for editor/src/webedit_db.cpp: 38 added lines, 37 removed lines.
Original line number Diff line number Diff line
@@ -238,7 +238,7 @@ std::string webedit::Database::getOption(const std::string &key,
    int rows = _db->exec(sql, res);
    if (rows < 1)
        return defaultVal;
    return std::string(res[0][0]);
    return res[0][0];
}

void webedit::Database::setOption(const std::string &key, const std::string &value) {
@@ -346,7 +346,7 @@ std::string webedit::Database::updateDocument(const std::string &domain,
    int rows = _db->exec(sql, res);
    int nextRev = 1;
    if (rows > 0) {
        try { nextRev = std::stoi(std::string(res[0][0])) + 1; } catch (...) {}
        try { nextRev = std::stoi(res[0][0]) + 1; } catch (...) {}
    }

    // Insert new revision
@@ -449,11 +449,11 @@ std::string webedit::Database::listDocuments(const std::string &domain) {

    for (int i = 0; i < rows; ++i) {
        json_object *obj = json_object_new_object();
        json_object_object_add(obj, "id", json_object_new_string(res[i][0]));
        json_object_object_add(obj, "name", json_object_new_string(res[i][1]));
        json_object_object_add(obj, "created", json_object_new_string(res[i][2]));
        json_object_object_add(obj, "modified", json_object_new_string(res[i][3]));
        json_object_object_add(obj, "group", json_object_new_string(res[i][4]));
        json_object_object_add(obj, "id", json_object_new_string(res[i][0].c_str()));
        json_object_object_add(obj, "name", json_object_new_string(res[i][1].c_str()));
        json_object_object_add(obj, "created", json_object_new_string(res[i][2].c_str()));
        json_object_object_add(obj, "modified", json_object_new_string(res[i][3].c_str()));
        json_object_object_add(obj, "group", json_object_new_string(res[i][4].c_str()));
        json_object_array_add(arr, obj);
    }

@@ -482,7 +482,7 @@ bool webedit::Database::findDocumentIdByNameGroup(const std::string &domain,
        return false;
    }

    docId = std::string(res[0][0]);
    docId = res[0][0];
    return true;
}

@@ -501,11 +501,11 @@ std::string webedit::Database::listRevisions(const std::string &docId) {

    for (int i = 0; i < rows; ++i) {
        json_object *obj = json_object_new_object();
        json_object_object_add(obj, "id", json_object_new_string(res[i][0]));
        json_object_object_add(obj, "revision", json_object_new_int(std::stoi(std::string(res[i][1]))));
        json_object_object_add(obj, "name", json_object_new_string(res[i][2]));
        json_object_object_add(obj, "created", json_object_new_string(res[i][3]));
        json_object_object_add(obj, "author", json_object_new_string(res[i][4]));
        json_object_object_add(obj, "id", json_object_new_string(res[i][0].c_str()));
        json_object_object_add(obj, "revision", json_object_new_int(std::stoi(res[i][1])));
        json_object_object_add(obj, "name", json_object_new_string(res[i][2].c_str()));
        json_object_object_add(obj, "created", json_object_new_string(res[i][3].c_str()));
        json_object_object_add(obj, "author", json_object_new_string(res[i][4].c_str()));
        json_object_array_add(arr, obj);
    }

@@ -620,13 +620,13 @@ std::string webedit::Database::listConnections(const std::string &ownerUid) {
    json_object *arr = json_object_new_array();
    for (int i = 0; i < rows; ++i) {
        json_object *obj = json_object_new_object();
        json_object_object_add(obj, "id", json_object_new_string(res[i][0]));
        json_object_object_add(obj, "name", json_object_new_string(res[i][1]));
        json_object_object_add(obj, "group", json_object_new_string(res[i][2]));
        json_object_object_add(obj, "url", json_object_new_string(res[i][3]));
        json_object_object_add(obj, "id", json_object_new_string(res[i][0].c_str()));
        json_object_object_add(obj, "name", json_object_new_string(res[i][1].c_str()));
        json_object_object_add(obj, "group", json_object_new_string(res[i][2].c_str()));
        json_object_object_add(obj, "url", json_object_new_string(res[i][3].c_str()));
        json_object_object_add(obj, "ignore_ssl",
            json_object_new_boolean(std::string(res[i][4]) == "1"));
        json_object_object_add(obj, "created", json_object_new_string(res[i][5]));
            json_object_new_boolean(res[i][4] == "1"));
        json_object_object_add(obj, "created", json_object_new_string(res[i][5].c_str()));
        json_object_array_add(arr, obj);
    }

@@ -653,7 +653,7 @@ bool webedit::Database::getConnection(const std::string &ownerUid,
    name = res[0][0];
    groupName = res[0][1];
    url = res[0][2];
    ignoreSsl = std::string(res[0][3]) == "1";
    ignoreSsl = res[0][3] == "1";
    return true;
}

@@ -710,11 +710,12 @@ std::string webedit::Database::listApiTokens(const std::string &ownerUid) {
    json_object *arr = json_object_new_array();
    for (int i = 0; i < rows; ++i) {
        json_object *obj = json_object_new_object();
        json_object_object_add(obj, "id", json_object_new_string(res[i][0]));
        json_object_object_add(obj, "label", json_object_new_string(res[i][1]));
        json_object_object_add(obj, "created", json_object_new_string(res[i][2]));
        json_object_object_add(obj, "id", json_object_new_string(res[i][0].c_str()));
        json_object_object_add(obj, "label", json_object_new_string(res[i][1].c_str()));
        json_object_object_add(obj, "created", json_object_new_string(res[i][2].c_str()));
        std::string lastUsed = res[i][3];
        json_object_object_add(obj, "last_used",
            res[i][3] ? json_object_new_string(res[i][3]) : nullptr);
            lastUsed.empty() ? nullptr : json_object_new_string(lastUsed.c_str()));
        json_object_array_add(arr, obj);
    }

@@ -884,11 +885,11 @@ std::string webedit::Database::listSurveys(const std::string &domain) {
    json_object *arr = json_object_new_array();
    for (int i = 0; i < rows; ++i) {
        json_object *obj = json_object_new_object();
        json_object_object_add(obj, "id",       json_object_new_string(res[i][0]));
        json_object_object_add(obj, "name",     json_object_new_string(res[i][1]));
        json_object_object_add(obj, "title",    json_object_new_string(res[i][2]));
        json_object_object_add(obj, "created",  json_object_new_string(res[i][3]));
        json_object_object_add(obj, "modified", json_object_new_string(res[i][4]));
        json_object_object_add(obj, "id",       json_object_new_string(res[i][0].c_str()));
        json_object_object_add(obj, "name",     json_object_new_string(res[i][1].c_str()));
        json_object_object_add(obj, "title",    json_object_new_string(res[i][2].c_str()));
        json_object_object_add(obj, "created",  json_object_new_string(res[i][3].c_str()));
        json_object_object_add(obj, "modified", json_object_new_string(res[i][4].c_str()));
        json_object_array_add(arr, obj);
    }

@@ -909,8 +910,8 @@ std::string webedit::Database::listSurveyNames(const std::string &domain) {
    json_object *arr = json_object_new_array();
    for (int i = 0; i < rows; ++i) {
        json_object *obj = json_object_new_object();
        json_object_object_add(obj, "id",   json_object_new_string(res[i][0]));
        json_object_object_add(obj, "name", json_object_new_string(res[i][1]));
        json_object_object_add(obj, "id",   json_object_new_string(res[i][0].c_str()));
        json_object_object_add(obj, "name", json_object_new_string(res[i][1].c_str()));
        json_object_array_add(arr, obj);
    }

@@ -933,12 +934,12 @@ std::string webedit::Database::getSurvey(const std::string &domain, const std::s
    if (rows < 1) return "{}";

    json_object *survey = json_object_new_object();
    json_object_object_add(survey, "id",       json_object_new_string(res[0][0]));
    json_object_object_add(survey, "name",     json_object_new_string(res[0][1]));
    json_object_object_add(survey, "title",    json_object_new_string(res[0][2]));
    json_object_object_add(survey, "xml",      json_object_new_string(res[0][3] ? res[0][3] : ""));
    json_object_object_add(survey, "created",  json_object_new_string(res[0][4]));
    json_object_object_add(survey, "modified", json_object_new_string(res[0][5]));
    json_object_object_add(survey, "id",       json_object_new_string(res[0][0].c_str()));
    json_object_object_add(survey, "name",     json_object_new_string(res[0][1].c_str()));
    json_object_object_add(survey, "title",    json_object_new_string(res[0][2].c_str()));
    json_object_object_add(survey, "xml",      json_object_new_string(res[0][3].c_str()));
    json_object_object_add(survey, "created",  json_object_new_string(res[0][4].c_str()));
    json_object_object_add(survey, "modified", json_object_new_string(res[0][5].c_str()));

    std::string result = json_object_to_json_string_ext(survey, JSON_C_TO_STRING_NOSLASHESCAPE);
    json_object_put(survey);
+47 −40
Changes for plugins/content/content.cpp: 47 added lines, 40 removed lines.
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ namespace blogi {
                }
#elif defined(_LIBCPP_VERSION)
                int y, m, d;
                if (std::sscanf(res[i][1], "%d-%d-%d", &y, &m, &d) != 3) {
                if (std::sscanf(res[i][1].c_str(), "%d-%d-%d", &y, &m, &d) != 3) {
                    std::cerr << "Parsing failed for date: " << res[i][1] << std::endl;
                    continue;
                }
@@ -287,12 +287,14 @@ namespace blogi {
                // Fallback: try as ID for direct ID links
                sql.clear();
                sql << "select content.id,content.title,content.text,users.displayname,content.created,content.author,content.slug from content LEFT JOIN users ON content.author=users.id WHERE content.id='" << dbpp::SQL::escaped(sbuf, decodedSlug.c_str()) <<"' LIMIT 1";
                if(Args->database[tid]->exec(sql,res) >= 1 && res[0][6] && res[0][6][0] != '\0') {
                std::string slug;
                if(Args->database[tid]->exec(sql,res) >= 1) slug = res[0][6];
                if(!slug.empty()) {
                    // Redirect old numeric URL to slug URL
                    libhttppp::HttpResponse resp;
                    resp.setState(HTTP301);
                    resp.setContentType("text/html");
                    std::string loc = Args->config->getsiteurl() + "/" + Args->config->getprefix() + "/content/read/" + res[0][6];
                    std::string loc = Args->config->getsiteurl() + "/" + Args->config->getprefix() + "/content/read/" + slug;
                    resp.setHeaderData("location")->push_back(loc);
                    resp.send(curreq,"",0);
                    return;
@@ -302,8 +304,8 @@ namespace blogi {
            }

            std::string cid = res[0][0];
            std::string contentSlug = res[0][6] ? res[0][6] : "";
            std::string contentTitle = res[0][1] ? res[0][1] : "";
            std::string contentSlug = res[0][6];
            std::string contentTitle = res[0][1];

            // Admin menu with GPO-based edit/delete visibility
            if (Args->auth->isLoggedIn(tid,curreq,sessionid)) {
@@ -323,7 +325,7 @@ namespace blogi {
                        if(Args->database[tid]->exec(asql,ares) >= 1)
                            currentAuthor = ares[0][0];

                        std::string postAuthor = res[0][5] ? res[0][5] : "";
                        std::string postAuthor = res[0][5];

                        for(size_t si = 0; si < Args->config->getAuthSourceCount(); ++si){
                            const AuthSource &src = Args->config->getAuthSource(si);
@@ -379,10 +381,10 @@ namespace blogi {

            // Use RenderPublished for the article wrapper
            json_object *params = json_object_new_object();
            json_object_object_add(params, "title", json_object_new_string(res[0][1] ? res[0][1] : ""));
            json_object_object_add(params, "author", json_object_new_string(res[0][3] ? res[0][3] : ""));
            json_object_object_add(params, "date", json_object_new_string(res[0][4] ? res[0][4] : ""));
            std::string text = res[0][2] ? res[0][2] : "";
            json_object_object_add(params, "title", json_object_new_string(contentTitle.c_str()));
            json_object_object_add(params, "author", json_object_new_string(res[0][3].c_str()));
            json_object_object_add(params, "date", json_object_new_string(res[0][4].c_str()));
            std::string text = res[0][2];
            RenderPublished(tid, text, params, page);
            json_object_put(params);

@@ -400,11 +402,12 @@ namespace blogi {
                if(ccount > 0){
                    for(int ci = 0; ci < ccount; ++ci){
                        std::vector<char> esbuf;
                        std::string commentAuthor = cres[ci][1];
                        cmtdat << "<div class=\"blog_comment\">"
                               << "<span class=\"comment_author\">"
                               << dbpp::SQL::escaped(esbuf, cres[ci][1] ? cres[ci][1] : "?") << "</span>"
                               << " <span class=\"comment_date\">" << (cres[ci][3] ? cres[ci][3] : "") << "</span>"
                               << "<div class=\"comment_text\">" << (cres[ci][2] ? cres[ci][2] : "") << "</div>"
                               << dbpp::SQL::escaped(esbuf, commentAuthor.empty() ? "?" : commentAuthor.c_str()) << "</span>"
                               << " <span class=\"comment_date\">" << cres[ci][3] << "</span>"
                               << "<div class=\"comment_text\">" << cres[ci][2] << "</div>"
                               << "</div>";
                    }
                } else {
@@ -961,7 +964,7 @@ namespace blogi {
                excep[libhttppp::HTTPException::Error] << "Post not found!";
                throw excep;
            }
            std::string postAuthor = pres[0][0] ? pres[0][0] : "";
            std::string postAuthor = pres[0][0];

            // Get current user's author id
            std::string uid;
@@ -1071,7 +1074,7 @@ namespace blogi {
                    throw excep;
                }

                if( atoi(res2[0][0])>0)
                if( atoi(res2[0][0].c_str())>0)
                    continue;

                sql = "DELETE FROM tags WHERE id='"; sql << res[i][1] << "';";
@@ -1112,7 +1115,7 @@ namespace blogi {
                    excep[libhttppp::HTTPException::Error] << "Post not found!";
                    throw excep;
                }
                std::string postAuthor = pres[0][0] ? pres[0][0] : "";
                std::string postAuthor = pres[0][0];

                std::string uid;
                Session sess(*Args->database[tid]);
@@ -1418,8 +1421,9 @@ std::cerr << "DEBUG: authid=" << authid << " currentAuthor=" << currentAuthor <<
                        bool allowed = false;
                        std::string postTitle;
                        if(Args->database[tid]->exec(psql,pres) >= 1){
                            std::string postAuthor = pres[0][0] ? pres[0][0] : "";
                            if(pres[0][1]) postTitle = pres[0][1];
                            std::string postAuthor = pres[0][0];
                            std::string postTitleVal = pres[0][1];
                            if(!postTitleVal.empty()) postTitle = postTitleVal;
                            if(currentAuthor == postAuthor && canDelOwn) allowed = true;
                            else if(canDelOthers) allowed = true;
                        }
@@ -1479,7 +1483,7 @@ std::cerr << "DEBUG: authid=" << authid << " currentAuthor=" << currentAuthor <<
                        std::string postAuthor;
                        if(Args->database[tid]->exec(psql,pres) >= 1){
                            found = true;
                            postAuthor = pres[0][0] ? pres[0][0] : "";
                            postAuthor = pres[0][0];
                            if(currentAuthor == postAuthor && canEditOwn) allowed = true;
                            else if(canEditOthers) allowed = true;
                        }
@@ -1548,21 +1552,21 @@ std::cerr << "DEBUG: authid=" << authid << " currentAuthor=" << currentAuthor <<
                        json_object_object_add(jf1, "name", json_object_new_string("blog_title"));
                        json_object_object_add(jf1, "type", json_object_new_string("text"));
                        json_object_object_add(jf1, "label", json_object_new_string(tr(_lang,"Title").c_str()));
                        json_object_object_add(jf1, "value", json_object_new_string(pres[0][1] ? pres[0][1] : ""));
                        json_object_object_add(jf1, "value", json_object_new_string(pres[0][1].c_str()));
                        json_object_array_add(jfields, jf1);

                        json_object *jf2 = json_object_new_object();
                        json_object_object_add(jf2, "name", json_object_new_string("blog_description"));
                        json_object_object_add(jf2, "type", json_object_new_string("text"));
                        json_object_object_add(jf2, "label", json_object_new_string(tr(_lang,"Short description").c_str()));
                        json_object_object_add(jf2, "value", json_object_new_string(pres[0][2] ? pres[0][2] : ""));
                        json_object_object_add(jf2, "value", json_object_new_string(pres[0][2].c_str()));
                        json_object_array_add(jfields, jf2);

                        json_object *jf3 = json_object_new_object();
                        json_object_object_add(jf3, "name", json_object_new_string("blog_content"));
                        json_object_object_add(jf3, "type", json_object_new_string("textarea"));
                        json_object_object_add(jf3, "label", json_object_new_string(tr(_lang,"Text").c_str()));
                        json_object_object_add(jf3, "value", json_object_new_string(pres[0][3] ? pres[0][3] : ""));
                        json_object_object_add(jf3, "value", json_object_new_string(pres[0][3].c_str()));
                        json_object_array_add(jfields, jf3);

                        json_object_object_add(jform, "fields", jfields);
@@ -1681,15 +1685,17 @@ std::cerr << "DEBUG: authid=" << authid << " currentAuthor=" << currentAuthor <<
                    for(int i = 0; i < ccount; ++i){
                        json_object *jrow = json_object_new_object();
                        json_object *jcells = json_object_new_array();
                        json_object_array_add(jcells, json_object_new_string(cres[i][0] ? cres[i][0] : ""));
                        json_object_array_add(jcells, json_object_new_string(cres[i][1] ? cres[i][1] : ""));
                        json_object_array_add(jcells, json_object_new_string(cres[i][2] ? cres[i][2] : ""));
                        json_object_array_add(jcells, json_object_new_string(cres[i][3] ? cres[i][3] : ""));
                        json_object_array_add(jcells, json_object_new_string(cres[i][4] ? cres[i][4] : ""));
                        json_object_array_add(jcells, json_object_new_string(cres[i][5] ? cres[i][5] : ""));

                        bool isApproved = cres[i][6] && (std::string(cres[i][6]) == "t" || std::string(cres[i][6]) == "true" || std::string(cres[i][6]) == "1");
                        bool isVerified = cres[i][7] && (std::string(cres[i][7]) == "t" || std::string(cres[i][7]) == "true" || std::string(cres[i][7]) == "1");
                        json_object_array_add(jcells, json_object_new_string(cres[i][0].c_str()));
                        json_object_array_add(jcells, json_object_new_string(cres[i][1].c_str()));
                        json_object_array_add(jcells, json_object_new_string(cres[i][2].c_str()));
                        json_object_array_add(jcells, json_object_new_string(cres[i][3].c_str()));
                        json_object_array_add(jcells, json_object_new_string(cres[i][4].c_str()));
                        json_object_array_add(jcells, json_object_new_string(cres[i][5].c_str()));

                        std::string approvedVal = cres[i][6];
                        std::string verifiedVal = cres[i][7];
                        bool isApproved = !approvedVal.empty() && (approvedVal == "t" || approvedVal == "true" || approvedVal == "1");
                        bool isVerified = !verifiedVal.empty() && (verifiedVal == "t" || verifiedVal == "true" || verifiedVal == "1");
                        std::string status;
                        if(isApproved)
                            status = tr(_lang,"Approved");
@@ -1750,13 +1756,13 @@ std::cerr << "DEBUG: authid=" << authid << " currentAuthor=" << currentAuthor <<
            for(int i = 0; i < ncount; ++i){
                json_object *jrow = json_object_new_object();
                json_object *jcells = json_object_new_array();
                json_object_array_add(jcells, json_object_new_string(res[i][0] ? res[i][0] : ""));
                json_object_array_add(jcells, json_object_new_string(res[i][1] ? res[i][1] : ""));
                json_object_array_add(jcells, json_object_new_string(res[i][2] ? res[i][2] : ""));
                json_object_array_add(jcells, json_object_new_string(res[i][3] ? res[i][3] : ""));
                json_object_array_add(jcells, json_object_new_string(res[i][0].c_str()));
                json_object_array_add(jcells, json_object_new_string(res[i][1].c_str()));
                json_object_array_add(jcells, json_object_new_string(res[i][2].c_str()));
                json_object_array_add(jcells, json_object_new_string(res[i][3].c_str()));
                json_object_object_add(jrow, "cells", jcells);

                std::string postAuthor = res[i][4] ? res[i][4] : "";
                std::string postAuthor = res[i][4];
                bool isOwn = (!currentAuthor.empty() && currentAuthor == postAuthor);

                json_object *jactions = json_object_new_array();
@@ -1765,7 +1771,7 @@ std::cerr << "DEBUG: authid=" << authid << " currentAuthor=" << currentAuthor <<
                    json_object *jedit = json_object_new_object();
                    json_object_object_add(jedit, "label", json_object_new_string(tr(_lang,"Edit").c_str()));
                    json_object_object_add(jedit, "url", json_object_new_string(
                        (Args->config->buildurl("editor?content_id=") + std::string(res[i][0]) + "&content_title=" + std::string(res[i][1] ? res[i][1] : "")).c_str()));
                        (Args->config->buildurl("editor?content_id=") + std::string(res[i][0]) + "&content_title=" + std::string(res[i][1])).c_str()));
                    json_object_array_add(jactions, jedit);
                }

@@ -1887,7 +1893,7 @@ std::cerr << "DEBUG: authid=" << authid << " currentAuthor=" << currentAuthor <<
                int migCount = Args->database[0]->exec(sql, res);
                std::vector<char> mbuf;
                for (int i = 0; i < migCount; ++i) {
                    std::string s = makeSlug(res[i][1]);
                    std::string s = makeSlug(res[i][1].c_str());
                    dbpp::SQL usql;
                    dbpp::DBResult ures;
                    usql << "UPDATE content SET slug='" << dbpp::SQL::escaped(mbuf, s.c_str())
@@ -1968,7 +1974,8 @@ std::cerr << "DEBUG: authid=" << authid << " currentAuthor=" << currentAuthor <<
                SearchRet::Data data;
                data.title=res[i][0];

                std::copy(res[i][1],res[i][1]+strlen(res[i][1]),std::back_inserter(data.text));
                std::string rowText = res[i][1];
                std::copy(rowText.begin(),rowText.end(),std::back_inserter(data.text));

                std::string surl=Args->config->buildurl("content/read/");

@@ -2132,7 +2139,7 @@ std::cerr << "DEBUG: authid=" << authid << " currentAuthor=" << currentAuthor <<
                    json_object_object_add(response, "status", json_object_new_string("duplicate"));
                    json_object_object_add(response, "message",
                        json_object_new_string(tr(_lang,"A post with this title already exists. Overwrite?").c_str()));
                    json_object_object_add(response, "existing_id", json_object_new_string(res[0][0]));
                    json_object_object_add(response, "existing_id", json_object_new_string(res[0][0].c_str()));
                    return;
                } else if (dupCount > 0 && overwrite) {
                    // Overwrite existing post
+14 −14

File changed.

Preview size limit exceeded, changes collapsed.

+8 −8
Changes for plugins/google/google.cpp: 8 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -196,9 +196,9 @@ namespace blogi {

            for(int i = 0; i < ncount; ++i) {
                std::string author = res[i][0];
                int rating = atoi(res[i][1]);
                std::string text = res[i][2] ? res[i][2] : "";
                bool approved = res[i][3] && atoi(res[i][3]) == 1;
                int rating = atoi(res[i][1].c_str());
                std::string text = res[i][2];
                bool approved = atoi(res[i][3].c_str()) == 1;

                // Hidden sentinel so the form handler knows which reviews were on screen
                json_object *jhidden = json_object_new_object();
@@ -260,11 +260,11 @@ namespace blogi {
                json_object *list = json_object_new_array();
                for(int i = 0; i < ncount; ++i) {
                    json_object *rev = json_object_new_object();
                    json_object_object_add(rev, "author_name", json_object_new_string(res[i][0]));
                    json_object_object_add(rev, "rating", json_object_new_int(atoi(res[i][1])));
                    json_object_object_add(rev, "text", json_object_new_string(res[i][2] ? res[i][2] : ""));
                    json_object_object_add(rev, "time", json_object_new_string(res[i][3] ? res[i][3] : ""));
                    json_object_object_add(rev, "author_photo_url", json_object_new_string(res[i][4] ? res[i][4] : ""));
                    json_object_object_add(rev, "author_name", json_object_new_string(res[i][0].c_str()));
                    json_object_object_add(rev, "rating", json_object_new_int(atoi(res[i][1].c_str())));
                    json_object_object_add(rev, "text", json_object_new_string(res[i][2].c_str()));
                    json_object_object_add(rev, "time", json_object_new_string(res[i][3].c_str()));
                    json_object_object_add(rev, "author_photo_url", json_object_new_string(res[i][4].c_str()));
                    json_object_array_add(list, rev);
                }
                const char* output = json_object_to_json_string(list);
Loading