Beispiel #1
0
function post_articles()
{
    valid_authorization();
    // get json object from request body
    $data = json_decode(urldecode(Flight::request()->getBody()));
    if ($data == null) {
        Flight::halt(403, 'Article not well formed.');
    }
    // indicate error
    if (!all_in_array(Flight::get('articleAttrAccepted'), array_keys(get_object_vars($data)))) {
        Flight::halt(403, 'Article not well formed.');
    }
    // ensure good associative array for insertion into database
    $newArticle = [];
    $attrAccepted = Flight::get('articleAttrAccepted');
    foreach ($data as $attr => $val) {
        if (in_array($attr, $attrAccepted)) {
            if ($attr == 'tags') {
                $val = implode(' ', $val);
            }
            $newArticle[$attr] = $val;
        }
    }
    // insert article
    $articleId = Flight::get('db')->insert(Flight::get('dbtables')['article'], $newArticle);
    // indicate error
    if ($articleId == 0) {
        Flight::halt(403, 'Article cannot be added.');
    }
    $newArticle['id'] = $articleId;
    Flight::halt(201, json_encode((object) $newArticle));
}
Beispiel #2
0
            $list[$i1][3][$i2] = $fullfn;
         }
         else {
            echo "WARNING: could not determine real file name for plugin '$fn'<br>\n";
         }
      }
   }
}
*/
#---------------------------------------------------------------------------
#-- inject values (into $list[]) imported from earlier loaded ewiki.ini
if ($ini) {
    foreach ($list as $fid => $row) {
        #-- enable feature, if all requ/mentioned plugins were loaded in .ini
        if ($row[0] === 0 || $row[0] === 1) {
            $is = all_in_array($row[3], $ini["plugins"]["load"]);
            $list[$fid][0] = $is ? 1 : 0;
        }
        #-- set feature options
        if ($row[4]) {
            foreach ($row[4] as $oid => $opts) {
                $name = $opts[2];
                $val = $ini["settings"][$name][0];
                if (strlen($val)) {
                    $list[$fid][4][$oid][3] = $val;
                }
            }
        }
    }
}
#-- compare two arrays, all elements of first must be in second