API- / Plugin-Informationen

News & Information um Linksave.in

Moderators: Developer, Syrex

API- / Plugin-Informationen

Postby crystal » 18.02.2009 14:56

Hier findet ihr eine Sammlung von API-Funktionen.
Sie sollten nur von Profis eingesetzt werden, die wissen, was sie tun!
PS: Wenn ihr eigene Plugins für Foren oder Blogs geschrieben habt, bitte schickt sie mir ;-)

Here you find a little collection of API-functions.
You should only use these if you know your PHP!
PS: If you have programmed your own plugins for forums or blogs, please send them to me ;-)





Viel Spaß / Have fun!
crystal
 
Posts: 320
Joined: 23.05.2008 18:18
Thanks: 0
Thanked: 0 time in 0 post

Ordnerinformationen anzeigen / Show some folder information

Postby crystal » 18.02.2009 14:58

Ordnerstatus anzeigen / Show folderstatus:
Aufruf/Request: http://linksave.in/!OrdnerID!/api-status
Rückgabe/Response: "online", "unknown", "offline" or "notyet" (wenn noch nicht überprüft / for not yet checked)


Verfügbare Containertypen anzeigen / Show available container-types:
Aufruf/Request: http://linksave.in/!OrdnerID!/api-containertypes
Rückgabe/Response: Containerarten, jeweils getrennt mit "|" / Containertypes, each divided by "|".


Hoster eines Ordners anzeigen / Show hoster of a folder:
Aufruf/Request: http://linksave.in/!OrdnerID!/api-hoster
Rückgabe/Response: Hostername (ohne Toplevel-Domain) oder "misc" für gemischte Links / Hostname (without TLD) or "misc" for mixed links.


Gesamtgröße eines Ordners anzeigen / Show size of a folder:
Aufruf/Request: http://linksave.in/!OrdnerID!/api-size
Rückgabe/Response: Ordnergröße in MB (oder "-1", wenn unbekannt) / Foldersize in MB (or "-1" for unknown).


Dateiname eines Ordners anzeigen / Show filename of a folder:
Aufruf/Request: http://linksave.in/!OrdnerID!/api-filename
Rückgabe/Response: Dateiname des ersten Links in dem Ordner (ohne Dateiendung) / Filename of the first link in that folder (without extension).


Anzahl der Links eines Ordners anzeigen / Show linkcount of a folder:
Aufruf/Request: http://linksave.in/!OrdnerID!/api-parts
Rückgabe/Response: Anzahl der Links / Linkcount.


Alle obigen Abfragen in einer / All above requests put in one:
Aufruf/Request: http://linksave.in/!OrdnerID!/api-more
Rückgabe/Response:
Spoiler:
Ordnerstatus / Folderstatus
Containerarten (getrennt mit "|") / Containertypes (divided by "|")
Hostername (ohne TLD) / Hostname (without TLD)
Ordnergröße (in MB) / Foldersize (in MB)
Dateiname des ersten Links (ohne Dateiendung) / Filename of the first link (without extension)
Anzahl der Links / Linkcount.
(jeweils getrennt durch Zeilenumbruch "\n" / each info divided by a line break "\n")



Anzahl der Besuche eines Ordners anzeigen / Show visits of a folder:
Aufruf/Request: http://linksave.in/!OrdnerID!/api-visits
Rückgabe/Response: Anzahl der Besuche / Visits.


cYa
crystal
 
Posts: 320
Joined: 23.05.2008 18:18
Thanks: 0
Thanked: 0 time in 0 post

Ordner per API erstellen / Create a folder with our API

Postby crystal » 18.02.2009 15:29

Dies ist nur ein Beispiel, ohne großen Funktionsumfang! Für mehr Details zur Schutz-API besuche bitte http://linksave.in/api.

This is only an example without big functional range! For more details on our protection-API please see http://linksave.in/api.


Code: Select all
<?php

$linksave["Username"] = "abcdefg";
$linksave["Passwort"] = "hijklmnop";

################################################

function PostToHost($host, $path, $data_to_send)
{
   $fp = @fsockopen($host, 80, $errno, $errstr, 5);
      if(!$fp) return false;

   foreach($data_to_send as $name=>$value) $data[]   = $name."=".$value;
   $data_to_send = implode("&", $data);

   $headers .= "POST ".$path." HTTP/1.1\r\n";
   $headers .= "Host: ".$host."\r\n";
   $headers .= "Content-Type: application/x-www-form-urlencoded\r\n";
   $headers .= "Content-Length: ". strlen($data_to_send) ."\r\n";
   $headers .= "Connection: close\r\n\r\n";
   $headers .= $data_to_send;

   fputs($fp, $headers);

   stream_set_blocking($fp, TRUE);
   stream_set_timeout($fp, 5);
   $status = stream_get_meta_data($fp);

   while(!feof($fp) && !$status['timed_out'])
   {
      $res .= fgets($fp, 1024);
      $status = stream_get_meta_data($fp);
      ob_flush(); flush();
   }
   fclose($fp);

   $result = explode("\r\n\r\n", $res);
   return $result[1];
}


if(!empty($_POST["links"]))
{
   $data = Array(
      "protect" => "true",
      "ordnername" => $_POST["name"],
      "links" => $_POST["links"],
      "myschutz" => $_POST["schutz"],
      "mirrors[0]" => $_POST["mirrors"][0],
      "mirrors[1]" => $_POST["mirrors"][1],
      "mirrors[2]" => $_POST["mirrors"][2]
   );

   $temp = PostToHost("linksave.in", "/protect?api=".$linksave["Username"].":".$linksave["Passwort"]."", $data);
   $result = substr(substr($temp, 4), 0, -3); // siehe Kommentar unten (Moderator)

   if(!ereg("ERROR", $result))
   {
      echo "<b>http://linksave.in/".$result."</b><br /><br />";
   }
   else
   {
      $error = str_replace("|", "\n", $result);
      echo "<pre>".$error."</pre><br /><br />";
   }
}

?>

<form method="POST" action="<?=$_SERVER["PHP_SELF"]?>">
  <p>
   <input type="text" name="name" value="<?=$_POST["name"]?>" /> Ordnername / Foldername
  </p>
  <p>
    <input type="radio" name="schutz" value="container_js" checked="checked" /> Container &amp; Webschutz / Container &amp; Webprotection
    <input type="radio" name="schutz" value="container " />Nur Container / Only container</p>
  <p>
    <textarea name="links" cols="45" rows="5"><?=$_POST["links"]?></textarea>
  </p>
  <p>
    <textarea name="mirrors[]" cols="45" rows="5"><?=$_POST["mirrors"][0]?></textarea>
  </p>
  <p>
    <textarea name="mirrors[]" cols="45" rows="5"><?=$_POST["mirrors"][1]?></textarea>
  </p>
  <p>
    <textarea name="mirrors[]" cols="45" rows="5"><?=$_POST["mirrors"][2]?></textarea>
  </p>
  <p>
    <input type="submit" value="Senden / Send" />
  </p>
</form>

cYa

Edit Moderator:
$result = substr(substr($temp, 4), 0, -3); sollte wegfallen und $result = $temp gesetzt werden.
Begründung: viewtopic.php?f=364&t=40755&p=371661#p371140
crystal
 
Posts: 320
Joined: 23.05.2008 18:18
Thanks: 0
Thanked: 0 time in 0 post

UCMS-Plugin for Linksave.in

Postby crystal » 18.02.2009 15:49

Hier ein UCMS-Plugin, damit der Status von Dateien angezeigt werden kann / Here a UCMS-plugin, so the status can be displayed.


1) Öffne die Datei "modules/entries/item.main.validate.inc.php" und suche nach / Open the file "modules/entries/item.main.validate.inc.php" and search for:
Code: Select all
function ValidateUrl($url, &$filesize)


2) Füge einen neue Fall ein / Insert a new case:
Code: Select all
case 'linksave.in':
{
     return(ValidateLinksaveUrl($url));
     break;
}


3) Füge dann irgendwo in der Datei (z.b. nach der obigen Funktion) ein / Insert anywhere in this file (eg. after the above function):
Code: Select all
//--------------------------------------------------------
// - Linksave.in Statuscheck -
//--------------------------------------------------------
function ValidateLinksaveUrl($url)
{
     if($http_data = HTTP_GetUrl("".$url."/api-status", true))
     {
          if(@preg_match("/online/i", $http_data, $matches))
          {
               return(PAGE_LOCAL_URL_VALIDATE_RESULT_SUCCESS);
          }
          else
          {
               return(PAGE_LOCAL_URL_VALIDATE_RESULT_ERROR);
          }
     }
     else
     {
          return(PAGE_LOCAL_URL_VALIDATE_RESULT_UNKNOWN);
     }
}


4) Öffne "modules/parse.inc.php" und suche nach / Open "modules/parse.inc.php" and search for:
Code: Select all
return(@in_array(@strtolower($hoster), Array('bluehost.to','depositfiles.com','file-bunker.org','filebox.to',[...],'xlice.net','xlspread.com')));


5) Füge dort im Array 'linksave.in' hinzu. Danach sollte es in etwa so aussehen / Insert 'linksave.in' into the array. After that it should look something like this:
Code: Select all
return(@in_array(@strtolower($hoster), Array('bluehost.to','depositfiles.com','file-bunker.org','filebox.to',[...],'xlice.net','xlspread.com','linksave.in')));
crystal
 
Posts: 320
Joined: 23.05.2008 18:18
Thanks: 0
Thanked: 0 time in 0 post

Linksave.in - Delphi Plugin

Postby crystal » 21.02.2009 13:49

Du kannst dir die Delphi Unit hier herrunterladen. Eine kleine Demo Testumgebung ist enthalten.
You can download the Delphi unit from here. Small demo is included.

Code: Select all
{*******************************************************}
{                                                       }
{       Linksave.in Delphi API                          }
{       Version 1.0.0.0                                 }
{       Copyright (c) 2009 Sebastian Klatte             }
{                                                       }
{*******************************************************}

unit LinksaveAPI;

interface

uses
  SysUtils, Classes, IdHTTP, IdMultiPartFormData;

  function MakeLSFolder(Files:TStrings;
                        AccountName:String='';AccountPassword:String='';
                        BackupA:TStrings=NIL;BackupB:TStrings=NIL;BackupC:TStrings=NIL;
                        LinksaveInType:Integer=1; // 0 = default from Account
                        Foldername:String=''; Description:String=''; Cover:String=''; Website:String='';
                        Category:Integer=0; // 0 = default only for Account Users
                        CCF:Boolean=TRUE; DLC:Boolean=TRUE; RSDF:Boolean=TRUE;
                        Captcha:Boolean=FALSE;
                        LinksaveInAdv:Integer=1; // 0 = default from Account
                        LSBannerurl:String=''; LSBannerlink:String=''; LSMirror:String='';
                        LinksaveInLocation:Integer=1;
                        Adminpassword:String='';Visitorpassword:String='';
                        EMailAdress:String=''):String;

implementation

function MakeLSFolder;
var IdHTTP:TIdHTTP; Params:TIdMultiPartFormDataStream;
const
  cLinksaveInType: Array[1..5] of String = ('container_js','container','container_plain','plain','js');
  cLinksaveInAdv : Array[1..2] of String = ('banner','mirror');
  cLinksaveInLocation: Array[1..5] of String = ('captchaseite','frame','oben','unten','rechts');
begin
  IdHTTP := TIdHTTP.Create(nil);
  Params := TIdMultiPartFormDataStream.Create;

  try
    Params.AddFormField('protect','protect');

    Params.AddFormField('links', Files.Text );

    if not (BackupA = nil) then
      Params.AddFormField('mirrors[]', BackupA.Text );
    if not (BackupB = nil) then
      Params.AddFormField('mirrors[]', BackupB.Text );
    if not (BackupC = nil) then
      Params.AddFormField('mirrors[]', BackupC.Text );     

    Params.AddFormField('ordnername', Foldername );
    Params.AddFormField('beschreibung', Description );
    Params.AddFormField('cover', Cover );
    Params.AddFormField('website', Website );

    if (LinksaveInType > 0) then
      begin
        Params.AddFormField('myschutz',cLinksaveInType[ LinksaveInType ]);
        if CCF then
          Params.AddFormField('container_ccf','1');
        if DLC then
          Params.AddFormField('container_dlc','1');
        if RSDF then
          Params.AddFormField('container_rsdf','1');
      end;

    if Captcha then
        Params.AddFormField('captcha','an')
      else Params.AddFormField('captcha','aus');

    if (AccountName <> '') then
      Params.AddFormField('kategorie', IntToStr(Category) );

    if (LinksaveInAdv > 0) and (AccountName <> '') then
      begin
        Params.AddFormField('werbung',cLinksaveInAdv[ LinksaveInAdv ]);
        Params.AddFormField('bannerurl', LSBannerurl );
        Params.AddFormField('bannerlink', LSBannerlink );
        Params.AddFormField('mirror', LSMirror );
        Params.AddFormField('location',cLinksaveInLocation[ LinksaveInLocation ]);
      end;

    Params.AddFormField('adminpasswort', Adminpassword );
    Params.AddFormField('besucherpasswort', Visitorpassword );

    Params.AddFormField('email', EMailAdress );

    IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';

    if (AccountName = '') then
        result := IDHTTP.Post('http://www.linksave.in/protect?api=TRUE', Params)
      else result := IDHTTP.Post('http://www.linksave.in/protect?api='+ AccountName +':'+ AccountPassword , Params);

    if (Pos('ERROR',result) = 0) then
      result := 'http://linksave.in/' + result;
  finally
    FreeAndNIL(Params);
    IdHTTP.Free;
  end;
end;

LinksaveInType = schutz Typ / protection type
BackupA,BackupB,BackupC = Mirror1,Mirror2,Mirror3

Als Ergebnis bekommt man den Linksave.in-Link oder eine Fehlermeldung / The result is a linksave.in link or a errortext.

Du kannst es so aufrufen / You can use it like this:
Code: Select all
Edit1.Text := MakeLSFolder(Memo1.Lines);
crystal
 
Posts: 320
Joined: 23.05.2008 18:18
Thanks: 0
Thanked: 0 time in 0 post


Return to News & Information

Who is online

Users browsing this forum: MaManGu and 3 guests