Posts mit dem Label PHP werden angezeigt. Alle Posts anzeigen
Posts mit dem Label PHP werden angezeigt. Alle Posts anzeigen

Mittwoch, 19. Juli 2023

Laravel Forge: fatal: couldn't find remote ref refs/heads

On Laravel Forge I checked out a branch and deleted it from the git server by accident. Now I can not fetch and can not switch branch. Fun fact Forge tells me it switched while it did not:

forge@myserver:~/myserver.de$ git fetch 

fatal: couldn't find remote ref refs/heads/mybranch

fatal: the remote end hung up unexpectedly

This can be fixed be open and edit .git/config

In remote section replace the checked out branch mybranch with * two times:

[remote "origin"]

    url = git@bitbucket.org:me/mygit

--  fetch = +refs/heads/mybranch:refs/remotes/origin/mybranch 

++  fetch = +refs/heads/*:refs/remotes/origin/*

Save and quite.

Now you can run "git fetch" and "git checkout main".

I also deleted the old branch: git branch -d mybranch 

Mittwoch, 17. Dezember 2014

IE Post empty with NTLM

With NTLM login enabled sometimes data send with POST is missing. This is because IE has an internal timeout and tries to recheck NTLM.

With fiddler you can see the problem. One hacky solution is to catch this request and response with a fake answer. After this the IE will send the normal POST data.

To get the correct NTLM response use fiddle during a NTLM login. Switch the inspector to "Auth" and look for the "Type: 1" response and replace below with long string behind "WWW-Authenticate: NTLM". Place this at the top of your page and it will catch and respond to any IE NTLM request.


$headers = apache_request_headers();
$auth = $headers['Authorization'];
if ($auth && substr($auth,0,5) == 'NTLM ')
{
    $msg = base64_decode(substr($auth, 5));
    if ($msg[8] == "\x01") {
        header('HTTP/1.1 401 Unauthorized');
        header('WWW-Authenticate: NTLM ');
        exit;
    }
}

Note: This might be a security risk. Make sure to check the user Session and send him to your NTLM login is needed.

Montag, 30. September 2013

PHP Versionen vergleichen

PHP verhält sich wie so vieles nicht in allen Versionen gleich. Um schnell einen Überblick zu bekommen wie sich ein Script in verschiedenen PHP Versionen verhält, kann man es bei 3v4l.org rein schmeißen und bekommt das Ergebnis für über 80 Versionen übersichtlich aufgeschlüsselt.
Brauch man nicht oft, aber manchmal ist das Gold wert!

Montag, 19. August 2013

PHP Debug Bar

In PHP mal schnell ein paar Debug Nachrichten, die SQL Querys und Expections schick ausgeben: http://phpdebugbar.com/

Dienstag, 22. November 2011

Encode and decode Dreamweaver password in PHP

If you want to generate a Dreamweaver site file (.ste) so you can import it, you need to encode the password for Dreamweaver. You can learn from Andrew Odri that the encryption is very bad. He wrote encode and decode functions for this in Javascript. Doing the same in PHP is way easier. Of course you can use this page to decode your side export. But they do not explain how it works:

function encodePassword($input)
{
  $output = '';
  
  for($i = 0; $i < strlen($input); $i++)
  {
    $output .= dechex(ord($input[$i]) + $i);
  }

  return strtoupper($output);
}


function decodePassword($input)
{
  $output = '';
  
  for($i = 0; $i < strlen($input); $i += 2)
  {
    $output .= chr(hexdec($input[$i].$input[$i+1]) - $i/2);
  }

  return ($output);
}

Montag, 11. Februar 2008

PHP Error: unexpected T_PAAMAYIM_NEKUDOTAYIM

Immer wieder schön, wenn Fehlermeldungen so hilfreich sind. Wie dieser hier:

Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM

Eine Erklärung dazu findet sich auf php.net unter Gültigkeitsbereichsoperator oder bei Wiki. Denn der Doppel-Doppelpunkt :: vom Gültigkeitsbereichsoperator den man z.B. von parent::__constructor(); kennt, heißt im Hebräisch Paamayim Nekudotayim. Klar, ist auch ein "dot" in Nekudotayim.

Den Fehler bekommt man wenn man etwas wie $a = new A; $a::__constructor(); schreibt. Richtig wäre A::__constructor();, also eine Klasse und nicht eine Variable vor dem "::". Ab PHP 5.3.0 ist die erste Variante aber auch erlaubt.

Bitte hinterlass einen Kommentar wobei der Fehler bei dir aufgetreten ist.

Hier gibt es übrigens PHP Bücher.