Ejemplo n.º 1
0
 public function generateProfile($name, $owner_id = 0)
 {
     $bean = new APIProfileBean();
     $bean->name = $name;
     $bean->owner_id = $owner_id;
     $bean->set('created', 'NOW()', true);
     $oprivkey = openssl_pkey_new(array('private_key_bits' => 512, 'private_key_type' => OPENSSL_KEYTYPE_RSA));
     openssl_pkey_export($oprivkey, $out);
     $bean->priv_pem = $out;
     try {
         $bean->insert();
     } catch (QueryFailedException $e) {
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
<form method="POST" action="<?php 
    echo dirname($_SERVER['REQUEST_URI']) . '/' . basename($_SERVER['PHP_SELF']);
    ?>
">
<label for="profilename">API Profile Name:</label> 
<input type="text" id="profilename" name="pname" /><br />
<input type="submit" name="submitCreate" value="Create" /> <input type="submit" name="submitEdit" value="Edit" />
</form>
<?php 
} else {
    if (isset($_POST['submitCreate']) || isset($_POST['submitEdit']) || isset($_POST['submitChanges'])) {
        if (!isset($_POST['pname'])) {
            endPage('Stop hacking.');
        }
        $apm = APIProfileModel::getInstance();
        $fields = APIProfileBean::getFields();
        if (isset($_POST['submitCreate']) && !$apm->generateProfile($_POST['pname'])) {
            endPage('Error creating profile.  Does that name already exist?');
        }
        if (isset($_POST['submitChanges'])) {
            if (!isset($_POST['pname'])) {
                endPage('Stop hacking.');
            }
            $apip = $apm->getByName($_POST['pname']);
            foreach ($fields as $field) {
                if ($field == 'allowed_app_fields' && isset($_POST[$field])) {
                    $apip->{$field} = explode(' ', $_POST[$field]);
                } else {
                    if ($field == 'active' || substr($field, 0, 5) == 'perm_') {
                        if (isset($_POST[$field]) && $_POST[$field] == 1) {
                            $apip->{$field} = 1;