コード例 #1
0
ファイル: EmployeeController.php プロジェクト: Algresh/day
 public function imageToArray($path)
 {
     if (is_resource($path)) {
         $image = $path;
         ob_start();
         //Start output buffer.
         imagejpeg($image);
         //This will normally output the image, but because of ob_start(), it won't.
         $contents = ob_get_contents();
         //Instead, output above is saved to $contents
         ob_end_clean();
         //End the output buffer.
         $dataUri = "data:image/jpeg;base64," . base64encode($contents);
         return array('data' => array('img' => $dataUri));
     } else {
         $type = pathinfo($path, PATHINFO_EXTENSION);
         $data = file_get_contents($path);
         $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
         return array('data' => array('img' => $base64));
     }
 }
コード例 #2
0
 /**
  * Get individual items on a cart (web order). Called by LS download process after getting the web order row ids
  *
  * @param string $passkey
  * @param int $intId
  * @return string
  */
 public function get_web_order_items($passkey, $intId)
 {
     if (!$this->check_passkey($passkey)) {
         return self::FAIL_AUTH;
     }
     $objCart = Cart::model()->findByPk($intId);
     $strReturn = "";
     foreach ($objCart->cartItems as $objItem) {
         $strReturn .= "Rowid:" . base64encode($objItem->id) . chr(13);
         $strReturn .= "Cart:" . base64encode($objItem->cart_id) . chr(13);
         $strReturn .= "CartType:" . base64encode($objCart->cart_type) . chr(13);
         $strReturn .= "Product:" . base64encode($objItem->product_id) . chr(13);
         $strReturn .= "Code:" . base64encode($objItem->code) . chr(13);
         $strReturn .= "Description:" . base64encode($objItem->description) . chr(13);
         $strReturn .= "Discount:" . base64encode($objItem->discount) . chr(13);
         $strReturn .= "Qty:" . base64encode($objItem->qty) . chr(13);
         $strReturn .= "Sell:" . base64encode($objItem->sell) . chr(13);
         $strReturn .= "SellBase:" . base64encode($objItem->sell_base) . chr(13);
         $strReturn .= "SellDiscount:" . base64encode($objItem->sell_discount) . chr(13);
         $strReturn .= "SellTotal:" . base64encode($objItem->sell_total) . chr(13);
         $strReturn .= "SerialNumbers:" . base64encode($objItem->serial_numbers) . chr(13);
         $strReturn .= "GiftRegistryItemObject:" . base64encode($objItem->wishlist_item) . chr(13);
         $strReturn .= "DatetimeAdded:" . base64encode(CDateTimeParser::parse($objItem->datetime_added, 'yyyy-MM-dd HH:mm:ss')) . chr(13);
         $strReturn .= "DatetimeMod:" . base64encode(CDateTimeParser::parse($objItem->datetime_mod, 'yyyy-MM-dd HH:mm:ss')) . chr(13) . chr(13);
     }
     return $strReturn;
 }
コード例 #3
0
function kleeja_base64_encode($str = '')
{
    return function_exists('base64_encode') ? base64_encode($str) : base64encode($str);
}
コード例 #4
0
ファイル: MiscTest.php プロジェクト: adhocore/dsa
 /**
  * @depends testBase64loader
  * @expectedException \InvalidArgumentException
  */
 public function testBase65encodeException()
 {
     base64encode([]);
 }
コード例 #5
0
ファイル: themify-utils.php プロジェクト: rinodung/live-theme
function themify_remote_filesize($url, $user = "", $pw = "")
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPTHEADER, 1);
    curl_setopt($ch, CURLOPTNOBODY, 1);
    curl_setopt($ch, CURLOPTRETURNTRANSFER, 1);
    if (!empty($user) && !empty($pw)) {
        $headers = array('Authorization: Basic ' . base64encode("{$user}:{$pw}"));
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    }
    $head = curl_exec($ch);
    curl_close($ch);
    $regex = '/Content-Length:\\s([0-9].+?)\\s/';
    $count = preg_match($regex, $head, $matches);
    return isset($matches[1]) ? $matches[1] : false;
}
コード例 #6
0
ファイル: functions.php プロジェクト: phpf/micro
/**
 * Generates a 32-byte base64-encoded random string safe for URLs.
 */
function generate_csrf_token()
{
    return base64encode(generate_uuid(), true);
}