function buildXML($params) { $menu = new JMenuTree($params); $items =& JSite::getMenu(); // Get Menu Items $rows = $items->getItems('menutype', $params->get('menutype')); $maxdepth = $params->get('maxdepth', 10); // Build Menu Tree root down (orphan proof - child might have lower id than parent) $user =& JFactory::getUser(); $ids = array(); $ids[0] = true; $last = null; $unresolved = array(); // pop the first item until the array is empty if there is any item if (is_array($rows)) { while (count($rows) && !is_null($row = array_shift($rows))) { if (!check_link($row->link, $row->id)) { continue; } if (array_key_exists($row->parent, $ids)) { $row->ionly = $params->get('menu_images_link'); $menu->addNode($row); // record loaded parents $ids[$row->id] = true; } else { // no parent yet so push item to back of list // SAM: But if the key isn't in the list and we dont _add_ this is infinite, so check the unresolved queue if (!array_key_exists($row->id, $unresolved) || $unresolved[$row->id] < $maxdepth) { array_push($rows, $row); // so let us do max $maxdepth passes // TODO: Put a time check in this loop in case we get too close to the PHP timeout if (!isset($unresolved[$row->id])) { $unresolved[$row->id] = 1; } else { $unresolved[$row->id]++; } } } } } return $menu->toXML(); }
echo check_link(['privileges', 'privileges/trash', 'privileges-levels', 'modules']); ?> "> <a role="button"><i class="fa fa-cogs"></i> Management</a> <ul> <li class="<?php echo check_link(['privileges', 'privileges/trash']); ?> " ><?php echo anchor(base_url('privileges'), 'Privileges'); ?> </li> <li class="<?php echo check_link('privileges-levels'); ?> " ><?php echo anchor(base_url('privileges-levels'), 'Privileges Levels'); ?> </li> <li class="<?php echo check_link('modules'); ?> " ><?php echo anchor(base_url('modules'), 'Modules'); ?> </li> </ul> </li> </ul>
} } } $oneforall_mods = explode(',', $oneforall_mod_names); foreach ($oneforall_mods as $oneforall_mod_name) { $oneforall_mod_name = trim($oneforall_mod_name); if (in_array($oneforall_mod_name, $modules)) { $sql = "SELECT `section_id`, `page_id`, `link`, `modified_when`\r\n\t\t\t\tFROM `" . TABLE_PREFIX . "mod_" . $oneforall_mod_name . "_items`\r\n\t\t\t\tWHERE `active` = '1'"; $rs_oneforall = $database->query($sql); if ($rs_oneforall->numRows() > 0) { while ($oneforall = $rs_oneforall->fetchRow()) { if (!in_array($oneforall['section_id'], $public)) { continue; } $page = $database->get_one("SELECT `link` FROM `" . TABLE_PREFIX . "pages` WHERE `page_id`='" . $oneforall['page_id'] . "'"); $checked = check_link($page . $oneforall['link'], $exclude); if ($checked === true) { $link = htmlspecialchars($wb->page_link($page . $oneforall['link'])); $lastmod = gmdate("Y-m-d", $oneforall['modified_when'] + TIMEZONE); output_xml($link, $lastmod, $oneforall_frequency, $oneforall_priority); $counter++; } else { $debug_info[] = $checked; } } } } } // Add another module here... // Example code /*
<input type="hidden" name="filter_sort_asc" value="<?php echo $filter_sort_asc; ?> "> <input type="hidden" name="filter_sort_desc" value="<?php echo $filter_sort_desc; ?> "> <fieldset class="container"> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td align="left" colspan="2"> <?php $html->draw_button('back'); if ($add_page != '') { $show_add_link = check_link($add_link); if ($show_add_link) { echo " <a id=\"top_add_link\" class=\"listview\" href=\"{$add_page}?filter_field_used={$enc_filter_field}&filter_used={$enc_filter}&filter_sort_asc={$enc_filter_sort_asc}&filter_sort_desc={$enc_filter_sort_desc}&page_from={$current_page}\">Add new record</a>"; } } if ($csv_page != '') { echo " <a class=\"listview\" href=\"{$csv_page}\">Export data</a>"; } if ($report_page != '') { echo " <a class=\"listview\" href=\"{$report_page}\">Reporting</a>"; } ?> <br><br> </td> </tr> <tr class="listViewBar">
} else { $debug_info[] = $checked; } } } } // Showcase if (in_array('showcase', $modules)) { $sql = "SELECT `section_id`, `link`, `modified_when`\n\t\t\tFROM `" . TABLE_PREFIX . "mod_showcase_items`\n\t\t\tWHERE `active` = '1'"; $rs_showcase = $database->query($sql); if ($rs_showcase->numRows() > 0) { while ($showcase = $rs_showcase->fetchRow()) { if (!in_array($showcase['section_id'], $public)) { continue; } $checked = check_link($showcase['link'], $exclude); if ($checked === true) { if (!empty($showcase['link'])) { $path = $database->get_one("SELECT `link` FROM `" . TABLE_PREFIX . "pages` WHERE `page_id` = (SELECT `page_id` FROM `" . TABLE_PREFIX . "mod_showcase_items` WHERE `link` = '" . $showcase['link'] . "' LIMIT 1);"); $showcase['link'] = $path . $showcase['link']; } $link = htmlspecialchars($wb->page_link($showcase['link'])); $lastmod = gmdate("Y-m-d", $showcase['modified_when'] + TIMEZONE); output_xml($link, $lastmod, $showcase_frequency, $showcase_priority); $counter++; } else { $debug_info[] = $checked; } } } }
<div class="sidebar"> <div class="sidebar_widget"> <h3 class="sidebar_header">Полезные ссылки</h3> <div class="sidebar_content"> <?php foreach ($links as $link) { ?> <?php $src = wp_get_attachment_url(get_post_thumbnail_id($link->ID)); $link = check_link($link->ID); ?> <div class="sidebar_link" style="background-image:url(<?php echo $src; ?> );"> <a target="_blank" href="<?php echo $link; ?> "></a> </div> <?php }
<?php } ?> </ul> </div> </div> </div> <div class="footer_bottom"> <div class="container"> <div class="footer_copyrights"> © 2016 Молодежная Организация ХНЕУ им. Семена Кузнеца </div> <div class="footer_socials"> <?php foreach ($socials as $social) { $link = check_link($social->ID); ?> <a href="<?php echo $link; ?> "> <span class="fa fa-<?php echo $social->post_title; ?> "></span> </a> <?php } ?>
<?php if ($result = $data_con->make_query()->result) { $a = 1; $show_edit_link = check_link($edit_link); $show_delete_link = check_link($delete_link); while ($row = $result->fetch_assoc()) { $separator_index = 0; if ($a % 2 == 0) { $class = 'listRowEven'; } else { $class = 'listRowOdd'; } $a++; extract($row); $pkey_string = ''; if (is_array($arr_pkey_name)) { foreach ($arr_pkey_name as $pkey_name) { $enc_pkey = urlencode(${$pkey_name}); make_list($pkey_string, $pkey_name . '=' . $enc_pkey, '&', FALSE); } } else { cobalt_error_handler('Could not create primary key string.', 'arr_pkey_name is not an array. arr_pkey_name must be an array that contains at least one primary key field name.'); } echo '<tr class="' . $class . '"><td class="oper_col" align="center">'; if ($view_page != '') { echo "<a href=\"{$view_page}?filter_field_used={$enc_filter_field}&filter_used={$enc_filter}&filter_sort_asc={$enc_filter_sort_asc}&filter_sort_desc={$enc_filter_sort_desc}&page_from={$current_page}&{$pkey_string}\"><img src=\"/" . BASE_DIRECTORY . "/images/" . $_SESSION['icon_set'] . "/view.png\" alt=\"View\" title=\"View\"></a>"; } if ($edit_page != '') { if ($show_edit_link) { echo " <a href=\"{$edit_page}?filter_field_used={$enc_filter_field}&filter_used={$enc_filter}&filter_sort_asc={$enc_filter_sort_asc}&filter_sort_desc={$enc_filter_sort_desc}&page_from={$current_page}&{$pkey_string}\"><img src=\"/" . BASE_DIRECTORY . "/images/" . $_SESSION['icon_set'] . "/edit.png\" alt=\"Edit\" title=\"Edit\"></a>";
if ($data['alias'] == $item['alias']) { $duplicate = true; } } } if ($duplicate) { $num = $num - 1; } else { if (!$duplicate) { // Lấy ảnh đại diện $items = $bound->find($pattern_img); if ($items and count($items)) { foreach ($items as $img) { $image_url = $img->src; } $source = check_link($image_url, $site['host']); if ($site['get_image']) { $basename = basename($source); foreach ($imgext as $ext) { if ($pos = strpos($basename, $ext)) { $basename = substr($basename, 0, $pos + strlen($ext)); break; } } // Thư mục chứa ảnh thumb if (file_exists($folder . '/' . $basename)) { $dest = $folder . '/' . time() . '_' . $basename; } else { $dest = $folder . '/' . $basename; } if (file_put_contents($dest, file_get_contents($source))) {
/** * Draws a horizontal 'flat' style menu (very simple case) */ function mosShowHFMenu(&$params, $style = 0) { $menu =& JSite::getMenu(); $user =& JFactory::getUser(); //get menu items $rows = $menu->getItems('menutype', $params->get('menutype')); $links = array(); if (is_array($rows) && count($rows)) { foreach ($rows as $row) { if (!check_link($row->link, $row->id)) { continue; } if ($row->access <= $user->get('aid', 0)) { $links[] = mosGetMenuLink($row, 0, $params); } } } $menuclass = 'mainlevel' . $params->get('class_sfx'); $lang =& JFactory::getLanguage(); if (count($links)) { switch ($style) { case 1: echo '<ul id="' . $menuclass . '">'; foreach ($links as $link) { echo '<li>' . $link . '</li>'; } echo '</ul>'; break; default: $spacer_start = $params->get('spacer'); $spacer_end = $params->get('end_spacer'); echo '<table width="100%" border="0" cellpadding="0" cellspacing="1">'; echo '<tr>'; echo '<td nowrap="nowrap">'; if ($spacer_end) { echo '<span class="' . $menuclass . '"> ' . $spacer_end . ' </span>'; } if ($spacer_start) { $html = '<span class="' . $menuclass . '"> ' . $spacer_start . ' </span>'; echo implode($html, $links); } else { echo implode('', $links); } if ($spacer_end) { echo '<span class="' . $menuclass . '"> ' . $spacer_end . ' </span>'; } echo '</td>'; echo '</tr>'; echo '</table>'; break; } } }
if ($modulendx != 0 || $moduleadm != 0) { if ($modulendx > 0) { $module = $modulendx; $type = "index"; } if ($moduleadm > 0) { $module = $moduleadm; $type = "admin"; } } else { $module = 0; $type = "index"; } //kulso link ellenorzese if ($form->getSubmitValue('link') != "") { $link = check_link($form->getSubmitValue('link')); } else { $link = ""; } //ha ki akarjuk torolni a regi kepet - de semmi mast nem csinalunk if (isset($delpic) && $delpic->getChecked()) { $filename = ""; if (file_exists($_SESSION['site_cnt_picdir'] . "/" . $content_picture)) { @unlink($_SESSION['site_cnt_picdir'] . "/" . $content_picture); } } if ($menuType == 'index') { if ($file->isUploadedFile()) { $filevalues = $file->getValue(); $sdir = preg_replace('|/$|', '', $_SESSION['site_cnt_picdir']) . '/'; $filename = time() . preg_replace('|[^\\da-zA-Z_\\.]|', '_', change_hunchar($filevalues['name']));
function HandleUpload() { global $tc_db, $board_class, $is_oekaki, $oekaki; if (!$is_oekaki) { if ($board_class->board['type'] == 0 || $board_class->board['type'] == 2 || $board_class->board['type'] == 3) { $imagefile_name = isset($_FILES['imagefile']) ? $_FILES['imagefile']['name'] : ''; if ($imagefile_name != '') { if (strpos($_FILES['imagefile']['name'], ',') != false) { exitWithErrorPage(_gettext('Please select only one image to upload.')); } if ($_FILES['imagefile']['size'] > $board_class->board['maximagesize']) { exitWithErrorPage(sprintf(_gettext('Please make sure your file is smaller than %dB'), $board_class->board['maximagesize'])); } switch ($_FILES['imagefile']['error']) { case UPLOAD_ERR_OK: break; case UPLOAD_ERR_INI_SIZE: exitWithErrorPage(sprintf(_gettext('The uploaded file exceeds the upload_max_filesize directive (%s) in php.ini.')), ini_get('upload_max_filesize')); break; case UPLOAD_ERR_FORM_SIZE: exitWithErrorPage(sprintf(_gettext('Please make sure your file is smaller than %dB'), $board_class->board['maximagesize'])); break; case UPLOAD_ERR_PARTIAL: exitWithErrorPage(_gettext('The uploaded file was only partially uploaded.')); break; case UPLOAD_ERR_NO_FILE: exitWithErrorPage(_gettext('No file was uploaded.')); break; case UPLOAD_ERR_NO_TMP_DIR: exitWithErrorPage(_gettext('Missing a temporary folder.')); break; case UPLOAD_ERR_CANT_WRITE: exitWithErrorPage(_gettext('Failed to write file to disk')); break; default: exitWithErrorPage(_gettext('Unknown File Error')); } $this->file_type = preg_replace('/.*(\\..+)/', '\\1', $_FILES['imagefile']['name']); if ($this->file_type == '.jpeg') { /* Fix for the rarely used 4-char format */ $this->file_type = '.jpg'; } $pass = true; if (!is_file($_FILES['imagefile']['tmp_name']) || !is_readable($_FILES['imagefile']['tmp_name'])) { $pass = false; } else { if ($this->file_type == '.jpg' || $this->file_type == '.gif' || $this->file_type == '.png') { if (!@getimagesize($_FILES['imagefile']['tmp_name'])) { $pass = false; } } } if (!$pass) { exitWithErrorPage(_gettext('File transfer failure. Please go back and try again.')); } $this->file_name = substr(htmlspecialchars(preg_replace('/(.*)\\..+/', '\\1', $_FILES['imagefile']['name']), ENT_QUOTES), 0, 50); $this->file_name = str_replace('.', '_', $this->file_name); $this->original_file_name = $this->file_name; $this->file_md5 = md5_file($_FILES['imagefile']['tmp_name']); $exists_thread = checkMd5($this->file_md5, $board_class->board['name'], $board_class->board['id']); if (is_array($exists_thread)) { exitWithErrorPage(_gettext('Duplicate file entry detected.'), sprintf(_gettext('Already posted %shere%s.'), '<a href="' . KU_BOARDSPATH . '/' . $board_class->board['name'] . '/res/' . $exists_thread[0] . '.html#' . $exists_thread[1] . '">', '</a>')); } if (strtolower($this->file_type) == 'svg') { require_once 'svg.class.php'; $svg = new Svg($_FILES['imagefile']['tmp_name']); $this->imgWidth = $svg->width; $this->imgHeight = $svg->height; } else { $imageDim = getimagesize($_FILES['imagefile']['tmp_name']); $this->imgWidth = $imageDim[0]; $this->imgHeight = $imageDim[1]; } $this->file_type = strtolower($this->file_type); $this->file_size = $_FILES['imagefile']['size']; $filetype_forcethumb = $tc_db->GetOne("SELECT " . KU_DBPREFIX . "filetypes.force_thumb FROM " . KU_DBPREFIX . "boards, " . KU_DBPREFIX . "filetypes, " . KU_DBPREFIX . "board_filetypes WHERE " . KU_DBPREFIX . "boards.id = " . KU_DBPREFIX . "board_filetypes.boardid AND " . KU_DBPREFIX . "filetypes.id = " . KU_DBPREFIX . "board_filetypes.typeid AND " . KU_DBPREFIX . "boards.name = '" . $board_class->board['name'] . "' and " . KU_DBPREFIX . "filetypes.filetype = '" . substr($this->file_type, 1) . "';"); if ($filetype_forcethumb != '') { if ($filetype_forcethumb == 0) { $this->file_name = time() . mt_rand(1, 99); /* If this board has a load balance url and password configured for it, attempt to use it */ if ($board_class->board['loadbalanceurl'] != '' && $board_class->board['loadbalancepassword'] != '') { require_once KU_ROOTDIR . 'inc/classes/loadbalancer.class.php'; $loadbalancer = new Load_Balancer(); $loadbalancer->url = $board_class->board['loadbalanceurl']; $loadbalancer->password = $board_class->board['loadbalancepassword']; $response = $loadbalancer->Send('thumbnail', base64_encode(file_get_contents($_FILES['imagefile']['tmp_name'])), 'src/' . $this->file_name . $this->file_type, 'thumb/' . $this->file_name . 's' . $this->file_type, 'thumb/' . $this->file_name . 'c' . $this->file_type, '', $this->isreply, true); if ($response != 'failure' && $response != '') { $response_unserialized = unserialize($response); $this->imgWidth_thumb = $response_unserialized['imgw_thumb']; $this->imgHeight_thumb = $response_unserialized['imgh_thumb']; $imageused = true; } else { exitWithErrorPage(_gettext('File was not properly thumbnailed') . ': ' . $response); } /* Otherwise, use this script alone */ } else { $this->file_location = KU_BOARDSDIR . $board_class->board['name'] . '/src/' . $this->file_name . $this->file_type; $this->file_thumb_location = KU_BOARDSDIR . $board_class->board['name'] . '/thumb/' . $this->file_name . 's' . $this->file_type; $this->file_thumb_cat_location = KU_BOARDSDIR . $board_class->board['name'] . '/thumb/' . $this->file_name . 'c' . $this->file_type; if (!move_uploaded_file($_FILES['imagefile']['tmp_name'], $this->file_location)) { exitWithErrorPage(_gettext('Could not copy uploaded image.')); } chmod($this->file_location, 0644); if ($_FILES['imagefile']['size'] == filesize($this->file_location)) { if (!$this->isreply && ($this->imgWidth > KU_THUMBWIDTH || $this->imgHeight > KU_THUMBHEIGHT) || $this->isreply && ($this->imgWidth > KU_REPLYTHUMBWIDTH || $this->imgHeight > KU_REPLYTHUMBHEIGHT)) { if (!$this->isreply) { if (!createThumbnail($this->file_location, $this->file_thumb_location, KU_THUMBWIDTH, KU_THUMBHEIGHT)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } } else { if (!createThumbnail($this->file_location, $this->file_thumb_location, KU_REPLYTHUMBWIDTH, KU_REPLYTHUMBHEIGHT)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } } } else { if (!createThumbnail($this->file_location, $this->file_thumb_location, $this->imgWidth, $this->imgHeight)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } } if (!createThumbnail($this->file_location, $this->file_thumb_cat_location, KU_CATTHUMBWIDTH, KU_CATTHUMBHEIGHT)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } $imageDim_thumb = getimagesize($this->file_thumb_location); $this->imgWidth_thumb = $imageDim_thumb[0]; $this->imgHeight_thumb = $imageDim_thumb[1]; $imageused = true; } else { exitWithErrorPage(_gettext('File was not fully uploaded. Please go back and try again.')); } } } else { /* Fetch the mime requirement for this special filetype */ $filetype_required_mime = $tc_db->GetOne("SELECT `mime` FROM `" . KU_DBPREFIX . "filetypes` WHERE `filetype` = " . $tc_db->qstr(substr($this->file_type, 1))); $this->file_name = htmlspecialchars_decode($this->file_name, ENT_QUOTES); $this->file_name = stripslashes($this->file_name); $this->file_name = str_replace("€", " ", $this->file_name); $this->file_name = str_replace(' ', '_', $this->file_name); $this->file_name = str_replace('#', '(number)', $this->file_name); $this->file_name = str_replace('@', '(at)', $this->file_name); $this->file_name = str_replace('/', '(fwslash)', $this->file_name); $this->file_name = str_replace('\\', '(bkslash)', $this->file_name); /* If this board has a load balance url and password configured for it, attempt to use it */ if ($board_class->board['loadbalanceurl'] != '' && $board_class->board['loadbalancepassword'] != '') { require_once KU_ROOTDIR . 'inc/classes/loadbalancer.class.php'; $loadbalancer = new Load_Balancer(); $loadbalancer->url = $board_class->board['loadbalanceurl']; $loadbalancer->password = $board_class->board['loadbalancepassword']; if ($filetype_required_mime != '') { $checkmime = $filetype_required_mime; } else { $checkmime = ''; } $response = $loadbalancer->Send('direct', $_FILES['imagefile']['tmp_name'], 'src/' . $this->file_name . $this->file_type, '', '', $checkmime, false, true); $this->file_is_special = true; /* Otherwise, use this script alone */ } else { $this->file_location = KU_BOARDSDIR . $board_class->board['name'] . '/src/' . $this->file_name . $this->file_type; if ($this->file_type == '.mp3') { require_once KU_ROOTDIR . 'lib/getid3/getid3.php'; $getID3 = new getID3(); $getID3->analyze($_FILES['imagefile']['tmp_name']); if (isset($getID3->info['id3v2']['APIC'][0]['data']) && isset($getID3->info['id3v2']['APIC'][0]['image_mime'])) { $source_data = $getID3->info['id3v2']['APIC'][0]['data']; $mime = $getID3->info['id3v2']['APIC'][0]['image_mime']; } elseif (isset($getID3->info['id3v2']['PIC'][0]['data']) && isset($getID3->info['id3v2']['PIC'][0]['image_mime'])) { $source_data = $getID3->info['id3v2']['PIC'][0]['data']; $mime = $getID3->info['id3v2']['PIC'][0]['image_mime']; } if ($source_data) { $im = imagecreatefromstring($source_data); if (preg_match("/png/", $mime)) { $ext = ".png"; imagepng($im, $this->file_location . ".tmp", 0, PNG_ALL_FILTERS); } else { if (preg_match("/jpg|jpeg/", $mime)) { $ext = ".jpg"; imagejpeg($im, $this->file_location . ".tmp"); } else { if (preg_match("/gif/", $mime)) { $ext = ".gif"; imagegif($im, $this->file_location . ".tmp"); } } } $this->file_thumb_location = KU_BOARDSDIR . $board_class->board['name'] . '/thumb/' . $this->file_name . 's' . $ext; if (!$this->isreply) { if (!createThumbnail($this->file_location . ".tmp", $this->file_thumb_location, KU_THUMBWIDTH, KU_THUMBHEIGHT)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } } else { if (!createThumbnail($this->file_location . ".tmp", $this->file_thumb_location, KU_REPLYTHUMBWIDTH, KU_REPLYTHUMBHEIGHT)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } } $imageDim_thumb = getimagesize($this->file_thumb_location); $this->imgWidth_thumb = $imageDim_thumb[0]; $this->imgHeight_thumb = $imageDim_thumb[1]; $imageused = true; unlink($this->file_location . ".tmp"); } } /* Move the file from the post data to the server */ if (!move_uploaded_file($_FILES['imagefile']['tmp_name'], $this->file_location)) { exitWithErrorPage(_gettext('Could not copy uploaded image.')); } /* Check if the filetype provided comes with a MIME restriction */ if ($filetype_required_mime != '') { /* Check if the MIMEs don't match up */ if (mime_content_type($this->file_location) != $filetype_required_mime) { /* Delete the file we just uploaded and kill the script */ unlink($this->file_location); exitWithErrorPage(_gettext('Invalid MIME type for this filetype.')); } } /* Make sure the entire file was uploaded */ if ($_FILES['imagefile']['size'] == filesize($this->file_location)) { $imageused = true; } else { exitWithErrorPage(_gettext('File transfer failure. Please go back and try again.')); } /* Flag that the file used isn't an internally supported type */ $this->file_is_special = true; } } } else { exitWithErrorPage(_gettext('Sorry, that filetype is not allowed on this board.')); } } elseif (isset($_POST['embed'])) { if ($_POST['embed'] != '') { $_POST['embed'] = strip_tags(substr($_POST['embed'], 0, 20)); $video_id = $_POST['embed']; $this->file_name = $video_id; if ($video_id != '' && strpos($video_id, '@') == false && strpos($video_id, '&') == false) { $embeds = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "embeds`"); $worked = false; foreach ($embeds as $line) { if (strtolower($_POST['embedtype']) == strtolower($line['name']) && in_array($line['filetype'], explode(',', $board_class->board['embeds_allowed']))) { $worked = true; $videourl_start = $line['videourl']; $this->file_type = '.' . strtolower($line['filetype']); } } if (!$worked) { exitWithErrorPage(_gettext('Invalid video type.')); } $results = $tc_db->GetOne("SELECT COUNT(*) FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $board_class->board['id'] . " AND `file` = " . $tc_db->qstr($video_id) . " AND `IS_DELETED` = 0"); if ($results[0] == 0) { $video_check = check_link($videourl_start . $video_id); switch ($video_check[1]) { case 404: exitWithErrorPage(_gettext('Unable to connect to') . ': ' . $videourl_start . $video_id); break; case 303: exitWithErrorPage(_gettext('Invalid video ID.')); break; case 302: // Continue break; case 301: // Continue break; case 200: // Continue break; default: exitWithErrorPage(_gettext('Invalid response code ') . ':' . $video_check[1]); break; } } else { $results = $tc_db->GetAll("SELECT `id`,`parentid` FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $board_class->board['id'] . " AND `file` = " . $tc_db->qstr($video_id) . " AND `IS_DELETED` = 0 LIMIT 1"); foreach ($results as $line) { $real_threadid = $line[1] == 0 ? $line[0] : $line[1]; exitWithErrorPage(sprintf(_gettext('That video ID has already been posted %shere%s.'), '<a href="' . KU_BOARDSFOLDER . '/' . $board_class->board['name'] . '/res/' . $real_threadid . '.html#' . $line[1] . '">', '</a>')); } } } else { exitWithErrorPage(_gettext('Invalid ID')); } } } } } else { $this->file_name = time() . mt_rand(1, 99); $this->original_file_name = $this->file_name; $this->file_md5 = md5_file($oekaki); $this->file_type = '.png'; $this->file_size = filesize($oekaki); $imageDim = getimagesize($oekaki); $this->imgWidth = $imageDim[0]; $this->imgHeight = $imageDim[1]; if (!copy($oekaki, KU_BOARDSDIR . $board_class->board['name'] . '/src/' . $this->file_name . $this->file_type)) { exitWithErrorPage(_gettext('Could not copy uploaded image.')); } $oekaki_animation = substr($oekaki, 0, -4) . '.pch'; if (file_exists($oekaki_animation)) { if (!copy($oekaki_animation, KU_BOARDSDIR . $board_class->board['name'] . '/src/' . $this->file_name . '.pch')) { exitWithErrorPage(_gettext('Could not copy animation.')); } unlink($oekaki_animation); } $thumbpath = KU_BOARDSDIR . $board_class->board['name'] . '/thumb/' . $this->file_name . 's' . $this->file_type; $thumbpath_cat = KU_BOARDSDIR . $board_class->board['name'] . '/thumb/' . $this->file_name . 'c' . $this->file_type; if (!$this->isreply && ($this->imgWidth > KU_THUMBWIDTH || $this->imgHeight > KU_THUMBHEIGHT) || $this->isreply && ($this->imgWidth > KU_REPLYTHUMBWIDTH || $this->imgHeight > KU_REPLYTHUMBHEIGHT)) { if (!$this->isreply) { if (!createThumbnail($oekaki, $thumbpath, KU_THUMBWIDTH, KU_THUMBHEIGHT)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } } else { if (!createThumbnail($oekaki, $thumbpath, KU_REPLYTHUMBWIDTH, KU_REPLYTHUMBHEIGHT)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } } } else { if (!createThumbnail($oekaki, $thumbpath, $this->imgWidth, $this->imgHeight)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } } if (!createThumbnail($oekaki, $thumbpath_cat, KU_CATTHUMBWIDTH, KU_CATTHUMBHEIGHT)) { exitWithErrorPage(_gettext('Could not create thumbnail.')); } $imgDim_thumb = getimagesize($thumbpath); $this->imgWidth_thumb = $imgDim_thumb[0]; $this->imgHeight_thumb = $imgDim_thumb[1]; unlink($oekaki); } }