Example #1
0
     print $objAdmin->getSubmit('Go');
     print "</form>";
 } else {
     if ($strSubAction == 'import3') {
         $objBreadcrumbs->add('Import', 'index.php?action=admin&subaction=import');
         $objAdmin->getFromRequest();
         require_once $objAdmin->get('path') . "/configuration.php";
         $conDB = mysql_connect($db_host, $db_read_user, $db_read_pass);
         if (!mysql_select_db($db_name, $conDB)) {
             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');