if ($datetimeid == $value->datetime) { $existFile = $config['image_path'] . $value->background_image; $x1 = $value->x1; $y1 = $value->y1; $width = $value->w; $height = $value->h; $text = substr($text, 0, $value->l); break; } } $newfile = time() . ".png"; $savepath = "./img_preview/" . $newfile; $tmp_text_box = "./img_preview/tmp_text_box.png"; $tmp_resize_img = "./img_preview/tmp_resize_img.png"; create_text_image($tmp_text_box, $text, $font); do_resize_image($tmp_text_box, $tmp_resize_img, $width, $height); //get size of image and list($rs_width, $rs_height) = getimagesize($tmp_resize_img); do_copy_image($tmp_resize_img, $existFile, $savepath, $x1, $y1 + $rs_height / 2, $width, $height); // unlink($tmp_text_box); // unlink($tmp_resize_img); //jsonp header("Content-Type: application/json"); echo $_GET['callback'] . "(" . json_encode(array('img' => $config['base_url'] . '/img_preview/' . $newfile, 'img_name' => $newfile)) . ")"; //-----------------------function------------------------// function str_to_utf8($str) { $decoded = utf8_decode($str); if (mb_detect_encoding($decoded, 'UTF-8', true) === false) { return $str; }
$myvideoimgnew = $config['pdir'] . "/" . $thepp; if (file_exists($myvideoimgnew)) { unlink($myvideoimgnew); } copy($uploadedimage, $myvideoimgnew); if ($processgif == "1") { do_resize_image2($myvideoimgnew, "700", "5000", true, $config['pdir'] . "/t/l-" . $thepp, $config['pdir'] . "/t/z-" . $thepp); do_resize_image2($myvideoimgnew, "500", "3000", true, $config['pdir'] . "/t/" . $thepp, $config['pdir'] . "/t/z-" . $thepp); do_resize_image2($myvideoimgnew, "220", "220", true, $config['pdir'] . "/t/s-" . $thepp, $config['pdir'] . "/t/z-" . $thepp); } else { //do_resize_image($myvideoimgnew, "700", "5000", true, $config['pdir']."/t/l-".$thepp); //do_resize_image($myvideoimgnew, "500", "3000", true, $config['pdir']."/t/".$thepp); //do_resize_image($myvideoimgnew, "220", "220", true, $config['pdir']."/t/s-".$thepp); do_resize_image($myvideoimgnew, "1600", "5000", true, $config['pdir'] . "/t/l-" . $thepp); do_resize_image($myvideoimgnew, "1200", "3000", true, $config['pdir'] . "/t/" . $thepp); do_resize_image($myvideoimgnew, "640", "640", true, $config['pdir'] . "/t/s-" . $thepp); } if (file_exists($config['pdir'] . "/" . $thepp)) { if ($config['wm'] == "1") { $watermark = $config['imagedir'] . "/" . $config['watermark']; if ($thepp2 == ".png") { $img = imagecreatefrompng($config['pdir'] . "/t/l-" . $thepp); } elseif ($thepp2 == ".jpg") { $img = imagecreatefromjpeg($config['pdir'] . "/t/l-" . $thepp); } else { $wskip = "1"; } if ($wskip != "1") { $img_width = imagesx($img); $img_height = imagesy($img); $watermark = imagecreatefrompng($watermark);
$_SESSION['FB'] = "1"; //add pics if (intval($fbpid) > 0) { $fp1 = $fbpicurl; $fp2 = $fbpicurl2; $tfpp = $userid . ".jpg"; $fimage = $config['mdir'] . "/o/" . $tfpp; if (!download_photo($fp2, $fimage)) { if (file_exists($fimage)) { unlink($fimage); } } else { $fi2 = $config['mdir'] . "/" . $tfpp; do_resize_image($fimage, "192", "192", false, $fi2); $fi3 = $config['mdir'] . "/thumbs/" . $tfpp; do_resize_image($fimage, "50", "50", false, $fi3); if (file_exists($config['mdir'] . "/o/" . $tfpp)) { $query = "UPDATE members SET profilepicture='{$tfpp}' WHERE USERID='" . mysql_real_escape_string($userid) . "'"; $conn->execute($query); $_SESSION['PP'] = $tfpp; } } } //add pics header("Location:{$config['baseurl']}/connect.php"); exit; } } } } }
$pkey = md5($pid); $query = "UPDATE posts SET pic='{$thepp}', active='1', pkey='" . mysql_real_escape_string($pkey) . "' WHERE PID='" . mysql_real_escape_string($pid) . "'"; $conn->execute($query); if (file_exists($myvideoimgnew)) { unlink($myvideoimgnew); } $theimageinfo = getimagesize($uploadedimage); $ow = $theimageinfo[0]; if ($ow > 0) { if ($processgif == "1") { do_resize_image2($uploadedimage, $ow, "12000", true, $config['pdir'] . "/" . $thepp, $config['pdir'] . "/t/z-" . $thepp); if (file_exists($config['pdir'] . "/t/z-" . $thepp)) { unlink($config['pdir'] . "/t/z-" . $thepp); } } else { do_resize_image($uploadedimage, $ow, "12000", true, $config['pdir'] . "/" . $thepp); } } unlink($uploadedimage); $pinurl = $thebaseurl . "/pin/" . $pkey; $query = "SELECT bname FROM boards WHERE BID='" . mysql_real_escape_string($board_id) . "' limit 1"; $executequery = $conn->execute($query); $bname = $executequery->fields['bname']; $seobname = seo_bname($bname); $boardurl = $thebaseurl . "/" . stripslashes($_SESSION['USERNAME']) . "/" . $seobname; $arr = array('success' => true, 'msg' => 'success', 'm1' => $lang['169'] . ' <a href="' . $boardurl . '">' . $bname . '</a>', 'm2' => '<a href="' . $pinurl . '">' . $lang['93'] . '</a>'); $query10 = "UPDATE boards SET pincount=pincount+1 WHERE BID='" . mysql_real_escape_string($board_id) . "'"; $conn->execute($query10); $query = "INSERT INTO activity SET USERID='" . mysql_real_escape_string($_SESSION['USERID']) . "', atype='pin', PID='" . mysql_real_escape_string($pid) . "', ptitle='" . mysql_real_escape_string($comment) . "', time_added='" . time() . "'"; $result = $conn->execute($query); if ($config['use_username'] == "1") {
function media_invoke() { $popup_form = ''; list($path, $opt) = GET('folder, opt', 'GETPOST'); list($do_action, $pending) = GET('do_action, pending', 'POST'); // Change default uploads dir $udir = cn_path_construct(SERVDIR, 'uploads'); if (getoption('uploads_dir')) { $udir = preparation_path(getoption('uploads_dir')); } $edir = getoption('uploads_ext') ? getoption('uploads_ext') : getoption('http_script_dir') . '/uploads'; $dfile = cn_path_construct($udir, $path); // Remove root identifier $path = preparation_path($path); // Path detection $path = preg_replace('/[^a-z0-9\\/_\\\\]/i', '-', $path); $root_dir = cn_path_construct($udir, $path) . DIRECTORY_SEPARATOR; $just_uploaded = array(); // Get path struct $pathes = spsep($path, DIRECTORY_SEPARATOR); if (isset($pathes[0]) && $pathes[0] === '') { unset($pathes[0]); } // Do upload files if (request_type('POST')) { cn_dsi_check(); // Allowed Exts. $AE = spsep(getoption('allowed_extensions')); // Generate thumbnail after upload $thumbnail_with_upload = getoption('thumbnail_with_upload'); // UPLOAD FILES if (REQ('upload', 'POST')) { list($overwrite) = GET('overwrite'); $is_uploaded = FALSE; // Try for fopen url upload if ($upload_from_inet = REQ('upload_from_inet')) { if (ini_get('allow_url_fopen')) { // Get filename $url_name = spsep($upload_from_inet, '/'); $url_name = $url_name[count($url_name) - 1]; $url_name = preg_replace('/(%20|\\s|\\?|&|\\/)/', '_', $url_name); $url_name = str_replace('%', '_', $url_name); // resolve filename $c_file = $dfile . $url_name; // Overwrite [if can], or add file if ($overwrite && file_exists($c_file) || !file_exists($c_file)) { // Use context for disable error notices if (function_exists('stream_context_create')) { $context = stream_context_create(array('http' => array('ignore_errors' => true))); $fw = fopen($upload_from_inet, 'rb', false, $context); } else { // Read file $fw = fopen($upload_from_inet, 'rb'); } // --------- (fetch content) ------ ob_start(); fpassthru($fw); $file_image = ob_get_clean(); fclose($fw); // --------- // write2disk if ($wf = fopen($c_file, 'w')) { fwrite($wf, $file_image); fclose($wf); } // check image list($w, $h) = getimagesize($c_file); if ($w && $h) { cn_throw_message('File uploaded'); $max_width = getoption('max_thumbnail_width'); if ($w > $max_width && $thumbnail_with_upload) { $resize_result = resize_image($c_file, $max_width, 0); cn_throw_message($resize_result['msg'], $resize_result['status'] ? 'n' : 'w'); } $is_uploaded = TRUE; $just_uploaded[$url_name] = TRUE; } else { cn_throw_message("Wrong image file", 'e'); unlink($c_file); } } else { cn_throw_message("Can't overwrite or save", 'e'); } } else { cn_throw_message('allow_url_fopen=0, check server configurations'); } } // Upload from local foreach ($_FILES['upload_file']['name'] as $id => $name) { if ($name) { $ext = NULL; if (preg_match('/\\.(\\w+)$/i', $name, $c)) { $ext = strtolower($c[1]); } // Check allowed ext if ($ext && in_array($ext, $AE)) { // encode url $name = str_replace('%2F', '/', urlencode($name)); // encoded? replace filename if (strpos($name, '%') !== FALSE) { $name = str_replace('%', '', strtolower($name)); } // check file for exist if (file_exists($c_file = $dfile . $name)) { if ($overwrite) { cn_throw_message('File [' . cn_htmlspecialchars($c_file) . '] overwritten', 'w'); } else { cn_throw_message('File [' . cn_htmlspecialchars($c_file) . '] already exists', 'e'); continue; } } // Upload file to server if (move_uploaded_file($_FILES['upload_file']['tmp_name'][$id], $c_file)) { $just_uploaded[$name] = TRUE; cn_throw_message('File uploaded [<b>' . cn_htmlspecialchars($name) . '</b>]'); $max_width = getoption('max_thumbnail_width'); list($w, $h) = getimagesize($c_file); if ($w > $max_width && $thumbnail_with_upload) { $resize_result = resize_image($c_file, $max_width, 0); cn_throw_message($resize_result['msg'], $resize_result['status'] ? 'n' : 'w'); } } else { cn_throw_message('File [' . cn_htmlspecialchars($c_file) . '] not uploaded! Please, check upload_max_filesize in PHP settings.', 'e'); } } else { cn_throw_message('File extension [' . cn_htmlspecialchars($ext) . '] not allowed', 'e'); } } elseif (!$is_uploaded) { cn_throw_message('No selected files for upload', 'e'); } } } elseif ($do_action || $pending) { list($rm) = GET('rm', 'POST'); // action --> delete entries if ($do_action == 'delete') { if (empty($rm)) { cn_throw_message('No files selected', 'w'); } else { foreach ($rm as $file) { if (file_exists($cfile = $dfile . $file)) { if (is_dir($cfile)) { rmdir($cfile); } else { //get thumbnail path $path_parts = pathinfo($cfile); $thumbnail_path = $path_parts['dirname'] . DIRECTORY_SEPARATOR . '.thumb.' . $path_parts['basename']; if (file_exists($thumbnail_path)) { unlink($thumbnail_path); } unlink($cfile); } } if (file_exists($cfile)) { cn_throw_message('File [' . cn_htmlspecialchars($cfile) . '] not deleted!', 'e'); } else { cn_throw_message('File [' . cn_htmlspecialchars($file) . '] deleted successfully'); } } } } elseif ($do_action == 'create') { $popup_form = i18n('Enter directory name') . ' <input type="text" name="new_dir" value="" />'; } elseif ($pending == 'create') { $new_dir_arr = GET('new_dir', 'POST'); $new_folder = array_pop($new_dir_arr); $new_folder = preg_replace('/[^a-z0-9_]/i', '-', $new_folder); if ($new_folder) { $cfile = $dfile . $new_folder; if (is_dir($cfile)) { cn_throw_message('Folder [' . $new_folder . '] already exists!', 'e'); } else { mkdir($cfile); if (!is_dir($cfile)) { cn_throw_message('Folder [' . cn_htmlspecialchars($cfile) . ' not created]', 'e'); } else { cn_throw_message('Folder [' . $new_folder . '] created!'); } } } else { cn_throw_message('Specify folder name', 'w'); } $popup_form = ''; } elseif ($do_action == 'rename') { if ($rm) { $popup_form = '<div class="big_font">' . i18n('Rename file to') . '</div>'; $popup_form .= i18n('Tip: Write new file name') . '<br />'; $popup_form .= '<table>'; foreach ($rm as $id => $fn) { $hfn = cn_htmlspecialchars($fn); $popup_form .= '<tr><td align="right" class="indent"><b>' . $hfn . '</b><td>'; $popup_form .= '<td><input type="hidden" name="ids[' . $id . ']" value="' . $hfn . '"/>→</td>'; $popup_form .= '<td><input style="width: 300px;" type="text" name="place[' . $id . ']" value="' . $hfn . '" /> '; $popup_form .= '</td></tr>'; } $popup_form .= '</table>'; } else { cn_throw_message('Select files to rename', 'w'); } } elseif ($pending == 'rename') { // ... list($ids, $place) = GET('ids, place', 'POST'); // prevent illegal moves $safe_dir = scan_dir($root_dir); foreach ($safe_dir as $id => $v) { $safe_dir[$id] = md5($v); } // do move all files / dirs foreach ($ids as $id => $file) { if (in_array(md5($file), $safe_dir)) { $filename = $place[$id]; if (strpos($filename, '\\') || strpos($filename, '/')) { cn_throw_message(i18n('The name of file [%1] should not contain special characters', cn_htmlspecialchars($file)), 'e'); continue; } $renameto = $root_dir . $filename; $thumb = $root_dir . '.thumb.' . $file; // do move if (rename($root_dir . $file, $renameto)) { if (file_exists($thumb)) { rename($thumb, $root_dir . '.thumb.' . $filename); } cn_throw_message(i18n('File [%1] renamed to [%2]', cn_htmlspecialchars($file), cn_htmlspecialchars($filename))); } else { cn_throw_message(i18n('File [%1] not renamed', cn_htmlspecialchars($file)), 'e'); } } } } elseif ($do_action == 'move') { if ($rm) { $popup_form = '<div class="big_font">' . i18n('Move files to') . '</div>'; $popup_form .= i18n('Tip: You can select the folder to move the file') . '<br />'; $popup_form .= '<table>'; $folders = array(); $dirs = scan_dir($root_dir); foreach ($dirs as $entry) { if (is_dir($root_dir . $entry) && !($entry === '..' || $entry === '.')) { $folders[] = $entry; } } foreach ($rm as $id => $fn) { $hfn = cn_htmlspecialchars($fn); $popup_form .= '<tr><td align="right" class="indent"><b>' . $hfn . '</b><td>'; $popup_form .= '<td><input type="hidden" name="ids[' . $id . ']" value="' . $hfn . '"/>→</td>'; $popup_form .= '<td>'; $cnt_folders = count($folders); if ($cnt_folders != 0 && !($cnt_folders == 1 && in_array($hfn, $folders))) { $popup_form .= '<select name="place_folder_' . $id . '">'; foreach ($folders as $dirn) { if ($dirn != $hfn) { $popup_form .= '<option value="' . $dirn . '">' . $dirn . '</option>'; } } $popup_form .= '</select>'; } if ($root_dir != $udir) { $popup_form .= '<nobr><input type="checkbox" onclick="javascript:hideFolderList(this,' . $id . ')" name="moveup[' . $id . ']" value="Y" /> Move up</nobr>'; } else { $popup_form .= '<nobr> X Move up (You are in root folder)</nobr>'; } $popup_form .= '</td></tr>'; } $popup_form .= '</table>'; } else { cn_throw_message('Select files to move', 'w'); } } elseif ($pending == 'move') { // ... list($ids, $moveup) = GET('ids, moveup', 'POST'); // prevent illegal moves $safe_dir = scan_dir($root_dir); foreach ($safe_dir as $id => $v) { $safe_dir[$id] = md5($v); } // do move all files / dirs foreach ($ids as $id => $file) { list($place_folder) = GET('place_folder_' . $id); if (in_array(md5($file), $safe_dir)) { $NF = ''; $foldername = preg_replace('/\\.\\//i', '', $place_folder); // move this file up if (isset($moveup[$id]) && count($pathes) > 0) { $nwfolder = dirname($root_dir); $foldername = 'up folder'; } else { $nwfolder = $root_dir . ($NF = isset($rm[0]) ? $rm[0] : '') . DIRECTORY_SEPARATOR . $foldername; if ($rm[0]) { $NF = $rm[0] . DIRECTORY_SEPARATOR; } } $moveto = $nwfolder . DIRECTORY_SEPARATOR . $file; //check for image thumbnail $thumb = $root_dir . '.thumb.' . $file; // do move if (rename($root_dir . $file, $moveto)) { if (file_exists($thumb)) { rename($thumb, $nwfolder . DIRECTORY_SEPARATOR . '.thumb.' . $file); } cn_throw_message(i18n('File [%1] moved to [%2]', cn_htmlspecialchars($file), cn_htmlspecialchars($foldername))); } else { cn_throw_message(i18n('File [%1] not moved', cn_htmlspecialchars($file)), 'e'); } } } } elseif ($do_action == 'thumb') { if (!empty($_POST['rm'])) { $popup_form = get_sizes_form('Make thumbnails', $do_action); } else { cn_throw_message('Select files to make thumbnail', 'w'); } } elseif ($pending == 'thumb') { do_resize_image($root_dir); } elseif ($do_action == 'resize') { if (!empty($_POST['rm'])) { $popup_form = get_sizes_form('Resize source image', $do_action); } else { cn_throw_message('Select files to resize', 'w'); } } elseif ($pending == 'resize') { do_resize_image($root_dir, false); } elseif (!hook('media/post_action')) { msg_info("Action error"); } } } // Check dir exists if (is_dir($root_dir)) { $raw_files = scan_dir($root_dir); } else { cn_throw_message('Dir not exists', 'e'); $raw_files = array(); } $dirs = $files = array(); foreach ($raw_files as $file) { if (preg_match('/avatar_/', $file)) { continue; } $file_location = "{$root_dir}/{$file}"; if (is_dir($file_location)) { $dirs[] = array('url' => "{$path}/{$file}", 'name' => $file); } elseif (filesize(cn_path_construct($udir, $path) . $file) != 0) { list($w, $h) = getimagesize(cn_path_construct($udir, $path) . $file); $is_thumb = preg_match('/\\.thumb\\./', $file); $files[] = array('name' => $file, 'url' => $edir . '/' . ($path ? $path . '/' : '') . $file, 'thumb' => file_exists($root_dir . '/.thumb.' . pathinfo($file, PATHINFO_BASENAME)) ? $edir . '/' . ($path ? $path . '/' : '') . '.thumb.' . pathinfo($file, PATHINFO_BASENAME) : '', 'local' => ($path ? $path . '/' : '') . $file, 'just_uploaded' => isset($just_uploaded[$file]) ? TRUE : FALSE, 'is_thumb' => $is_thumb, 'w' => $w, 'h' => $h, 'fs' => round(filesize($file_location) / 1024, 1)); } } uasort($dirs, 'usort_by_name_asc'); uasort($files, 'usort_by_name_asc'); // Top level (dashboard) cn_bc_add('Dashboard', cn_url_modify(array('reset'))); cn_bc_add('Media manager', cn_url_modify()); cn_assign("files, dirs, path, pathes, popup_form, root_dir", $files, $dirs, $path, $pathes, $popup_form, $root_dir); if ($opt === 'inline') { echo exec_tpl('window', 'title=Quick insert image', 'style=media/style.css', 'content=' . exec_tpl('media/general')); } else { echoheader('-@media/style.css', 'Media manager'); echo exec_tpl('media/general'); echofooter(); } }