Code Duplication    Length = 17-17 lines in 2 locations

class/oledrion_utils.php 1 location

@@ 1477-1493 (lines=17) @@
1474
     * @param $url
1475
     * @return string
1476
     */
1477
    public function postIt($datastream, $url)
1478
    {
1479
        $url     = preg_replace('@^http://@i', '', $url);
1480
        $host    = substr($url, 0, strpos($url, '/'));
1481
        $uri     = strstr($url, '/');
1482
        $reqbody = '';
1483
        foreach ($datastream as $key => $val) {
1484
            if (!empty($reqbody)) {
1485
                $reqbody .= '&';
1486
            }
1487
            $reqbody .= $key . '=' . urlencode($val);
1488
        }
1489
        $contentlength = strlen($reqbody);
1490
        $reqheader     = "POST $uri HTTP/1.1\r\n" . "Host: $host\n" . "Content-Type: application/x-www-form-urlencoded\r\n" . "Content-Length: $contentlength\r\n\r\n" . "$reqbody\r\n";
1491
1492
        return $reqheader;
1493
    }
1494
1495
    /**
1496
     * Retourne le type Mime d'un fichier en utilisant d'abord finfo puis mime_content

class/utility.php 1 location

@@ 1620-1636 (lines=17) @@
1617
     * @param $url
1618
     * @return string
1619
     */
1620
    public static function postIt($datastream, $url)
1621
    {
1622
        $url     = preg_replace('@^http://@i', '', $url);
1623
        $host    = substr($url, 0, strpos($url, '/'));
1624
        $uri     = strstr($url, '/');
1625
        $reqbody = '';
1626
        foreach ($datastream as $key => $val) {
1627
            if (!empty($reqbody)) {
1628
                $reqbody .= '&';
1629
            }
1630
            $reqbody .= $key . '=' . urlencode($val);
1631
        }
1632
        $contentlength = strlen($reqbody);
1633
        $reqheader     = "POST $uri HTTP/1.1\r\n" . "Host: $host\n" . "Content-Type: application/x-www-form-urlencoded\r\n" . "Content-Length: $contentlength\r\n\r\n" . "$reqbody\r\n";
1634
1635
        return $reqheader;
1636
    }
1637
1638
    /**
1639
     * Retourne le type Mime d'un fichier en utilisant d'abord finfo puis mime_content