コード例 #1
0
ファイル: vb3.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_points_gifts_and_charges($db, $table_prefix, $file_base)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'reputation');
     foreach ($rows as $row) {
         if (import_check_if_imported('points', strval($row['reputationid']))) {
             continue;
         }
         $time = $row['dateline'];
         $amount = $row['reputation'];
         $viewer_member = import_id_remap_get('member', strval($row['whoadded']), true);
         $member = import_id_remap_get('member', strval($row['userid']), true);
         $reason = $row['reason'];
         $anonymous = 0;
         $GLOBALS['SITE_DB']->query_insert('gifts', array('date_and_time' => $time, 'amount' => $amount, 'gift_from' => $viewer_member, 'gift_to' => $member, 'reason' => insert_lang_comcode($reason, 4), 'anonymous' => $anonymous));
         import_id_remap_put('points', strval($row['reputationid']), -1);
     }
 }
コード例 #2
0
ファイル: wowbb.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'calendar');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['event_id']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['user_id']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         if ($row['event_recurrence'] == 1) {
             $bits = explode('|', $row['event_recurrence_settings']);
             // $num_units, $every, $days_of_week (e.g. 1,2,5 (sunday is 0)), $which_week, $recurrence_ends
             if ($bits[3] == 'd' || $bits[3] == 'l') {
                 $bits[3] = '1';
             }
             $recurrence_part = str_repeat('0', intval($bits[3]) - 1) . '1';
             switch ($bits[1]) {
                 case 'd':
                     $recurrence = 'daily';
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
                 case 'w':
                     if ($bits[2] == '') {
                         $recurrence = 'weekly';
                     } else {
                         $days = explode(',', $bits[2]);
                         $string = '0000000';
                         foreach ($days as $day) {
                             $string[$day] = '1';
                         }
                         $recurrence = 'weekly';
                         $recurrence_part = str_repeat('0000000', intval($bits[3]) - 1) . $string;
                     }
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * 7 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
                 case 'm':
                     $recurrence = 'monthly';
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * 32 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
                 case 'y':
                     $recurrence = 'yearly';
                     if ($bits[4] != '') {
                         $recurrences = (strtotime($bits[4]) - strtotime($row['event_start'])) / (60 * 60 * 24 * 365 * $bits[0] * (is_numeric($bits[3]) ? intval($bits[3]) : 1));
                     }
                     break;
             }
             $string = str_pad('', strlen($recurrence_part) * intval($bits[0]));
             for ($i = 0; $i < strlen($string); $i++) {
                 $string[$i] = $recurrence_part[$i / intval($bits[0])];
             }
             $recurrence .= ' ' . $string;
         }
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['event_start'])));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['event_end'])));
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, intval(floor($recurrences)), 0, $row['event_title'], $row['event_note'], 3, $row['event_public'], $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, $submitter, 0, strtotime($row['event_start']));
         import_id_remap_put('event', strval($row['event_id']), $id_new);
     }
 }
コード例 #3
0
ファイル: smf2.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     $rows = $db->query_select('calendar');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['id_event']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['id_member']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         $days = intval(floor((strtotime($row['end_date']) - strtotime($row['start_date'])) / (60 * 60 * 24)));
         //Max 7 days in SMF
         if ($days == 0) {
             $recurrence = 'none';
         } else {
             $recurrence = 'daily ';
             for ($i = 1; $i <= $days; $i++) {
                 $recurrence .= '1';
             }
         }
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['start_date']))));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['end_date']))));
         $description = '';
         if ($row['id_topic'] != 0) {
             $atts = $db->query('SELECT * FROM ' . $table_prefix . 'attachments WHERE id_msg=' . strval($row['id_topic']) . ' ORDER BY id_msg ASC');
             $attid = isset($atts[0]['id_attach']) ? $atts[0]['id_attach'] : 0;
             $att_imported = $attid > 0 && import_check_if_imported('post_files', strval($attid)) ? true : false;
             $messages = $db->query('SELECT * FROM ' . $table_prefix . 'messages WHERE id_topic=' . strval($row['id_topic']) . ' ORDER BY id_topic ASC');
             $description = isset($messages[0]['body']) && $messages[0]['body'] != '' ? str_replace(array('[html]', '[/html]'), array('', ''), html_to_comcode($messages[0]['body'])) : '';
         }
         if ($att_imported) {
             $attid_new = import_id_remap_get('post_files', strval($attid), true);
             $description .= "\n\n" . '[attachment]' . strval($attid_new) . '[/attachment]';
         }
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $description, 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter);
         if ($att_imported) {
             $GLOBALS['SITE_DB']->query_insert('attachment_refs', array('r_referer_type' => 'calendar', 'r_referer_id' => strval($id_new), 'a_id' => $attid_new));
         }
         import_id_remap_put('event', strval($row['id_event']), $id_new);
     }
     $rows = array();
     $rows = $db->query_select('calendar_holidays');
     foreach ($rows as $row) {
         if (import_check_if_imported('event_holiday', strval($row['id_holiday']))) {
             continue;
         }
         $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         $recurrence = 'none';
         $recurrences = NULL;
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['event_date']))));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['event_date']))));
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $row['title'], 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter);
         import_id_remap_put('event_holiday', strval($row['id_holiday']), $id_new);
     }
 }
コード例 #4
0
ファイル: aef.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_notifications($db, $table_prefix, $file_base)
 {
     require_code('notifications');
     $row_start = 0;
     $rows = array();
     do {
         $rows = $db->query('SELECT * FROM ' . $table_prefix . 'notify_topic', 200, $row_start);
         foreach ($rows as $row) {
             if (import_check_if_imported('topic_notification', strval($row['notify_tid']) . '-' . strval($row['notify_mid']))) {
                 continue;
             }
             $member_id = import_id_remap_get('member', strval($row['notify_mid']), true);
             if (is_null($member_id)) {
                 continue;
             }
             $topic_id = import_id_remap_get('topic', strval($row['notify_tid']), true);
             if (is_null($topic_id)) {
                 continue;
             }
             enable_notifications('ocf_topic', strval($topic_id), $member_id);
             import_id_remap_put('topic_notification', strval($row['notify_tid']) . '-' . strval($row['notify_mid']), 1);
         }
         $row_start += 200;
     } while (count($rows) > 0);
 }
コード例 #5
0
ファイル: ipb1.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_ocf_personal_topics($db, $table_prefix, $old_base_dir)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'messages WHERE vid<>\'sent\' ORDER BY msg_date');
     // Group them up into what will become topics
     $groups = array();
     foreach ($rows as $row) {
         if ($row['from_id'] > $row['recipient_id']) {
             $a = $row['recipient_id'];
             $b = $row['from_id'];
         } else {
             $a = $row['from_id'];
             $b = $row['recipient_id'];
         }
         $title = str_replace('Re: ', '', $row['title']);
         $title = str_replace('RE: ', '', $title);
         $title = str_replace('Re:', '', $title);
         $title = str_replace('RE:', '', $title);
         $groups[strval($a) . ':' . strval($b) . ':' . @html_entity_decode($title, ENT_QUOTES, get_charset())][] = $row;
     }
     // Import topics
     foreach ($groups as $group) {
         $row = $group[0];
         if (import_check_if_imported('pt', strval($row['msg_id']))) {
             continue;
         }
         // Create topic
         $from_id = import_id_remap_get('member', strval($row['from_id']), true);
         if (is_null($from_id)) {
             $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $to_id = import_id_remap_get('member', strval($row['recipient_id']), true);
         if (is_null($to_id)) {
             $to_id = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $topic_id = ocf_make_topic(NULL, '', '', 1, 1, 0, 0, 0, $from_id, $to_id, false);
         $first_post = true;
         foreach ($group as $_postdetails) {
             if ($first_post) {
                 $title = @html_entity_decode($row['title'], ENT_QUOTES, get_charset());
             } else {
                 $title = '';
             }
             $post = $this->clean_ipb_post($_postdetails['message']);
             $validated = 1;
             $from_id = import_id_remap_get('member', strval($_postdetails['from_id']), true);
             if (is_null($from_id)) {
                 $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id();
             }
             $poster_name_if_guest = $GLOBALS['OCF_DRIVER']->get_member_row_field($from_id, 'm_username');
             $ip_address = $GLOBALS['OCF_DRIVER']->get_member_row_field($from_id, 'm_ip_address');
             $time = $_postdetails['msg_date'];
             $poster = $from_id;
             $last_edit_time = NULL;
             $last_edit_by = NULL;
             ocf_make_post($topic_id, $title, $post, 0, $first_post, $validated, 0, $poster_name_if_guest, $ip_address, $time, $poster, NULL, $last_edit_time, $last_edit_by, false, false, NULL, false);
             $first_post = false;
         }
         import_id_remap_put('pt', strval($row['msg_id']), $topic_id);
     }
 }
コード例 #6
0
ファイル: ocp_merge.php プロジェクト: erico-deh/ocPortal
 /**
  * Import custom fields for a particular record.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  ID_TEXT		The content type.
  * @param  ?ID_TEXT		The import type to get remapping from (NULL: no remapping).
  */
 function _import_catalogue_entry_linkage($db, $table_prefix, $content_type, $import_type)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'catalogue_entry_linkage WHERE ' . db_string_equal_to('content_type', $content_type));
     if (is_null($rows)) {
         return;
     }
     foreach ($rows as $row) {
         $catalogue_entry_id = import_id_remap_get('catalogue_entry', strval($row['catalogue_entry_id']), true);
         if (is_null($catalogue_entry_id)) {
             continue;
         }
         $content_id = is_null($import_type) ? $row['content_id'] : import_id_remap_get($import_type, @strval($row['content_id']), true);
         if (is_null($content_id)) {
             continue;
         }
         $row['catalogue_entry_id'] = $catalogue_entry_id;
         $row['content_id'] = $content_id;
         $GLOBALS['SITE_DB']->query_insert('catalogue_entry_linkage', $row);
     }
 }
コード例 #7
0
ファイル: admin_import.php プロジェクト: erico-deh/ocPortal
 /**
  * Special import-esque function to aid switching to OCF after importing forum previously served by a forum driver.
  *
  * @return tempcode	Information about progress
  */
 function ocf_switch()
 {
     $out = new ocp_tempcode();
     $todos = array('USER' => array('member', db_get_first_id(), NULL), 'GROUP' => array('group', NULL, 'group_id'));
     foreach ($todos as $db_abstraction => $definition) {
         list($import_code, $default_id, $field_name_also) = $definition;
         $count = 0;
         $extra = is_null($field_name_also) ? '' : ' OR ' . db_string_equal_to('m_name', $field_name_also);
         $fields = $GLOBALS['SITE_DB']->query('SELECT m_table,m_name FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE (NOT (m_table LIKE \'' . db_encode_like('f_%') . '\')) AND (' . db_string_equal_to('m_type', $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '*' . $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '?' . $db_abstraction) . $extra . ')');
         foreach ($fields as $field) {
             if ($field['m_table'] == 'stats') {
                 continue;
             }
             // Lots of data and it's not important
             //echo '(working) '.$field['m_table'].'/'.$field['m_name'].'<br />';
             $values = $GLOBALS['SITE_DB']->query_select($field['m_table'], array('*'));
             foreach ($values as $value) {
                 $current = $value[$field['m_name']];
                 $remapped = import_id_remap_get($import_code, $current, true);
                 if (is_null($remapped)) {
                     $remapped = $default_id;
                 }
                 if (!is_null($remapped)) {
                     $value2 = $value;
                     $value2[$field['m_name']] = -$remapped;
                     $c = $GLOBALS['SITE_DB']->query_update($field['m_table'], $value2, $value, '', NULL, NULL, true, true);
                     if (is_null($c)) {
                         $GLOBALS['SITE_DB']->query_delete($field['m_table'], $value);
                     } else {
                         $count += $c;
                     }
                 } else {
                     $GLOBALS['SITE_DB']->query_delete($field['m_table'], $value);
                 }
             }
             $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' SET ' . $field['m_name'] . '=-' . $field['m_name'] . ' WHERE ' . $field['m_name'] . '<0');
         }
         $out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_' . $db_abstraction, $count == 0 ? '?' : strval($count))));
     }
     // info.php
     global $FILE_BASE;
     $info_file = (file_exists('use_comp_name') ? array_key_exists('COMPUTERNAME', $_ENV) ? $_ENV['COMPUTERNAME'] : $_SERVER['SERVER_NAME'] : 'info') . '.php';
     $info = @fopen($FILE_BASE . '/' . $info_file, 'wt') or intelligent_write_error($FILE_BASE . '/' . $info_file);
     fwrite($info, "<" . "?php\n");
     global $SITE_INFO;
     $SITE_INFO['forum_type'] = 'ocf';
     $SITE_INFO['ocf_table_prefix'] = $SITE_INFO['table_prefix'];
     $SITE_INFO['db_forums'] = $SITE_INFO['db_site'];
     $SITE_INFO['db_forums_host'] = array_key_exists('db_site_host', $SITE_INFO) ? $SITE_INFO['db_site_host'] : 'localhost';
     $SITE_INFO['db_forums_user'] = $SITE_INFO['db_site_user'];
     $SITE_INFO['db_forums_password'] = $SITE_INFO['db_site_password'];
     $SITE_INFO['board_prefix'] = get_base_url();
     foreach ($SITE_INFO as $key => $val) {
         $_val = str_replace('\\', '\\\\', $val);
         fwrite($info, '$SITE_INFO[\'' . $key . '\']=\'' . $_val . "';\n");
     }
     fwrite($info, "?" . ">\n");
     fclose($info);
     fix_permissions($FILE_BASE . '/' . $info_file);
     sync_file($FILE_BASE . '/' . $info_file);
     $out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_INFO')));
     $LANG = get_site_default_lang();
     $trans5 = insert_lang(do_lang('FORUM'), 1, NULL, false, NULL, $LANG);
     $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => 'forum', 'zone_title' => insert_lang(do_lang('SECTION_FORUMS'), 1), 'zone_default_page' => 'forumview', 'zone_header_text' => $trans5, 'zone_theme' => '-1', 'zone_wide' => NULL, 'zone_require_session' => 0, 'zone_displayed_in_menu' => 1));
     require_code('menus2');
     add_menu_item_simple('zone_menu', NULL, 'SECTION_FORUMS', 'forum' . ':forumview', 0, 1);
     return $out;
 }
コード例 #8
0
ファイル: joomla.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_news_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('news');
     $fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => 'news')));
     $categories = $db->query("SELECT id,title,description,image FROM " . $table_prefix . "sections WHERE title='News'");
     foreach ($categories as $category) {
         $title = $category['title'];
         $cat_id = $GLOBALS['SITE_DB']->query_select('news_categories', array('id'), array('nc_title' => $title), '', 1);
         if (count($cat_id) == 0) {
             $cat_title = $category['title'];
             $category_id = $GLOBALS['SITE_DB']->query("SELECT N.id FROM " . $GLOBALS['SITE_DB']->get_table_prefix() . "translate  AS T INNER JOIN  " . $GLOBALS['SITE_DB']->get_table_prefix() . "news_categories AS N ON T.id=N.nc_title AND " . db_string_equal_to('T.text_original', $cat_title));
             if (count($category_id) == 0) {
                 $desc = html_to_comcode($category['description']);
                 $id = add_news_category($category['title'], $category['image'], $desc, NULL, NULL);
             } else {
                 $id = $category_id[0]['id'];
             }
         } else {
             $id = $cat_id[0]['id'];
         }
         $rows = $db->query('SELECT * FROM ' . $table_prefix . 'content WHERE sectionid=' . strval($category['id']));
         foreach ($rows as $row) {
             $val = $row['title'];
             $news_id = $GLOBALS['SITE_DB']->query("SELECT N.id FROM " . $GLOBALS['SITE_DB']->get_table_prefix() . "translate  AS T INNER JOIN  " . $GLOBALS['SITE_DB']->get_table_prefix() . "news AS N ON T.id=N.title AND " . db_string_equal_to('T.text_original', $val) . " AND news_category=" . strval($id) . " AND news_category<>''");
             if (count($news_id) == 0) {
                 $title = $row['title'];
                 $news = html_to_comcode($row['introtext']);
                 $author = $db->query_value_null_ok('users', 'name', array('id' => $row['created_by']));
                 if (is_null($author)) {
                     $author = do_lang('UNKNOWN');
                 }
                 $access = $row['access'];
                 if ($access == 0) {
                     $validated = 1;
                 } else {
                     $validated = 0;
                 }
                 $allow_rating = 1;
                 $allow_comments = 1;
                 $allow_trackbacks = 1;
                 $notes = '';
                 $news_article = '';
                 $main_news_category = $id;
                 $news_category = NULL;
                 $datetimearr = explode(' ', $row['created']);
                 $datearr = explode('-', $datetimearr[0]);
                 $timearr = explode(':', $datetimearr[1]);
                 $date = intval($datearr[2]);
                 $month = intval($datearr[1]);
                 $year = intval($datearr[0]);
                 $hour = intval($timearr[0]);
                 $min = intval($timearr[1]);
                 $sec = intval($timearr[2]);
                 $time = mktime($hour, $min, $sec, $month, $date, $year);
                 $submitter = import_id_remap_get('member', strval($row['created_by']));
                 $views = $row['hits'];
                 $datetimearr = explode(' ', $row['modified']);
                 $datearr = explode('-', $datetimearr[0]);
                 $timearr = explode(':', $datetimearr[1]);
                 $date = intval($datearr[2]);
                 $month = intval($datearr[1]);
                 $year = intval($datearr[0]);
                 $hour = intval($timearr[0]);
                 $min = intval($timearr[1]);
                 $sec = intval($timearr[2]);
                 $edit_date = mktime($hour, $min, $sec, $month, $date, $year);
                 $nid = NULL;
                 $image = 'newscats/' . preg_replace('#\\..*$#', '', $row['images']);
                 @mkdir(get_custom_file_base() . '/themes/default/images_custom/newscats', 0777);
                 fix_permissions(get_custom_file_base() . '/themes/default/images_custom/newscats', 0777);
                 sync_file(get_custom_file_base() . '/themes/default/images_custom/newscats');
                 $newimagepath = get_custom_file_base() . '/themes/default/images_custom/newscats/' . rawurldecode($row['images']);
                 $oldimagepath = $old_base_dir . "/images/stories/" . rawurldecode($row['images']);
                 @copy($oldimagepath, $newimagepath);
                 fix_permissions($newimagepath);
                 sync_file($newimagepath);
                 add_news($title, $news, $author, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $news_article, $main_news_category, $news_category, $time, $submitter, $views, $edit_date, $nid, $image);
             }
         }
     }
 }
コード例 #9
0
ファイル: mkportal.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  * @return tempcode		Import message
  */
 function import_downloads_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('downloads2');
     require_code('authors');
     //check is the comment forum configured in ocPortal
     $this->test_for_comments_forum();
     $category_id_remap = array();
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'download_sections ORDER BY id');
     ocf_over_msn();
     //used to fixed the correct forum prefix
     $category_id_remap[0] = db_get_first_id();
     ocf_over_local();
     //used to fixed the correct forum prefix
     // Create categories
     $orig_parents = array();
     foreach ($rows as $row) {
         $id = import_id_remap_get('download_category', strval($row['id']), true);
         if (!is_null($id)) {
             $category_id_remap[$row['id']] = $id;
             continue;
         }
         $orig_parents[$row['id']] = array($row['father'], $row['evento'], $row['descrizione']);
         $id = add_download_category(html_entity_decode($row['evento'], ENT_QUOTES, get_charset()), db_get_first_id(), '', '', '');
         $category_id_remap[$row['id']] = $id;
         ocf_over_msn();
         //used to fixed the correct forum prefix
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         ocf_over_local();
         //used to fixed the correct forum prefix
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'downloads', 'category_name' => strval($id), 'group_id' => $group_id));
         }
         import_id_remap_put('download_category', strval($row['id']), $id);
     }
     foreach ($orig_parents as $cid => $bits) {
         list($orig_parent, $category, $description) = $bits;
         if ($orig_parent == 0) {
             ocf_over_msn();
             //used to fixed the correct forum prefix
             $parent_id = db_get_first_id();
             ocf_over_local();
             //used to fixed the correct forum prefix
         } else {
             $parent_id = $category_id_remap[$orig_parent];
         }
         ocf_over_msn();
         //used to fixed the correct forum prefix
         edit_download_category(html_entity_decode($category, ENT_QUOTES, get_charset()), $parent_id, html_to_comcode($description), $category_id_remap[$cid], '', '', '', '');
         ocf_over_local();
         //used to fixed the correct forum prefix
     }
     // Read in downloads
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'download');
     $rows2 = array();
     foreach ($rows as $i => $row) {
         $rows[$i]['validated'] = $row['validate'];
         $rows[$i]['date'] = $row['data'];
         $rows2[$i]['totalvotes'] = $row['rate'];
         $rows2[$i]['hits'] = $row['click'];
         $rows2[$i]['screenshot'] = $row['screen1'];
         $rows2[$i]['screenshot2'] = $row['screen2'];
     }
     // Import downloads
     foreach ($rows as $row) {
         if (import_check_if_imported('download', strval($row['id']))) {
             continue;
         }
         $original_filename = $row['file'];
         $file_parts = explode('.', $row['file']);
         $file_ext = count($file_parts) > 1 ? $file_parts[count($file_parts) - 1] : '';
         $just_filename = strlen($file_ext) > 0 ? preg_replace('#\\.' . $file_ext . '#', '', $row['file']) : $row['file'];
         $mkp_disk_name = 'mk_' . strval($row['id']) . '_' . $just_filename . '.mk';
         $save_filename = $old_base_dir . '/mkportal/modules/downloads/file/' . $mkp_disk_name;
         $copy_destination = get_custom_file_base() . '/uploads/downloads/' . $mkp_disk_name;
         if (@copy($save_filename, $copy_destination) !== false) {
             fix_permissions($copy_destination);
             sync_file($copy_destination);
         }
         $url = 'uploads/downloads/' . $mkp_disk_name;
         $comments_text = $row['demo'] == '' ? '' : do_lang('DEMO_URL') . ': ' . $row['demo'];
         $member = $row['idauth'];
         if (is_null($member)) {
             $member = get_member();
         }
         $row['name'] = @html_entity_decode($row['name'], ENT_QUOTES, get_charset());
         ocf_over_msn();
         //used to fixed the correct forum prefix
         $new_id = add_download($category_id_remap[$row['idcategoria']], $row['name'], $url, html_to_comcode($row['description']), $row['autore'], html_to_comcode($comments_text), NULL, $row['validate'], 1, 1, 1, '', $original_filename, $row['peso'], 0, 0, NULL, $row['data'], $row['downloads'], $row['click'], $member);
         ocf_over_local();
         //used to fixed the correct forum prefix
         import_id_remap_put('download', strval($row['id']), $new_id);
         //get comments forum
         $forum_name = get_option('comments_forum_name');
         ocf_over_msn();
         //used to fixed the correct forum prefix
         $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name);
         ocf_over_local();
         //used to fixed the correct forum prefix
         // Comments
         $comments = $db->query('SELECT * FROM ' . $table_prefix . 'download_comments WHERE identry=' . strval($row['id']) . ' ORDER BY data');
         if (!is_null($forum_id)) {
             foreach ($comments as $comment) {
                 ocf_over_msn();
                 //used to fixed the correct forum prefix
                 $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['autore']);
                 if (is_null($member)) {
                     $member = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                 }
                 ocf_over_local();
                 //used to fixed the correct forum prefix
                 $title = '';
                 $post = $comment['testo'];
                 $content_url = build_url(array('page' => 'downloads', 'id' => $new_id, 'type' => 'view'), get_module_zone('downloads'));
                 ocf_over_msn();
                 //used to fixed the correct forum prefix
                 $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'downloads_' . strval($new_id), $member, $title, html_to_comcode($post), $row['name'], do_lang('COMMENT'), $content_url->evaluate());
                 ocf_over_local();
                 //used to fixed the correct forum prefix
             }
         }
         //check is the 'galleries' addon installed first, before importing the screenshots
         if (addon_installed('galleries')) {
             // Image
             if ($row['screen1'] != '') {
                 $image_url = $row['screen1'];
                 $thumb_url = '';
                 add_image('', 'download_' . strval($new_id), '', $image_url, $thumb_url, $row['validate'], 1, 1, 1, '');
             }
             // Image 2
             if ($row['screen2'] != '') {
                 $image_url = $row['screen2'];
                 $thumb_url = '';
                 add_image('', 'download_' . strval($new_id), '', $image_url, $thumb_url, $row['validate'], 1, 1, 1, '');
             }
         }
         //import download rating too
         $this->_import_ratings($db, 'downloads', $row['id'], $new_id, $row['rate'], $table_prefix);
     }
     $out = do_template('IMPORT_MESSAGE', array('_GUID' => 'ff9131c37b9e4fa2cff991e3479ae867', 'MESSAGE' => do_lang_tempcode('IMPORT_REBUILD_CACHE', do_lang('IMAGE_THUMBNAILS'))));
     return $out;
 }
コード例 #10
0
ファイル: ipb.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_ocf_warnings($db, $table_prefix, $file_base)
 {
     $select = '*';
     if (either_param('importer') == 'ipb2') {
         $select = 'wlog_id AS id,wlog_mid,wlog_notes,wlog_date,wlog_addedby,wlog_contact_content';
     }
     $rows = $db->query('SELECT ' . $select . ' FROM ' . $table_prefix . 'warn_logs');
     foreach ($rows as $row) {
         if (import_check_if_imported('warning', strval($row['id']))) {
             continue;
         }
         $member_id = import_id_remap_get('member', strval($row['wlog_mid']), true);
         if (is_null($member_id)) {
             continue;
         }
         $by = import_id_remap_get('member', strval($row['wlog_addedby']));
         $id_new = ocf_make_warning($member_id, @html_entity_decode($row['wlog_contact_content'], ENT_QUOTES, get_charset()), $by, $row['wlog_date']);
         import_id_remap_put('warning', strval($row['id']), $id_new);
     }
 }
コード例 #11
0
ファイル: smf.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     $rows = $db->query_select('calendar');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['ID_EVENT']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['ID_MEMBER']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         $days = intval(floor((strtotime($row['endDate']) - strtotime($row['startDate'])) / (60 * 60 * 24)));
         //Max 7 days in SMF
         if ($days == 0) {
             $recurrence = 'daily 1';
         } else {
             $recurrence = 'daily ';
             for ($i = 1; $i <= $days; $i++) {
                 $recurrence .= '1';
             }
         }
         $start_hour = 0;
         $start_minute = 0;
         list($start_year, $start_month, $start_day) = array_map('intval', explode('-', $row['eventDate']));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array($start_year, $start_month, $start_day, $start_hour, $start_minute);
         $description = '';
         if ($row['ID_TOPIC'] != 0) {
             $messages = $db->query('SELECT * FROM ' . $table_prefix . 'messages WHERE ID_TOPIC=' . strval($row['ID_TOPIC']) . ' ORDER BY ID_TOPIC ASC');
             ocf_over_msn();
             $description = isset($messages[0]['body']) && $messages[0]['body'] != '' ? html_to_comcode($messages[0]['body']) : '';
             ocf_over_local();
         }
         ocf_over_msn();
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $description, 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter);
         ocf_over_local();
         import_id_remap_put('event', strval($row['ID_EVENT']), $id_new);
     }
     $rows = array();
     $rows = $db->query_select('calendar_holidays');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['ID_HOLIDAY']))) {
             continue;
         }
         $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         $recurrence = 'none';
         $recurrences = NULL;
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['eventDate']))));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['eventDate']))));
         ocf_over_msn();
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $row['title'], 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter);
         ocf_over_local();
         import_id_remap_put('event', strval($row['ID_HOLIDAY']), $id_new);
     }
 }
コード例 #12
0
ファイル: phpbb3.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_reported_posts_forum($db, $table_prefix, $file_base)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'reports');
     foreach ($rows as $row) {
         $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name(get_option('reported_posts_forum'));
         if (is_null($forum_id)) {
             warn_exit(do_lang_tempcode('NO_REPORTED_POST_FORUM'));
         }
         $post_id = import_id_remap_get('post', strval($row['post_id']), true);
         if (is_null($post_id)) {
             continue;
         }
         $user_id = import_id_remap_get('post', strval($row['user_id']), true);
         if (is_null($user_id)) {
             continue;
         }
         $post_info = $GLOBALS['SITE_DB']->query_select('f_posts', array('*'), array('id' => $post_id), '', 1);
         $topic_info = $GLOBALS['SITE_DB']->query_select('f_topics', array('*'), array('id' => $post_info[0]['p_topic_id']), '', 1);
         $post_title = @html_entity_decode($post_info[0]['p_title'], ENT_QUOTES);
         if ($post_title == '') {
             $post_title = $post_title[0]['t_cache_first_title'];
         }
         $poster = $post_info[0]['p_poster_name_if_guest'];
         $member = $GLOBALS['FORUM_DRIVER']->get_username($user_id);
         if (is_null($member)) {
             $member = do_lang('UNKNOWN');
         }
         $title = do_lang('REPORTED_POST_TITLE', $post_title);
         $topic_id = ocf_make_topic($forum_id, $title, '', $row['topic_approved'], $row['report_closed'] == 1 ? 0 : 1, 0, 0, 0, NULL, NULL, false);
         $post = do_template('OCF_REPORTED_POST', array('POST_ID' => strval($post_id), 'MEMBER' => $member, 'TOPIC_NAME' => $topic_info[0]['t_cache_first_title'], 'POST' => $row['report_text'], 'POSTER' => $poster));
         ocf_make_post($topic_id, $title, $post->evaluate(), 0, true, 1, 0, $member, NULL, $row['report_time'], NULL, NULL, NULL, NULL, false, true, NULL, true, $title, 0, NULL, false, $forum_id);
     }
 }
コード例 #13
0
ファイル: mybb.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_calendar($db, $table_prefix, $file_base)
 {
     require_code('calendar2');
     $rows = $db->query_select('events');
     foreach ($rows as $row) {
         if (import_check_if_imported('event', strval($row['eid']))) {
             continue;
         }
         $submitter = import_id_remap_get('member', strval($row['uid']), true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id();
         }
         $recurrence = 'none';
         $recurrences = NULL;
         $event_repeat_data = unserialize($row['repeats']);
         $event_repeats = isset($event_repeat_data['repeats']) && $event_repeat_data['repeats'] != 0 ? $event_repeat_data['repeats'] : 0;
         switch ($event_repeats) {
             case 1:
                 $week_array = array(0, 0, 0, 0, 0, 0, 0);
                 $start_day_num = intval(date('w', $row['starttime']));
                 $every_days = $event_repeat_data['days'];
                 $week_array[$start_day_num] = 1;
                 $next_day = $start_day_num;
                 for ($i = 1; $i < 7; $i++) {
                     $next_day += $every_days;
                     if ($next_day > 6) {
                         $next_day -= 6;
                     }
                     $week_array[$next_day] = 1;
                 }
                 $recurrence = 'daily ' . implode('', $week_array);
                 break;
             case 2:
                 $recurrence = 'daily 1111100';
                 break;
             case 3:
                 $week_array = array(0, 0, 0, 0, 0, 0, 0);
                 $week_array[0] = isset($event_repeat_data['days'][0]) && $event_repeat_data['days'][0] != '' ? 1 : 0;
                 $week_array[1] = isset($event_repeat_data['days'][1]) && $event_repeat_data['days'][1] != '' ? 1 : 0;
                 $week_array[2] = isset($event_repeat_data['days'][2]) && $event_repeat_data['days'][2] != '' ? 1 : 0;
                 $week_array[3] = isset($event_repeat_data['days'][3]) && $event_repeat_data['days'][3] != '' ? 1 : 0;
                 $week_array[4] = isset($event_repeat_data['days'][4]) && $event_repeat_data['days'][4] != '' ? 1 : 0;
                 $week_array[5] = isset($event_repeat_data['days'][5]) && $event_repeat_data['days'][5] != '' ? 1 : 0;
                 $week_array[6] = isset($event_repeat_data['days'][6]) && $event_repeat_data['days'][6] != '' ? 1 : 0;
                 $recurrence = 'daily ' . implode('', $week_array);
                 break;
             case 4:
                 $pattern = '1';
                 $repeat_every_n_years = $event_repeat_data['months'];
                 for ($i = 1; $i < $repeat_every_n_years; $i++) {
                     $pattern .= '0';
                 }
                 $recurrence = 'monthly ' . $pattern;
                 break;
             case 5:
                 $pattern = '1';
                 $repeat_every_n_years = $event_repeat_data['years'];
                 for ($i = 1; $i < $repeat_every_n_years; $i++) {
                     $pattern .= '0';
                 }
                 $recurrence = 'yearly ' . $pattern;
                 break;
         }
         list($start_year, $start_month, $start_day, $start_hour, $start_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['starttime'])));
         list($end_year, $end_month, $end_day, $end_hour, $end_minute) = explode('-', date('Y-m-d-h-i', strtotime($row['endtime'])));
         ocf_over_msn();
         $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['name'], $row['description'], 3, $row['visible'], $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, $submitter, 0, $row['dateline']);
         ocf_over_local();
         import_id_remap_put('event', strval($row['eid']), $id_new);
     }
 }