MyBB Community Forums

Full Version: Imageshack Upload
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
1 - Get imageshack api key: http://imageshack.us/api_request/

2 - Create imageshack.php in root

<html>
<head>
<title>Upload to Imageshack</title>
</head>
</html>
<style>
    body {text-align: center; background-color: #f7f7f7; overflow-x:hidden; overflow-y:auto;}
</style>
	<img src="images/ims.png" border="0" />
	<br /><br />
	<button onclick="document.querySelector('input.file').click()">Select file...</button>
    <form style="display:none" enctype="multipart/form-data" action="./api.php" method="POST">
    <input id="fileupl" class="file" type="file" name="img" onchange="this.form.submit();" />
    </form>

3 - Create api.php

<?php
  $formatcheck = '0';
  $imagem = getimagesize($_FILES['img']['tmp_name']);
  if ($imagem){
        rename($_FILES['img']['tmp_name'], "/tmp/" . $_FILES['img']['name']);

     $postData = array();
     $postData['fileupload'] = "@/tmp/" . $_FILES['img']['name'];
     $postData['submit']      = "Submit";
     $postData['key']                = "your_api_key";
     $postData['rembar']      = "no";
     $postData['xml']                = "yes";

    $timeout = 30;
    $curl    = curl_init();

    curl_setopt($curl, CURLOPT_URL, 'http://www.imageshack.us/upload_api.php');
    curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $xml_raw = curl_exec($curl);
    curl_close ($curl);

    $xml = new SimpleXMLElement($xml_raw);

    if ($xml->error != '') {
        $imgur_error_code = $xml->error;

        settype($imgur_error_code, "string");

        echo "<h1>Error #" . $imgur_error_code . "</h1>";
    }
    else {
        imagedestroy($image);
        $imgur_original = $xml->links[0]->image_link;

        settype($imgur_original, "string");}
  }
  else {
        echo "Invalid format";
		$formatcheck = '1';
  }

?>

<script>
	var editor = eval('opener.' + 'clickableEditor');
	if (<?php echo $formatcheck; ?> == '0') {		
			var code = '[img]<?php echo $imgur_original; ?>[/img]';
			editor.performInsert(code);
			javascript:window.close();}
	else {
	        var code = 'Invalid format';
			editor.performInsert(code);
			javascript:window.close();}
	
</script>

3.1 - Change your_api_key in api.php with key obtained in 1

4 - Copy ims.png [attachment=30941] in images folder of your mybb installation.

5 - Copy imageshack.png [attachment=30940] in jscripts/editor_themes/default/images/ and jscripts/editor_themes/office2007/images/

6 - Open jscripts/editor.js

6.1 - Find

{type: 'button', name: 'img', sprite: 'image', insert: 'image', extra: 1, title: this.options.lang.title_image},

6.2 - Add after

{type: 'button', name: 'imageshack', insert: 'imageshack', image: 'imageshack.png', title: 'Upload to Imageshack'},

6.3 - Find

insertIMG: function()
	{
		image = prompt(this.options.lang.enter_image, "http://");

		if(image)
		{
			this.performInsert("[img]"+image+"[/img]", "", true);
		}
	},

6.4 - Add after

insertImageshack: function()
	{
		MyBB.popupWindow('imageshack.php', 'imageshack', 210, 120);
	},

6.5 - Find

case "image":
				this.insertIMG();
				break;

6.6 - Add after

case "imageshack":
				this.insertImageshack();
				break;
Great. Have +rep Big Grin
Sabe de alguma forma de substituir / adicionar os anexos por upload para dropbox ou algum sistema semelhante?

Do you know any way to replace the attachments uploaded to dropbox or some similar system?
I'm sure this can be done spending some time on it:
https://www.dropbox.com/developers/core/start/php
Very good! Thanks! +
(2014-01-30, 04:21 AM)effone Wrote: [ -> ]I'm sure this can be done spending some time on it:
https://www.dropbox.com/developers/core/start/php

You can try?
Thank you very very much!!

A question: imageshack reuse image space? can I see after images are uploaded on imageshack?

I would not want that after a certain time were erased..

Thank you
Few questions.

-Images uploaded to imageshack are they public and forever the same URL?

-Is there a way to alter settings/paramters of any kind upon upload (haven't tried yet)

-What are the limitations (size/formats/etc...)