function add_dir($base, $subdir = "") { global $page; if (!is_dir($base)) { print "Error: {$base} is not a directory\n"; return; } print "Adding {$subdir}\n"; $dir = opendir("{$base}/{$subdir}"); while ($filename = readdir($dir)) { $fullpath = "{$base}/{$subdir}/{$filename}"; if (is_link($fullpath)) { // ignore } else { if (is_dir($fullpath)) { if ($filename[0] != ".") { add_dir($base, "{$subdir}/{$filename}"); } } else { $tmpfile = $fullpath; $tags = $subdir; $tags = str_replace("/", " ", $tags); $tags = str_replace("__", " ", $tags); print "{$subdir}/{$filename} (" . str_replace(" ", ",", $tags) . ")... "; $error = add_image($tmpfile, $filename, $tags); if (is_null($error)) { print "ok\n"; } else { print "failed: {$error}\n"; } } } } closedir($dir); }
function setUp() { parent::setUp(); require_code('galleries'); require_code('galleries2'); $this->glry_id = add_image('', '', '', 'http://www.msn.com', 'images/test.jpg', 0, 0, 0, 0, '', NULL, NULL, NULL, 0, NULL); $this->assertTrue('http://www.msn.com' == $GLOBALS['SITE_DB']->query_value('images', 'url', array('id' => $this->glry_id))); }
include 'product_add.php'; break; case 'ADD PRODUCT': $category_id = filter_input(INPUT_POST, 'category_id', FILTER_SANITIZE_NUMBER_INT); $category_id = filter_var($category_id, FILTER_VALIDATE_INT); $product_name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING); $product_price = filter_input(INPUT_POST, 'price', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $product_price = filter_var($product_price, FILTER_VALIDATE_FLOAT); $product_description = filter_input(INPUT_POST, 'description', FILTER_SANITIZE_STRING); if ($category_id == NULL || $category_id == FALSE || $product_name == NULL || $product_price == NULL || $product_price == FALSE) { $message = "Invalid product data. Check all fields and try again."; $categories = get_categories(); include 'product_add.php'; } else { $product_id = add_product($product_name, $product_price, $product_description, $category_id); add_image($product_id); header("Location: .?action=grid_products"); } break; case 'edit_product_form': $categories = get_categories(); $product_id = filter_input(INPUT_GET, 'product_id', FILTER_SANITIZE_NUMBER_INT); $product_id = filter_var($product_id, FILTER_VALIDATE_INT); $product = get_product($product_id); include 'product_edit.php'; break; case 'UPDATE': $product_id = filter_input(INPUT_POST, 'product_id', FILTER_SANITIZE_NUMBER_INT); $product_id = filter_var($product_id, FILTER_VALIDATE_INT); $category_id = filter_input(INPUT_POST, 'category_id', FILTER_SANITIZE_NUMBER_INT); $category_id = filter_var($category_id, FILTER_VALIDATE_INT);
$cmd = isset($_POST["cmd"]) ? $_POST["cmd"] : ""; if (DEBUG) { $fd = fopen("debug.txt", "a"); fwrite($fd, print_r($_POST, true)); fwrite($fd, print_r($_FILES, true)); fwrite($fd, print_r($debug_msgs, true)); fclose($fd); } $response = new response(); switch ($cmd) { case "login": login($_POST["uname"], $_POST["password"]); break; case "fetch-albums": list_albums(); break; case "fetch-album-images": list_images($_POST["set_albumName"]); break; case "add-item": add_image($_POST["set_albumName"], $_FILES["userfile"]["name"], $_POST["caption"]); break; case "new-album": // there is a title field as well, but since plogger doesn't use it, we drop it gr_add_album($_POST["set_albumName"], $_POST["newAlbumTitle"], $_POST["newAlbumDesc"]); break; default: $response->set_key("status", GR_STAT_UNKNOWN_CMD); $response->set_key("status_text", "Unknown command."); } $response->write();
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); $title = from($_REQUEST, 'title'); $image = from($_REQUEST, 'image'); $tag = from($_REQUEST, 'tag'); $url = from($_REQUEST, 'url'); $content = from($_REQUEST, 'content'); $description = from($_REQUEST, 'description'); $user = $_SESSION[config("site.url")]['user']; $draft = from($_REQUEST, 'draft'); $category = from($_REQUEST, 'category'); if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) { if (!empty($url)) { add_image($title, $tag, $url, $content, $user, $description, $image, $draft, $category); } else { $url = $title; add_image($title, $tag, $url, $content, $user, $description, $image, $draft, $category); } } else { $message['error'] = ''; if (empty($title)) { $message['error'] .= '<li>Title field is required.</li>'; } if (empty($tag)) { $message['error'] .= '<li>Tag field is required.</li>'; } if (empty($content)) { $message['error'] .= '<li>Content field is required.</li>'; } if (empty($image)) { $message['error'] .= '<li>Image field is required.</li>'; }
$relation_data = 0; break; } if (!file_exists("usecode/{$data}.dat")) { make_header("Error: File Not Found"); $tpl->assign("TEXT", "File \"usecode/{$data}.dat\" was not found on the server.<br>Please avoid using direct links to this website unless from a bookmarked page."); $tpl->parse("CONTENT", ".any"); } else { $ucc = add_tip("UCC", "Usecode C"); $bgimg = add_image("bgsm.png", "[BG]", false); $siimg = add_image("sism.png", "[SI]", false); $exultimg = add_image("exultsm.png", "[Exult]", false); $exultbgimg = add_image("exultbgsm.png", "[Exult: BG]", false); $exultsiimg = add_image("exultsism.png", "[Exult: SI]", false); $bgexultimg = add_image("bgexultsm.png", "[BG, Exult]", false); $siexultimg = add_image("siexultsm.png", "[SI, Exult]", false); $true = inline_code("true"); $false = inline_code("false"); $exult = add_link("Exult", "http://exult.sourceforge.net/"); make_header($head); if ($TYPE == 5) { include "usecode/{$proto}.dat"; } include "usecode/{$data}.dat"; if (isset($relation_data) && is_array($relation_data) && count($relation_data) > 0) { $list = array(); foreach ($relation_data as $reldata) { if (array_key_exists($DATAFILE, $reldata)) { $list = $reldata[$DATAFILE]; break; }
save_section($connection); break; case 8: save_youtube($connection); break; case 9: save_image($connection); break; case 10: add_section($connection); break; case 11: add_youtube($connection); break; case 12: add_image($connection); break; default: print '[["ERROR"]["Save had an invalid ID"]]'; } } /* Navigation items */ // Add items function add_section_item($id, $is_sub, $content, $connection) { $nav_type = $is_sub ? "SUB_NAV_ITEM" : "NAV_ITEM"; $insert_or_update_nits_stmt = insert_or_update_nits_stmt($connection); $insert_or_update_nits_stmt->bind_param("siss", $nav_type, $id, $content, $content); catch_execution_error($insert_or_update_nits_stmt->execute(), $connection); } function add_link_item($id, $is_sub, $content, $connection)
</table> </div> <div id="gc_product_photos"> <div class="gc_segment_content"> <iframe src="<?php echo site_url($this->config->item('admin_folder') . '/products/product_image_form'); ?> " style="height:120px; border:0px;"> </iframe> <div id="gc_photos"> <span class="error" style="color: red; display: none"></span> <?php foreach ($images as $photo_id => $photo_obj) { if (!empty($photo_obj)) { $photo = (array) $photo_obj; add_image($photo_id, $photo['filename'], $photo['alt'], $photo['caption'], isset($photo['primary'])); } } ?> </div> </div> </div> </div> </form> <?php function add_image($photo_id, $filename, $alt, $caption, $primary = false) { ob_start(); ?>
function RenderName($name, $x, $y) { global $character_id; global $im; global $font; global $font_size; global $__database; global $guild_info_location; $background = imagecolorallocatealpha($im, 0, 0, 0, 33); $fontcolor = imagecolorallocate($im, 255, 255, 255); $startWidth = $x - calculateWidth($name) / 2; $endWidth = $x + calculateWidth($name) / 2; DrawNameBox($im, $startWidth, $y - 17, $endWidth - 1, $y - 2, $background); ImageTTFText($im, $font_size, 0, $startWidth + 3, $y - 5, $fontcolor, $font, $name); $q = $__database->query("SELECT g.name, g.emblem_bg, g.emblem_bg_color, g.emblem_fg, g.emblem_fg_color FROM guild_members c INNER JOIN guilds g ON g.id = c.guild_id WHERE c.character_id = " . $character_id); if ($q->num_rows == 1) { $res = $q->fetch_array(); $name = $res[0]; $hasemblem = $res[1] != 0 || $res[2] != 0 || $res[3] != 0 || $res[4] != 0 ? true : false; $startWidth = $x - calculateWidth($name) / 2; $endWidth = $x + calculateWidth($name) / 2; DrawNameBox($im, $startWidth, $y, $endWidth - 1, $y + 15, $background); ImageTTFText($im, $font_size, 0, $startWidth + 2, $y + 12, $fontcolor, $font, $name); ImageTTFText($im, $font_size, 0, $startWidth + 3, $y + 12, $fontcolor, $font, $name); // Boldness if ($hasemblem) { if ($res[1] != 0 || $res[2] != 0) { add_image($guild_info_location . '/BackGround/0000' . $res[1] . '/' . $res[2] . '.png', $startWidth - 18, $y + 1); } if ($res[3] != 0 || $res[4] != 0) { $name = ""; $sort = floor($res[3] / 1000); if ($sort == 2) { $name = "Animal"; } elseif ($sort == 3) { $name = "Plant"; } elseif ($sort == 4) { $name = "Pattern"; } elseif ($sort == 5) { $name = "Letter"; } elseif ($sort == 9) { $name = "Etc"; } add_image($guild_info_location . '/Mark/' . $name . '/0000' . $res[3] . '/' . $res[4] . '.png', $startWidth - 17, $y + 2); } } } }
/** * save profile * * @return int */ function saveProfile() { global $app; $user =& JFactory::getUser(); $logUser = new CofiUser($user->id); $this->_headline = JText::_('COFI_PROFILE_SAVED'); // redirect link $redirectLink = JRoute::_("index.php?option=com_discussions&view=profile"); // check if user is logged in - maybe session has timed out if ($user->guest) { // if user is not logged in, kick him back to index page $app->redirect($redirectLink, JText::_('COFI_PROFILE_NOT_SAVED'), "message"); } $db =& $this->getDBO(); // delete Avatar if ($this->_delete_avatar == 1) { del_image($this->_userid, "avatar", JPATH_BASE, $db); } // avatar upload if (isset($_FILES['avatar']) and !$_FILES['avatar']['error']) { add_image($this->_userid, "avatar", JPATH_BASE, $db); } $sql = "UPDATE " . $db->nameQuote('#__discussions_users') . " SET" . " signature = " . $db->Quote($this->_signature) . ", zipcode = " . $db->Quote($this->_zipcode) . ", city = " . $db->Quote($this->_city) . ", country = " . $db->Quote($this->_country) . ", website = " . $db->Quote($this->_website) . ", twitter = " . $db->Quote($this->_twitter) . ", facebook = " . $db->Quote($this->_facebook) . ", flickr = " . $db->Quote($this->_flickr) . ", youtube = " . $db->Quote($this->_youtube) . ", show_online_status = " . $db->Quote($this->_show_online_status) . " WHERE id = '" . $user->id . "'"; $db->setQuery($sql); $db->query(); $app->redirect($redirectLink, JText::_('COFI_PROFILE_HAS_BEEN_SAVED'), "notice"); return 0; // save OK }
/** * 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('downloads'); $category_id_remap = array(); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'downloads_categories ORDER BY cid'); $category_id_remap[0] = db_get_first_id(); $orig_parents = array(); foreach ($rows as $row) { $orig_parents[$row['cid']] = array($row['parentid'], $row['title'], $row['cdescription']); $id = add_download_category('', 0, '', '', ''); $category_id_remap[$row['cid']] = $id; $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); 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)); } } foreach ($orig_parents as $cid => $bits) { list($orig_parent, $category, $description) = $bits; if ($orig_parent == 0) { $parent_id = db_get_first_id(); } else { $parent_id = $category_id_remap[$orig_parent]; } edit_download_category($category, $parent_id, $description, $category_id_remap[$cid], '', '', '', ''); } $rows = $db->query('SELECT * FROM ' . $table_prefix . 'downloads_downloads'); foreach ($rows as $i => $row) { $rows[$i]['validated'] = 1; $rows[$i]['date'] = $this->mysql_time_to_timestamp($row['date']); } $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'downloads_newdownload'); foreach ($rows2 as $i => $row) { $rows2[$i]['validated'] = 0; $rows2[$i]['totalvotes'] = 0; $rows2[$i]['hits'] = 0; $rows2[$i]['date'] = time(); $rows2[$i]['screenshot'] = ''; } $rows = array_merge($rows, $rows2); foreach ($rows as $row) { $url_parts = explode('/', $row['url']); $original_filename = rawurldecode($url_parts[count($url_parts) - 1]); $url = $row['url']; if (url_is_local($url)) { $url = get_custom_base_url() . '/' . $url; } $comments = ''; $comments_rows = $db->query('SELECT editorialtext FROM ' . $table_prefix . 'downloads_editorials WHERE downloadid=' . $row['lid']); if (array_key_exists(0, $comments_rows)) { $comments = $comments_rows[0]['editorialtext']; } $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($row['submitter']); if (is_null($member)) { $member = get_member(); } $new_id = add_download($category_id_remap[$row['cid']], $row['title'], $url, html_to_comcode($row['description']), $row['name'], html_to_comcode($comments), NULL, $row['validated'], 1, 1, 1, '', $original_filename, $row['filesize'], 0, 0, NULL, $row['date'], $row['hits'], $row['hits'], $member); if ($row['totalvotes'] != 0) { $real_rating = $row['downloadratingsummary']; // Same scale as ocPortal :) $GLOBALS['SITE_DB']->query_insert('rating', array('rating_for_type' => 'downloads', 'rating_for_id' => strval($new_id), 'rating_member' => get_member(), 'rating_ip' => '127.0.0.1', 'rating_time' => time(), 'rating' => $real_rating)); } // Homepage->Into author $test = $GLOBALS['SITE_DB']->query_value_null_ok('authors', 'url', array('author' => $row['name'])); if (is_null($test)) { require_code('authors'); add_author($row['name'], $row['homepage'], NULL, '', ''); } else { $GLOBALS['SITE_DB']->query_update('authors', array('url' => $row['homepage']), array('author' => $row['name'])); } // Image if ($row['screenshot'] != '' && addon_installed('galleries')) { $image_url = $row['screenshot']; if (url_is_local($image_url)) { $image_url = get_custom_base_url() . '/' . $image_url; } $thumb_url = ''; add_image('', 'download_' . strval($new_id), '', $image_url, $thumb_url, $row['validated'], 1, 1, 1, ''); } } $out = do_template('IMPORT_MESSAGE', array('_GUID' => 'ff9131c37b9e4fa2cff991e3479ae867', 'MESSAGE' => do_lang_tempcode('IMPORT_REBUILD_CACHE', do_lang('IMAGE_THUMBNAILS')))); return $out; }
function do_work() { $num_wanted = 100000; require_code('config2'); set_option('post_history_days', '0'); // Needed for a little sanity in recent post retrieval set_value('disable_sunk', '1'); // members (remember to test the username autocompleter, and birthdays) // authors (remember to check author autocompleter and popup author list) // lots of people getting notifications on a forum // lots of people getting notifications on a topic require_code('authors'); require_code('ocf_members_action'); require_code('notifications'); for ($i = $GLOBALS['FORUM_DB']->query_value('f_members', 'COUNT(*)'); $i < $num_wanted; $i++) { $member_id = ocf_make_member(uniqid('', true), uniqid('', true), uniqid('', true) . '@example.com', array(), intval(date('d')), intval(date('m')), intval(date('Y')), array(), NULL, NULL, 1, NULL, NULL, '', NULL, '', 0, 0, 1, '', '', '', 1, 1, NULL, 1, 1, '', NULL, '', false); add_author(random_line(), '', $member_id, random_text(), random_text()); enable_notifications('ocf_topic', 'forum:' . strval(db_get_first_id()), $member_id); enable_notifications('ocf_topic', strval(db_get_first_id()), $member_id); // number of friends to a single member $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $member_id, 'member_liked' => db_get_first_id() + 1, 'date_and_time' => time()), false, true); } $member_id = db_get_first_id() + 2; // point earn list / gift points to a single member require_code('points2'); for ($j = $GLOBALS['SITE_DB']->query_value('gifts', 'COUNT(*)'); $j < $num_wanted; $j++) { give_points(10, $member_id, mt_rand(db_get_first_id(), min(100, $num_wanted - 1)), random_line(), false, false); } // number of friends of a single member for ($j = intval(floatval($GLOBALS['SITE_DB']->query_value('chat_buddies', 'COUNT(*)')) / 2.0); $j < $num_wanted; $j++) { $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $member_id, 'member_liked' => $j + db_get_first_id(), 'date_and_time' => time()), false, true); } echo 'done member/authors/points/notifications/friends stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // banners require_code('banners2'); for ($i = $GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)'); $i < $num_wanted; $i++) { add_banner(uniqid('', true), get_logo_url(), random_line(), random_text(), 100, get_base_url(), 3, '', db_get_first_id(), NULL, db_get_first_id() + 1, 1); } echo 'done banner stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // comcode pages require_code('files'); require_code('files2'); for ($i = $GLOBALS['SITE_DB']->query_value('comcode_pages', 'COUNT(*)'); $i < $num_wanted; $i++) { $file = uniqid('', true); /*$path=get_custom_file_base().'/site/pages/comcode_custom/'.fallback_lang().'/'.$file.'.txt'; $myfile=fopen($path,'wt'); fwrite($myfile,random_text()); fclose($myfile); sync_file($path); fix_permissions($path);*/ $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => 'site', 'the_page' => $file, 'p_parent_page' => '', 'p_validated' => 1, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => db_get_first_id(), 'p_show_as_edit' => 0)); } echo 'done comcode stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // zones require_code('zones2'); require_code('abstract_file_manager'); for ($i = $GLOBALS['SITE_DB']->query_value('zones', 'COUNT(*)'); $i < min($num_wanted, 1000); $i++) { actual_add_zone(uniqid('', true), random_line(), 'start', random_line(), 'default', 0, 0, 0); } echo 'done zone stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // calendar events require_code('calendar2'); for ($i = $GLOBALS['SITE_DB']->query_value('calendar_events', 'COUNT(*)'); $i < $num_wanted; $i++) { add_calendar_event(db_get_first_id(), '', NULL, 0, random_line(), random_text(), 1, 1, intval(date('Y')), intval(date('m')), intval(date('d')), 0, 0); } echo 'done event stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // chat rooms require_code('chat2'); require_code('chat'); for ($i = $GLOBALS['SITE_DB']->query_value('chat_rooms', 'COUNT(*)'); $i < $num_wanted; $i++) { $room_id = add_chatroom(random_text(), random_line(), mt_rand(db_get_first_id() + 1, $num_wanted - 1), strval(db_get_first_id() + 1), '', '', '', fallback_lang()); } $room_id = db_get_first_id() + 1; // messages in chat room for ($j = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)'); $j < $num_wanted; $j++) { $_message_parsed = insert_lang_comcode(random_text(), 4); $GLOBALS['SITE_DB']->query_insert('chat_messages', array('system_message' => 0, 'ip_address' => '', 'room_id' => $room_id, 'user_id' => db_get_first_id(), 'date_and_time' => time(), 'the_message' => $_message_parsed, 'text_colour' => get_option('chat_default_post_colour'), 'font_name' => get_option('chat_default_post_font'))); } echo 'done chat stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // download categories under a subcategory require_code('downloads2'); $subcat_id = add_download_category(random_line(), db_get_first_id(), random_text(), ''); for ($i = $GLOBALS['SITE_DB']->query_value('download_categories', 'COUNT(*)'); $i < $num_wanted; $i++) { add_download_category(random_line(), $subcat_id, random_text(), ''); } // downloads (remember to test content by the single author) require_code('downloads2'); require_code('awards'); $time = time(); for ($i = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)'); $i < $num_wanted; $i++) { $content_id = add_download(db_get_first_id(), random_line(), get_logo_url(), random_text(), 'admin', random_text(), NULL, 1, 1, 1, 1, '', uniqid('', true) . '.jpg', 100, 110, 1); give_award(db_get_first_id(), strval($content_id), $time - $i); } $content_id = db_get_first_id(); $content_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $content_id), 'site'); for ($j = $GLOBALS['SITE_DB']->query_value('trackbacks', 'COUNT(*)'); $j < $num_wanted; $j++) { // trackbacks $GLOBALS['SITE_DB']->query_insert('trackbacks', array('trackback_for_type' => 'downloads', 'trackback_for_id' => $content_id, 'trackback_ip' => '', 'trackback_time' => time(), 'trackback_url' => '', 'trackback_title' => random_line(), 'trackback_excerpt' => random_text(), 'trackback_name' => random_line())); // ratings $GLOBALS['SITE_DB']->query_insert('rating', array('rating_for_type' => 'downloads', 'rating_for_id' => $content_id, 'rating_member' => $j + 1, 'rating_ip' => '', 'rating_time' => time(), 'rating' => 3)); // posts in a comment topic $GLOBALS['FORUM_DRIVER']->make_post_forum_topic(get_option('comments_forum_name'), 'downloads_' . strval($content_id), get_member(), random_text(), random_line(), '', do_lang('COMMENT'), $content_url->evaluate(), NULL, NULL, 1, 1); } echo 'done download stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // forums under a forum (don't test it can display, just make sure the main index still works) require_code('ocf_forums_action'); for ($i = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)'); $i < $num_wanted; $i++) { ocf_make_forum(random_line(), random_text(), db_get_first_id(), array(), db_get_first_id() + 3); } // forum topics require_code('ocf_topics_action'); require_code('ocf_posts_action'); require_code('ocf_forums'); require_code('ocf_topics'); for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_topics', 'COUNT(*)')) / 2.0); $i < $num_wanted; $i++) { $topic_id = ocf_make_topic(db_get_first_id(), '', '', NULL, 1, 0, 0, 0, NULL, NULL, false); ocf_make_post($topic_id, random_line(), random_text(), 0, true, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, false); } // forum posts in a topic require_code('ocf_topics_action'); require_code('ocf_posts_action'); $topic_id = ocf_make_topic(db_get_first_id() + 1, '', '', NULL, 1, 0, 0, 0, NULL, NULL, false); for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)')) / 3.0); $i < $num_wanted; $i++) { ocf_make_post($topic_id, random_line(), random_text(), 0, true, 0, 0, NULL, NULL, NULL, mt_rand(db_get_first_id(), $num_wanted - 1), NULL, NULL, NULL, false, false); } echo 'done forum stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // clubs require_code('ocf_groups_action'); require_code('ocf_groups'); for ($i = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $i < $num_wanted; $i++) { ocf_make_group(random_line(), 0, 0, 0, random_line(), '', NULL, NULL, NULL, 5, 0, 70, 50, 100, 100, 30000, 700, 25, 1, 0, 0, 0, $i, 1, 0, 1); } echo 'done club stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // galleries under a subcategory require_code('galleries2'); $xsubcat_id = uniqid('', true); add_gallery($xsubcat_id, random_line(), random_text(), '', '', 'root'); for ($i = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)'); $i < $num_wanted; $i++) { add_gallery(uniqid('', true), random_line(), random_text(), '', '', $xsubcat_id); } // images require_code('galleries2'); for ($i = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)'); $i < $num_wanted; $i++) { add_image('', 'root', random_text(), get_logo_url(), get_logo_url(), 1, 1, 1, 1, ''); } // videos / validation queue require_code('galleries2'); for ($i = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)'); $i < $num_wanted; $i++) { add_video('', 'root', random_text(), get_logo_url(), get_logo_url(), 0, 1, 1, 1, '', 0, 0, 0); } echo 'done galleries stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // newsletter subscribers require_code('newsletter'); for ($i = $GLOBALS['SITE_DB']->query_value('newsletter', 'COUNT(*)'); $i < $num_wanted; $i++) { basic_newsletter_join(uniqid('', true) . '@example.com'); } echo 'done newsletter stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // polls (remember to test poll archive) require_code('polls'); for ($i = $GLOBALS['SITE_DB']->query_value('poll', 'COUNT(*)'); $i < $num_wanted; $i++) { $poll_id = add_poll(random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), 10, 0, 0, 0, 0, ''); } // votes on a poll $poll_id = db_get_first_id(); for ($j = $GLOBALS['SITE_DB']->query_value('poll_votes', 'COUNT(*)'); $j < $num_wanted; $j++) { $cast = mt_rand(1, 6); $ip = uniqid('', true); $GLOBALS['SITE_DB']->query_insert('poll_votes', array('v_poll_id' => $poll_id, 'v_voter_id' => 2, 'v_voter_ip' => $ip, 'v_vote_for' => $cast)); } echo 'done polls stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // quizzes require_code('quiz'); for ($i = $GLOBALS['SITE_DB']->query_value('quizzes', 'COUNT(*)'); $i < $num_wanted; $i++) { add_quiz(random_line(), 0, random_text(), random_text(), random_text(), '', 0, time(), NULL, 3, 300, 'SURVEY', 1, '1) Some question'); } echo 'done quizzes stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // successful searches (to test the search recommender) // ACTUALLY: I have manually verified the code, it is an isolated portion // cedi pages (do a long descendant tree for some, and orphans for others) // cedi posts (remember to test cedi changes screen) require_code('cedi'); for ($i = $GLOBALS['SITE_DB']->query_value('seedy_pages', 'COUNT(*)'); $i < $num_wanted; $i++) { $page_id = cedi_add_page(random_line(), random_text(), '', 1); cedi_add_post($page_id, random_text(), 1, NULL, false); } echo 'done cedi stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // iotds require_code('iotds'); for ($i = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)'); $i < $num_wanted; $i++) { add_iotd(get_logo_url(), random_line(), random_text(), get_logo_url(), 1, 0, 0, 0, ''); } echo 'done iotd stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // logged hack attempts for ($i = $GLOBALS['SITE_DB']->query_value('hackattack', 'COUNT(*)'); $i < $num_wanted; $i++) { $GLOBALS['SITE_DB']->query_insert('hackattack', array('url' => get_base_url(), 'data_post' => '', 'user_agent' => '', 'referer' => '', 'user_os' => '', 'the_user' => db_get_first_id(), 'date_and_time' => time(), 'ip' => uniqid('', true), 'reason' => 'ASCII_ENTITY_URL_HACK', 'reason_param_a' => '', 'reason_param_b' => '')); } // logged hits in one day require_code('site'); for ($i = $GLOBALS['SITE_DB']->query_value('stats', 'COUNT(*)'); $i < $num_wanted; $i++) { log_stats('/testing' . uniqid('', true), mt_rand(100, 2000)); } echo 'done logs stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // blogs and news entries (remember to test both blogs [categories] list, and a list of all news entries) require_code('news'); for ($i = $GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)'); $i < $num_wanted; $i++) { add_news(random_line(), random_text(), 'admin', 1, 1, 1, 1, '', random_text(), NULL, NULL, NULL, db_get_first_id() + $i); } echo 'done news stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // support tickets require_code('tickets'); require_code('tickets2'); for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_topics', 'COUNT(*)')) / 2.0); $i < $num_wanted; $i++) { ticket_add_post(mt_rand(db_get_first_id(), $num_wanted - 1), uniqid('', true), db_get_first_id(), random_line(), random_text(), '', ''); } echo 'done tickets stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // catalogues require_code('catalogues2'); $root_id = db_get_first_id(); for ($i = $GLOBALS['SITE_DB']->query_value('catalogues', 'COUNT(*)'); $i < $num_wanted; $i++) { $catalogue_name = uniqid('', true); $root_id = actual_add_catalogue($catalogue_name, random_line(), random_text(), mt_rand(0, 3), 1, '', 30); } // catalogue categories under a subcategory (remember to test all catalogue views: atoz, index, and root cat) $catalogue_name = 'products'; $subcat_id = actual_add_catalogue_category($catalogue_name, random_line(), random_text(), '', $root_id); for ($j = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)'); $j < $num_wanted; $j++) { actual_add_catalogue_category($catalogue_name, random_line(), random_text(), '', $subcat_id); } echo 'done catalogue stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // items in ecommerce store require_code('catalogues2'); $cat_id = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'MIN(id)', array('c_name' => 'products')); $fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => 'products'))); for ($i = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'COUNT(*)'); $i < $num_wanted; $i++) { $map = array($fields[0] => random_line(), $fields[1] => uniqid('', true), $fields[2] => '1.0', $fields[3] => '1', $fields[4] => '0', $fields[5] => '1', $fields[6] => '0%', $fields[7] => get_logo_url(), $fields[8] => '2.0', $fields[9] => random_text()); $pid = actual_add_catalogue_entry($cat_id, 1, '', 1, 1, 1, $map); unset($map); } // outstanding ecommerce orders $pid = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'MIN(id)', array('c_name' => 'products')); require_code('shopping'); for ($j = $GLOBALS['SITE_DB']->query_value('shopping_cart', 'COUNT(*)'); $j < $num_wanted; $j++) { $product_det = array('product_id' => $pid, 'product_name' => $fields[0], 'product_code' => $fields[1], 'price' => $fields[2], 'tax' => preg_replace('#[^\\d\\.]#', '', $fields[6]), 'description' => $fields[9], 'quantity' => mt_rand(1, 20), 'product_type' => 'catalogue_items', 'product_weight' => $fields[8]); $GLOBALS['SITE_DB']->query_insert('shopping_cart', array('session_id' => mt_rand(0, 1000000), 'ordered_by' => mt_rand(db_get_first_id() + 1, $num_wanted - 1), 'product_id' => $product_det['product_id'], 'product_name' => $product_det['product_name'], 'product_code' => $product_det['product_code'], 'quantity' => $product_det['quantity'], 'price' => round(floatval($product_det['price']), 2), 'price_pre_tax' => $product_det['tax'], 'product_description' => $product_det['description'], 'product_type' => $product_det['product_type'], 'product_weight' => $product_det['product_weight'], 'is_deleted' => 0)); } for ($j = $GLOBALS['SITE_DB']->query_value('shopping_order', 'COUNT(*)'); $j < $num_wanted; $j++) { $order_id = $GLOBALS['SITE_DB']->query_insert('shopping_order', array('c_member' => mt_rand(db_get_first_id() + 1, $num_wanted - 1), 'session_id' => mt_rand(0, 1000000), 'add_date' => time(), 'tot_price' => '123.00', 'order_status' => 'ORDER_STATUS_awaiting_payment', 'notes' => '', 'purchase_through' => 'purchase_module', 'transaction_id' => '', 'tax_opted_out' => 0), true); $GLOBALS['SITE_DB']->query_insert('shopping_order_details', array('p_id' => 123, 'p_name' => random_line(), 'p_code' => 123, 'p_type' => 'catalogue_items', 'p_quantity' => 1, 'p_price' => '12.00', 'order_id' => $order_id, 'dispatch_status' => '', 'included_tax' => '1.00')); } echo 'done store stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } echo '{{DONE}}' . chr(10); }
if ($_REQUEST['config'] == 3) { /* IMAGES ACTIONS */ if (isset($_REQUEST['save'])) { $file = isset($_FILES['image']) && $_FILES['image']['name'] != '' ? $_FILES['image'] : NULL; if (isset($_REQUEST['imageid'])) { /* UPDATE */ $result = update_image($_REQUEST['imageid'], $_REQUEST['name'], $_REQUEST['imagetype'], $file); $msg_ok = S_IMAGE_UPDATED; $msg_fail = S_CANNOT_UPDATE_IMAGE; $audit_action = 'Image [' . $_REQUEST['name'] . '] updated'; } else { /* ADD */ if (!count(get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY))) { access_deny(); } $result = add_image($_REQUEST['name'], $_REQUEST['imagetype'], $file); $msg_ok = S_IMAGE_ADDED; $msg_fail = S_CANNOT_ADD_IMAGE; $audit_action = 'Image [' . $_REQUEST['name'] . '] added'; } show_messages($result, $msg_ok, $msg_fail); if ($result) { add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_IMAGE, $audit_action); unset($_REQUEST['form']); } } else { if (isset($_REQUEST['delete']) && isset($_REQUEST['imageid'])) { /* DELETE */ $image = get_image_by_imageid($_REQUEST['imageid']); $result = delete_image($_REQUEST['imageid']); show_messages($result, S_IMAGE_DELETED, S_CANNOT_DELETE_IMAGE);
/** * Standard aed_module add actualiser. * * @return ID_TEXT The ID of the entry added */ function add_actualisation() { $cat = post_param('cat'); if (can_submit_to_gallery($cat) === false) { access_denied('SUBMIT_HERE'); } make_member_gallery_if_needed($cat); $this->check_images_allowed($cat); $title = post_param('title'); $validated = post_param_integer('validated', 0); $allow_rating = post_param_integer('allow_rating', 0); $allow_comments = post_param_integer('allow_comments', 0); $notes = post_param('notes', ''); $allow_trackbacks = post_param_integer('allow_trackbacks', 0); $this->handle_resizing_and_watermarking(); $urls = get_url('url', 'file', 'uploads/galleries' . (get_value('use_gallery_subdirs') == '1' ? '/' . $cat : ''), 0, OCP_UPLOAD_IMAGE, true, 'thumb_url', 'file2'); if ($urls[0] == '' || $urls[1] == '') { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } if (substr($urls[0], 0, 8) != 'uploads/' && is_null(http_download_file($urls[0], 0, false)) && !is_null($GLOBALS['HTTP_MESSAGE_B'])) { attach_message($GLOBALS['HTTP_MESSAGE_B'], 'warn'); } $comments = post_param('comments'); $this->donext_type = $cat; $id = add_image($title, $cat, $comments, $urls[0], $urls[1], $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes); if ($validated == 1 || !addon_installed('unvalidated')) { if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'galleries') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'galleries', $cat)) { syndicate_described_activity('galleries:ACTIVITY_ADD_IMAGE', $title == '' ? $urls[2] : $title, '', '', '_SEARCH:galleries:image:' . strval($id), '', '', 'galleries'); } } if (has_edit_permission('cat_mid', get_member(), get_member_id_from_gallery_name($cat), 'cms_galleries', array('galleries', $cat)) && post_param_integer('rep_image', 0) == 1) { $GLOBALS['SITE_DB']->query_update('galleries', array('rep_image' => $urls[1]), array('name' => $cat), '', 1); } return strval($id); }
$from = get_custom_file_base() . '/exports/mods/' . $file; $new_file = basename($file, '.tar') . $version_for_name . '.tar'; $to = get_custom_file_base() . "/uploads/downloads/" . $new_file; @unlink($to); copy($from, $to); $addon_path = 'uploads/downloads/' . $new_file; $fsize = filesize($addon_path); $test = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'url', array('url' => $addon_path)); if (is_null($test)) { require_code('tar'); $tar = tar_open($from, 'rb'); $info_file = tar_get_file($tar, 'mod.inf', true); $info = better_parse_ini_file(NULL, $info_file['data']); tar_close($tar); $name = $info['name']; $description = str_replace('\\n', "\n", $info['description']); $author = $info['author']; $url = "data_custom/addon_screenshots/" . preg_replace('#^theme-#', 'theme__', preg_replace('#\\d+$#', '', basename($file, '.tar'))) . ".png"; if (!file_exists(get_custom_file_base() . '/' . $url)) { $url = "data_custom/addon_screenshots/" . strtolower(preg_replace('#^theme-#', 'theme__', preg_replace('#\\d+$#', '', basename($file, '.tar')))) . ".png"; } $downid = add_download($cid, $name, $addon_path, $description, $author, '', NULL, 1, 1, 2, 1, '', $new_file, $fsize, 0, 0, NULL, NULL, 0, 0, $admin); if (file_exists(get_custom_file_base() . '/' . $url)) { add_image('', 'download_' . strval($downid), '', str_replace(' ', '%20', $url), '', 1, 0, 0, 0, '', NULL, NULL, NULL, 0); } } } } closedir($dh); echo "All themes have been imported as downloads"; }
/** * 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_images_and_galleries($db, $table_prefix, $file_base) { require_code('galleries2'); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'galleries', NULL, NULL, true); if (is_null($rows)) { return; } foreach ($rows as $row) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $row['name'])); if (is_null($test)) { add_gallery($row['name'], $this->get_lang_string($db, $row['fullname']), $this->get_lang_string($db, $row['description']), $this->get_lang_string($db, $row['teaser']), $row['notes'], $row['parent_id'], $row['accept_images'], $row['accept_videos'], $row['is_member_synched'], $row['flow_mode_interface'], $row['rep_image'], $row['watermark_top_left'], $row['watermark_top_right'], $row['watermark_bottom_left'], $row['watermark_bottom_right'], $row['allow_rating'], $row['allow_comments'], false, $row['add_date']); } } $this->_import_catalogue_entry_linkage($db, $table_prefix, 'gallery', NULL); $this->_import_review_supplement($db, $table_prefix, 'galleries', NULL); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'images ORDER BY id'); $on_same_msn = $this->on_same_msn($file_base); foreach ($rows as $row) { if (import_check_if_imported('image', strval($row['id']))) { continue; } $submitter = $on_same_msn ? $row['submitter'] : import_id_remap_get('member', $row['submitter'], true); if (is_null($submitter)) { $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id']; $id_new = add_image(array_key_exists('title', $row) ? $row['title'] : '', $row['cat'], $this->get_lang_string($db, $row['comments']), $row['url'], $row['thumb_url'], $row['validated'], $row['allow_rating'], $row['allow_comments'], $row['allow_trackbacks'], $row['notes'], $submitter, $row['add_date'], $row['edit_date'], $row['image_views'], $id); import_id_remap_put('image', strval($row['id']), $id_new); } $this->_import_review_supplement($db, $table_prefix, 'images', 'image'); $this->_import_catalogue_entry_linkage($db, $table_prefix, 'image', NULL); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'videos ORDER BY id'); foreach ($rows as $row) { if (import_check_if_imported('video', strval($row['id']))) { continue; } $submitter = $on_same_msn ? $row['submitter'] : import_id_remap_get('member', $row['submitter'], true); if (is_null($submitter)) { $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id']; $id_new = add_video(array_key_exists('title', $row) ? $row['title'] : '', $row['cat'], $this->get_lang_string($db, $row['comments']), $row['url'], $row['thumb_url'], $row['validated'], $row['allow_rating'], $row['allow_comments'], $row['allow_trackbacks'], $row['notes'], $row['video_length'], $row['video_width'], $row['video_height'], $submitter, $row['add_date'], $row['edit_date'], $row['video_views'], $id); import_id_remap_put('video', strval($row['id']), $id_new); } $this->_import_review_supplement($db, $table_prefix, 'videos', 'video'); $this->_import_catalogue_entry_linkage($db, $table_prefix, 'video', NULL); }
<?php require_once 'common.php'; require_once 'models/add_news.model.php'; $data = array(); $image = $_FILES['articleimage']; $sendnewsletter = $_POST['sendnewsletter']; if ($_POST['title']) { if ($image) { $info = new SplFileInfo($image['name']); $image_id = add_image(array('name' => $image['name'], 'type' => $info->getExtension())); if ($image_id) { $uploads_dir = '../img/news-img/'; $uploadfile = $uploads_dir . basename($image_id) . '.' . $info->getExtension(); move_uploaded_file($image['tmp_name'], $uploadfile); } } $data['date_create'] = date('Y-m-d', time()); $data['image_id'] = $image_id; $article_id = add_article($data); unset($data); $data['article_id'] = $article_id; $data['title'] = $_POST['title']; $data['addedby'] = $_POST['name']; $data['full_text'] = $_POST['article']; $lang_id = ''; $lang = get_lang(); $langradio = $_POST['languages']; foreach ($lang as $lk => $lv) { if ($lv['lang'] == $langradio) { $lang_id = $lv['id'];
if (DEBUG) { $fd = fopen('debug.txt', 'a'); fwrite($fd, print_r($_POST, true)); fwrite($fd, print_r($_FILES, true)); fwrite($fd, print_r($debug_msgs, true)); fclose($fd); } $response = new response(); switch ($cmd) { case 'login': login($_POST['uname'], $_POST['password']); break; case 'fetch-albums': list_albums(); break; case 'fetch-album-images': list_images($_POST['set_albumName']); break; case 'add-item': add_image($_POST['set_albumName'], $_FILES['userfile']['name'], $_POST['caption']); break; case 'new-album': // There is a title field as well, but since Plogger doesn't use it, we drop it gr_add_album($_POST['set_albumName'], $_POST['newAlbumTitle'], $_POST['newAlbumDesc']); break; default: $response->set_key('status', GR_STAT_UNKNOWN_CMD); $response->set_key('status_text', 'Unknown command.'); } $response->write(); close_db();
loginPrompt($_POST[username], $_POST[remember_me], $_SESSION["error"]); } else { /*----- CONTENT ------*/ ?> <div class="row"> <div class="tweleve columns content full-width"> <h1>Image Uploader</h1> <?php $file = str_replace(' ', '_', $_FILES['uploaded_file']['name']); $file = strtolower($file); $target_path = $target_path . $file; if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path)) { echo "<div class=\"center\"><h3>The file " . $file . " has been uploaded</h3>"; echo "<img src=\"" . $target_path . "\" width=\"218px\">\n <h3>You can use this file: " . $target_path . "</h3>\n </div>"; if ($ads != 'ads') { add_image($file); } else { echo '<div class="top-spacer_20"><a href="ad_add.php?target=' . $target_path . '">Add this image to a new ad</a></div>'; } } else { echo "<div class=\"center error\">There was an error uploading the file, please try again!</div>"; } if ($ads == 'ads') { echo "<a href=\"ad_image_uploader.php\">Upload another ad image</a>"; } ?> <p> <a href="cp.php">Control Panel</a> </div> </div> <?php
/** * Add a directory full of images * * @param $base string * @return array */ function add_dir($base) { $results = array(); foreach (list_files($base) as $full_path) { $short_path = str_replace($base, "", $full_path); $filename = basename($full_path); $tags = path_to_tags($short_path); $result = "{$short_path} (" . str_replace(" ", ", ", $tags) . ")... "; try { add_image($full_path, $filename, $tags); $result .= "ok"; } catch (UploadException $ex) { $result .= "failed: " . $ex->getMessage(); } $results[] = $result; } return $results; }
/** * 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_images_and_galleries($db, $table_prefix, $old_base_dir) { require_code('galleries2'); //check is the comment forum configured in ocPortal $this->test_for_comments_forum(); $ocp_path = get_custom_file_base(); //copy watermark image $save_filename = $old_base_dir . 'mkportal/modules/gallery/wt.png'; //NOTE: this is the default watermark image in MKPortal, if customer needs to use another image, he/she needs to overwite it $watermark_image = ''; if (file_exists($save_filename)) { $copy_destination = $ocp_path . '/uploads/watermarks/wt.png'; @copy($save_filename, $copy_destination); fix_permissions($copy_destination); sync_file($copy_destination); $watermark_image = get_custom_base_url() . '/uploads/watermarks/wt.png'; } //now we need to get MKPortal settings for the watermark images $rows = $db->query('SELECT * FROM ' . $table_prefix . 'config WHERE ' . db_string_equal_to('chiave', 'watermark_pos') . ' OR ' . db_string_equal_to('chiave', 'watermark_enable')); $watermark_pos = '2'; //Possible values: 0 - Top-right; 1 - Center; 2 - Bottom-right (default for MKPortal) $watermark_enable = '0'; //by default it is disabled foreach ($rows as $row) { if ($row['chiave'] == 'watermark_pos') { $watermark_pos = $row['valore']; if ($watermark_pos == '1') { $watermark_pos = '2'; //ocPortal doesn't have watermark center position, so we will use the mkPortal default position: Bottom-right } continue; } if ($row['chiave'] == 'watermark_enable') { $watermark_enable = $row['valore']; continue; } } //add galleries first $rows = $db->query('SELECT * FROM ' . $table_prefix . 'gallery_events'); //for some strange reason the gallery categories are called events foreach ($rows as $row) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $row['evento'])); if (is_null($test)) { $rep_image = ''; $add_date = $db->query_value_null_ok('gallery', 'MIN(data)', array('evento' => $row['id'])); $add_date = !is_null($add_date) ? $add_date : time(); //set default values for the watermark positions $watermark_top_left = ''; $watermark_top_right = ''; $watermark_bottom_left = ''; $watermark_bottom_right = ''; if ($watermark_enable == '1' && strlen($watermark_image) > 0 && file_exists($watermark_image)) { //$watermark_pos - Possible values: 0 - Top-right; 1 - Center; 2 - Bottom-right (default for MKPortal) if ($watermark_pos == '2') { $watermark_top_right = $watermark_image; } else { $watermark_bottom_right = $watermark_image; } } $row['evento'] = @html_entity_decode($row['evento'], ENT_QUOTES, get_charset()); //find is there already a personal category container $pcc_gallery = $GLOBALS['SITE_DB']->query_select('galleries', NULL, array('name' => 'gallery_' . strval($row['father']))); $main_gallery = $GLOBALS['SITE_DB']->query_select('galleries', NULL, array('parent_id' => '')); $root_gallery = isset($pcc_gallery[0]['name']) && strlen($pcc_gallery[0]['name']) > 0 ? $pcc_gallery[0]['name'] : isset($main_gallery[0]['name']) && strlen($main_gallery[0]['name']) > 0 ? $main_gallery[0]['name'] : 'root'; $check_gallery_imported = $GLOBALS['SITE_DB']->query_select('galleries', NULL, array('name' => 'gallery_' . strval($row['id']))); if (!array_key_exists(0, $check_gallery_imported)) { add_gallery('gallery_' . strval($row['id']), $row['evento'], '', '', '', $root_gallery, 1, 0, 0, 0, $rep_image, $watermark_top_left, $watermark_top_right, $watermark_bottom_left, $watermark_bottom_right, 1, 1, false, $add_date); } } } //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 //now we need to import the images $rows = $db->query('SELECT * FROM ' . $table_prefix . 'gallery ORDER BY id'); // NB: In MKPortal "gallery" is the images table, and "gallery_events" is the galleries table foreach ($rows as $row) { if (import_check_if_imported('image', strval($row['id']))) { continue; } $submitter = $row['idauth']; //import_id_remap_get('member',$GLOBALS['FORUM_DRIVER']->get_member_from_username($row['autore']),true); if (is_null($submitter)) { $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id']; ocf_over_msn(); $comment_text = html_to_comcode($row['titolo'] . ' ' . $row['descrizione']); ocf_over_local(); //copy image and thumbnail and apply urls $url = ''; $thumb_url = ''; //image source and destination $save_filename = $old_base_dir . '/mkportal/modules/gallery/album/' . $row['file']; $copy_destination = $ocp_path . '/uploads/galleries/' . $row['file']; //image thumbnail source and destination $save_tfilename = $old_base_dir . '/mkportal/modules/gallery/album/t_' . $row['file']; $copy_tdestination = $ocp_path . '/uploads/galleries_thumbs/' . $row['file']; if (@copy($save_filename, $copy_destination) !== false) { fix_permissions($copy_destination); sync_file($copy_destination); } if (@copy($save_tfilename, $copy_tdestination) !== false) { fix_permissions($copy_tdestination); sync_file($copy_tdestination); } $url = get_custom_base_url() . '/uploads/galleries/' . $row['file']; $thumb_url = get_custom_base_url() . '/uploads/galleries_thumbs/' . $row['file']; $id_new = add_image('', 'gallery_' . strval($row['evento']), $comment_text, $url, $url, $row['validate'], 1, 1, 1, '', $submitter, $row['data'], NULL, $row['click'], $id); import_id_remap_put('image', strval($row['id']), $id_new); //import comments for image $comments = $db->query('SELECT * FROM ' . $table_prefix . 'gallery_comments WHERE identry=' . strval($row['id']) . ' ORDER BY data'); if (!is_null($forum_id)) { foreach ($comments as $comment) { $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['autore']); if (is_null($member)) { $member = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } $title = ''; $post = $comment['testo']; $content_url = build_url(array('page' => 'galleries', 'id' => $id_new, 'type' => 'view'), get_module_zone('galleries')); ocf_over_msn(); //used to fixed the correct forum prefix $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'galleries_' . strval($id_new), $member, $title, html_to_comcode($post), $row['titolo'], do_lang('COMMENT'), $content_url->evaluate()); ocf_over_local(); //used to fixed the correct forum prefix } } //import gallery rating too $this->_import_ratings($db, 'galleries', $row['id'], $id_new, $row['rate'], $table_prefix); } }