Beispiel #1
0
 public function getCats($r)
 {
     $t = new Dase_Template($r);
     $item = Dase_DBO_Item::getByTitle($this->db, $r, 'Cats');
     if (!$item) {
         $user = $pass = '';
         foreach ($r->getSuperusers() as $eid => $pass) {
             $user = $eid;
             $pass = $pass;
             break;
         }
         $image_url = $r->app_root . '/www/img/cats.jpg';
         $body = file_get_contents($image_url);
         $post_url = $r->app_root . '/items';
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $post_url);
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
         curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
         curl_setopt($ch, CURLOPT_USERPWD, $user . ':' . $pass);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         $headers = array("Content-Type: image/jpeg", "Title: Cats");
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $result = curl_exec($ch);
         $info = curl_getinfo($ch);
         curl_close($ch);
         $r->renderRedirect('admin/cats');
     } else {
         $t->assign('item', $item);
         $r->renderResponse($t->fetch('framework/cats.tpl'));
     }
 }