Programming - a large cat nest, void cat https://anbig.com AnBig void cat Tue, 26 Sep 2023 09:56:53 +0000 zh-CN hourly one https://wordpress.org/?v=6.5.4 JS invalidates all timers https://anbig.com/2023/09/26/js%e4%bd%bf%e5%ae%9a%e6%97%b6%e5%99%a8%e5%85%a8%e9%83%a8%e5%a4%b1%e6%95%88/ https://anbig.com/2023/09/26/js%e4%bd%bf%e5%ae%9a%e6%97%b6%e5%99%a8%e5%85%a8%e9%83%a8%e5%a4%b1%e6%95%88/#respond Tue, 26 Sep 2023 09:56:52 +0000 https://anbig.com/?p=1436
 Function.prototype.temp_constructor= Function.prototype.constructor; Function.prototype.constructor=function(){ if (arguments && typeof arguments[0]==="string"){ if (arguments[0]==="debugger") return "" } return Function.prototype.temp_constructor.apply(this, arguments); }; //The hook timer function replaces the debugger _setInterval = setInterval setInterval = function setInterval(code, time){ console.log(code, time) code = code.toString().replace(/debugger/, "").replace(/function ()/, "function xxx") return _setInterval(new Function(code) , time) } _setTimeout = setTimeout setTimeout = function setTimeout(code, time){ console.log(code, time) code = code.toString().replace(/debugger/, "").replace(/function ()/, "function xxx") return _setTimeout(new Function(code), time) }
]]>
https://anbig.com/2023/09/26/js%e4%bd%bf%e5%ae%9a%e6%97%b6%e5%99%a8%e5%85%a8%e9%83%a8%e5%a4%b1%e6%95%88/feed/ zero
MySQL deletes duplicate data and only keeps the latest https://anbig.com/2022/11/15/mysql-%e5%88%a0%e9%99%a4%e9%87%8d%e5%a4%8d%e6%95%b0%e6%8d%ae%e5%8f%aa%e4%bf%9d%e7%95%99%e6%9c%80%e6%96%b0/ https://anbig.com/2022/11/15/mysql-%e5%88%a0%e9%99%a4%e9%87%8d%e5%a4%8d%e6%95%b0%e6%8d%ae%e5%8f%aa%e4%bf%9d%e7%95%99%e6%9c%80%e6%96%b0/#respond Tue, 15 Nov 2022 01:02:23 +0000 https://anbig.com/?p=1222 delete from fa_posts where id not in ( select max(id) from fa_posts group by content)


]]>
https://anbig.com/2022/11/15/mysql-%e5%88%a0%e9%99%a4%e9%87%8d%e5%a4%8d%e6%95%b0%e6%8d%ae%e5%8f%aa%e4%bf%9d%e7%95%99%e6%9c%80%e6%96%b0/feed/ zero
About the problem that the page in the iframe cannot set cookies (sessions) https://anbig.com/2021/11/03/%e5%85%b3%e4%ba%8eiframe -%e4%b8%ad%e9%a1%b5%e9%9d%a2%e6%97%a0%e6%b3%95%e8%ae%be%e7%bd%aecookie%ef%bc%88session%ef%bc%89%e9%97%ae%e9%a2%98/ https://anbig.com/2021/11/03/%e5%85%b3%e4%ba%8eiframe -%e4%b8%ad%e9%a1%b5%e9%9d%a2%e6%97%a0%e6%b3%95%e8%ae%be%e7%bd%aecookie%ef%bc%88session%ef%bc%89%e9%97%ae%e9%a2%98/#respond Wed, 03 Nov 2021 06:12:27 +0000 http://anbig.com/?p=1055 The reason is that the default value of SameSite in the browser is Lax

See https://www.ruanyifeng.com/blog/2019/09/cookie-samesite.html

Try the following methods respectively:

1. Direct setting of php code

 header('Set-Cookie: cross-site-cookie=name;  SameSite=None; Secure'); setcookie('cross-site-cookie', 'name', ['samesite' => 'None', 'secure' => true]); //This method seems feasible, but it needs to have a base class in the project, which can be set uniformly session_set_cookie_params(['samesite' => 'None', 'secure' => true]); $currentCookieParams = session_get_cookie_params(); $cookie_domain= 'your domain'; if (PHP_VERSION_ID >= 70300) { session_set_cookie_params([ 'lifetime' =>  $currentCookieParams["lifetime"], 'path' => '/', 'domain' => $cookie_domain, 'secure' => "1", 'httponly' => "1", 'samesite' => 'None', ]); } else { session_set_cookie_params( $currentCookieParams["lifetime"], '/;  samesite=None', $cookie_domain, "1", "1" ); } session_start(); //Waiting for verification
]]>
https://anbig.com/2021/11/03/%e5%85%b3%e4%ba%8eiframe -%e4%b8%ad%e9%a1%b5%e9%9d%a2%e6%97%a0%e6%b3%95%e8%ae%be%e7%bd%aecookie%ef%bc%88session%ef%bc%89%e9%97%ae%e9%a2%98/feed/ zero
Js implements preview before uploading pictures https://anbig.com/2017/02/27/js-%e5%ae%9e%e7%8e%b0%e5%9b%be%e7%89%87%e4%b8%8a%e4%bc%a0%e5%89%8d%e9%a2%84%e8%a7%88/ https://anbig.com/2017/02/27/js-%e5%ae%9e%e7%8e%b0%e5%9b%be%e7%89%87%e4%b8%8a%e4%bc%a0%e5%89%8d%e9%a2%84%e8%a7%88/#comments Mon, 27 Feb 2017 10:39:19 +0000 http://blog.anbig.com/?p=402

 <! DOCTYPE html>
< html >
< head lang = "en" >
< meta charset = "UTF-8" >
< title ></ title >
</ head >
< body >
< img src = "" alt = "" id = "Cimg" style = "width:200px; height:200px;border-radius:200px;border:1px solid red; " />
< input type = "file" id = "fi" onchange = "imagePreview(this)" />
< script type = "text/javascript" >
function imagePreview ( input ){
var files = input . files ;
//Assume that "preview" is the div of the image to be displayed
var preview = input . parentNode ;
for ( var i = zero ; i < files . length ; i ++ ) { //Preview the newly added picture
var file = files [ i ];
var imageType = /^image\// ;
if ( ! imageType . test ( file . type ) ) {
alert ( "Please select a picture type to upload" );
continue ;
}
var img = document . getElementById ( "Cimg" )
img . classList . add ( "obj" );
img . file = file ;
img . style . width = "100px" ;
preview . appendChild ( img );
var reader = new FileReader ();
reader . onload = ( function ( aImg ) {
return function ( e ) {
aImg . src = e . target . result ;
};
})( img );
reader . readAsDataURL ( file );
}
}
</ script >

</ script >
</ body >
</ html >

]]>
https://anbig.com/2017/02/27/js-%e5%ae%9e%e7%8e%b0%e5%9b%be%e7%89%87%e4%b8%8a%e4%bc%a0%e5%89%8d%e9%a2%84%e8%a7%88/feed/ one
C # Use opengl to draw a solid circle https://anbig.com/2017/02/15/c-%e4%bd%bf%e7%94%a8opengl%e7%94%bb%e5%ae%9e%e5%bf%83%e5%9c%86/ https://anbig.com/2017/02/15/c-%e4%bd%bf%e7%94%a8opengl%e7%94%bb%e5%ae%9e%e5%bf%83%e5%9c%86/#comments Wed, 15 Feb 2017 00:06:38 +0000 http://blog.anbig.com/?p=399 public void Fill_Circle(Brush brushh, Point pnt,int r)
{
if (opengl)
{
double M_PI = 3.1415926;
double inc = M_PI / 12;
double max = 2 * M_PI;
GL.Begin(PrimitiveType. TriangleFan);
GL.Color4(((SolidBrush)brushh). Color);

int x = pnt.X;
int y = pnt.Y;
for (double d = 0; d < max; d += inc)
{
GL.Vertex2(Math. Cos(d) * r + x, Math.Sin(d) * r + y);
}

GL.End();
}
else
{
//graphicsObjectGDIP. FillPolygon(brushh, list);
}
}

]]>
https://anbig.com/2017/02/15/c-%e4%bd%bf%e7%94%a8opengl%e7%94%bb%e5%ae%9e%e5%bf%83%e5%9c%86/feed/ five
PHP adds watermark to the picture https://anbig.com/2017/02/12/php%e7%bb%99%e5%9b%be%e7%89%87%e6%b7%bb%e5%8a%a0%e6%b0%b4%e5%8d%b0/ https://anbig.com/2017/02/12/php%e7%bb%99%e5%9b%be%e7%89%87%e6%b7%bb%e5%8a%a0%e6%b0%b4%e5%8d%b0/#respond Sun, 12 Feb 2017 12:34:09 +0000 http://blog.anbig.com/?p=396 <? php $img_src ="bg.png"; $img = imagecreatefrompng($img_src); $black = imagecolorallocate($img, 0, 0, 0); $text = $_GET['text']; $font ="acgfont.ttf"; imagefttext($img, 12, 0, 20, 45, $black, $font, $text); header("content-type: image/png"); //Transparent processing imagesavealpha($img, true); //Imagealphablending ($resize_im, false);//Do not merge colors, and directly replace them with $im image colors, including transparent colors; //Imagesavealpha ($resize_im, true);//Don't lose the transparent color of the $resize_im image; imagepng($img); imagedestroy($img); ?> ]]> https://anbig.com/2017/02/12/php%e7%bb%99%e5%9b%be%e7%89%87%e6%b7%bb%e5%8a%a0%e6%b0%b4%e5%8d%b0/feed/ zero Noejs obtains remote json data https://anbig.com/2017/01/14/noejs-%e8%8e%b7%e5%8f%96%e8%bf%9c%e7%a8%8bjson%e6%95%b0%e6%8d%ae/ https://anbig.com/2017/01/14/noejs-%e8%8e%b7%e5%8f%96%e8%bf%9c%e7%a8%8bjson%e6%95%b0%e6%8d%ae/#respond Sat, 14 Jan 2017 14:23:03 +0000 http://blog.anbig.com/?p=390 var http =require("http")
var server = http.createServer(function(req, res){}).listen(8877);
var url1 = "xxx.com/json"

http.get(url1, function(res){
var json = "";

res.setEncoding("utf8"); // If it is a resource type, it needs to be set to binary
res.on("data", function(chunk){
json+=chunk;
});

res.on("end", function(){
console.log(json)
});
});

]]>
https://anbig.com/2017/01/14/noejs-%e8%8e%b7%e5%8f%96%e8%bf%9c%e7%a8%8bjson%e6%95%b0%e6%8d%ae/feed/ zero
Open File Identifier https://anbig.com/2016/10/13/%e6%89%93%e5%bc%80%e6%96%87%e4%bb%b6%e6%a0%87%e8%af%86%e7%ac%a6/ https://anbig.com/2016/10/13/%e6%89%93%e5%bc%80%e6%96%87%e4%bb%b6%e6%a0%87%e8%af%86%e7%ac%a6/#respond Thu, 13 Oct 2016 15:08:26 +0000 http://blog.anbig.com/?p=335 parameter pathname Pointing to the file path string to be opened . The following are parameters flags Flags that can be used :

O_RDONLY Open file as read-only

O_WRONLY Open file in write only mode

O_RDWR Open file in read-write mode . The above three flags are mutually exclusive, that is, they cannot be used at the same time, but they can be used with the following flags OR ( | )Operator combination .

O_CREAT If the file to be opened does not exist, the file will be created automatically .

O_EXCL If O_CREAT This command will check whether the file exists . If the file does not exist, the file will be created; otherwise, the file will be opened incorrectly . In addition, if O_CREAT And O_EXCL At the same time, if the file to be opened is a symbolic connection, the file will fail to be opened .

O_NOCTTY If the file to be opened is a terminal device, the terminal will not be regarded as a process control terminal .

O_TRUNC If the file exists and is opened in a writable manner, this flag will clear the file length as zero , and the data originally stored in the file will also disappear .

O_APPEND When reading or writing a file, it will move from the end of the file, that is, the written data will be added to the end of the file in an additional way .

O_NONBLOCK Open the file in an unblocked way, that is, whether there is data reading or waiting, it will immediately return to the process .

O_NDELAY with O_NONBLOCK.

O_SYNC Open files in sync .

O_NOFOLLOW If the parameter pathname If the file referred to is a symbolic connection, the file opening will fail .

O_DIRECTORY If the parameter pathname If the file you are referring to is not a directory, opening the file will fail. Note: This is Linux2. 2 Special flag in the future to avoid some system security problems

]]>
https://anbig.com/2016/10/13/%e6%89%93%e5%bc%80%e6%96%87%e4%bb%b6%e6%a0%87%e8%af%86%e7%ac%a6/feed/ zero
C language to obtain the file list under the file directory https://anbig.com/2016/09/09/c-%e8%af%ad%e8%a8%80 -%e8%8e%b7%e5%8f%96%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e4%b8%8b%e6%96%87%e4%bb%b6%e5%88%97%e8%a1%a8/ https://anbig.com/2016/09/09/c-%e8%af%ad%e8%a8%80 -%e8%8e%b7%e5%8f%96%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e4%b8%8b%e6%96%87%e4%bb%b6%e5%88%97%e8%a1%a8/#comments Fri, 09 Sep 2016 01:46:02 +0000 http://blog.anbig.com/?p=328 #include <sys/types.h> #include <dirent.h> #include <unistd.h> #include <stdio.h> int main(){ DIR *dir; struct dirent *ptr; dir = opendir("."); /// open the dir while((ptr = readdir(dir)) != NULL) ///read the list of this dir { #ifdef _WIN32 printf("d_name: %s\n", ptr->d_name); #endif #ifdef __linux printf("d_type:%d d_name: %s\n", ptr->d_type,ptr->d_name); #endif } closedir(dir); return 0; } ]]> https://anbig.com/2016/09/09/c-%e8%af%ad%e8%a8%80 -%e8%8e%b7%e5%8f%96%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95%e4%b8%8b%e6%96%87%e4%bb%b6%e5%88%97%e8%a1%a8/feed/ one Jquery js parent window calls child window functions compatible https://anbig.com/2016/03/04/jquery-js-%e7%88%b6%e7%aa%97%e5%8f%a3%e8%b0%83%e7%94%a8%e5%ad%90%e7%aa%97%e5%8f%a3%e5%87%bd%e6%95%b0 -%e5%85%bc%e5%ae%b9/ https://anbig.com/2016/03/04/jquery-js-%e7%88%b6%e7%aa%97%e5%8f%a3%e8%b0%83%e7%94%a8%e5%ad%90%e7%aa%97%e5%8f%a3%e5%87%bd%e6%95%b0 -%e5%85%bc%e5%ae%b9/#respond Fri, 04 Mar 2016 10:02:45 +0000 http://blog.anbig.com/?p=161 Basically compatible with all browsers

 $(window.parent.document).contents().find("#gamePlay")[0].contentWindow.startGame();

StartGame() is the js function of the iframe page. When testing, it was found that the function referencing js in the iframe could not be called directly, but the js function of the iframe html page could only be called first.

]]>
https://anbig.com/2016/03/04/jquery-js-%e7%88%b6%e7%aa%97%e5%8f%a3%e8%b0%83%e7%94%a8%e5%ad%90%e7%aa%97%e5%8f%a3%e5%87%bd%e6%95%b0 -%e5%85%bc%e5%ae%b9/feed/ zero