/** * 解压图片ID * @param string $id 十六进制 * @param array * <code>array( * 'node_id', * 'img_id', * 'width', * 'height', * 'type', * 'ext', * )</code> */ function unpackId($id64) { if (strlen($id64) != 23) { return false; } if (!self::$map64) { $bmap = array(); for ($i = 0; $i < 64; $i++) { $bmap[$i] = self::$base64[$i]; } self::$map64 = $bmap = array_flip($bmap); } else { $bmap = self::$map64; } $id16 = ''; $bins = array(); for ($i = 0; $i < 23; $i += 4) { $bins[] = $bmap[$id64[$i]] << 2 | $bmap[$id64[$i + 1]] >> 4; $bins[] = ($bmap[$id64[$i + 1]] & 0xf) << 4 | $bmap[$id64[$i + 2]] >> 2; if ($i < 20) { $bins[] = ($bmap[$id64[$i + 2]] & 0x3) << 6 | $bmap[$id64[$i + 3]]; } } $type = $bins[16] & 0xf; if (!isset($this->imageExts[$type])) { return false; } $nodeId = $bins[0] << 8 | $bins[1]; $incrId = $bins[2] << 24 | $bins[3] << 16 | $bins[4] << 8 | $bins[5]; $blockId = $bins[6] << 16 | $bins[7] << 8 | $bins[8]; $fileId = $bins[9] << 24 | $bins[10] << 16 | $bins[11] << 8 | $bins[12]; $width = $bins[13] << 6 | $bins[14] >> 2; $height = ($bins[14] & 0x3) << 12 | $bins[15] << 4 | $bins[16] >> 4; return array('node_id' => $nodeId, 'incr_id' => $incrId, 'block_id' => $blockId, 'file_id' => $fileId, 'width' => $width, 'height' => $height, 'type' => $type, 'ext' => $this->imageExts[$type]); }
function post_edit_action() { $data = $_POST['data']; $api = new StorageExport(); $api->updateNode(intval($data['node_id']), $data); header('Location: /guanli/node/'); }
/** * 备份图片 */ function post_backup_action() { $datas = $this->gets('img_id', 'from', 'blob'); $api = new StorageExport(); $api->doBackup($datas['img_id'], $datas['blob'], $datas['from']); }