Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 690

Imageshack Upload

$
0
0
1 - Get imageshack api key: http://imageshack.us/api_request/

2 - Create imageshack.php in root

PHP Code:
<html>
<
head>
<
title>Upload to Imageshack</title>
</
head>
</
html>
<
style>
    
body {text-aligncenterbackground-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 Code:
<?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($curlCURLOPT_URL'http://www.imageshack.us/upload_api.php');
    
curl_setopt($curlCURLOPT_TIMEOUT$timeout);
    
curl_setopt($curlCURLOPT_POST1);
    
curl_setopt($curlCURLOPT_POSTFIELDS$postData);
    
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
    
$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 in images folder of your mybb installation.

5 - Copy imageshack.png in jscripts/editor_themes/default/images/ and jscripts/editor_themes/office2007/images/

6 - Open jscripts/editor.js

6.1 - Find

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

6.2 - Add after

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

6.3 - Find

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

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

6.4 - Add after

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

6.5 - Find

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

6.6 - Add after

Code:
case "imageshack":
                this.insertImageshack();
                break;


.png  imageshack.png (Size: 1.32 KB / Downloads: 25)

.png  ims.png (Size: 2.61 KB / Downloads: 1)

Viewing all articles
Browse latest Browse all 690

Trending Articles