Example #1
0
 public function setImage($img)
 {
     $objPicture = $this->getForeignObject('picture');
     $objAlbum = $objPicture->getForeignObject('album');
     $mime_type = $objAlbum->get('mime');
     if (!$mime_type || $mime_type == '') {
         $mime_type = DEFAULT_MIME;
     }
     $objImageData = new clsDB('imagedata');
     $objImageData->set('data', base64_encode(imgToString($img, $mime_type)), false);
     $objImageData->set('mime', $mime_type);
     $objImageData->save();
     $this->set('imagedata_id', $objImageData->get('id'));
     return 0;
 }
Example #2
0
 public function setImage($img)
 {
     $objAlbum = $this->getForeignObject('album');
     $mime_type = $objAlbum->get('mime');
     if (!$mime_type || $mime_type == '') {
         $mime_type = DEFAULT_MIME;
     }
     ob_start();
     /* Start output buffering (so we can caption the file). */
     switch ($mime_type) {
         case 'image/jpeg':
             if (!imagejpeg($img, NULL, 100)) {
                 return "image_nosave";
             }
             break;
         case 'image/png':
             if (!imagepng($img)) {
                 return "image_nosave";
             }
             break;
         case 'image/gif':
             if (!imagegif($img)) {
                 return "image_nosave";
             }
             break;
         default:
             return 'image_filetype';
     }
     $objImageData = new clsDB('imagedata');
     $objImageData->set('data', base64_encode(ob_get_clean()));
     $objImageData->set('mime', $mime_type);
     $objImageData->save();
     $this->set('imagedata_id', $objImageData->get('id'));
     return 0;
 }
Example #3
0
 /** This gets a little tricky... */
 public static function getPolicyFromRequest($strName, $objUser)
 {
     /* Create the object that'll be able to read the request. */
     $objPolicy = new clsDB($strName);
     /* Load the fields from the request. */
     $objPolicy->getFromRequest(array('id', 'allow_post_picture', 'allow_post_comment', 'allow_rate', 'allow_view', 'allow_delete_picture', 'allow_create_subalbum'));
     /* Set the name so we can access the database. */
     $objPolicy->setName('albumpolicy');
     /* Load it (to get the user_id). */
     $objPolicy->load();
     /* Check the user_id to see if we have any issues. */
     if (!$objUser->get('is_admin') && $objPolicy->get('user_id') != $objUser->get('id')) {
         throw new Exception('exception_accessdenied');
     }
     /* Set the name back so we can read the request again. */
     $objPolicy->setName($strName);
     /* Read the user's input from the request. */
     $objPolicy->getFromRequest(array('id', 'allow_post_picture', 'allow_post_comment', 'allow_rate', 'allow_view', 'allow_delete_picture', 'allow_create_subalbum'));
     /* Set the name back to what it ought to be (so we can save it). */
     $objPolicy->setName('albumpolicy');
     /* And that it! */
     return $objPolicy;
 }
Example #4
0
        }
    }
}
if ($strSubAction == 'settings_save') {
    $objSetting = new clsDB('setting');
    $objSetting->getFromRequest(array('id', 'value'));
    $objSetting->save();
    $strSubAction = 'settings';
}
if ($strSubAction == 'settings') {
    $arrSettings = clsDB::getListStatic('setting');
    print "<table>";
    print "<tr>";
    print "<td>Name</td><td>Value</td><td>Comments</td><td>Save</td>";
    print "</tr>";
    foreach ($arrSettings as $objSetting) {
        print "<form action='index.php' method='get'>";
        print $objSetting->getHiddenField('id');
        print "<input type='hidden' name='action'    value='admin'>";
        print "<input type='hidden' name='subaction' value='settings_save'>";
        print "<tr>";
        print "<td>" . $objSetting->get('name') . "</td>";
        print "<td>" . $objSetting->getTextField('value') . "</td>";
        print "<td>" . $objSetting->get('comment') . "</td>";
        print "<td>" . $objSetting->getSubmit('Save') . "</td>";
        print "</tr>";
        print "</form>";
        print "<tr><td>&nbsp;</td></tr>";
    }
    print "</table>";
}