static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements) { zval retval; zval fname; if (Z_TYPE_P(rval) != IS_OBJECT) { return 0; } //??? TODO: resize before if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_P(rval), elements, 1)) { return 0; } ZVAL_DEREF(rval); if (Z_OBJCE_P(rval) != PHP_IC_ENTRY && zend_hash_str_exists(&Z_OBJCE_P(rval)->function_table, "__wakeup", sizeof("__wakeup")-1)) { ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1); BG(serialize_lock)++; call_user_function_ex(CG(function_table), rval, &fname, &retval, 0, 0, 1, NULL); BG(serialize_lock)--; zval_dtor(&fname); zval_dtor(&retval); } if (EG(exception)) { return 0; } return finish_nested_data(UNSERIALIZE_PASSTHRU); }
static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements) { zval retval; zval fname; HashTable *ht; if (Z_TYPE_P(rval) != IS_OBJECT) { return 0; } ht = Z_OBJPROP_P(rval); zend_hash_extend(ht, zend_hash_num_elements(ht) + elements, (ht->u.flags & HASH_FLAG_PACKED)); if (!process_nested_data(UNSERIALIZE_PASSTHRU, ht, elements, 1)) { return 0; } ZVAL_DEREF(rval); if (Z_OBJCE_P(rval) != PHP_IC_ENTRY && zend_hash_str_exists(&Z_OBJCE_P(rval)->function_table, "__wakeup", sizeof("__wakeup")-1)) { ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1); BG(serialize_lock)++; call_user_function_ex(CG(function_table), rval, &fname, &retval, 0, 0, 1, NULL); BG(serialize_lock)--; zval_dtor(&fname); zval_dtor(&retval); } if (EG(exception)) { return 0; } return finish_nested_data(UNSERIALIZE_PASSTHRU); }
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements) { zval *retval_ptr = NULL; zval fname; if (Z_TYPE_PP(rval) != IS_OBJECT) { return 0; } if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_PP(rval), elements, 1)) { return 0; } if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY && zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))) { INIT_PZVAL(&fname); ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0); BG(serialize_lock)++; call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC); BG(serialize_lock)--; } if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } if (EG(exception)) { return 0; } return finish_nested_data(UNSERIALIZE_PASSTHRU); }
PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) { void *next; zend_long i; var_entries *var_hash = (*var_hashx)->first; var_dtor_entries *var_dtor_hash = (*var_hashx)->first_dtor; zend_bool wakeup_failed = 0; zval wakeup_name; ZVAL_UNDEF(&wakeup_name); #if VAR_ENTRIES_DBG fprintf(stderr, "var_destroy(%ld)\n", var_hash?var_hash->used_slots:-1L); #endif while (var_hash) { next = var_hash->next; efree_size(var_hash, sizeof(var_entries)); var_hash = next; } while (var_dtor_hash) { for (i = 0; i < var_dtor_hash->used_slots; i++) { zval *zv = &var_dtor_hash->data[i]; #if VAR_ENTRIES_DBG fprintf(stderr, "var_destroy dtor(%p, %ld)\n", var_dtor_hash->data[i], Z_REFCOUNT_P(var_dtor_hash->data[i])); #endif /* Perform delayed __wakeup calls */ if (Z_EXTRA_P(zv) == VAR_WAKEUP_FLAG) { if (!wakeup_failed) { zval retval; if (Z_ISUNDEF(wakeup_name)) { ZVAL_STRINGL(&wakeup_name, "__wakeup", sizeof("__wakeup") - 1); } BG(serialize_lock)++; if (call_user_function_ex(CG(function_table), zv, &wakeup_name, &retval, 0, 0, 1, NULL) == FAILURE || Z_ISUNDEF(retval)) { wakeup_failed = 1; GC_FLAGS(Z_OBJ_P(zv)) |= IS_OBJ_DESTRUCTOR_CALLED; } BG(serialize_lock)--; zval_ptr_dtor(&retval); } else { GC_FLAGS(Z_OBJ_P(zv)) |= IS_OBJ_DESTRUCTOR_CALLED; } } i_zval_ptr_dtor(zv ZEND_FILE_LINE_CC); } next = var_dtor_hash->next; efree_size(var_dtor_hash, sizeof(var_dtor_entries)); var_dtor_hash = next; } zval_ptr_dtor_nogc(&wakeup_name); }
PHPAPI void php_var_unserialize_destroy(php_unserialize_data_t d) { /* fprintf(stderr, "UNSERIALIZE_DESTROY == lock: %u, level: %u\n", BG(serialize_lock), BG(unserialize).level); */ if (BG(serialize_lock) || BG(unserialize).level == 1) { var_destroy(&d); efree(d); } if (!BG(serialize_lock) && !--BG(unserialize).level) { BG(unserialize).data = NULL; } }
t_bool ft_parse(t_buff *buff, const char *parse) { if (ft_strchr(parse, BG(buff)) == NULL) return (false); buff->i++; while (!BEOF(buff)) { if (ft_strchr(parse, BG(buff)) == NULL) break ; buff->i++; } return (true); }
static int php_url_scanner_ex_activate(int type) { url_adapt_state_ex_t *ctx; if (type) { ctx = &BG(url_adapt_session_ex); } else { ctx = &BG(url_adapt_output_ex); } memset(ctx, 0, ((size_t) &((url_adapt_state_ex_t *)0)->tags)); return SUCCESS; }
static int php_ini_on_update_tags(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage, int type) { url_adapt_state_ex_t *ctx; char *key; char *tmp; char *lasts = NULL; if (type) { ctx = &BG(url_adapt_session_ex); } else { ctx = &BG(url_adapt_output_ex); } tmp = estrndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); if (ctx->tags) zend_hash_destroy(ctx->tags); else { ctx->tags = malloc(sizeof(HashTable)); if (!ctx->tags) { efree(tmp); return FAILURE; } } zend_hash_init(ctx->tags, 0, NULL, tag_dtor, 1); for (key = php_strtok_r(tmp, ",", &lasts); key; key = php_strtok_r(NULL, ",", &lasts)) { char *val; val = strchr(key, '='); if (val) { char *q; size_t keylen; *val++ = '\0'; for (q = key; *q; q++) { *q = tolower(*q); } keylen = q - key; zend_hash_str_add_mem(ctx->tags, key, keylen, val, strlen(val)+1); } } efree(tmp); return SUCCESS; }
long php_getgid(void) { TSRMLS_FETCH(); php_statpage(TSRMLS_C); return (BG(page_gid)); }
//PORT: LRESULT return (was UINT) LRESULT CEditSpinSlider::OnNcHitTest(CPoint point) { // TODO: Add your message handler code here and/or call default UINT ret = CEdit::OnNcHitTest(point); if(ret == HTNOWHERE) { ScreenToClient(&point); CRect Client; GetClientRect(&Client); CRect BG(Client.right,Client.top,Client.right+23,Client.bottom); CRect Up(Client.right,Client.top+1,Client.right+10,Client.top+(Client.Height()/2)-1); CRect Down = Up; Down.top = Up.bottom+1; Down.bottom = Client.bottom-1; CRect Right = Up; Right.bottom = Down.bottom; Right.left = Up.right+1; Right.right = Client.right+22; if(Up.PtInRect(point)) return 30; if(Down.PtInRect(point)) return 31; if(Right.PtInRect(point)) return 32; } return ret; }
static inline void php_url_scanner_reset_vars_impl(int type) { url_adapt_state_ex_t *url_state; if (type) { url_state = &BG(url_adapt_session_ex); } else { url_state = &BG(url_adapt_output_ex); } if (url_state->form_app.s) { ZSTR_LEN(url_state->form_app.s) = 0; } if (url_state->url_app.s) { ZSTR_LEN(url_state->url_app.s) = 0; } }
t_bool ft_parsespace(t_buff *buff) { if (!BIF(buff, &ft_isspace)) return (false); while (ft_isspace(BG(buff))) buff->i++; return (true); }
// タイトル画面 void game_title(AppEnv& app_env) { // 画像読み込み Texture title("res/png/sys01_logo.png"); // タイトルロゴ Texture start("res/png/sys02_start.png"); // スタートボタン Texture BG("res/png/bg01_gradation.png"); // 背景 // この処理内だけで使う変数 const short One_Second = 60; // 1秒 = 60.frame const short Logo_Line = 8; // 描画サイズ const short Draw_Limit = Logo_Ha - Logo_Line; // 描画アニメの終了判定 short time_count = 0; // タイマー short blink = 0; // 点滅アニメーション float draw_y = 0; // ロゴ変化アニメ:描画位置 while (1) { if (!app_env.isOpen()) { return; } // 左クリックでループ終了 if (app_env.isPushButton(Mouse::LEFT)) { app_env.flushInput(); return; } // 画像の点滅処理 { blink = (time_count / 30) % 2; time_count++; if (time_count == One_Second) { time_count = 0; } // 1秒カウントしたらリセット } // タイトルロゴに変化をつける処理 { draw_y += 1.5; if (draw_y >= Draw_Limit) { draw_y = 0; } // 描画位置をリセット } app_env.setupDraw(); // 背景表示 drawTextureBox((-Window::WIDTH / 2), (-Window::HEIGHT / 2), Window::WIDTH, Window::HEIGHT, 0, 0, Bg_W, Bg_H, BG, Color(0, 0, 0, 0.5)); // タイトルロゴ表示 drawTextureBox((-Logo_W * 1), (Logo_Ha * 1), Logo_W * 2, Logo_Ha, 0, 0, Logo_W, Logo_Ha, title, Color(1, 0.75, 0.5)); drawTextureBox((-Logo_W * 1), (Logo_Ha * 1) + draw_y, Logo_W * 2, Logo_Line, 0, (Logo_Ha - Logo_Line) - draw_y, Logo_W, Logo_Line, title, Color(1, 1, 1)); // クリックスタート drawTextureBox((-Logo_W * 0.5), (-Logo_Hb * 2), Logo_W, Logo_Hb, 0, 0, Logo_W, Logo_Hb, start, Color(1, 1, 0.5, blink)); app_env.update(); } }
static int php_url_scanner_ex_deactivate(int type) { url_adapt_state_ex_t *ctx; if (type) { ctx = &BG(url_adapt_session_ex); } else { ctx = &BG(url_adapt_output_ex); } smart_str_free(&ctx->result); smart_str_free(&ctx->buf); smart_str_free(&ctx->tag); smart_str_free(&ctx->arg); smart_str_free(&ctx->attr_val); return SUCCESS; }
void drawtext(DC *dc, const char *text, Color col[ColLast], int x_offs, int force_width, int breaklines) { XSetForeground(dc->dpy, dc->gc, BG(dc, col)); XFillRectangle(dc->dpy, dc->canvas, dc->gc, dc->x, dc->y, dc->w, dc->h); if(!text) return; set_text(dc, text, force_width, breaklines); pango_xft_render_layout(dc->xftdrawable, &col[ColFG].xft, dc->plo, (dc->x + x_offs) * PANGO_SCALE, dc->y * PANGO_SCALE); }
static int check_host_whitelist(url_adapt_state_ex_t *ctx) { php_url *url_parts = NULL; HashTable *allowed_hosts = ctx->type ? &BG(url_adapt_session_hosts_ht) : &BG(url_adapt_output_hosts_ht); ZEND_ASSERT(ctx->tag_type == TAG_FORM); if (ctx->attr_val.s && ZSTR_LEN(ctx->attr_val.s)) { url_parts = php_url_parse_ex(ZSTR_VAL(ctx->attr_val.s), ZSTR_LEN(ctx->attr_val.s)); } else { return SUCCESS; /* empty URL is valid */ } if (!url_parts) { return FAILURE; } if (url_parts->scheme) { /* Only http/https should be handled. A bit hacky check this here, but saves a URL parse. */ if (strcasecmp(url_parts->scheme, "http") && strcasecmp(url_parts->scheme, "https")) { php_url_free(url_parts); return FAILURE; } } if (!url_parts->host) { php_url_free(url_parts); return SUCCESS; } if (!zend_hash_num_elements(allowed_hosts) && check_http_host(url_parts->host) == SUCCESS) { php_url_free(url_parts); return SUCCESS; } if (!zend_hash_str_find(allowed_hosts, url_parts->host, strlen(url_parts->host))) { php_url_free(url_parts); return FAILURE; } php_url_free(url_parts); return SUCCESS; }
int main(int argc, char * argv[]) { //Load the config and apply //Load the configs of screen win_w = cfg.Load(KEY_WINWIDTH); win_h = cfg.Load(KEY_WINHEIGHT); //Load the volumn and apply snd.ApplyCfg(BGMCN, cfg.Load(BGMCN)); snd.ApplyCfg(SECN, cfg.Load(SECN)); snd.ApplyCfg(VCECN, cfg.Load(VCECN)); //Init SDL_Init(SDL_INIT_EVENTS); win = SDL_CreateWindow("MaikazeSekai", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, win_w, win_h, SDL_WINDOW_OPENGL); ren = SDL_CreateRenderer(win, -1, 0); SDL_RenderSetLogicalSize(ren, 1280, 720); blk = SDL_CreateTexture(ren, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, win_w, win_h); //sent the renderer to Class Image as a stage and init them with the FileMgr img.Init(ren, &file); snd.Init(&file); auto *rw = SDL_RWFromFile("z:/star.png", "r"); auto sur = IMG_Load_RW(rw, AUTOFREE); auto tex = SDL_CreateTextureFromSurface(ren, sur); SDL_FreeSurface(sur); SDL_Rect rt = { 0, 0, 2362, 7087 }; SDL_RenderCopy(ren, tex, NULL, &rt); SDL_RenderPresent(ren); SDL_DestroyTexture(tex); auto *rw2 = SDL_RWFromFile("z:/1.png", "r"); auto sur2 = IMG_Load_RW(rw2, AUTOFREE); auto tex2 = SDL_CreateTextureFromSurface(ren, sur2); SDL_FreeSurface(sur2); SDL_Rect rt2 = { 0, 0, 800, 900 }; SDL_RenderCopy(ren, tex2, NULL, &rt2); SDL_RenderPresent(ren); //SDL_DestroyTexture(tex); // BGM("yui.wav", 1, 0); BG("sample.png"); img.OnDraw(); //Refresh the textures on renderer SDL_RenderPresent(ren); UnLoadBG(); //SDL_DestroyTexture() //Logo(); //Title(); SDL_Quit(); return 0; }
void drawmenu(void) { int curpos; Item *item; dc->x = 0; dc->y = 0; dc->h = bh; drawrect(dc, 0, 0, mw, mh, True, BG(dc, normcol)); if(prompt && *prompt) { dc->w = promptw; drawtext(dc, prompt, selcol); dc->x = dc->w; } /* draw input field */ dc->w = (lines > 0 || !matches) ? mw - dc->x : inputw; drawtext(dc, text, normcol); if((curpos = textnw(dc, text, cursor) + dc->h/2 - 2) < dc->w) drawrect(dc, curpos, 2, 1, dc->h - 4, True, FG(dc, normcol)); /* // Draw hits */ dc->w = textw(dc, hitstxt); dc->x = mw - dc->w; drawtext(dc, hitstxt, selcol); dc->x = 0; if(lines > 0) { /* draw vertical list */ dc->w = mw - dc->x; for(item = curr; item != next; item = item->right) { dc->y += dc->h; drawtext(dc, item->text, (item == sel) ? selcol : (item->out) ? outcol : normcol); } } else if(matches) { /* draw horizontal list */ dc->x += inputw; dc->w = textw(dc, "<"); if(curr->left) drawtext(dc, "<", normcol); for(item = curr; item != next; item = item->right) { dc->x += dc->w; dc->w = MIN(textw(dc, item->text), mw - dc->x - textw(dc, ">")); drawtext(dc, item->text, (item == sel) ? selcol : (item->out) ? outcol : normcol); } dc->w = textw(dc, ">"); dc->x = mw - dc->w; if(next) drawtext(dc, ">", normcol); } mapdc(dc, win, mw, mh); }
static int php_ini_on_update_hosts(zend_ini_entry *entry, zend_string *new_value, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage, int type) { HashTable *hosts; char *key; char *tmp; char *lasts = NULL; if (type) { hosts = &BG(url_adapt_session_hosts_ht); } else { hosts = &BG(url_adapt_output_hosts_ht); } zend_hash_clean(hosts); /* Use user supplied host whitelist */ tmp = estrndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); for (key = php_strtok_r(tmp, ",", &lasts); key; key = php_strtok_r(NULL, ",", &lasts)) { size_t keylen; zend_string *tmp_key; char *q; for (q = key; *q; q++) { *q = tolower(*q); } keylen = q - key; if (keylen > 0) { tmp_key = zend_string_init(key, keylen, 0); zend_hash_add_empty_element(hosts, tmp_key); zend_string_release(tmp_key); } } efree(tmp); return SUCCESS; }
s32 main(s32 argc, const char* argv[]) { padInfo padinfo ; padData paddata ; sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, eventHandler, NULL); ioPadInit(7); pngData png; NoRSX *GFX = new NoRSX(); Image IMG(GFX); Background BG(GFX); Object OBJ(GFX); Font F(GFX); IMG.LoadPNG_Buf(NoRSX_Image_bin,NoRSX_Image_bin_size, &png); u32 imgX =(GFX->width/2)-(png.width/2), imgY = (GFX->height/2)-(png.height/2); exitapp = 1; int frame=0; while(exitapp){ static time_t starttime = 0; double fps = 0; if (starttime == 0) starttime = time (NULL); else fps = frame / difftime (time (NULL), starttime); ioPadGetInfo(&padinfo); if(padinfo.status[0]){ ioPadGetData(0, &paddata); if(paddata.BTN_CROSS){ exitapp = 0; } } BG.Mono(0xb4e83a); //a green hex color (you can use hex colors insted of COLOR_XXXXXXX) OBJ.Circle(400,900,100,COLOR_YELLOW); OBJ.Rectangle(500,400,200,500,COLOR_ORANGE); OBJ.Line(400,400,900,100,COLOR_GREY); IMG.AlphaDrawIMG(imgX,imgY,&png); F.Printf(150,200,COLOR_BLACK,"SCREEN %d X %d",GFX->width,GFX->height); F.Print(150,250,COLOR_YELLOW,"PRESS X TO EXIT"); F.Printf(150,100,COLOR_GREEN,"FPS %f", fps); GFX->Flip(); frame ++; sysUtilCheckCallback(); } GFX->NoRSX_Exit(); ioPadEnd(); return 0; }
static inline void php_url_scanner_session_handler_impl(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode, int type) { size_t len; url_adapt_state_ex_t *url_state; if (type) { url_state = &BG(url_adapt_session_ex); } else { url_state = &BG(url_adapt_output_ex); } if (ZSTR_LEN(url_state->url_app.s) != 0) { *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0), url_state); if (sizeof(uint32_t) < sizeof(size_t)) { if (len > UINT_MAX) len = UINT_MAX; } *handled_output_len = len; } else if (ZSTR_LEN(url_state->url_app.s) == 0) { url_adapt_state_ex_t *ctx = url_state; if (ctx->buf.s && ZSTR_LEN(ctx->buf.s)) { smart_str_append(&ctx->result, ctx->buf.s); smart_str_appendl(&ctx->result, output, output_len); *handled_output = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s)); *handled_output_len = ZSTR_LEN(ctx->buf.s) + output_len; smart_str_free(&ctx->buf); smart_str_free(&ctx->result); } else { *handled_output = estrndup(output, *handled_output_len = output_len); } } else { *handled_output = NULL; } }
/* {{{ php_statpage */ PHPAPI void php_statpage(TSRMLS_D) { struct stat *pstat; pstat = sapi_get_stat(TSRMLS_C); if (BG(page_uid)==-1 || BG(page_gid)==-1) { if(pstat) { BG(page_uid) = pstat->st_uid; BG(page_gid) = pstat->st_gid; BG(page_inode) = pstat->st_ino; BG(page_mtime) = pstat->st_mtime; } else { /* handler for situations where there is no source file, ex. php -r */ BG(page_uid) = getuid(); BG(page_gid) = getgid(); } } }
int print_line(int row, line *l) { if (l < ccur->chat) l += SCROLLBACK_BUFFER; if (!l->len || l == ccur->cur_line) return 3; int count = 1; char *ptr1, *ptr2, *wrap; ptr1 = l->text; ptr2 = l->text + l->len; while ((ptr1 = word_wrap(ptr1, ptr2)) != NULL && ptr1 != ptr2) count++; if (row - count > 2) row = print_line(row - count, l - 1) + count - 1; ptr1 = l->text; if ((wrap = word_wrap(ptr1, ptr2)) != NULL) row = print_more(wrap, ptr2, row); else wrap = ptr2; int from_fg; char *from_bg = ""; if (l->type == LINE_JOIN || l->type == LINE_PART || l->type == LINE_QUIT) from_fg = 239; else if (l->type == LINE_PINGED) from_fg = 255, from_bg = BG(1); else from_fg = nick_col(l->from); if (row > 2) { printf("\x1b[%d;1H\x1b[2K", row); printf(FG(239)" %02d:%02d %*s"FG(%d)"%s%s"BG_R FG(239)" ~ "FG(250), l->time_h, l->time_m, (int)(ccur->nick_pad - strlen(l->from)), "", from_fg, from_bg, l->from); while (ptr1 < wrap) putchar(*ptr1++); }
void drawtext(DC *dc, const char *text, Bool fill, unsigned long col[ColLast]) { char buf[BUFSIZ]; size_t mn, n = strlen(text); /* shorten text if necessary */ for(mn = MIN(n, sizeof buf); textnw(dc, text, mn) + dc->font.height/2 > dc->w; mn--) if(mn == 0) return; memcpy(buf, text, mn); if(mn < n) for(n = MAX(mn-3, 0); n < mn; buf[n++] = '.'); if(fill) drawrect(dc, 0, 0, dc->w, dc->h, True, BG(dc, col)); drawtextn(dc, buf, mn, col); }
static PHP_INI_MH(OnUpdateTags) { url_adapt_state_ex_t *ctx; char *key; char *lasts; char *tmp; ctx = &BG(url_adapt_state_ex); tmp = estrndup(new_value, new_value_length); if (ctx->tags) zend_hash_destroy(ctx->tags); else { ctx->tags = malloc(sizeof(HashTable)); if (!ctx->tags) { return FAILURE; } } zend_hash_init(ctx->tags, 0, NULL, NULL, 1); for (key = php_strtok_r(tmp, ",", &lasts); key; key = php_strtok_r(NULL, ",", &lasts)) { char *val; val = strchr(key, '='); if (val) { char *q; int keylen; *val++ = '\0'; for (q = key; *q; q++) *q = tolower(*q); keylen = q - key; /* key is stored withOUT NUL val is stored WITH NUL */ zend_hash_add(ctx->tags, key, keylen, val, strlen(val)+1, NULL); } } efree(tmp); return SUCCESS; }
PHPAPI php_unserialize_data_t php_var_unserialize_init() { php_unserialize_data_t d; /* fprintf(stderr, "UNSERIALIZE_INIT == lock: %u, level: %u\n", BG(serialize_lock), BG(unserialize).level); */ if (BG(serialize_lock) || !BG(unserialize).level) { d = ecalloc(1, sizeof(struct php_unserialize_data)); if (!BG(serialize_lock)) { BG(unserialize).data = d; BG(unserialize).level = 1; } } else { d = BG(unserialize).data; ++BG(unserialize).level; } return d; }
PHPAPI long php_getlastmod(TSRMLS_D) { php_statpage(TSRMLS_C); return BG(page_mtime); }
PHPAPI int php_var_unserialize_ex(UNSERIALIZE_PARAMETER) { const unsigned char *cursor, *limit, *marker, *start; zval *rval_ref; limit = max; cursor = *p; if (YYCURSOR >= YYLIMIT) { return 0; } if (var_hash && (*p)[0] != 'R') { var_push(var_hash, rval); } start = cursor; #line 518 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; switch (yych) { case 'C': case 'O': goto yy13; case 'N': goto yy5; case 'R': goto yy2; case 'S': goto yy10; case 'a': goto yy11; case 'b': goto yy6; case 'd': goto yy8; case 'i': goto yy7; case 'o': goto yy12; case 'r': goto yy4; case 's': goto yy9; case '}': goto yy14; default: goto yy16; } yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: #line 873 "ext/standard/var_unserializer.re" { return 0; } #line 580 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; goto yy3; yy5: yych = *++YYCURSOR; if (yych == ';') goto yy87; goto yy3; yy6: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy83; goto yy3; yy7: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy77; goto yy3; yy8: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy53; goto yy3; yy9: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy46; goto yy3; yy10: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy39; goto yy3; yy11: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy32; goto yy3; yy12: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy25; goto yy3; yy13: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy17; goto yy3; yy14: ++YYCURSOR; #line 867 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } #line 629 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; yy17: yych = *++YYCURSOR; if (yybm[0+yych] & 128) { goto yy20; } if (yych == '+') goto yy19; yy18: YYCURSOR = YYMARKER; goto yy3; yy19: yych = *++YYCURSOR; if (yybm[0+yych] & 128) { goto yy20; } goto yy18; yy20: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yybm[0+yych] & 128) { goto yy20; } if (yych <= '/') goto yy18; if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; #line 722 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; zend_long elements; char *str; zend_string *class_name; zend_class_entry *ce; int incomplete_class = 0; int custom_object = 0; zval user_func; zval retval; zval args[1]; if (!var_hash) return 0; if (*start == 'C') { custom_object = 1; } len2 = len = parse_uiv(start + 2); maxlen = max - YYCURSOR; if (maxlen < len || len == 0) { *p = start + 2; return 0; } str = (char*)YYCURSOR; YYCURSOR += len; if (*(YYCURSOR) != '"') { *p = YYCURSOR; return 0; } if (*(YYCURSOR+1) != ':') { *p = YYCURSOR+1; return 0; } len3 = strspn(str, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\"); if (len3 != len) { *p = YYCURSOR + len3 - len; return 0; } class_name = zend_string_init(str, len, 0); do { if(!unserialize_allowed_class(class_name, classes)) { incomplete_class = 1; ce = PHP_IC_ENTRY; break; } /* Try to find class directly */ BG(serialize_lock)++; ce = zend_lookup_class(class_name); if (ce) { BG(serialize_lock)--; if (EG(exception)) { zend_string_release(class_name); return 0; } break; } BG(serialize_lock)--; if (EG(exception)) { zend_string_release(class_name); return 0; } /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) { incomplete_class = 1; ce = PHP_IC_ENTRY; break; } /* Call unserialize callback */ ZVAL_STRING(&user_func, PG(unserialize_callback_func)); ZVAL_STR_COPY(&args[0], class_name); BG(serialize_lock)++; if (call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL) != SUCCESS) { BG(serialize_lock)--; if (EG(exception)) { zend_string_release(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); return 0; } php_error_docref(NULL, E_WARNING, "defined (%s) but not found", Z_STRVAL(user_func)); incomplete_class = 1; ce = PHP_IC_ENTRY; zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); break; } BG(serialize_lock)--; zval_ptr_dtor(&retval); if (EG(exception)) { zend_string_release(class_name); zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); return 0; } /* The callback function may have defined the class */ if ((ce = zend_lookup_class(class_name)) == NULL) { php_error_docref(NULL, E_WARNING, "Function %s() hasn't defined the class it was called for", Z_STRVAL(user_func)); incomplete_class = 1; ce = PHP_IC_ENTRY; } zval_ptr_dtor(&user_func); zval_ptr_dtor(&args[0]); break; } while (1); *p = YYCURSOR; if (custom_object) { int ret; ret = object_custom(UNSERIALIZE_PASSTHRU, ce); if (ret && incomplete_class) { php_store_class_name(rval, ZSTR_VAL(class_name), len2); } zend_string_release(class_name); return ret; } elements = object_common1(UNSERIALIZE_PASSTHRU, ce); if (incomplete_class) { php_store_class_name(rval, ZSTR_VAL(class_name), len2); } zend_string_release(class_name); return object_common2(UNSERIALIZE_PASSTHRU, elements); } #line 805 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy26; if (yych <= '/') goto yy18; if (yych <= '9') goto yy27; goto yy18; } yy26: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy27: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy27; if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; #line 715 "ext/standard/var_unserializer.re" { if (!var_hash) return 0; return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } #line 837 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; if (yych <= '/') goto yy18; if (yych <= '9') goto yy34; goto yy18; yy33: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy34: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy34; if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; #line 691 "ext/standard/var_unserializer.re" { zend_long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ *p = YYCURSOR; if (!var_hash) return 0; if (elements < 0) { return 0; } array_init_size(rval, elements); //??? we can't convert from packed to hash during unserialization, because //??? reference to some zvals might be keept in var_hash (to support references) if (elements) { zend_hash_real_init(Z_ARRVAL_P(rval), 0); } if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL_P(rval), elements, 0)) { return 0; } return finish_nested_data(UNSERIALIZE_PASSTHRU); } #line 882 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; if (yych <= '/') goto yy18; if (yych <= '9') goto yy41; goto yy18; yy40: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy41: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy41; if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; #line 663 "ext/standard/var_unserializer.re" { size_t len, maxlen; zend_string *str; len = parse_uiv(start + 2); maxlen = max - YYCURSOR; if (maxlen < len) { *p = start + 2; return 0; } if ((str = unserialize_str(&YYCURSOR, len, maxlen)) == NULL) { return 0; } if (*(YYCURSOR) != '"') { zend_string_free(str); *p = YYCURSOR; return 0; } YYCURSOR += 2; *p = YYCURSOR; ZVAL_STR(rval, str); return 1; } #line 931 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; if (yych <= '/') goto yy18; if (yych <= '9') goto yy48; goto yy18; yy47: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy48: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy48; if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; #line 636 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; len = parse_uiv(start + 2); maxlen = max - YYCURSOR; if (maxlen < len) { *p = start + 2; return 0; } str = (char*)YYCURSOR; YYCURSOR += len; if (*(YYCURSOR) != '"') { *p = YYCURSOR; return 0; } YYCURSOR += 2; *p = YYCURSOR; ZVAL_STRINGL(rval, str, len); return 1; } #line 979 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { if (yych <= ',') { if (yych == '+') goto yy57; goto yy18; } else { if (yych <= '-') goto yy55; if (yych <= '.') goto yy60; goto yy18; } } else { if (yych <= 'I') { if (yych <= '9') goto yy58; if (yych <= 'H') goto yy18; goto yy56; } else { if (yych != 'N') goto yy18; } } yych = *++YYCURSOR; if (yych == 'A') goto yy76; goto yy18; yy55: yych = *++YYCURSOR; if (yych <= '/') { if (yych == '.') goto yy60; goto yy18; } else { if (yych <= '9') goto yy58; if (yych != 'I') goto yy18; } yy56: yych = *++YYCURSOR; if (yych == 'N') goto yy72; goto yy18; yy57: yych = *++YYCURSOR; if (yych == '.') goto yy60; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy58: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; if (yych <= ':') { if (yych <= '.') { if (yych <= '-') goto yy18; goto yy70; } else { if (yych <= '/') goto yy18; if (yych <= '9') goto yy58; goto yy18; } } else { if (yych <= 'E') { if (yych <= ';') goto yy63; if (yych <= 'D') goto yy18; goto yy65; } else { if (yych == 'e') goto yy65; goto yy18; } } yy60: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy61: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; if (yych <= ';') { if (yych <= '/') goto yy18; if (yych <= '9') goto yy61; if (yych <= ':') goto yy18; } else { if (yych <= 'E') { if (yych <= 'D') goto yy18; goto yy65; } else { if (yych == 'e') goto yy65; goto yy18; } } yy63: ++YYCURSOR; #line 627 "ext/standard/var_unserializer.re" { #if SIZEOF_ZEND_LONG == 4 use_double: #endif *p = YYCURSOR; ZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL)); return 1; } #line 1076 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy66; if (yych <= '/') goto yy18; if (yych <= '9') goto yy67; goto yy18; } yy66: yych = *++YYCURSOR; if (yych <= ',') { if (yych == '+') goto yy69; goto yy18; } else { if (yych <= '-') goto yy69; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; } yy67: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy67; if (yych == ';') goto yy63; goto yy18; yy69: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy67; goto yy18; yy70: ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; if (yych <= ';') { if (yych <= '/') goto yy18; if (yych <= '9') goto yy70; if (yych <= ':') goto yy18; goto yy63; } else { if (yych <= 'E') { if (yych <= 'D') goto yy18; goto yy65; } else { if (yych == 'e') goto yy65; goto yy18; } } yy72: yych = *++YYCURSOR; if (yych != 'F') goto yy18; yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; #line 611 "ext/standard/var_unserializer.re" { *p = YYCURSOR; if (!strncmp((char*)start + 2, "NAN", 3)) { ZVAL_DOUBLE(rval, php_get_nan()); } else if (!strncmp((char*)start + 2, "INF", 3)) { ZVAL_DOUBLE(rval, php_get_inf()); } else if (!strncmp((char*)start + 2, "-INF", 4)) { ZVAL_DOUBLE(rval, -php_get_inf()); } else { ZVAL_NULL(rval); } return 1; } #line 1151 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; goto yy18; yy77: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy78; if (yych <= '/') goto yy18; if (yych <= '9') goto yy79; goto yy18; } yy78: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy79: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; #line 585 "ext/standard/var_unserializer.re" { #if SIZEOF_ZEND_LONG == 4 int digits = YYCURSOR - start - 3; if (start[2] == '-' || start[2] == '+') { digits--; } /* Use double for large zend_long values that were serialized on a 64-bit system */ if (digits >= MAX_LENGTH_OF_LONG - 1) { if (digits == MAX_LENGTH_OF_LONG - 1) { int cmp = strncmp((char*)YYCURSOR - MAX_LENGTH_OF_LONG, long_min_digits, MAX_LENGTH_OF_LONG - 1); if (!(cmp < 0 || (cmp == 0 && start[2] == '-'))) { goto use_double; } } else { goto use_double; } } #endif *p = YYCURSOR; ZVAL_LONG(rval, parse_iv(start + 2)); return 1; } #line 1204 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= '2') goto yy18; yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; #line 579 "ext/standard/var_unserializer.re" { *p = YYCURSOR; ZVAL_BOOL(rval, parse_iv(start + 2)); return 1; } #line 1218 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; #line 573 "ext/standard/var_unserializer.re" { *p = YYCURSOR; ZVAL_NULL(rval); return 1; } #line 1227 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy90; if (yych <= '/') goto yy18; if (yych <= '9') goto yy91; goto yy18; } yy90: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy91: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; #line 548 "ext/standard/var_unserializer.re" { zend_long id; *p = YYCURSOR; if (!var_hash) return 0; id = parse_iv(start + 2) - 1; if (id == -1 || (rval_ref = var_access(var_hash, id)) == NULL) { return 0; } if (rval_ref == rval) { return 0; } if (Z_ISUNDEF_P(rval_ref) || (Z_ISREF_P(rval_ref) && Z_ISUNDEF_P(Z_REFVAL_P(rval_ref)))) { ZVAL_UNDEF(rval); return 1; } ZVAL_COPY(rval, rval_ref); return 1; } #line 1275 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { if (yych != '+') goto yy18; } else { if (yych <= '-') goto yy96; if (yych <= '/') goto yy18; if (yych <= '9') goto yy97; goto yy18; } yy96: yych = *++YYCURSOR; if (yych <= '/') goto yy18; if (yych >= ':') goto yy18; yy97: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy18; if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; #line 522 "ext/standard/var_unserializer.re" { zend_long id; *p = YYCURSOR; if (!var_hash) return 0; id = parse_iv(start + 2) - 1; if (id == -1 || (rval_ref = var_access(var_hash, id)) == NULL) { return 0; } zval_ptr_dtor(rval); if (Z_ISUNDEF_P(rval_ref) || (Z_ISREF_P(rval_ref) && Z_ISUNDEF_P(Z_REFVAL_P(rval_ref)))) { ZVAL_UNDEF(rval); return 1; } if (Z_ISREF_P(rval_ref)) { ZVAL_COPY(rval, rval_ref); } else { ZVAL_NEW_REF(rval_ref, rval_ref); ZVAL_COPY(rval, rval_ref); } return 1; } #line 1324 "ext/standard/var_unserializer.c" } #line 875 "ext/standard/var_unserializer.re" return 0; }
zend_long php_getgid(TSRMLS_D) { php_statpage(TSRMLS_C); return (BG(page_gid)); }
static void php_stat(const char *filename, php_stat_len filename_length, int type, pval *return_value) { struct stat *stat_sb; int rmask=S_IROTH,wmask=S_IWOTH,xmask=S_IXOTH; /* access rights defaults to other */ BLS_FETCH(); stat_sb = &BG(sb); if (!BG(CurrentStatFile) || strcmp(filename, BG(CurrentStatFile))) { if (!BG(CurrentStatFile) || filename_length > BG(CurrentStatLength)) { if (BG(CurrentStatFile)) { efree(BG(CurrentStatFile)); } BG(CurrentStatLength) = filename_length; BG(CurrentStatFile) = estrndup(filename, filename_length); } else { memcpy(BG(CurrentStatFile), filename, filename_length+1); } #if HAVE_SYMLINK BG(lsb).st_mode = 0; /* mark lstat buf invalid */ #endif if (VCWD_STAT(BG(CurrentStatFile), &BG(sb)) == -1) { if (!IS_LINK_OPERATION() && (type != 15 || errno != ENOENT)) { /* fileexists() test must print no error */ php_error(E_NOTICE,"stat failed for %s (errno=%d - %s)", BG(CurrentStatFile), errno, strerror(errno)); } efree(BG(CurrentStatFile)); BG(CurrentStatFile) = NULL; if (!IS_LINK_OPERATION()) { /* Don't require success for link operation */ RETURN_FALSE; } } } #if HAVE_SYMLINK if (IS_LINK_OPERATION() && !BG(lsb).st_mode) { /* do lstat if the buffer is empty */ if (VCWD_LSTAT(filename, &BG(lsb)) == -1) { php_error(E_NOTICE, "lstat failed for %s (errno=%d - %s)", filename, errno, strerror(errno)); RETURN_FALSE; } } #endif if (type >= 9 && type <= 11) { if(BG(sb).st_uid==getuid()) { rmask=S_IRUSR; wmask=S_IWUSR; xmask=S_IXUSR; } else if(BG(sb).st_gid==getgid()) { rmask=S_IRGRP; wmask=S_IWGRP; xmask=S_IXGRP; } else { int groups,n,i; gid_t *gids; groups = getgroups(0,NULL); if(groups) { gids=(gid_t *)emalloc(groups*sizeof(gid_t)); n=getgroups(groups,gids); for(i=0;i<n;i++){ if(BG(sb).st_gid==gids[i]) { rmask=S_IRGRP; wmask=S_IWGRP; xmask=S_IXGRP; break; } } efree(gids); } } } switch (type) { case 0: /* fileperms */ RETURN_LONG((long)BG(sb).st_mode); case 1: /* fileinode */ RETURN_LONG((long)BG(sb).st_ino); case 2: /* filesize */ RETURN_LONG((long)BG(sb).st_size); case 3: /* fileowner */ RETURN_LONG((long)BG(sb).st_uid); case 4: /* filegroup */ RETURN_LONG((long)BG(sb).st_gid); case 5: /* fileatime */ RETURN_LONG((long)BG(sb).st_atime); case 6: /* filemtime */ RETURN_LONG((long)BG(sb).st_mtime); case 7: /* filectime */ RETURN_LONG((long)BG(sb).st_ctime); case 8: /* filetype */ #if HAVE_SYMLINK if (S_ISLNK(BG(lsb).st_mode)) { RETURN_STRING("link",1); } #endif switch(BG(sb).st_mode&S_IFMT) { case S_IFIFO: RETURN_STRING("fifo",1); case S_IFCHR: RETURN_STRING("char",1); case S_IFDIR: RETURN_STRING("dir",1); case S_IFBLK: RETURN_STRING("block",1); case S_IFREG: RETURN_STRING("file",1); #if defined(S_IFSOCK) && !defined(ZEND_WIN32)&&!defined(__BEOS__) case S_IFSOCK: RETURN_STRING("socket",1); #endif } php_error(E_WARNING,"Unknown file type (%d)",BG(sb).st_mode&S_IFMT); RETURN_STRING("unknown", 1); case 9: /*is writable*/ if (getuid()==0) { RETURN_LONG(1); /* root */ } RETURN_LONG((BG(sb).st_mode & wmask) != 0); case 10: /*is readable*/ if (getuid()==0) { RETURN_LONG(1); /* root */ } RETURN_LONG((BG(sb).st_mode&rmask)!=0); case 11: /*is executable*/ if (getuid()==0) { xmask = S_IXROOT; /* root */ } RETURN_LONG((BG(sb).st_mode&xmask)!=0 && !S_ISDIR(BG(sb).st_mode)); case 12: /*is file*/ RETURN_LONG(S_ISREG(BG(sb).st_mode)); case 13: /*is dir*/ RETURN_LONG(S_ISDIR(BG(sb).st_mode)); case 14: /*is link*/ #if HAVE_SYMLINK RETURN_LONG(S_ISLNK(BG(lsb).st_mode)); #else RETURN_FALSE; #endif case 15: /*file exists*/ RETURN_TRUE; /* the false case was done earlier */ case 16: /* lstat */ #if HAVE_SYMLINK stat_sb = &BG(lsb); #endif /* FALLTHROUGH */ case 17: /* stat */ if (array_init(return_value) == FAILURE) { RETURN_FALSE; } add_next_index_long(return_value, stat_sb->st_dev); add_next_index_long(return_value, stat_sb->st_ino); add_next_index_long(return_value, stat_sb->st_mode); add_next_index_long(return_value, stat_sb->st_nlink); add_next_index_long(return_value, stat_sb->st_uid); add_next_index_long(return_value, stat_sb->st_gid); #ifdef HAVE_ST_RDEV add_next_index_long(return_value, stat_sb->st_rdev); #else add_next_index_long(return_value, -1); #endif add_next_index_long(return_value, stat_sb->st_size); add_next_index_long(return_value, stat_sb->st_atime); add_next_index_long(return_value, stat_sb->st_mtime); add_next_index_long(return_value, stat_sb->st_ctime); #ifdef HAVE_ST_BLKSIZE add_next_index_long(return_value, stat_sb->st_blksize); #else add_next_index_long(return_value, -1); #endif #ifdef HAVE_ST_BLOCKS add_next_index_long(return_value, stat_sb->st_blocks); #else add_next_index_long(return_value, -1); #endif /* Support string references as well as numerical*/ add_assoc_long ( return_value , "dev" , stat_sb->st_dev ); add_assoc_long ( return_value , "ino" , stat_sb->st_ino ); add_assoc_long ( return_value , "mode" , stat_sb->st_mode ); add_assoc_long ( return_value , "nlink" , stat_sb->st_nlink ); add_assoc_long ( return_value , "uid" , stat_sb->st_uid ); add_assoc_long ( return_value , "gid" , stat_sb->st_gid ); #ifdef HAVE_ST_RDEV add_assoc_long ( return_value, "rdev" , stat_sb->st_rdev ); #endif #ifdef HAVE_ST_BLKSIZE add_assoc_long ( return_value , "blksize" , stat_sb->st_blksize ); #endif add_assoc_long ( return_value , "size" , stat_sb->st_size ); add_assoc_long ( return_value , "atime" , stat_sb->st_atime ); add_assoc_long ( return_value , "mtime" , stat_sb->st_mtime ); add_assoc_long ( return_value , "ctime" , stat_sb->st_ctime ); #ifdef HAVE_ST_BLOCKS add_assoc_long ( return_value , "blocks" , stat_sb->st_blocks ); #endif return; } php_error(E_WARNING, "didn't understand stat call"); RETURN_FALSE; }