DemoController.php 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Exports\BasicExport;
  4. use App\Http\Filters\DemoFilter;
  5. use App\Http\Logics\Admin\SiteSyncLogic;
  6. use App\Http\Models\Agent;
  7. use App\Http\Models\Article;
  8. use App\Http\Models\HootsuiteUser;
  9. use App\Http\Models\ILog;
  10. use App\Http\Models\Link;
  11. use App\Http\Models\LinkTask;
  12. use App\Http\Models\LinkTaskDetail;
  13. use App\Http\Models\LinkTaskUrl;
  14. use App\Http\Models\MasterMeter;
  15. use App\Http\Models\Permission;
  16. use App\Http\Models\Project;
  17. use App\Http\Models\Role;
  18. use App\Http\Models\Site;
  19. use App\Http\Models\SiteProcess;
  20. use App\Http\Models\Social;
  21. use App\Http\Models\SocialPublish;
  22. use App\Http\Models\UrlCheck;
  23. use App\Http\Models\User;
  24. use App\Http\Models\WeekTaskInfo;
  25. use App\Imports\ArticleImport;
  26. use App\Imports\DemoImport;
  27. use App\Imports\DemoLinkImport;
  28. use App\Imports\DemoLinkTypeImport;
  29. use App\Jobs\TranArticle;
  30. use App\Libs\EasySms;
  31. use App\Libs\Translate;
  32. use App\Mail\Demo;
  33. use DirkGroenen\Pinterest\Pinterest;
  34. use Facebook\Facebook;
  35. use function foo\func;
  36. use GuzzleHttp\Client;
  37. use GuzzleHttp\Exception\ClientException;
  38. use GuzzleHttp\Exception\RequestException;
  39. use GuzzleHttp\Pool;
  40. use function GuzzleHttp\Promise\unwrap;
  41. use GuzzleHttp\Psr7\Request;
  42. use GuzzleHttp\Psr7\Response;
  43. use Illuminate\Contracts\View\Factory as ViewFactory;
  44. use Illuminate\Database\Eloquent\Collection;
  45. use Illuminate\Database\Query\Builder;
  46. use Illuminate\Support\Facades\Blade;
  47. use Illuminate\Support\Facades\Cache;
  48. use Illuminate\Support\Facades\Crypt;
  49. use Illuminate\Support\Facades\DB;
  50. use Illuminate\Support\Facades\File;
  51. use Illuminate\Support\Facades\Log;
  52. use Illuminate\Support\Facades\Mail;
  53. use Illuminate\Support\Facades\Redis;
  54. use Illuminate\Support\Facades\Route;
  55. use Illuminate\Support\Facades\Storage;
  56. use Illuminate\Support\Facades\View;
  57. use Illuminate\Support\Str;
  58. use Laravel\Socialite\Facades\Socialite;
  59. use Lightit\LinkedinShare\Facades\LinkedinShare;
  60. use Maatwebsite\Excel\Facades\Excel;
  61. use function PHPSTORM_META\type;
  62. use Psr\Http\Message\ResponseInterface;
  63. use Ramsey\Uuid\Uuid;
  64. use Thujohn\Twitter\Facades\Twitter;
  65. use afs\Request\V20180112 as Afs;
  66. //use Overtrue\EasySms\EasySms;
  67. class DemoController extends Controller
  68. {
  69. public function demo()
  70. {
  71. $a=xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY,[]);
  72. // Collection::
  73. return 123;
  74. }
  75. protected $method;
  76. /**site
  77. * var string $secret_key 加解密的密钥
  78. */
  79. protected $secret_key;
  80. /**
  81. * var string $iv 加解密的向量,有些方法需要设置比如CBC
  82. */
  83. protected $iv;
  84. /**
  85. * @R
  86. * var string $options (不知道怎么解释,目前设置为0没什么问题)
  87. */
  88. protected $options;
  89. public function encrypt($data)
  90. {
  91. return openssl_encrypt($data, $this->method, $this->secret_key, $this->options, $this->iv);
  92. }
  93. public function three()
  94. {
  95. $users = User::query()->get();
  96. foreach ($users as $u) {
  97. }
  98. $d = User::query()->get();
  99. dd($d);
  100. $u = User::query()->where(['raw' => 5])->first();
  101. dd($u);
  102. $records = User::query()->where(['dd' => 111])->get();
  103. dd($records->toArray());
  104. $records = [];
  105. $data = User::query()->where(['id' => 1])->first();
  106. dd($data);
  107. $user = User::query()->first();
  108. $userList = $user->limit(1)->get();
  109. foreach ($userList as $item) {
  110. $a = 1;
  111. }
  112. // $a = 'https://www.pinterest.com/vanshao86/api-demo/';
  113. //
  114. // $res = substr(preg_replace('/(http|https):\/\/www.pinterest.com\//i', '', $a), 0, -1);
  115. // dd($res);
  116. $social = Social::query()->where(['site_id' => 1, 'type' => 'pin'])->first();
  117. $pin = new Pinterest($social->app_id, $social->app_secret);
  118. $pin->auth->setOAuthToken($social->token);
  119. try {
  120. $pin->pins->create([
  121. "note" => time() . 'hello',
  122. "image_url" => "http://wall.yinqingli.com/storage/social/Y5bUoajNFpNGVN2yIw3FvU8mzu18jgCAkkTN9w1I.jpg",
  123. "board" => "hinaqin/api-demo",
  124. 'link' => 'http://www.sohu.com'
  125. ]);
  126. } catch (\Throwable $throwable) {
  127. dd($throwable->getMessage());
  128. }
  129. dd('success');
  130. //
  131. $boards = $pin->users->getMeBoards();
  132. $results = [];
  133. foreach ($boards as $item) {
  134. // $results[] = substr(preg_replace('/(http|https):\/\/www.pinterest.com\//i', '', $a), 0, -1);
  135. }
  136. dd($results);
  137. //
  138. // "url" => "https://www.pinterest.com/hinaqin/"
  139. // "first_name" => "hina"
  140. // "last_name" => "qin"
  141. // "id" => "844988086243903392"
  142. // $me = $pin->users->me();
  143. // dump($me);
  144. $state = $pin->auth->getState();
  145. dump($state);
  146. // $boards = $pin->users->getMeBoards();
  147. // dump($boards);
  148. // $boardDetail=$pin->boards->get("hina qin/api-demo");
  149. // dump($boardDetail);
  150. try {
  151. $pin->pins->create([
  152. "note" => "Test board from API",
  153. "image_url" => "http://admin.yinqingli.com/storage/201906/jpg/1Q987Ryl6mdPFhJljhy5O1EhPol9M79dSVFbGnod.jpeg",
  154. "board" => "hinaqin/api-demo"
  155. ]);
  156. } catch (\Throwable $throwable) {
  157. dd($throwable->getMessage());
  158. }
  159. dd('success');
  160. error_log(file_get_contents('php://input'));
  161. return '3';
  162. }
  163. public function four()
  164. {
  165. dd("hello");
  166. dd($this->facebook());
  167. // $uploaded_media = Twitter::uploadMedia(['media' => File::get(public_path('filename.jpg'))]);
  168. // return Twitter::postTweet(['status' => 'Laravel is beautiful', 'media_ids' => $uploaded_media->media_id_string]);
  169. $uploaded_media = Twitter::uploadMedia(['media' => File::get(public_path('filename.jpg'))]);
  170. Twitter::postTweet(['status' => 'Laravel is beautiful', 'media_ids' => $uploaded_media->media_id_string]);
  171. dd($this->twitter());
  172. }
  173. public function five()
  174. {
  175. $this->linked();
  176. }
  177. public function linked()
  178. {
  179. $img = 'http://admin.yinqingli.com/storage/201906/jpg/1Q987Ryl6mdPFhJljhy5O1EhPol9M79dSVFbGnod.jpeg';
  180. $token = 'AQUOiNxK2Fn0fEwbqCzeo26xT-CFp_DO57GJ1Hqf9XoD1zezGa1knRuENJyu7RtJTjQhSS3UZ_winzcHsxHxm_nWE0pJUclmN21BMsTmiYnqA_i2mjo8l26ZjZ0Y0Qn2umh0aGqt5XGVw9_YY5HkHmy_5JUjGQb7SMpdEO1mobEyb9CK0L5-jPcLAfmwLDRrap3KeeOIdu3i8EgPKzJG8dNqmcsbHuA1Gnq3WX1kXtBtKmnd1KzPxGbQSK9-V_txzz3VhdsRs6CFqoZrWdZjcxngkN26etQg6cG58Il1f7W7PVS8SKjpyC6rzIAEN9ee00dp3EvyfckcJDZTtYbojr-HUnmw_Q';
  181. LinkedinShare::shareArticle($token, 'http://www.baidu.com', 'LinkedInShare', 'accessToken');
  182. dd('success');
  183. }
  184. public function pin()
  185. {
  186. $pin = new Pinterest(config('services.pinterest.client_id'), config('services.pinterest.client_secret'));
  187. $pin->auth->setOAuthToken('AsityC1Rl6-kSqfwD98akYNaj5gxFatL7qHFJjNF8JCvpODAwAu6ADAAAUegRfKs6higoeEAAAAA');
  188. dump($pin->getRateLimitRemaining());
  189. try {
  190. $pin->pins->create([
  191. "note" => "Test board from API",
  192. "image_url" => "http://admin.yinqingli.com/storage/201906/jpg/1Q987Ryl6mdPFhJljhy5O1EhPol9M79dSVFbGnod.jpeg",
  193. "board" => "hinaqin/api-demo"
  194. ]);
  195. } catch (\Throwable $throwable) {
  196. dd($throwable->getMessage());
  197. }
  198. }
  199. public function twitter()
  200. {
  201. error_reporting(E_ALL);
  202. ini_set('display_errors', 1);
  203. $consumerKey = 'QfqLozpNfcbXp042lMmQtFQbE';
  204. $consumerSecret = 'rI4crlFCxprr2DtbA9BygpymuiClkG6hKArU7C6uuyuKEfpAi2';
  205. $accessToken = '4296714074-8HUSqvOOfHRAnq880OQu3X36pZu69ltPOkddwYK';
  206. $accessTokenSecret = 'bxtLHmfZkfYj2GlNcoPLgMKjvmd23ad8hmZTI4IJCQbVM';
  207. // $path = 'http://admin.yinqingli.com/storage/201906/jpg/1Q987Ryl6mdPFhJljhy5O1EhPol9M79dSVFbGnod.jpeg';
  208. $path = public_path('profile_small.jpg');
  209. try {
  210. $twitter = new \DG\Twitter\Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
  211. dd($twitter->send('this is sixth demo from api', [$path, public_path('demo-head.png')], ['possibly_sensitive' => false]));
  212. } catch (\TwitterException $e) {
  213. dd($e->getMessage());
  214. }
  215. dd('success');
  216. }
  217. public function HelloWorld()
  218. {
  219. $fn = function ($b) use (&$fn) {
  220. return 1;
  221. };
  222. $fn(1);
  223. return response()->json(['message' => '操作成功'], 400);
  224. }
  225. public function ins()
  226. {
  227. $taskUrls = ['http://www.baidu.com', 'http://www.sohu.com'];
  228. $client = new Client([
  229. 'verify' => false,
  230. 'timeout' => 10
  231. ]); //并发请求链接地址
  232. $requests = function () use ($taskUrls) {
  233. foreach ($taskUrls as $item) {
  234. yield new \GuzzleHttp\Psr7\Request('GET', $item);
  235. }
  236. };
  237. $pool = new Pool($client, $requests(), [
  238. 'concurrency' => 10, //同时并发抓取几个
  239. 'fulfilled' => function (Response $response, $index) {
  240. },
  241. 'rejected' => function (\Throwable $throwable, $index) {
  242. Log::error(var_export($throwable->getMessage(), 1));
  243. },
  244. ]);
  245. $promise = $pool->promise();
  246. $promise->wait();
  247. }
  248. public function facebook()
  249. {
  250. //// User::query()->where([''])
  251. // $testUserToken = 'EAAiLLRwuSRgBAAxxqmoMpiNlC0haZBUctZAIFSng5NZADyY6MPZAXxsWG37MjI9yZB3i5edKZAp3UvvhzCJ88L3ZA3g5hnsGkPgEUeDwo9TAZA5ZC4SYzqBMFjt97a5EgqqkKZBRHiYJacqHVPlntvxdTBn9au9xhZBhkuy2shESAb5TWvf5CwKSbJk';
  252. //
  253. // // 发布到pages
  254. // try {
  255. // $fb = new Facebook([
  256. // 'app_id' => '2404825676269848',
  257. // 'app_secret' => 'e4387c50b2e0388baa547f60f85aa8f9',
  258. // 'default_access_token' => $testUserToken, // optional
  259. // ]);
  260. //
  261. // } catch (\Throwable $throwable) {
  262. //
  263. // }
  264. //
  265. // $fb->setDefaultAccessToken($testUserToken);
  266. //
  267. // $linkData = [
  268. // 'link' => 'http://www.baidu.com', //TODO change
  269. // 'message' => 'hello i m vae',
  270. // ];
  271. // $pageId = '2822252084511458';
  272. //// $pageId = '688544178276351';
  273. // $response = $fb->post('/' . $pageId . '/feed', $linkData, $testUserToken);
  274. // dd($response->getBody());
  275. // User::query()->where([''])
  276. $testUserToken = 'EAAiLLRwuSRgBAH7I0dQvhXWIjOSejzocB7GkLxKimnkSsCrS43Vs9NNcJvZAEiWt0FUMxwdOAfSxlR0I8IMX9N4X6qZBeoViojSJXCDVUPrY4go7fwkubnwHXDoscGkKzTQXxeWoYv6rIJHmzkkqgg7JlRvfNQgEOu8dmjYQZDZD';
  277. // 发布到pages
  278. try {
  279. $fb = new Facebook([
  280. 'app_id' => '2404825676269848',
  281. 'app_secret' => 'e4387c50b2e0388baa547f60f85aa8f9',
  282. 'default_access_token' => $testUserToken, // optional
  283. ]);
  284. $pageId = '2822252084511458';
  285. $response = $fb->get('/' . $pageId . '?fields=access_token');
  286. dd($response->getBody(), $response->getAccessToken());
  287. } catch (\Throwable $throwable) {
  288. }
  289. }
  290. /**
  291. *
  292. * @param int $a
  293. * @return int
  294. */
  295. public function six($a = 1)
  296. {
  297. error_log(6);
  298. return 6;
  299. }
  300. protected function preparePostFields($array)
  301. {
  302. if (is_array($array)) {
  303. $params = array();
  304. foreach ($array as $key => $value) {
  305. $params[] = $key . '=' . urlencode($value);
  306. }
  307. return implode('&', $params);
  308. } else {
  309. return $array;
  310. }
  311. }
  312. function diffBetweenTwoDays($day1, $day2)
  313. {
  314. $second1 = strtotime($day1);
  315. $second2 = strtotime($day2);
  316. if ($second1 < $second2) {
  317. $tmp = $second2;
  318. $second2 = $second1;
  319. $second1 = $tmp;
  320. }
  321. return ($second1 - $second2) / 86400;
  322. }
  323. public function message()
  324. {
  325. $client = new Client();
  326. $code = '';
  327. $redirect_uri = '';
  328. $client_id = '';
  329. $client_secret = '';
  330. $bearer = 'Bearer ';
  331. $authorization = '';
  332. try {
  333. $response = $client->request('POST', 'https://platform.hootsuite.com/v1/messages', [
  334. 'headers' => [
  335. 'Authorization' => $authorization
  336. ],
  337. 'form_params' => [
  338. 'text' => 'authorization_code',
  339. 'socialProfileIds' => [
  340. ],
  341. 'scheduledSendTime' => date(DATE_ISO8601, strtotime('+8 hour')),
  342. 'webhookUrls' => [
  343. ],
  344. 'privacy' => [
  345. 'facebook' => [
  346. 'visibility' => [
  347. 'everyone'
  348. ]
  349. ],
  350. 'linkedIn' => [
  351. 'visibility' => [
  352. 'anyone'
  353. ]
  354. ]
  355. ],
  356. 'emailNotification' => false, //一个标志,用于确定消息发布时是否发送电子邮件通知。
  357. //对象,用于发送社会配置文件元数据。目前只适用于Pinterest消息
  358. 'extendedInfo' => [
  359. [
  360. 'socialProfileType' => 'PINTEREST',
  361. 'socialProfileId' => '',
  362. 'data' => [
  363. 'boardId' => '',
  364. 'destinationUrl' => ''
  365. ]
  366. ]
  367. ]
  368. ]
  369. ]);
  370. dd($response->getBody()->getContents());
  371. } catch (\GuzzleHttp\Exception\GuzzleException $exception) {
  372. dd($exception->getMessage());
  373. }
  374. }
  375. public function two123(\Illuminate\Http\Request $request)
  376. {
  377. dd("");
  378. $client = new Client();
  379. $code = 'qIv0xhL8RZySH_QqcPcvbe8Y17WxnhcjI18rGREbwgg.PGQzVLTwDQsUPL0Aiqbg09ycXtXFNAjPjrhUSPexP4M';
  380. // $redirect_uri = '';
  381. $redirect_uri = 'https://getpostman.com/oauth2/callback';
  382. $client_id = 'c1ada351-6797-406e-8706-342af91ecad5';
  383. $client_secret = 'R-6nps.tHElD';
  384. $bearer = 'Bearer ';
  385. $refresh_token = 'pzj7ZzpuhaGhrirTLa9CLkEYXD6tNDesEiPOlIZqiPk.XkqlaBNlxtoiaKHHC9E4JuFx6XZk0pW6_rFkVrBKZ18';
  386. $authorization = base64_encode(sprintf('%s:%s', $client_id, $client_secret));
  387. dd($authorization);
  388. try {
  389. $response = $client->request('POST', 'https://platform.hootsuite.com/oauth2/token', [
  390. 'headers' => [
  391. 'Authorization' => $authorization
  392. ],
  393. 'form_params' => [
  394. 'grant_type' => 'refresh_token',
  395. // 'code' => $code,
  396. // 'redirect_uri' => $redirect_uri,
  397. 'scope' => 'offline',
  398. 'refresh_token' => $refresh_token
  399. ]
  400. ]);
  401. dd($response->getBody()->getContents());
  402. } catch (\GuzzleHttp\Exception\GuzzleException $exception) {
  403. dd($exception->getMessage());
  404. }
  405. // $client->post();
  406. // $clientId = "5049113417978258277";
  407. // $clientSecret = "c00f71c0587ddb07b506b51c2beafa8ff953f958451d1779c42ada1a02209dfd";
  408. // $redirectUrl = "https://wall.yinqingli.com/demo/two";
  409. // $config = new \SocialiteProviders\Manager\Config($clientId, $clientSecret, $redirectUrl);
  410. $user = Socialite::driver('pinterest')->user();
  411. dd($user);
  412. $user = Socialite::with('twitter')->user();
  413. dd($user);
  414. config([
  415. 'services.pinterest' => [
  416. 'client_id' => env('PINTEREST_CLIENT_ID'),
  417. 'client_secret' => env('PINTEREST_CLIENT_SECRET'),
  418. 'redirect' => env('PINTEREST_REDIRECT_URL')
  419. ]
  420. ]);
  421. $user = Socialite::driver('facebook')->user();
  422. if (empty($user->token)) {
  423. return view('admin/errors/tips', [
  424. 'tips' => '用户令牌获取失败!!!'
  425. ]);
  426. }
  427. try {
  428. $pageId = '2822252084511458';
  429. $fb = new Facebook([
  430. 'app_id' => '2404825676269848',
  431. 'app_secret' => 'e4387c50b2e0388baa547f60f85aa8f9',
  432. 'default_access_token' => $user->token, // optional
  433. ]);
  434. $response = $fb->get(sprintf('/%s?fields=access_token', $pageId));
  435. $responseJson = json_decode($response->getBody(), true);
  436. if (empty($responseJson['access_token'])) {
  437. return view('admin/errors/tips', [
  438. 'tips' => '页面令牌获取失败!!!'
  439. ]);
  440. }
  441. $pageToken = $responseJson['access_token'];
  442. Social::query()->where(['type' => 'facebook'])->update([
  443. 'token' => $user->token,
  444. 'token_expired_at' => date('Y-m-d H:i:s', strtotime('+59 days')),
  445. 'page_token' => $pageToken,
  446. 'page_token_expired_at' => date('Y-m-d H:i:s', strtotime('+59 days'))
  447. ]);
  448. return view('admin/errors/tips', [
  449. 'tips' => '授权成功,有效期60天'
  450. ]);
  451. } catch (\Throwable $throwable) {
  452. Log::warning(var_export($throwable->getMessage(), 1));
  453. return view('admin/errors/tips', [
  454. 'tips' => '页面令牌获取失败!!!'
  455. ]);
  456. }
  457. dd($user);
  458. // dump($user);
  459. return view('admin/errors/tips', [
  460. 'tips' => '授权成功'
  461. ]);
  462. for ($i = 0; $i < 50; $i++) {
  463. auth()->user();
  464. echo '123' . '<br>';
  465. }
  466. return;
  467. $user = Socialite::driver('LinkedIn')->user();
  468. Social::query()->where(['type' => 'linkedIn'])->update([
  469. 'token' => $user->token,
  470. 'token_expired_at' => date('Y-m-d H:i:s', strtotime('+59 days'))
  471. ]);
  472. return view('admin/errors/tips', [
  473. 'tips' => '授权成功,有效期60天'
  474. ]);
  475. dump($request->input());
  476. dd($user);
  477. dd($user);
  478. $user = Socialite::driver('instagram')->user();
  479. dd($user);
  480. $user = Socialite::driver('facebook')->user();
  481. dd($user);
  482. $user = Socialite::driver('Twitter')->user();
  483. dd($user);
  484. }
  485. function bubbleSort($arr)
  486. {
  487. optional();
  488. $len = count($arr);
  489. for ($i = 0; $i < $len - 1; $i++) {
  490. for ($j = 0; $j < $len - 1 - $i; $j++) {
  491. if (mb_strlen($arr[$j]['source']) < mb_strlen($arr[$j + 1]['source'])) {
  492. $tmp = $arr[$j];
  493. $arr[$j] = $arr[$j + 1];
  494. $arr[$j + 1] = $tmp;
  495. }
  496. }
  497. }
  498. return $arr;
  499. }
  500. protected function cancelPass()
  501. {
  502. $where = [1551, 1602, 1666];
  503. $data = LinkTask::query()->whereIn('id', $where)->get();
  504. // dd($data);
  505. LinkTask::query()->whereIn('id', $where)->update(['status' => 3, 'audit_at' => null]);
  506. LinkTaskDetail::query()->whereIn('task_id', $where)->update(['status' => 3]);
  507. }
  508. protected function getEndTime($time, $num = 0)
  509. {
  510. // return strtotime('+1 month -1 day', $time);
  511. return strtotime('last day of -' . $num . ' month', strtotime(date('Y-m-d 23:59:59', $time))); //num=0
  512. return strtotime('first day of -' . $num . ' month', $time); //num=1
  513. }
  514. public function getYmOrTime($time, $num = 0, $flag = 0)
  515. {
  516. $time = strtotime(sprintf('first day of -%s month', $num), $time);
  517. return $flag ? $time : date('Ym', $time);
  518. }
  519. protected function sortSomething($data = [], $condition = [])
  520. {
  521. $data = [
  522. ['id' => 9],
  523. ['id' => 1],
  524. ['id' => 2],
  525. ['id' => 4],
  526. ['id' => 1],
  527. ];
  528. $result = [];
  529. $condition = [1, 4, 2];
  530. $keyMap = [];
  531. foreach ($data as $item) {
  532. if (!isset($keyMap[$item['id']])) {
  533. $keyMap[$item['id']] = [$item];
  534. } else {
  535. $keyMap[$item['id']][] = $item;
  536. }
  537. }
  538. foreach ($condition as $v) {
  539. foreach ($keyMap as $key => $item) {
  540. if ($v == $key) {
  541. foreach ($item as $m) {
  542. $result[] = $m;
  543. }
  544. }
  545. }
  546. }
  547. foreach ($data as $item) {
  548. $has = false;
  549. foreach ($result as $value) {
  550. if ($value['id'] == $item['id']) {
  551. $has = true;
  552. }
  553. }
  554. if (!$has) {
  555. $result[] = $item;
  556. }
  557. }
  558. return $result;
  559. }
  560. public function getEndDate($time)
  561. {
  562. return date('Y-m-d', strtotime('+1 month -1 day', $time));
  563. }
  564. private function ex()
  565. {
  566. throw new \Exception('dasd');
  567. }
  568. function insertionSort($arr)
  569. {
  570. $len = count($arr);
  571. for ($i = 1; $i < $len; $i++) {
  572. $preIndex = $i - 1;
  573. $current = $arr[$i];
  574. while ($preIndex >= 0 && $arr[$preIndex] > $current) {
  575. $arr[$preIndex + 1] = $arr[$preIndex];
  576. $preIndex--;
  577. }
  578. $arr[$preIndex + 1] = $current;
  579. }
  580. return $arr;
  581. }
  582. private $_iv = "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f";
  583. private $_secret = "2b 73 ae f0 85 7d 77 81 1f 35 2c 07 3b 61 08 d7";
  584. // function strtohex($x)
  585. // {
  586. // $s = '';
  587. // foreach (str_split($x) as $c) $s .= sprintf("%02X", ord($c));
  588. // return ($s);
  589. // }
  590. function trimAll($s)
  591. {
  592. return preg_replace("/\s/", "", $s);
  593. }
  594. public function pad($data, $blocksize = 16)
  595. {
  596. $pad = $blocksize - (strlen($data) % $blocksize);
  597. return $data . str_repeat(chr($pad), $pad);
  598. }
  599. function toDec($a)
  600. {
  601. $aList = explode(" ", $a);
  602. foreach ($aList as &$item) {
  603. $item = hexdec($item);
  604. }
  605. return implode("", $aList);
  606. }
  607. public function cbc($data)
  608. {
  609. // $iv =openssl_random_pseudo_bytes(16);
  610. return openssl_encrypt($data, 'aes-128-cbc', $this->binStr($this->_secret), OPENSSL_ZERO_PADDING, $this->binStr($this->_iv));
  611. }
  612. function binStr($hex)
  613. {
  614. $user = User::query()->firstOrCreate([]);
  615. // $aList = explode(" ", $hex);
  616. //
  617. // foreach ($aList as &$item) {
  618. // $item = hex2bin($item);
  619. // }
  620. //
  621. //
  622. // return implode("",$aList);
  623. return hex2bin($this->trimAll($hex));
  624. }
  625. public function maopao($arr)
  626. {
  627. for ($i = 0; $i < count($arr) - 1; $i++) {
  628. for ($j = 0; $j < count($arr) - 1 - $i; $j++) {
  629. if ($arr[$j + 1] < $arr[$j]) {
  630. [$arr[$j + 1], $arr[$j]] = [$arr[$j], $arr[$j + 1]];
  631. }
  632. }
  633. }
  634. return $arr;
  635. }
  636. protected function getMonthNum($targetTime)
  637. {
  638. $target = date('Ym', $targetTime);
  639. $now = date('Ym');
  640. $ty = substr($target, 0, 4);
  641. $tm = substr($target, 4, 2);
  642. $ny = substr($now, 0, 4);
  643. $nm = substr($now, 4, 2);
  644. $yd = intval($ty) - intval($ny);
  645. $md = intval($tm - $nm);
  646. $result = $yd * 12 + $md;
  647. return $result;
  648. }
  649. public function mp()
  650. {
  651. $dataList = [5, 3, 6, 7, 2, 1, 9, 4];
  652. dd($dataList);
  653. for ($i = 0; $i < count($dataList) - 1; $i++) {
  654. for ($j = 0; $j < count($dataList) - $i - 1; $j++) {
  655. if ($dataList[$j] > $dataList[$j + 1]) {
  656. [$dataList[$j + 1], $dataList[$j]] = [$dataList[$j], $dataList[$j + 1]];
  657. }
  658. }
  659. }
  660. return $dataList;
  661. }
  662. public function two()
  663. {
  664. return view('demo');
  665. }
  666. public function one(\Illuminate\Http\Request $request)
  667. {
  668. $a=(object)['a'];
  669. echo "dd","aa";
  670. print "ddd";
  671. print_r($a);
  672. var_dump($a);
  673. return;
  674. // dump("begin");
  675. // dump($request->input());
  676. // dump("end");
  677. $callback = $request->input('callback');
  678. $NVCVal = $request->input('a');
  679. // dump($NVCVal);
  680. $iClientProfile = \DefaultProfile::getProfile("cn-hangzhou", "LTAI4GFn9MshqB1EDmDi1pAz", "1Tyw13WirvozGottsxICxDMsLX66lH");
  681. $client = new \DefaultAcsClient($iClientProfile);
  682. \DefaultProfile::addEndpoint("cn-hangzhou", "cn-hangzhou", "afs", "afs.aliyuncs.com");
  683. $request = new Afs\AnalyzeNvcRequest();
  684. $request->setData($NVCVal);// 必填参数,由前端获取getNVCVal方法获得的值。
  685. // 通过setScoreJsonStr方法声明"服务端调用人机验证服务接口得到的返回结果"与"前端执行操作"间的映射关系,并通知验证码服务端进行二次验证授权。
  686. // 注意:前端页面必须严格按照该映射关系执行相应操作,否则将导致调用异常。
  687. // 例如,在setScoreJsonStr方法中声明"400":"SC",则当服务端返回400时,您的前端必须唤醒刮刮卡验证(SC),如果唤醒滑块验证(NC)则将导致失败。
  688. $request->setScoreJsonStr("{\"200\":\"PASS\",\"400\":\"NC\",\"600\":\"SC\",\"800\":\"BLOCK\"}");// 根据业务需求设置各返回结果对应的客户端处置方式。
  689. $response = $client->getAcsResponse($request);
  690. //{"success":true,"result":{"success":false,"msg":"build nvc analyze param error","code":800}}
  691. $data = ["success" => true, "result" => [
  692. "code" => $response->BizCode
  693. ]];
  694. return sprintf("%s(%s)",$callback, json_encode($data));
  695. // onJSONPCallback()
  696. print_r($response);
  697. return;
  698. setcookie('SameSite', 'Lax');
  699. Log::channel('daily')->info('demo');
  700. return;
  701. dd($this->mp());
  702. $a = '555';
  703. dd(substr($a, 6, 5));
  704. $aaa = (object)[
  705. 'a' => 1,
  706. 'b' => 2
  707. ];
  708. dd($aaa->c->b ?? '');
  709. $beginAt = date('Y-m-01 00:00:00');
  710. $endAt = date('Y-m-t 23:59:59');
  711. $res = Article::query()->selectRaw('COUNT(id) as total,site_id')->where([['created_at', '>=', $beginAt], ['created_at', '<=', $endAt]])
  712. ->groupBy('site_id')->pluck('total', 'site_id')->toArray();
  713. dd($res);
  714. $datetime1 = date_create('2009-10-11');
  715. $datetime2 = date_create('2010-12-13');
  716. $interval = date_diff($datetime1, $datetime2);
  717. $records = [];
  718. $results = Site::query()->selectRaw('id,domain,cn_title,expired_at,cert_expired_date')->with(['users'])->where(['status' => 3])->get();
  719. foreach ($results as $result) {
  720. $records[] = [
  721. 'cn_title' => $result->cn_title,
  722. 'domain' => $result->domain,
  723. 'expired_at' => $result->expired_at,
  724. 'cert_expired_date' => $result->cert_expired_date,
  725. 'optimize' => implode(",", $result->users->where('role_id', 26)->where('status', 1)->pluck('nickname')->toArray())
  726. ];
  727. }
  728. array_unshift($records, ['项目名称', '域名', '到期时间', 'SSL证书到期时间', '优化师']);
  729. return (new BasicExport($records))->download(sprintf('%s.xls', date('YmdHis')));
  730. dd($this->maopao([1, 5, 6, 2, 4, 5]));
  731. $records = array(
  732. array(
  733. 'id' => 2135,
  734. 'first_name' => 'John',
  735. 'last_name' => 'Doe',
  736. ),
  737. array(
  738. 'id' => 3245,
  739. 'first_name' => 'Sally',
  740. 'last_name' => 'Smith',
  741. ),
  742. array(
  743. 'id' => 5342,
  744. 'first_name' => 'Jane',
  745. 'last_name' => 'Jones',
  746. ),
  747. array(
  748. 'id' => 5623,
  749. 'first_name' => 'Peter',
  750. 'last_name' => 'Doe',
  751. )
  752. );
  753. dd(array_column($records, null));
  754. //
  755. // $pingya = DB::table('user_has_sites')->where(['user_id' => 3])->pluck('site_id')->toArray(); //萍亚
  756. // $lisa = DB::table('user_has_sites')->where(['user_id' => 4])->get(); //lisa
  757. //
  758. //
  759. // foreach ($lisa as $item) {
  760. // if (in_array($item->site_id, $pingya)) {
  761. // DB::table('user_has_sites')->where(['user_id' => $item->user_id, 'site_id' => $item->site_id])->delete();
  762. // }
  763. // }
  764. // dd('success');
  765. $client = new Client();
  766. $res = $client->get('
  767. ', [
  768. 'verify' => false,
  769. 'timeout' => 50
  770. ]);
  771. dd($res->getBody()->getContents());
  772. $aa = array(
  773. 'code' => 200,
  774. 'data' =>
  775. array(
  776. 'data' =>
  777. array(
  778. 0 =>
  779. array(
  780. 'id' => '6025193629',
  781. 'state' => 'SCHEDULED',
  782. 'text' => 'Urea as a nitrogen fertilizer is the most important fertilizer in the world\'s agriculture. However, the urea in the soil is rapidly decomposed by the urease enzyme in the soil to decompose a large amo...',
  783. 'scheduledSendTime' => '2020-07-07T19:00:00Z',
  784. 'socialProfile' =>
  785. array(
  786. 'id' => '128251879',
  787. ),
  788. 'mediaUrls' => NULL,
  789. 'media' => NULL,
  790. 'webhookUrls' => NULL,
  791. 'tags' => NULL,
  792. 'targeting' => NULL,
  793. 'privacy' => NULL,
  794. 'location' => NULL,
  795. 'emailNotification' => false,
  796. 'postUrl' => NULL,
  797. 'postId' => NULL,
  798. 'reviewers' => NULL,
  799. 'createdByMember' =>
  800. array(
  801. 'id' => '20746677',
  802. ),
  803. 'lastUpdatedByMember' =>
  804. array(
  805. 'id' => '20746677',
  806. ),
  807. 'extendedInfo' => NULL,
  808. 'sequenceNumber' => NULL,
  809. ),
  810. 1 =>
  811. array(
  812. 'id' => '6025193630',
  813. 'state' => 'SCHEDULED',
  814. 'text' => 'Urea as a nitrogen fertilizer is the most important fertilizer in the world\'s agriculture. However, the urea in the soil is rapidly decomposed by the urease enzyme in the soil to decompose a large amo...',
  815. 'scheduledSendTime' => '2020-07-07T19:00:00Z',
  816. 'socialProfile' =>
  817. array(
  818. 'id' => '128251866',
  819. ),
  820. 'mediaUrls' => NULL,
  821. 'media' => NULL,
  822. 'webhookUrls' => NULL,
  823. 'tags' => NULL,
  824. 'targeting' => NULL,
  825. 'privacy' => NULL,
  826. 'location' => NULL,
  827. 'emailNotification' => false,
  828. 'postUrl' => NULL,
  829. 'postId' => NULL,
  830. 'reviewers' => NULL,
  831. 'createdByMember' =>
  832. array(
  833. 'id' => '20746677',
  834. ),
  835. 'lastUpdatedByMember' =>
  836. array(
  837. 'id' => '20746677',
  838. ),
  839. 'extendedInfo' => NULL,
  840. 'sequenceNumber' => NULL,
  841. ),
  842. 2 =>
  843. array(
  844. 'id' => '6025193823',
  845. 'state' => 'SCHEDULED',
  846. 'text' => 'Urea as a nitrogen fertilizer is the most important fertilizer in the world\'s agriculture. However, the urea in the soil is rapidly decomposed by the urease enzyme in the soil to decompose a large amo...',
  847. 'scheduledSendTime' => '2020-07-07T19:00:00Z',
  848. 'socialProfile' =>
  849. array(
  850. 'id' => '128251875',
  851. ),
  852. 'mediaUrls' => NULL,
  853. 'media' => NULL,
  854. 'webhookUrls' => NULL,
  855. 'tags' => NULL,
  856. 'targeting' => NULL,
  857. 'privacy' => NULL,
  858. 'location' => NULL,
  859. 'emailNotification' => false,
  860. 'postUrl' => NULL,
  861. 'postId' => NULL,
  862. 'reviewers' => NULL,
  863. 'createdByMember' =>
  864. array(
  865. 'id' => '20746677',
  866. ),
  867. 'lastUpdatedByMember' =>
  868. array(
  869. 'id' => '20746677',
  870. ),
  871. 'extendedInfo' => NULL,
  872. 'sequenceNumber' => NULL,
  873. ),
  874. ),
  875. ),
  876. );
  877. dd(json_encode($aa));
  878. dd(date('Y-m-d 00:00:00', strtotime('last day of -1 month')));
  879. $bin = '00001011';
  880. $dec = bindec($bin);
  881. dump(chr($dec));
  882. // dump($dec);
  883. $hex = bin2hex($bin);
  884. dump($hex);
  885. // $hello=bin2hex('abcdefgh');
  886. dd(pack("H16", $hex));
  887. // dd($this->trimAll($this->_iv));
  888. // dd($this->toDec($this->_iv));
  889. $a = "15 00 00 00 00 18 86 25 61 29 8B 00 01 02 03 00 00 00 00 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF F4 01 14 0A 0C 5A 08 01 A0 00";
  890. // $a=hexdec($a);
  891. // $aList = explode(" ", $a);
  892. //
  893. // foreach ($aList as &$item) {
  894. // $item = hexdec($item);
  895. // }
  896. //
  897. // $a = implode(" ", $aList);
  898. //
  899. // dump($a);
  900. $cdata = $this->cbc($this->binStr($a));
  901. // dump($cdata);
  902. dd(bin2hex($cdata));
  903. // $result=$this->pad($cdata);
  904. // dd(bin2hex($result));
  905. // dd($this->pad($cdata));
  906. $a = 0x1f;
  907. dd($a);
  908. $str = "The Supercapacitors: its Basic Principles, Classification, and its Electrical Performance";
  909. $str2 = preg_replace("/[^a-zA-Z0-9\s]/", "", $str);
  910. dd(strtolower(preg_replace("/\s+/", "-", $str2)));
  911. $words = explode(" ", "The Supercapacitors: its Basic Principles, Classification, and its Electrical Performance");
  912. foreach ($words as &$w) {
  913. $w = strtolower($w);
  914. }
  915. dd(implode("-", $words));
  916. dd(crc32("asdasdasddasdasda"));
  917. $hashVal = hash("md5", "dsadasdasdas");
  918. $hashInt = hexdec($hashVal);
  919. dd($hashInt);
  920. dd(date('Y-m-d', strtotime('2020-01-02')));
  921. $lock = Cache::lock('snap_up:', 10);
  922. /**
  923. * @var \Illuminate\Cache\RedisLock $lock
  924. */
  925. // Role::query()->scopes([])->get();
  926. dd(1 >> 2);
  927. dd($lock->release(123));
  928. try {
  929. $a = 0;
  930. $b = 0;
  931. dump($a / $b);
  932. } catch (\Throwable $throwable) {
  933. throw new \Exception("heng");
  934. } finally {
  935. dd(123);
  936. }
  937. dd($this->insertionSort([5, 1, 3, 4, 6]));
  938. $path = 'http://kamcappower.com/uploads/image/20190628/11/application-prospect-of-supercapacitors-in-smart-grid.jpg';
  939. // dd(file_get_contents($path));
  940. $image = \exif_imagetype($path);
  941. $mime = image_type_to_mime_type($image);
  942. dd($mime);
  943. dd(get_class(HootsuiteUser::query()->first()));
  944. // $path='https://www.kamcappower.com/uploads/image/20190613/14/medical.jpg';
  945. // $image= exif_imagetype($path);
  946. // $mime = image_type_to_mime_type($image);
  947. // dd($mime);
  948. $path = './demo.jpg';
  949. dd(mime_content_type($path));
  950. dump(filesize($path));
  951. // $data = fopen($path, 'r');
  952. $data = file_get_contents($path);
  953. dd(strlen($data));
  954. dump(mime_content_type($data));
  955. dd($data);
  956. dd(date('Z'));
  957. $sendAt = '2020-06-01 12:12:12';
  958. dd(date(DATE_ISO8601, strtotime($sendAt)));
  959. dd(date('Y-m-d\TH:i:s\Z', strtotime($sendAt)));
  960. $this->ex();
  961. dd(123);
  962. $client_id = 'c1ada351-6797-406e-8706-342af91ecad5';
  963. $redirect_uri = 'https://admin.yinqingli.com/admin/socials/hootsuite';
  964. // $redirect_uri = 'https://getpostman.com/oauth2/callback';
  965. $state = 'helloworld';
  966. return redirect(sprintf(
  967. 'https://platform.hootsuite.com/oauth2/auth?response_type=code&client_id=%s&scope=offline&state=%s&redirect_uri=%s',
  968. $client_id,
  969. $state,
  970. $redirect_uri
  971. ));
  972. dd(3600 + '5');
  973. dd(floor(3599 / 60));
  974. Cache::put('demo', 456, 5);
  975. dd(Cache::get('demo'));
  976. return;
  977. $client = new Client();
  978. $url = sprintf('%s/admin/hootsuite/refresh-token', config('app.wall_url'));
  979. try {
  980. $response = $client->request('POST', $url, [
  981. 'form_params' => [
  982. 'refreshToken' => 'k4uJi9hyIERYbHPalo494wdSA-wG4h2K4yXNKdTeNzs.Z3Ez16oApdXjZPvFRyAiHrQGMKp3VCY4vI9xJfYI5PY'
  983. ]
  984. ]);
  985. $result = $response->getBody()->getContents();
  986. dd($result);
  987. } catch (\GuzzleHttp\Exception\GuzzleException $exception) {
  988. dd($exception->getMessage());
  989. }
  990. // 阻塞IO 用户线程去读取数据包 内核没有准备好 用户线程阻塞掉
  991. // 非阻塞IO 用户线程轮询去读取数据包
  992. // 多路复用IO 内核线程轮询socket 看看有哪些数据包 准备好 ,如果准备好了 则通知用户线程去读取
  993. // 信号驱动模式 用户线程注册一个信号 ,当内核数据包准备好了的话通知给用户线程 让其以去读取
  994. // 异步IO 用户线程 要去读取数据 内核立马返回好 我知道了 然后当数据包准备好了的话 内核会将数据处理好 并且通知用户线程 已经好了 这里第二阶段是与前四个的主要区别是 当第二阶段内核拷贝数据时 用户线程不会阻塞
  995. dd(date('YW'));
  996. $callFn = function () {
  997. return '';
  998. };
  999. $a = [5, 8, 1, 5, 3, 2, 6, 9];
  1000. dd(max($a));
  1001. dd(date('Y-m-t', strtotime('2020-02-01')));
  1002. dd($this->getEndDate(strtotime('2020-03-01 00:00:00')));
  1003. dd(base64_decode('MjAyMDAz'));
  1004. DB::connection()->enableQueryLog();
  1005. $data = SocialPublish::query()->where(['id' => 4323])->whereJsonContains('result_status->pin', 2)->get();
  1006. dump(DB::getQueryLog());
  1007. dd($data);
  1008. // User::query()->select()->where()->exists();
  1009. DB::connection()->enableQueryLog();
  1010. $result = User::query()->whereIn('id', [])->get();
  1011. dd(DB::getQueryLog());
  1012. dd($result);
  1013. dd($this->sortSomething());
  1014. $time = $this->getYmOrTime(strtotime('2020-03-01 00:00:00'), 0, 1);
  1015. dump($time);
  1016. dd($this->getEndTime($time));
  1017. User::query()->whereIn('id', [])->get()->pluck('')->toArray();
  1018. $this->cancelPass();
  1019. return;
  1020. $header = [
  1021. "typ" => 'jwt',
  1022. "alg" => 'md5'
  1023. ];
  1024. $payload = [
  1025. 'name' => "ggc",
  1026. 'id' => 1
  1027. ];
  1028. $signStr = base64_encode(json_encode($header)) . '.' . base64_encode(json_encode($payload));
  1029. $sign = md5($signStr);
  1030. $result = $signStr . '.' . $sign;
  1031. dd($result);
  1032. dd(date('w'));
  1033. $user = User::query()->first();
  1034. $time = date('H');
  1035. dd($time > 10);
  1036. $str = '{"displayName":"App\\Jobs\\TranArticle","job":"Illuminate\\Queue\\CallQueuedHandler@call","maxTries":1,"timeout":560,"timeoutAt":null,"data":{"commandName":"App\\Jobs\\TranArticle","command":"O:20:\"App\\Jobs\\TranArticle\":11:{s:7:\"timeout\";i:560;s:5:\"\u0000*\u0000id\";i:9413;s:10:\"\u0000*\u0000content\";s:1376:\"<p>1H,1H,2H,2H-Perfluorodecyltrimethoxysilane<\/p><p><br\/><\/p><p>\u672c\u4ea7\u54c1\u5177\u6709\u4f18\u826f\u7684\u62d2\u6c34\u3001\u62d2\u6cb9\u548c\u9632\u53cd\u5c04\u6027\uff0c\u53ef\u7528\u4e8e\u73bb\u7483\u3001\u9676\u74f7\u3001\u82b1\u5c97\u77f3\u3001\u74f7\u7816\u3001\u5929\u7136\u77f3\u6750\u3001\u6728\u5851\u590d\u5408\u6750\u6599\u8868\u9762\u9632\u6c34\u9632\u6c61\u81ea\u6e05\u6d01\u5904\u7406\uff0c\u5efa\u7b51\u6750\u6599\u7684\u6297\u6c61\u6d82\u5c42\uff0c\u6eb6\u80f6-\u51dd\u80f6\u4f53\u7cfb\u7684\u6dfb\u52a0\u5242\uff0c\u6c1f\u7845\u6811\u8102\u7684\u5408\u6210\uff0c\u5316\u5986\u54c1\u4e2d\u989c\u6599\u7684\u8868\u9762\u5305\u8986\uff0c\u5316\u5b66\u6c14\u76f8\u6c89\u79ef\uff08CVD\uff09\u7b49\u3002<\/p><p><br\/><\/p><p>2-(3,4-Epoxycyclohexyl)ethyltrimethoxysilane<\/p><p><br\/><\/p><p>\u4e3b\u8981\u5e94\u7528\u4e8e\u6c34\u6027\u6d82\u6599\u7684\u589e\u7c98\u5242\uff0c\u6539\u5584\u6d82\u6599\u7684\u8010\u9ec4\u53d8\uff0c\u9644\u7740\u529b\uff0c\u6d82\u819c\u7684\u8010\u6d17\u5237\u6027;<\/p><p>\u4e3b\u8981\u5e94\u7528\u4e8e\u4e19\u70ef\u9178\u548c\u805a\u6c28\u916f\u6c34\u6027\u6d82\u6599\uff0c\u4f5c\u4e3a\u7c98\u63a5\u4fc3\u8fdb\u5242\u548c\u4ea4\u8054\u5242\uff0c\u63d0\u9ad8\u6d82\u5c42\u7684\u8010\u9ec4\u53d8\u3001\u8010\u6c34\u3001\u8010\u78e8\u3001\u8010\u6d17\u5237\u6027\u53ca\u9644\u7740\u529b\u7b49\uff0c\u5ef6\u957f\u5728\u6c34\u6027\u6811\u8102\u4e2d\u7684\u50a8\u5b58\u671f;<\/p><p>\u5e94\u7528\u4e8e\u73af\u6c27\u6811\u8102\u548c\u57fa\u6750\u7684\u7c98\u63a5\u5242\uff0c\u6539\u5584\u73af\u6c27\u6811\u8102\u7535\u5b50\u6750\u6599\u3001\u704c\u5c01\u6750\u6599\u3001\u5c24\u5176\u63d0\u9ad8\u6e7f\u6001\u4e0b\u7684\u7535\u6c14\u6027\u80fd\u3002<\/p><p><br\/><\/p><p>3,3,3-Trifluoropropylmethyldimethoxysilane<\/p><p><br\/><\/p><p>\u5b83\u7ed3\u5408\u4e86\u6709\u673a\u7845\u4e0e\u6709\u673a\u6c1f\u7684\u4f18\u5f02\u6027\u80fd\uff0c\u5728\u5176\u5206\u5b50\u4e2d\u540c\u65f6\u5177\u6709\u80fd\u4e0e\u65e0\u673a\u8d28\u6750\u6599(\u5982\u73bb\u7483\u3001\u7845\u7802\u3001\u91d1\u5c5e\u7b49)\u5316\u5b66\u7ed3\u5408\u7684\u53cd\u5e94\u57fa\u56e2\u53ca\u4e0e\u6709\u673a\u8d28\u6750\u6599(\u5982\u5408\u6210\u6811\u8102\u3001\u6a61\u80f6\u7b49)\u5316\u5b66\u7ed3\u5408\u7684\u53cd\u5e94\u57fa\u56e2\uff0c\u53ef\u628a\u4e24\u79cd\u6027\u8d28\u60ac\u6b8a\u7684\u6750\u6599\u8fde\u63a5\u5728\u4e00\u8d77\uff0c\u8d77\u5230\u6539\u5584\u590d\u5408\u6750\u6599\u7684\u6027\u80fd\u548c\u589e\u52a0\u7c98\u63a5\u5f3a\u5ea6\u7684\u4f5c\u7528\u3002<\/p><p><br\/><\/p>\";s:5:\"tries\";i:1;s:6:\"\u0000*\u0000job\";N;s:10:\"connection\";N;s:5:\"queue\";s:9:\"translate\";s:15:\"chainConnection\";N;s:10:\"chainQueue\";N;s:5:\"delay\";N;s:7:\"chained\";a:0:{}}"}}';
  1037. dd(unserialize($str));
  1038. // $pendingList = WeekTaskPending::all();
  1039. //
  1040. // foreach ($pendingList as $item) {
  1041. // WeekTaskInfo::query()->insert([
  1042. // 'describe' => $item->describe,
  1043. // 'duty_id' => $item->duty_id,
  1044. // 'design_id' => $item->design_id,
  1045. // 'feedback' => $item->feedback,
  1046. // 'remark' => $item->remark,
  1047. // 'status' => $item->status,
  1048. // 'day' => 0,
  1049. // 'user_type' => 'wfp'
  1050. // ]);
  1051. // }
  1052. dd('success');
  1053. dd(date('W', strtotime('2019-12-29 00:00:00')));
  1054. dd(date('Ymd', base64_decode("MTU4Mjk5MTk5OQ==")));
  1055. // dd(123);
  1056. $str = '大家好 我 是vae,下雨,jakfdf daa';
  1057. dd(word_count($str));
  1058. $token = 'AQV_jYClTugQt6aU8ih9_AH58XsgwQYBXeYFx6_obC9hphCXuUj4ubJ2qr6Bzf8EMiAZSxwLc6saRjCQcsHed3aPwBtZw_XQf1kVBOoGe8aT3rONP3xfw6As-1hmO13B8PBdMLH80Pnk6Ga2eq39kAbOE44poPj5Z8sm_8lcygmutcp07uS4ZaCkqoPnec-7kBZtkVp6LNEC92kA99Br0b5Bx_VmhiYMael3Rb3KQXwSFXW9Asr9bHzc-xOkB_OTJuNMGjd924On0-rKNepwcpeIlmm-QglBdPHUq50ss6bX8B9BxV3tZOsGXFnCwb0z2h4VCXjBsd4UehbtW9zgttuyRtQDng';
  1059. try {
  1060. LinkedinShare::shareNoneCompany($token, 'a test', '45546656', 'accessToken');
  1061. } catch (\Throwable $throwable) {
  1062. dd($throwable->getMessage());
  1063. }
  1064. dd('sdas');
  1065. echo 0 % 2;
  1066. // TranArticle::dispatch(1, '你好ya')->onQueue('translate');
  1067. return 123;
  1068. $reachAt = date_create('2019-02-06 12:00:00');
  1069. $nowAt = date_create();
  1070. $diff = date_diff($reachAt, $nowAt);
  1071. dd($diff->d);
  1072. $hello = User::query()->find(1);
  1073. dd(optional($hello)->username);
  1074. dd(date('Y-m-d H:i:s', strtotime('first day of -0 month')));
  1075. $dd = [(object)['a' => 1]];
  1076. foreach ($dd as $item) {
  1077. $item->he = "哈哈";
  1078. }
  1079. dd($dd);
  1080. $var = 'hello';
  1081. dd(substr($var, -3, 2));
  1082. dd(User::query()->where([])->get());
  1083. dd($request->input());
  1084. User::query()->get()->when(true, function () {
  1085. });
  1086. dd(Mail::to('15555124010@163.com')->send(new Demo(['msg' => 'hello world'])));
  1087. $demo = 'a:7:{s:10:"sale_price";i:0;s:12:"price_ladder";a:3:{i:0;a:2:{s:6:"amount";i:3;s:5:"price";d:47;}i:1;a:2:{s:6:"amount";i:4;s:5:"price";d:46;}i:2;a:2:{s:6:"amount";i:5;s:5:"price";d:45;}}s:15:"restrict_amount";s:3:"100";s:7:"deposit";s:2:"10";s:13:"deliver_goods";s:6:"285822";s:15:"retainage_start";i:1524108960;s:13:"retainage_end";i:1524109800;}';
  1088. dd(unserialize($demo));
  1089. $builder = LinkTask::query()->with(['site', 'worker']);
  1090. $noticeGroupIds = LinkTask::query()->where(['worker_id' => 8])
  1091. ->where([
  1092. ['release_at', '<', date('Y-m-d H:i:s', strtotime('+2 day'))],
  1093. ['release_at', '>', date('Y-m-d H:i:s')],
  1094. ])->pluck('group_id')->toArray();
  1095. $noticeGroupIds = $noticeGroupIds ? $noticeGroupIds : [-1];
  1096. $raw = sprintf('(CASE WHEN group_id in (%s) THEN 1 ELSE 0 END) AS flag,link_tasks.*', implode(',', $noticeGroupIds));
  1097. dump($raw);
  1098. $builder->where($condition ?? [])->where(function (\Illuminate\Database\Eloquent\Builder $b) {
  1099. $b->where('release_at', '<', date('Y-m-d H:i:s'))->orWhereNull('release_at');
  1100. });
  1101. $tasks = $builder->selectRaw($raw)->orderByDesc('flag')->orderByDesc('id')
  1102. ->paginate($request->input('pageSize') ?? TABLE_PAGE_SIZE);
  1103. dd($tasks->items());
  1104. dd($this->diffBetweenTwoDays('2019-12-04', '2019-11-01'));
  1105. dd($request->input("ids"), $request->input("list"));
  1106. goto hello;
  1107. $rankConnection = DB::connection('rank');
  1108. $maxSn = $rankConnection->table('project_keyword')->where(['project_id' => 103])->max('sn');
  1109. dd($maxSn);
  1110. dd(User::get());
  1111. $a = [1, 2, 3];
  1112. $index = array_search(1, $a);
  1113. if ($index !== false) {
  1114. unset($a[$index]);
  1115. }
  1116. dd(array_values($a));
  1117. $selects = DB::table('user_has_inquire')->where(['inquire_id' => 1])
  1118. ->get()->pluck('user_id')->toArray();
  1119. dd($selects);
  1120. $data = strtotime('2019-10-01 00:00:00');
  1121. dd(date('Y-m-d H:i:s', strtotime('+1 month -1 day', $data)));
  1122. $result = LinkTaskDetail::query()->whereNull('task_id')->where('enable', 1)->update(['status' => 5]);
  1123. dd($result);
  1124. dd(User::query()->whereStatus('1')->get());
  1125. $client = new Client();
  1126. $response = $client->post('http://translate.api.yinqingli.net/translate/translate', [
  1127. 'form_params' => [
  1128. 'q' => '大家好我是VAE',
  1129. 'source' => 'en',
  1130. 'target' => 'zh-CN'
  1131. ]
  1132. ]);
  1133. $str = json_decode($response->getBody()->getContents(), true);
  1134. $ff = $str['data']['translations'][0]['translatedText'];
  1135. dd($ff);
  1136. dd($response->getBody()->getContents());
  1137. dd(LinkTaskDetail::query()->selectRaw('link_id,any_value(id) as id')->groupBy('link_id')->limit(2)->get());
  1138. dd(explode(',', ''));
  1139. //
  1140. // $result=Article::query()->whereNull('publish_at')->whereNotNull('sync_at')->update(['publish_at'=>'']);
  1141. //
  1142. // dd($result);
  1143. dd(SocialPublish::query()->whereJsonContains('result_status', ['pin' => 3])->get());
  1144. ILog::query()->create([
  1145. 'content' => '12'
  1146. ]);
  1147. DB::connection()->enableQueryLog();
  1148. $site = Site::query()->withCount('articles')->get();
  1149. dd(DB::getQueryLog());
  1150. $articleIds = Article::query()->withCount('')->pluck('id')->toArray();
  1151. $article = Article::query()->selectRaw('site_id')->whereIn('site_id', $articleIds)->where([
  1152. ['created_at', '>', date('Y-m-d H:i:s', strtotime('-2 week'))]
  1153. ])->groupBy('site_id')->pluck('site_id')->toArray();
  1154. dd($article);
  1155. $xmls = file_get_contents("http://www.peiyangchem.com/sitemap.xml");
  1156. $xml = simplexml_load_string($xmls);
  1157. $xmljson = json_encode($xml);
  1158. $xml = json_decode($xmljson, true);
  1159. dd($xml);
  1160. $homepageReachCount = DB::connection('rank')->table('project_history')->select('top10')
  1161. ->where([
  1162. ['project_id', '=', 570],
  1163. ['create_time', '<', time()]
  1164. ])->orderByDesc('create_time')->first();
  1165. dd($homepageReachCount);
  1166. // dd(date('Ym',strtotime('first day of -1 month')));
  1167. $rankDatabase = DB::connection('rank');
  1168. $result = $rankDatabase->table('webmaster_effect')->selectRaw('SUM(clicks) as clicks,project_id')->whereIn('project_id', [
  1169. 252, 291
  1170. ])->where(['ym' => date('Ym', strtotime('-1 month'))])->groupBy('project_id')->get()->keyBy('project_id')->toArray();
  1171. dd($result);
  1172. dd(123);
  1173. dd(Agent::query()->whereRaw('JSON_CONTAINS(JSON_ARRAY("1"),channel_ids)')->get());
  1174. app();
  1175. $user = User::query()->where(['id' => 1])->first();
  1176. dump($user->update(['nickname' => '郭大聪']));
  1177. dd($user);
  1178. // dd(filesize('./demo2.jpg'));
  1179. // dd(sprintf('%%s%%','hello'));
  1180. // DB::connection()->enableQueryLog();
  1181. //
  1182. //// $data=Article::query()->where(['site_id' => 50])->where('created_at', '>', 0)->count();
  1183. //
  1184. // User::query()->where('created_at', '>', date('Y-m-d H:i:s'))->get();
  1185. // $logs = DB::getQueryLog();
  1186. // dd($logs);
  1187. //
  1188. // dd(\request()->all());
  1189. hello:
  1190. // $baseUrl = 'https://platform.hootsuite.com';
  1191. $online = Site::query()->selectRaw('SUM(id) as count')->where([
  1192. ])->groupBy('status')->get()->toArray();
  1193. dd($online);
  1194. optional();
  1195. $size = "large";
  1196. $var_array = array("color" => "blue",
  1197. "size" => "medium",
  1198. "shape" => "sphere");
  1199. extract($var_array, EXTR_PREFIX_SAME, "wddx");
  1200. echo "$color, $size, $shape, $wddx_size\n";
  1201. // $my_array = array("Dog","Cat","Horse");
  1202. //
  1203. // list($a, $b, $c) = $my_array;
  1204. dd($uu);
  1205. for ($i = 0; $i < 12; $i++) {
  1206. dump(date('Y-m-d H:i:s', strtotime('-' . $i . ' month', strtotime(date('Y-m-01 00:00:00', time())))));
  1207. }
  1208. return '123';
  1209. $time = strtotime(date('Y-m-01 00:00:00'));
  1210. $tm = strtotime('last day of -' . 0 . ' month', strtotime(date('Y-m-d 23:59:59', $time)));
  1211. dd(date('Y-m-d H:i:s', $tm));
  1212. dd(date('Y-m-d 23:59:59', time()));
  1213. dd(date('Y-m-d H:i:s', strtotime('last day of -' . 1 . ' month', strtotime('2019-08-31 23:59:59'))));
  1214. dd(date('Y-m-d H:i:s', strtotime('+1 month', strtotime('2019-08-31 00:00:00'))));
  1215. $client = new Client;
  1216. $response = $client->post('build.cn/api/pin-boards', [
  1217. 'form_params' => [
  1218. 'token' => 123
  1219. ]
  1220. ]);
  1221. dd($response->getBody()->getContents());
  1222. $str = $response->getBody()->getContents();
  1223. dd(bcrypt(123456));
  1224. dd(date('Y-m-d 00:00:00', strtotime("first day of next month")));
  1225. dd(date('Y-m-01 00:00:00'));
  1226. dd(date('Y-m-d H:i:s', strtotime('last day of ')));
  1227. $b = 'dd';
  1228. $a = [];
  1229. dd($a[$b]);
  1230. // $top10ListMap[$item->old_id]->top10 ?? '未关联';
  1231. // dd(Article::query()->where(['site_id'=>50])->where('created_at','>',0)->count());
  1232. DB::connection()->enableQueryLog();
  1233. Article::query()->where(['site_id' => 50])->where('created_at', '>', 0)->count();
  1234. User::query()->where('created_at', '>', date('Y-m-d H:i:s'))->get();
  1235. $logs = DB::getQueryLog();
  1236. dd($logs);
  1237. return;
  1238. // dd(Excel::import(new DemoLinkImport(), '232外链.xlsx', 'public'));
  1239. // dd(Excel::import(new ArticleImport(), '232文章.xlsx', 'public'));
  1240. $user = User::query()->first();
  1241. $user->makeHidden(['']);
  1242. // $clientId = "5049113417978258277";
  1243. // $clientSecret = "c00f71c0587ddb07b506b51c2beafa8ff953f958451d1779c42ada1a02209dfd";
  1244. // $redirectUrl = "https://wall.yinqingli.com/demo/two";
  1245. // $config = new \SocialiteProviders\Manager\Config($clientId, $clientSecret, $redirectUrl);
  1246. return Socialite::driver('pinterest')->scopes(['read_public', 'write_public'])->redirect();
  1247. dd('one');
  1248. // dd(Site::query()->where(['id'=>122])->update([
  1249. // 'webmaster_domain'=>'123'
  1250. // ]));
  1251. set_time_limit(0);
  1252. //
  1253. // config([
  1254. // 'services.twitter.redirect' => sprintf('%s?siteId=%s', config('services.twitter.redirect'), 100)
  1255. // ]);
  1256. //
  1257. // dd(config('services.twitter'));
  1258. // dd('success');
  1259. //
  1260. // Twitter::reconfig([
  1261. // 'consumer_key' => env('TWITTER_CONSUMER_KEY'),
  1262. // 'consumer_secret' => env('TWITTER_CONSUMER_SECRET'),
  1263. // 'token' => '1159374080497180673-AkWfJt1gQmqlRPaerDcwTjaFbGnzTz',
  1264. // 'secret' => 'O1MtL9HhN66nwaDYPmZEZJrwndEppgiEd6wTdL5j2urQL'
  1265. // ]);
  1266. //
  1267. // $content = 'hello world';
  1268. //
  1269. // dd(Twitter::postTweet(['status' => $content]));
  1270. config([
  1271. 'services.twitter.redirect' => sprintf('%s?siteId=%s', config('services.twitter.redirect'), 100)
  1272. ]);
  1273. return Socialite::with('twitter')->redirect();
  1274. //
  1275. $user = User::query()->first();
  1276. $user = User::find(1);
  1277. $user->update([
  1278. 'nickname' => '郭中聪',
  1279. ]);
  1280. dd($user);
  1281. dd(md5(123456));
  1282. $str = 'Military Connectors Will Enter a New Era of "Digital Transmission"';
  1283. dd(htmlspecialchars($str));
  1284. $users = DB::table('users')->whereIn('id', [5, 1])->get();
  1285. foreach ($users as $inx => $user) {
  1286. dump($inx, $user);
  1287. }
  1288. return;
  1289. $a = 1;
  1290. dd(compact('a', 'b'));
  1291. $url = 'http://www.yinqingli.com';
  1292. $content = 'hello world';
  1293. $token = 'AQVN7nSiMlOjcK4meXnQWcAuXE3yxonYFHrhNnANF5BXBnuSM8X_eccBZKJDjbKzaq1qcaye3IPZSinqcmBKzF4bJwJWTyXYTmUM_-RjEfH-bEzrorVTu1A_kWY83M06pRyMhLrCmcm61UZg5TNsIzlEvap_4H65V-A7WsRNv4Xn5OPvMOb4gXze4opr-vIMVrJaVsYpyp1CBj0lQY6W8PQs208WAzL_ietV7AozWnp04gMIcQhYTotsm_ZvuzskG5cAhVY23P8uZiIFLZnOg6gKVfi_HnqvPCJ-Du8thmnoUjQ_ONSbgdV3LlFDdTJ2flpwZjNesKTfcEVZKG_Q-gbURms1Kw';
  1294. dd(LinkedinShare::shareArticleCompany($token, $url, $content, 'accessToken'));
  1295. return true;
  1296. dd(User::query()->whereIn('id', [5, 1])->get());
  1297. // dd();
  1298. dd(trim(null));
  1299. dd(User::query()->with('trashed')->get());
  1300. // $a = mt_rand(0, 1);
  1301. //
  1302. // echo date('Y-m-d H:i:s').'<br>';
  1303. // if ($a) {
  1304. // sleep(10);
  1305. // echo date('Y-m-d H:i:s');
  1306. // echo 'true';
  1307. // } else {
  1308. // echo date('Y-m-d H:i:s');
  1309. // echo 'false';
  1310. // }
  1311. // dd('done');
  1312. $lock = Cache::lock('foo', 10);
  1313. $result = $lock->get();
  1314. // dump($result);
  1315. if ($result) {
  1316. sleep(8);
  1317. echo $result ? '1' : '2';
  1318. echo date('Y-m-d H:i:s');
  1319. return '操作中...';
  1320. } else {
  1321. echo date('Y-m-d H:i:s');
  1322. return '没得锁...';
  1323. }
  1324. // $lock=Cache::lock('foo', 10);
  1325. //
  1326. // if ($lock->block(5)) {
  1327. // // 等待最多5秒后获取锁定...
  1328. // return '有锁';
  1329. // }
  1330. // dd('done');
  1331. $lock = Cache::lock('foo', 10);
  1332. $result = $lock->get();
  1333. // dump($result);
  1334. if ($result) {
  1335. //获取锁定10秒...
  1336. sleep(9);
  1337. return '操作中...';
  1338. // $lock->release();
  1339. } else {
  1340. return '没得锁...';
  1341. }
  1342. // dd('done');
  1343. // Cache::put('foo','demo',10);
  1344. // dd(Cache::get('foo'));
  1345. // Cache::lock('foo',10);
  1346. // dd(Cache::get('foo'));
  1347. // if (Cache::lock('foo', 10)->get()) {
  1348. // // 获取锁定10秒...
  1349. // echo 1;
  1350. // Cache::lock('foo')->release();
  1351. //
  1352. // } else {
  1353. // echo 2;
  1354. // }
  1355. // if (Cache::lock('foo', 10)->block(5)) {
  1356. // // 等待最多5秒后获取锁定...
  1357. //
  1358. // echo '1';
  1359. // } else {
  1360. // echo 2;
  1361. // }
  1362. //
  1363. // Cache::store('redis')->put('hello_1','world',10);
  1364. // return;
  1365. dd(Cache::store('redis')->get('hello_1'));
  1366. dd(Redis::get('123'));
  1367. dd(111);
  1368. $_publisher = 1;
  1369. echo $_publisher;
  1370. dd(mt_rand(100, 999));
  1371. return Socialite::with('facebook')->scopes(['manage_pages', 'publish_pages'])->redirect();
  1372. // $demo = UrlCheck::query()->where([['created_at', '>', date('Y-m-d H:i:s')]])->get();
  1373. // dd($demo);
  1374. $one = 1;
  1375. $two = 2;
  1376. // dd(1);
  1377. dd(compact('one', 'two', 'three'));
  1378. $linkTypes = Link::TYPES + ['已过期'];
  1379. dd($linkTypes, array_values($linkTypes));
  1380. dd(new \DateTime(date('Y-m-t 23:59:59')));
  1381. Cache::put(sprintf('index_%s', date('Ym')), serialize([1, 2]), new \DateTime(date('Y-m-t 23:59:59')));
  1382. dd(date('Y-m-d H:i:s', strtotime(date('Y-m-t 23:59:59'))));
  1383. dd(date('Y-m-t', strtotime('2019-07')));
  1384. dd(date('Y-m-t 23:59:59'));
  1385. $nowDatetime = new \DateTime();
  1386. $reachDatetime = new \DateTime('2019-07-19 19:00:00');
  1387. dump($interval = $nowDatetime->diff($reachDatetime));
  1388. dd($interval->format('%a'));
  1389. dd(date('Y-m-d H:i:s', strtotime('next month', strtotime('2019-12'))));
  1390. return;
  1391. $users = User::query()->select()->where()->distinct()->get();
  1392. $rankDatabase = DB::connection('rank');
  1393. $data = $rankDatabase->table('project_keyword')->selectRaw('
  1394. SUM(CASE WHEN google_rank <= 10 THEN 1 ELSE 0 END) as top10,
  1395. SUM(CASE WHEN google_rank <= 30 THEN 1 ELSE 0 END) as top30,
  1396. SUM(CASE WHEN google_rank <= 100 THEN 1 ELSE 0 END) as top100
  1397. ')->where([])->whereIn('project_id', [103, 91])->groupBy('project_id')->get();
  1398. dd($data);
  1399. dd(array_column(Site::NATURE_TYPE, 'val', 'inx'));
  1400. $sites = Article::query()->whereExists(function (Builder $builder) {
  1401. $builder->select(DB::raw(1))->from('user_has_sites')->whereRaw('user_id=1 AND user_has_sites.site_id=sites.id ');
  1402. })->get();
  1403. dd($sites);
  1404. $userRecords = User::query()->with('sites')->whereIn('id', [10])->get();
  1405. foreach ($userRecords as $record) {
  1406. $record->sites()->attach(2);
  1407. dd($record->sites->pluck('id')->toArray());
  1408. }
  1409. return;
  1410. return Socialite::with('facebook')->redirect();
  1411. dd(Site::query()->whereNotExists(function (Builder $builder) {
  1412. $builder->select(DB::raw(1))->from('sites_process')
  1413. ->whereRaw('sites_process.process_id=15 AND sites_process.active=1 AND sites.id = sites_process.site_id');;
  1414. })->get());
  1415. DB::connection('rank')->table('traffic_report_hourly')->selectRaw('SUM(pv) AS pv')->where([
  1416. ['create_time', '>', strtotime(date('Y-m-01'))],
  1417. ['create_time', '<', strtotime(date('Y-m-t'))]
  1418. ])->groupBy('project_id')->get();
  1419. dd(Site::query()->selectRaw('COUNT(id) as total,nature_type')->groupBy('nature_type')->get());
  1420. $result = DB::connection('rank')->table('project_history')->selectRaw('Max(create_time) as max,top10,project_id')->where([
  1421. ['create_time', '>', strtotime(date('Y-m-01'))],
  1422. ['create_time', '<', strtotime(date('Y-m-t'))]
  1423. ])->groupBy('project_id')->get();
  1424. dd($result);
  1425. $config = [
  1426. 'connection_name' => sprintf('connection_name_%s', 20),
  1427. 'host' => '127.0.0.1',
  1428. 'port' => '3306',
  1429. 'database' => 'demo',
  1430. 'username' => 'root',
  1431. 'password' => '123',
  1432. ];
  1433. config_connection($config);
  1434. try {
  1435. $record = DB::connection($config['connection_name'])->table('content')->where(['id' => 5])->first();
  1436. } catch (\Throwable $throwable) {
  1437. dd($throwable->getMessage());
  1438. }
  1439. dd(123);
  1440. return Socialite::with('LinkedIn')->scopes(['r_emailaddress', 'r_liteprofile', 'w_member_social'])->redirect();
  1441. $file = 'http://admin.yinqingli.com/storage/201907/jpg/1rZSMSmdfN3XUJSSSZc9ThmYFXZxSiAl2EYROFoJ.jpg';
  1442. dd(pathinfo($file));
  1443. $data = file_get_contents($file);
  1444. // dd($data);
  1445. // dd(Storage::putFile('photos',$data));
  1446. dd(Storage::disk('public')->put('file2.jpg', $data, 'public'));
  1447. dd($data);
  1448. $a = 1;
  1449. dd(compact('a'));
  1450. dd(Site::query()->select(['old_id'])->whereIn('id', [])->pluck('old_id')->filter());
  1451. $collection = collect([
  1452. ['a' => 1],
  1453. ['a' => 2],
  1454. ['a' => 3],
  1455. ['a' => 4],
  1456. ]);
  1457. dd($chunks = $collection->chunk(3)->toArray());
  1458. $url = 'https://serpbook.com/serp/api/?action=addkeyword&auth=2fd8ddefa9f2874f54afde3223b364cc&url=jhhearing.com&kw=jinghao%20hearing&region=google.com&language=en&category=yql';
  1459. $http = new Client;
  1460. try {
  1461. $response = $http->request('get', $url);
  1462. } catch (\GuzzleHttp\Exception\GuzzleException $throwable) {
  1463. dd();
  1464. }
  1465. dd($response->getBody()->getContents());
  1466. $a = 1;
  1467. dd((array)$a);
  1468. $uploaded_media = \Thujohn\Twitter\Facades\Twitter::uploadMedia(['media' => File::get(public_path('demo-head.png'))]);
  1469. \Thujohn\Twitter\Facades\Twitter::postTweet(['status' => 'Laravel is beautiful', 'media_ids' => $uploaded_media->media_id_string]);
  1470. dd('success');
  1471. return;
  1472. $temp = SiteProcess::query()->find(584);
  1473. $evaluate = $temp->evaluate ?? [];
  1474. dd(array_merge($evaluate, ['score_feedback' => ['score' => 5]]));
  1475. dd($evaluate);
  1476. dd(User::query()->where(['id' => 1])->update(['nickname' => '郭中聪']));
  1477. $a = null;
  1478. dd($a->ll ?? null);
  1479. dd(substr('123', 1));
  1480. $cont = '<p><img src="http://build.cn/storage/uploads/image/2019/07/01/b514629e083d49294270198aa58338f6.jpg" title="/uploads/image/2019/07/01/b514629e083d49294270198aa58338f6.jpg" alt="profile_small.jpg"/><img src="http://build.cn/storage/123" title="123" alt="logo_new.png"/></p>';
  1481. $url = str_replace('/', '\/', config('app.url'));
  1482. dd(preg_replace(sprintf('/%s/i', $url), '', $cont));
  1483. dd(app('ueditor.storage'));
  1484. dd(Site::query()->first(['old_id']));
  1485. dd($this->ins());
  1486. return Socialite::with('instagram')->redirect();
  1487. $url = str_replace('/', '\/', 'http://test.yinqingli.com');
  1488. // dd($url);
  1489. dd(preg_replace_callback(sprintf('/(src=.)%s/i', $url), function ($matches) {
  1490. dump($matches[1]);
  1491. return $matches[1];
  1492. }, '<img src="http://test.yinqingli.com/storage/201906/jpg/mAT971ksTiUKs0JtM59K7CGPdqE75SlfDul0IFf4.jpeg">'));
  1493. // return Socialite::with('facebook')->scopes(['manage_pages', 'publish_pages'])->redirect();
  1494. // return Socialite::with('Twitter')->redirect();
  1495. // return Socialite::with('Instagram')->redirect();
  1496. return Socialite::with('LinkedIn')->scopes(['r_emailaddress', 'r_liteprofile', 'w_member_social'])->redirect();
  1497. config(['database.connections.' . $dbConfig->connection_name => [
  1498. 'driver' => 'mysql',
  1499. 'host' => $dbConfig->host,
  1500. 'port' => $dbConfig->port,
  1501. 'database' => $dbConfig->database,
  1502. 'username' => $dbConfig->username,
  1503. 'password' => $dbConfig->password
  1504. ]]);
  1505. DB::connection($dbConfig->connection_name)->table('');
  1506. $taskDetailRecords = LinkTaskDetail::query()->whereIn('task_id', [1, 3])->get(); //获取与人物关联的任务详情记录
  1507. dump($taskDetailRecords->pluck('task_id', 'id')->toArray());
  1508. dd(123);
  1509. // Collection::
  1510. dd(LinkTaskUrl::query()->whereIn('link_tasks_detail_id', [1])->get()->groupBy('link_tasks_detail_id'));
  1511. $data = LinkTask::query()->first();
  1512. dd($data->links);
  1513. dd($data->links()->sync([2]));
  1514. foreach ($data->links as $link) {
  1515. dump($link->pivot);
  1516. }
  1517. return;
  1518. $record = Article::query()->filter($filter)->get()->toArray();
  1519. dd($record);
  1520. // $client = new Client;
  1521. // $promiseList[] = $client->requestAsync('GET', 'http://build.cn/demo/two');
  1522. // $promiseList[] = $client->requestAsync('GET', 'http://build.cn/demo/three');
  1523. //// $promiseList[] = $client->requestAsync('GET', 'http://build.cn/demo/four');
  1524. //// $promiseList[] = $client->requestAsync('GET', 'http://build.cn/demo/five');
  1525. //// $promiseList[] = $client->requestAsync('GET', 'http://build.cn/demo/six');
  1526. // try {
  1527. // $resultList = unwrap($promiseList);
  1528. // } catch (\Throwable $throwable) {
  1529. // dd($throwable->getMessage());
  1530. // return;
  1531. // }
  1532. //
  1533. // foreach ($resultList as $item) {
  1534. // dump($item->getBody()->getContents());
  1535. // }
  1536. // return 123;
  1537. $urlList = ['two', 'three', 'four', 'five', 'll'];
  1538. $client = new Client([
  1539. 'timeout' => 5
  1540. ]);
  1541. $requests = function () use ($urlList) {
  1542. // error_log('total=' . $total);
  1543. foreach ($urlList as $item) {
  1544. yield new Request('GET', sprintf('http://build.cn/demo/%s', $item));
  1545. }
  1546. };
  1547. $pool = new Pool($client, $requests(), [
  1548. 'concurrency' => 5,
  1549. 'fulfilled' => function (Response $response, $index) {
  1550. error_log('success');
  1551. error_log(var_export($index, 1));
  1552. // dump($response->get);
  1553. },
  1554. 'rejected' => function (ClientException $exception, $index) {
  1555. error_log('fail');
  1556. error_log(var_export($exception->getMessage(), 1));
  1557. },
  1558. ]);
  1559. $promise = $pool->promise();
  1560. $promise->wait();
  1561. return 'success';
  1562. // $this->secret_key = isset($key) ? $key : exit('key为必须项');
  1563. //
  1564. // $this->method = $method;
  1565. //
  1566. // $this->iv = $iv;
  1567. //
  1568. // $this->options = $options;
  1569. $encData = openssl_encrypt('44', 'aes-128-ecb', '456');
  1570. dd($encData);
  1571. dd(openssl_encrypt('1112', OPENSSL_CIPHER_AES_128_CBC, '456'));
  1572. dd(call_user_func_array(array($this, 'demo'), ['a' => 1]));
  1573. error_log('123');
  1574. return;
  1575. $t = SiteProcess::find(12);
  1576. dd($t->detail);
  1577. dd(TABLE_PAGE_SIZE);
  1578. dd(Route::currentRouteName());
  1579. // $config = [
  1580. // // HTTP 请求的超时时间(秒)
  1581. // 'timeout' => 5.0,
  1582. //
  1583. // // 默认发送配置
  1584. // 'default' => [
  1585. // // 网关调用策略,默认:顺序调用
  1586. // 'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class,
  1587. //
  1588. // // 默认可用的发送网关
  1589. // 'gateways' => [
  1590. // 'aliyun',
  1591. // ],
  1592. // ],
  1593. // // 可用的网关配置
  1594. // 'gateways' => [
  1595. // 'errorlog' => [
  1596. // 'file' => '/tmp/easy-sms.log',
  1597. // ],
  1598. // 'aliyun' => [
  1599. // 'access_key_id' => 'LTAINvaCNbO0kN9A',
  1600. // 'access_key_secret' => 'stvr2EocXDDKW3MZN7csi0SIuuVb6G',
  1601. // 'sign_name' => '引擎力',
  1602. // ],
  1603. // //...
  1604. // ],
  1605. // ];
  1606. //
  1607. // $easySms = new EasySms($config);
  1608. //
  1609. // dd($easySms->send(15555124010, [
  1610. // 'content' => '您的验证码为: 6379',
  1611. // 'template' => 'SMS_162110318',
  1612. // 'data' => [
  1613. // 'code' => 6379
  1614. // ],
  1615. // ]));
  1616. $sms = new EasySms();
  1617. try {
  1618. dd($sms->send(15555124010));
  1619. } catch (\Throwable $throwable) {
  1620. dd($throwable->getMessage());
  1621. }
  1622. dd(json_decode((new Translate)->request('短短十年左右,中国不仅跃升为混凝土设备年销量、保有量世界第一的国家,更诞生了全球领军的混凝土设备制造商。目前徐工、中联、三一三家企业占据了全球混凝土设备市场90%以上的份额。在中国混凝土设备市场最红火的2012年,全年各类混凝土设备销量超过7万台,销售收入约为1000亿元人民币。2013年,在混凝土泵车销量大幅下滑的情况下,混凝土搅拌站销量依然与2012年持'), true));
  1623. dd(Uuid::uuid1());
  1624. $api = 'TFXmzOx3EwYhJoS1p1Fma2A4JkqPXjYO';
  1625. $client = new Client;
  1626. $response = $client->post('http://openapi.youdao.com/api', [
  1627. 'q' => '你好,世界',
  1628. 'from' => 'auto',
  1629. 'to' => 'auto',
  1630. 'appKey' => $api,
  1631. 'signType' => 'v3',
  1632. 'curtime' => time(),
  1633. 'salt' => Uuid::uuid1(),
  1634. 'sign' => ''
  1635. ]);
  1636. $str = $response->getBody()->getContents();
  1637. dd($str);
  1638. $client = new Client;
  1639. $response = $client->request('get', 'http://www.bts-biotechnology.com/openapi/content/getOptsByJson');
  1640. $str = $response->getBody()->getContents();
  1641. dd($str);
  1642. dd(asset('storage/201904/jpg/tVIr4ywlWQ3FvrpJwlbSfkHz0dYUUJXPbVgw5J1U.jpeg'));
  1643. dd(base64_decode('MTU1NDk5ODQwMA=='));
  1644. dd(strtotime(date('Ym00')) + 86400 * 2);
  1645. dd();
  1646. return view('system/user_show');
  1647. DB::connection()->enableQueryLog();
  1648. Project::query()->scopes(['project' => ['projectIds' => [1]]])->get();
  1649. dd(DB::getQueryLog());
  1650. dd(strtotime(date('Ymd 00:00:00')));
  1651. dd(strtotime('-1 month', strtotime('-1 day')));
  1652. Permission::query()->updateOrCreate([
  1653. 'type' => rand(1, 100)
  1654. ], ['id' => 12]);
  1655. return 123;
  1656. $content = '{{$name}}{{$email}}';
  1657. $view = view($content, ['name' => 'laravel', 'email' => 'laravel@laravel-china.org']);
  1658. $contents = $view->render();
  1659. dd($view);
  1660. dd(date('Y-m-d H:i:s', strtotime('20180231')));
  1661. dd(strtotime(date('Ymd000000')));
  1662. dd(date('Y年m月d H:i:s', strtotime('-1 day', strtotime(date('Ymd00:00:00')))));
  1663. }
  1664. public function tableList()
  1665. {
  1666. $users = Permission::query()->paginate();
  1667. dump($users->items());
  1668. return response()->json([
  1669. 'rows' => $users->items(),
  1670. 'total' => $users->total()
  1671. ]);
  1672. }
  1673. function blade2str($blade, $data = array())
  1674. {
  1675. }
  1676. }