示例#1
2
 function touchbase_run_time($debug)
 {
     pre_r("{$debug}: " . number_format((microtime(true) - PHP_START) * 1000, 1) . "ms");
 }
/**
 * Print debug messages
 *
 * @param string $type  The type of debug messages to print
 */
function dompdf_debug($type, $msg)
{
    global $_DOMPDF_DEBUG_TYPES, $_dompdf_show_warnings, $_dompdf_debug;
    if (isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug)) {
        $arr = debug_backtrace();
        echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] . "): " . $arr[1]["function"] . ": ";
        pre_r($msg);
    }
}
示例#3
0
文件: frame.cls.php 项目: artre/study
 function __toString()
 {
     // Skip empty text frames
     if ($this->_node->nodeName == "#text" && preg_replace("/\\s/", "", $this->_node->data) === "") {
         return "";
     }
     $str = "<b>" . $this->_node->nodeName . ":</b><br/>";
     $str .= (string) $this->_node . "<br/>";
     $str .= "Id: " . $this->get_id() . "<br/>";
     $str .= "Class: " . get_class($this) . "<br/>";
     if ($this->_node->nodeName == "#text") {
         $tmp = htmlspecialchars($this->_node->nodeValue);
         $str .= "<pre>'" . mb_substr($tmp, 0, 70) . (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>";
     }
     if ($this->_parent) {
         $str .= "\nParent:" . $this->_parent->_node->nodeName . " (" . (string) $this->_parent->_node . ") " . "<br/>";
     }
     if ($this->_prev_sibling) {
         $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . " (" . (string) $this->_prev_sibling->_node . ") " . "<br/>";
     }
     if ($this->_next_sibling) {
         $str .= "Next: " . $this->_next_sibling->_node->nodeName . " (" . (string) $this->_next_sibling->_node . ") " . "<br/>";
     }
     $d = $this->get_decorator();
     while ($d && $d != $d->get_decorator()) {
         $str .= "Decorator: " . get_class($d) . "<br/>";
         $d = $d->get_decorator();
     }
     $str .= "Position: " . pre_r($this->_position, true);
     $str .= "\nContaining block: " . pre_r($this->_containing_block, true);
     $str .= "\nMargin width: " . pre_r($this->get_margin_width(), true);
     $str .= "\nMargin height: " . pre_r($this->get_margin_height(), true);
     $str .= "\nStyle: <pre>" . $this->_style->__toString() . "</pre>";
     if ($this->_decorator instanceof Block_Frame_Decorator) {
         $str .= "Lines:<pre>";
         foreach ($this->_decorator->get_lines() as $line) {
             foreach ($line["frames"] as $frame) {
                 if ($frame instanceof Text_Frame_Decorator) {
                     $str .= "\ntext: ";
                     $str .= htmlspecialchars($frame->get_text());
                 } else {
                     $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . (string) $frame->get_node() . ")";
                 }
             }
             $str .= "\ny => " . $line["y"] . "\n" . "w => " . $line["w"] . "\n" . "h => " . $line["h"] . "\n";
         }
         $str .= "</pre>";
     }
     $str .= "\n";
     if (php_sapi_name() == "cli") {
         $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"), array("\n", "", ""), $str));
     }
     return $str;
 }
示例#4
0
 /**
  * an image object, will be an XObject in the document, includes description and data
  */
 function o_image($id, $action, $options = '')
 {
     if ($action != 'new') {
         $o =& $this->objects[$id];
     }
     switch ($action) {
         case 'new':
             // make the new object
             $this->objects[$id] = array('t' => 'image', 'data' => &$options['data'], 'info' => array());
             $this->objects[$id]['info']['Type'] = '/XObject';
             $this->objects[$id]['info']['Subtype'] = '/Image';
             $this->objects[$id]['info']['Width'] = $options['iw'];
             $this->objects[$id]['info']['Height'] = $options['ih'];
             if (!isset($options['type']) || $options['type'] == 'jpg') {
                 if (!isset($options['channels'])) {
                     $options['channels'] = 3;
                 }
                 switch ($options['channels']) {
                     case 1:
                         $this->objects[$id]['info']['ColorSpace'] = '/DeviceGray';
                         break;
                     default:
                         $this->objects[$id]['info']['ColorSpace'] = '/DeviceRGB';
                         break;
                 }
                 $this->objects[$id]['info']['Filter'] = '/DCTDecode';
                 $this->objects[$id]['info']['BitsPerComponent'] = 8;
             } else {
                 if ($options['type'] == 'png') {
                     $this->objects[$id]['info']['Filter'] = '/FlateDecode';
                     $this->objects[$id]['info']['DecodeParms'] = '<< /Predictor 15 /Colors ' . $options['ncolor'] . ' /Columns ' . $options['iw'] . ' /BitsPerComponent ' . $options['bitsPerComponent'] . '>>';
                     if (strlen($options['pdata'])) {
                         $tmp = ' [ /Indexed /DeviceRGB ' . (strlen($options['pdata']) / 3 - 1) . ' ';
                         $this->numObj++;
                         $this->o_contents($this->numObj, 'new');
                         $this->objects[$this->numObj]['c'] = $options['pdata'];
                         $tmp .= $this->numObj . ' 0 R';
                         $tmp .= ' ]';
                         $this->objects[$id]['info']['ColorSpace'] = $tmp;
                         if (isset($options['transparency'])) {
                             switch ($options['transparency']['type']) {
                                 case 'indexed':
                                     $tmp = ' [ ' . $options['transparency']['data'] . ' ' . $options['transparency']['data'] . '] ';
                                     $this->objects[$id]['info']['Mask'] = $tmp;
                                     break;
                                 case 'color-key':
                                     $tmp = ' [ ' . $options['transparency']['r'] . ' ' . $options['transparency']['r'] . $options['transparency']['g'] . ' ' . $options['transparency']['g'] . $options['transparency']['b'] . ' ' . $options['transparency']['b'] . ' ] ';
                                     $this->objects[$id]['info']['Mask'] = $tmp;
                                     pre_r($tmp);
                                     break;
                             }
                         }
                     } else {
                         if (isset($options['transparency'])) {
                             switch ($options['transparency']['type']) {
                                 case 'indexed':
                                     $tmp = ' [ ' . $options['transparency']['data'] . ' ' . $options['transparency']['data'] . '] ';
                                     $this->objects[$id]['info']['Mask'] = $tmp;
                                     break;
                                 case 'color-key':
                                     $tmp = ' [ ' . $options['transparency']['r'] . ' ' . $options['transparency']['r'] . ' ' . $options['transparency']['g'] . ' ' . $options['transparency']['g'] . ' ' . $options['transparency']['b'] . ' ' . $options['transparency']['b'] . ' ] ';
                                     $this->objects[$id]['info']['Mask'] = $tmp;
                                     break;
                             }
                         }
                         $this->objects[$id]['info']['ColorSpace'] = '/' . $options['color'];
                     }
                     $this->objects[$id]['info']['BitsPerComponent'] = $options['bitsPerComponent'];
                 }
             }
             // assign it a place in the named resource dictionary as an external object, according to
             // the label passed in with it.
             $this->o_pages($this->currentNode, 'xObject', array('label' => $options['label'], 'objNum' => $id));
             // also make sure that we have the right procset object for it.
             $this->o_procset($this->procsetObjectId, 'add', 'ImageC');
             break;
         case 'out':
             $tmp =& $o['data'];
             $res = "\n" . $id . " 0 obj\n<<";
             foreach ($o['info'] as $k => $v) {
                 $res .= "\n/" . $k . ' ' . $v;
             }
             if ($this->encrypted) {
                 $this->encryptInit($id);
                 $tmp = $this->ARC4($tmp);
             }
             $res .= "\n/Length " . strlen($tmp) . ">>\nstream\n" . $tmp . "\nendstream\nendobj";
             return $res;
             break;
     }
 }
示例#5
0
 function __toString()
 {
     // Skip empty text frames
     //     if ( $this->is_text_node() &&
     //          preg_replace("/\s/", "", $this->_node->data) === "" )
     //       return "";
     $str = "<b>" . $this->_node->nodeName . ":</b><br/>";
     //$str .= spl_object_hash($this->_node) . "<br/>";
     $str .= "Id: " . $this->get_id() . "<br/>";
     $str .= "Class: " . get_class($this) . "<br/>";
     if ($this->is_text_node()) {
         $tmp = htmlspecialchars($this->_node->nodeValue);
         $str .= "<pre>'" . mb_substr($tmp, 0, 70) . (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>";
     } elseif ($css_class = $this->_node->getAttribute("class")) {
         $tmp = htmlspecialchars($css_class);
         $str .= "CSS class: '{$css_class}'<br/>";
     }
     if ($this->_parent) {
         $str .= "\nParent:" . $this->_parent->_node->nodeName . " (" . spl_object_hash($this->_parent->_node) . ") " . "<br/>";
     }
     if ($this->_prev_sibling) {
         $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . " (" . spl_object_hash($this->_prev_sibling->_node) . ") " . "<br/>";
     }
     if ($this->_next_sibling) {
         $str .= "Next: " . $this->_next_sibling->_node->nodeName . " (" . spl_object_hash($this->_next_sibling->_node) . ") " . "<br/>";
     }
     $d = $this->get_decorator();
     while ($d && $d != $d->get_decorator()) {
         $str .= "Decorator: " . get_class($d) . "<br/>";
         $d = $d->get_decorator();
     }
     $str .= "Position: " . pre_r($this->_position, true);
     $str .= "\nContaining block: " . pre_r($this->_containing_block, true);
     $str .= "\nMargin width: " . pre_r($this->get_margin_width(), true);
     $str .= "\nMargin height: " . pre_r($this->get_margin_height(), true);
     $str .= "\nStyle: <pre>" . $this->_style->__toString() . "</pre>";
     if ($this->_decorator instanceof Block_Frame_Decorator) {
         $str .= "Lines:<pre>";
         foreach ($this->_decorator->get_line_boxes() as $line) {
             foreach ($line->get_frames() as $frame) {
                 if ($frame instanceof Text_Frame_Decorator) {
                     $str .= "\ntext: ";
                     $str .= "'" . htmlspecialchars($frame->get_text()) . "'";
                 } else {
                     $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . spl_object_hash($frame->get_node()) . ")";
                 }
             }
             $str .= "\ny => " . $line->y . "\n" . "w => " . $line->w . "\n" . "h => " . $line->h . "\n" . "left => " . $line->left . "\n" . "right => " . $line->right . "\n";
         }
         $str .= "</pre>";
     }
     $str .= "\n";
     if (php_sapi_name() === "cli") {
         $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"), array("\n", "", ""), $str));
     }
     return $str;
 }
示例#6
0
 function __toString()
 {
     $str = "";
     $str .= "Columns:<br/>";
     $str .= pre_r($this->_columns, true);
     $str .= "Rows:<br/>";
     $str .= pre_r($this->_rows, true);
     $str .= "Frames:<br/>";
     $arr = array();
     foreach ($this->_frames as $key => $val) {
         $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]);
     }
     $str .= pre_r($arr, true);
     if (php_sapi_name() == "cli") {
         $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"), array("\n", chr(27) . "[01;33m", chr(27) . "[0m"), $str));
     }
     return $str;
 }
 /**
  *	Request
  *	@param requestMethod
  *	@param requestEndpoint
  *	@param requestBody
  *	@return VOID
  */
 public function request($requestMethod, $requestEndpoint, $requestBody = NULL, $requestHeaders = [])
 {
     if (!$requestMethod || !$requestEndpoint) {
         throw new \InvalidArgumentException("Missing Arguments");
     }
     $this->addHeaders($requestHeaders);
     if (Router::isDev()) {
         ob_start();
         \pre_r($requestMethod, $requestEndpoint, $requestBody, $this->getAllHeaders());
         $apiLog = ob_get_contents();
         ob_end_clean();
         error_log($apiLog);
     }
     $c = curl_init();
     curl_setopt($c, CURLOPT_URL, $requestEndpoint);
     curl_setopt($c, CURLOPT_TIMEOUT, 30);
     curl_setopt($c, CURLOPT_USERAGENT, 'touchbase-php-library/2.0');
     curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($c, CURLINFO_HEADER_OUT, true);
     curl_setopt($c, CURLOPT_HTTPHEADER, $this->getAllHeaders());
     curl_setopt($c, CURLOPT_CUSTOMREQUEST, strtoupper($requestMethod));
     curl_setopt($c, CURLOPT_POSTFIELDS, $requestBody);
     curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
     $this->_lastResponse = curl_exec($c);
     $this->_lastResponseStatus = curl_getinfo($c, CURLINFO_HTTP_CODE);
     $this->_lastResponseContentType = curl_getinfo($c, CURLINFO_CONTENT_TYPE);
     $curlError = curl_error($c);
     if ($curlError) {
         throw new \RuntimeException(is_string($curlError) ? $curlError : "Something Terrible Happened!");
     }
     return $this->_lastResponse;
 }
示例#8
0
 /**
  *	Logout
  *	@return BOOL
  */
 public function logout()
 {
     if (!Cookie::delete(self::LOGIN_COOKIE_KEY)) {
         \pre_r("Failed to delete cookie");
     }
 }
示例#9
-1
 /**
  *	Store User
  *	@param AuthedUserInterface
  *	@return BOOL
  */
 public function storeUser(AuthedUserInterface $user)
 {
     $this->_user = $user;
     $encryptedData = Encryption::encrypt(implode("|", [$user->ID(), $this->cookieHash($user), json_encode($user->userInfo())]));
     $cookieData = base64_encode(Encryption::encrypt(implode("|", [$user->username(), $encryptedData])));
     //Set Cookie;
     if (!Cookie::set(self::LOGIN_COOKIE_KEY, $cookieData, Cookie::ONE_DAY, WORKING_DIR, null, true)) {
         \pre_r("Failed to set cookie");
     }
     return true;
 }