All pastes #744376 Raw Edit

Athlan

public php v1 · immutable
·published 2007-10-21 12:21 UTC
rendered paste body
<?phpclass blogowisko_Vapplet extends Vapplet{  public function index_Action()  {    $aRequiredFields = array    (      'sUser',      'sPass',      'sMail',      'aCategories',    );        foreach($aRequiredFields as $sField)      if(!$this->$sField)        throw new VappletException('Param "' . $sField . '" has not been filled!');        $aUser = $this->setModel('user')->get($this->User()->id);    $aBlog = $this->setModel('blog')->get($this->User()->id, true);    $sBlog = 'http://' . strtolower($aUser['user_name']) . '.' . SERVICE . '/';        $aRequest = array    (      'user'         => $aUser['user_name'],      'pass'         => strrev(md5($this->sPass)),      'main'         => $this->sMail,      'url'          => $sBlog,      'feed'         => $sBlog . 'feed/',      'title'        => $aBlog['settings_title'],      'description'  => $aBlog['settings_desc'],      'tags'         => $this->_ParseTags($aBlog['settings_keywords']),      'categories'   => $this->aCategories,      'gg'           => $aUser['user_gg'],      'skype'        => $aUser['user_skype'],    );        $sRequest = base64_encode(serialize($aRequest));        // ok, this is only a test    Vframe::dump($aRequest, true);    return;    // @todo: delete this code        $sResponse = file_get_contents('http://blogowisko.org/api_a3sx4.php?request=' . $sRequest);        if($sResponse == 'ok')      return true;        return $this->_ParseResponse($sResponse);  }    private function _ParseTags($sKeywords)  {    $aTags = array();        foreach(explode(',', $sKeywords) as $sTag)      $aTags[] = trim($sTag);        return $aTags;  }    private function _ParseResponse($sResponse)  {    $aCodes = array    (      1 => 'Użytkownik o podanym loginie juz istnieje w serwisie blogowisko.org. Wybierz inny.',      2 => 'Ten adres email jest już w użyciu w serwisie blogowisko.org, wybierz inny.',      3 => 'Ten blog już został dodany do serwisu blogowisko.net.',    );        return (isset($aCodes[$sResponse])) ? $aCodes[$sResponse] : 'Nieznany błąd "' . $sResponse . '".';  }}?>