• Stars
    star
    138
  • Rank 264,508 (Top 6 %)
  • Language
    JavaScript
  • Created about 12 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript tool to unserialize data taken from PHP. It can parse "serialize()" output, or even serialized sessions data.

js-php-unserialize

Build Status

JavaScript tool to unserialize data taken from PHP. It can parse "serialize()" output, or even serialized sessions data.

Credits

  • The PHP unserializer is taken from kvz's phpjs project.
  • The session unserializer's idea is taken from dumpling, which is highly limited by its lack of a real unserializer, and has lot of crash cases.

Installation

Node.js

Install from npm :

npm install php-unserialize

The use it the usual way :

var PHPUnserialize = require('php-unserialize');

console.log(PHPUnserialize.unserialize('a:0:{}')); // {}

Browser

Download tarball from github and then unarchive this where you want, then you can simply include it in your page :

<script src="/path/to/php-unserialize.js"></script>
<script>
  console.log(PHPUnserialize.unserialize('a:0:{}')); // {}
</script>

Compatibility issues

This library has been tested server-side only. For example it uses [].reduce, so it may not work on some browsers. Do not hesitate to make pull requests to fix it for you favorite browsers :)

Notes

  • Note that array() will be converted to {} and not []. That can be discussed as array() in PHP has various significations. A choice had to be done, but it may change in the future (cf. next point).
  • A less obvious conversion is array('a', 'b') which will be converted to {"0": "a", "1": "b"}. Quite annoying, and it will be fixed if necessary (this means I won't work on this issue unless you really need it, but I agree this is not normal behavior).

Usage

The module exposes two methods:

unserialize(string)

Unserialize output taken from PHP's serialize() method.

It currently does not suport objects.

unserializeSession(string)

Unserialize PHP serialized session. PHP uses a weird custom format to serialize session data, something like "$key1$serializedData1|$key2$serializedData2|…", this methods will parse this and unserialize chunks so you can have a simple anonymous objects.

More Repositories

1

github-todos

Git hook to convert your TODOs into Github issues
JavaScript
1,286
star
2

json-server-gui

GUI for json-server
JavaScript
224
star
3

node-ftp-server

Featureless FTP server
JavaScript
82
star
4

show-time

Watch TV shows and movies with a simple CLI
JavaScript
76
star
5

node-jus-i18n

Full-featured I18N module for Node.js
JavaScript
21
star
6

ABBundle

Symfony 2 bundle to ease A/B testing
PHP
18
star
7

node-chat-socketio-handshake

Demo pour mon blog
JavaScript
15
star
8

node-base-converter

Simple math module (mainly to train with npm)
JavaScript
15
star
9

connect-access-control

Connect (Express) Access Control simple middleware
JavaScript
14
star
10

cli-fuzzy-search

CLI library to provide a fuzzy search box with suggestions
JavaScript
12
star
11

node-every-stream

Stream everything, from/to everywhere
JavaScript
12
star
12

301.tl

Source code for 301.tl URL shortener
JavaScript
9
star
13

fun-helpers

JavaScript library providing some functional helpers, all very Promise-friendly
JavaScript
8
star
14

ender-swig

Swig module for Ender
JavaScript
8
star
15

node-twitter-timeline-cleaner

`ttc` provides some useful statistics about your account, helping you to cleanup your timeline
JavaScript
7
star
16

i18ntools

Play! module for i18n
Python
7
star
17

MicroJS

µJS is the ltimate micro-library to build you own fully featured framework for Javascript
JavaScript
5
star
18

lyonjs2012-03

Présentation Headless browsers au LyonJS Mars 2012
JavaScript
5
star
19

lyonjs2011-10

Slides et démo pour LyonJS Octobre 2011
JavaScript
5
star
20

videocast

Send video files to your Chromecast from your CLI, control volume, seek, pause, stop... from your terminal
JavaScript
5
star
21

node-drupal-notifications

Node.JS+Socket.IO server and client to allow realtime notifications (demoed with Drupal, but generic purpose)
JavaScript
5
star
22

node-npm-metadata-mirror

Monitor NPM changes and keep an up-to-date mirror of modules metadata (not the whole data, i.e. including attachments info, but not attachments body)
JavaScript
4
star
23

Symfony2Tools

My personal toolbox for Symfony2 projects
Shell
4
star
24

formation-nodejs-avril-2013

Dépôt de la formation Node.js des 22 & 23 avril 2013
JavaScript
4
star
25

node-ETL

An ETL (inspired by Talend Open Studio, but let's use some code instead of GUI) for Node
CoffeeScript
3
star
26

javascript-questions-cli

JavaScript quizz, right in your terminal
JavaScript
3
star
27

wordpress-304

Wordpress plugin that properly enables support for 304 - Not Modified HTTP status
PHP
3
star
28

inquirer-checkbox-status

Checkbox prompt for Inquirer with live custom status info about current selection
JavaScript
2
star
29

node-phishing-detector

This module will allow you to detect phishing URLs based on any source (default is Phishtank)
JavaScript
2
star
30

node-jus-task

Fully functional CLI task tool for the framework "jus" (WiP)
JavaScript
2
star
31

formation-node-2020-07

CSS
2
star
32

punch-rss-generator

Generate your RSS file along with Punch blog content handler
JavaScript
2
star
33

android-horaires-sncf

Application de visualisation en direct des prochains départs de votre gare la plus proche
2
star
34

demo-reunion-technique-nodejs

Démos utilisées lors de la réunion technique Node.JS du 17/06/2011 chez Clever Age (note: 1 démo = 1 branche)
2
star
35

test-mobile

Test jQuery Mobile pour un PoC
PHP
1
star
36

node-review-sample

ignore this repo, I'm making some tests
1
star
37

node-filter

Filters to validate values (inspired from PHP's filters API) for Node.js
JavaScript
1
star
38

formation-react-2021-04

Human Coders
CSS
1
star
39

file-share-server

Sample code for BlendWebMix '14
JavaScript
1
star
40

sublime-text-2__config

Ma configuration ST2
Python
1
star
41

formation-react-2020-05

CSS
1
star
42

punch-markdown-highlight

Add syntax highlighting in your Punch contents
JavaScript
1
star
43

Mime-CMS

Draft for a Content Management System based on mime types and intents
1
star
44

demo-json-schema

For PHP Tour Nantes 2012
PHP
1
star
45

doggybag

Stuff we share across our projects. It's like a toolbox but it smells good!
JavaScript
1
star
46

naholyr.github.com

Ruby
1
star
47

formation-react-2016-09

All your base are belong to us
HTML
1
star
48

node-jus-config

Configuration loader for Node.JS, supporting multiple file formats, and loading over multiple directories to allow overriding. Used by Jus framework.
JavaScript
1
star
49

formation-node-2016-10-10

Formation Node 10/10 - 12/10
HTML
1
star
50

node-pending-streams

Streams for pending files
JavaScript
1
star