2014-01-29, 07:03 PM
1 - Get imageshack api key: http://imageshack.us/api_request/
2 - Create imageshack.php in root
3 - Create api.php
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
6.2 - Add after
6.3 - Find
6.4 - Add after
6.5 - Find
6.6 - Add after
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;