if ($objAlbum->get('max_width') > MAX_X || $objAlbum->get('max_width') <= 0 || !is_numeric($objAlbum->get('max_width'))) { $blnGood = false; $objTemplate->setText('ERROR', "Width must be a number between 1 and " . MAX_X . ".<br>"); } if ($objAlbum->get('max_height') > MAX_X || $objAlbum->get('max_height') <= 0 || !is_numeric($objAlbum->get('max_height'))) { $blnGood = false; $objTemplate->setText('ERROR', "Height must be a number between 1 and " . MAX_X . ".<br>"); } if (array_search($objAlbum->get('mime'), array('image/jpeg', 'image/png', 'image/gif')) === false) { $blnGood = false; $objTemplate->setText('ERROR', "Mime choices are image/jpeg, image/png, and image/gif.<br>"); } /* Validate fields. */ if ($blnGood) { if ($objAlbum->isNew()) { $objAlbum->set('user_id', $objUser->get('id')); } if (!$objAlbum->exists('simple_permissions')) { $objAlbumGuest = clsAlbum::getPolicyFromRequest('albumpolicy_guest', $objUser); $objAlbumGuest->save(); $objAlbum->set('albumpolicy_guest_id', $objAlbumGuest->get('id')); $objAlbumMember = clsAlbum::getPolicyFromRequest('albumpolicy_member', $objUser); $objAlbumMember->save(); $objAlbum->set('albumpolicy_member_id', $objAlbumMember->get('id')); $objAlbumGroup = clsAlbum::getPolicyFromRequest('albumpolicy_group', $objUser); $objAlbumGroup->save(); $objAlbum->set('albumpolicy_group_id', $objAlbumGroup->get('id')); } else { $objAlbumGuest = clsAlbum::getPolicyFromRequest('albumpolicy_guest', $objUser); $objAlbumMember = clsAlbum::getPolicyFromRequest('albumpolicy_member', $objUser); $objAlbumGroup = clsAlbum::getPolicyFromRequest('albumpolicy_group', $objUser);
print "Error: couldn't connect to the ospap database: " . mysql_error($conDB); } else { $result = mysql_query("SELECT * FROM categories"); $arrAlbums = array(); $i = 0; while ($arrResult = mysql_fetch_assoc($result)) { if (!$objAdmin->exists('category' . $arrResult['category_id']) || $objAdmin->get('category' . $arrResult['category_id']) == 0) { print "Skipping '" . $arrResult['name'] . "'<br>"; continue; } $user_id = $objAdmin->get('category' . $arrResult['category_id']); $objOwner = new clsUser($user_id); /* Create the album if we haven't already. */ if (!isset($arrAlbums[$arrResult['category_id']])) { $objAlbum = new clsAlbum(); $objAlbum->set('name', str_replace("<br />", "", html_entity_decode($arrResult['name']))); $objAlbum->set('caption', str_replace("<br />", "", html_entity_decode($arrResult['caption']))); $objAlbum->set('date', date('Y-m-d H:i:s', strtotime($arrResult['date_created']) + $i++), false); /* Adding '$i' here is a bit of a kludge, but it keeps dates sortable (since ospap1 didn't keep track of times). */ $objAlbum->set('user_id', $user_id); $objAlbum->set('mime', 'image/jpeg'); $objAlbum->set('max_width', '640'); $objAlbum->set('max_height', '480'); $objAlbum->setDefaultPolicies($objOwner); $objAlbum->save(); $arrAlbums[$arrResult['category_id']] = $objAlbum; } $objAlbum = $arrAlbums[$arrResult['category_id']]; print "Importing from '" . $objAlbum->get('name') . "'<br>"; $i = 0; $pictureResult = mysql_query("SELECT * FROM pictures WHERE category_id = '" . $arrResult['category_id'] . "' ");