loadHTML('' . $stockBody, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET); $xpath = new DOMXPath($doc); $insert = $pdo->prepare('INSERT INTO catalog (name, category, body, image, alt, url, label, extra_url, extra_label, position) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); foreach ($xpath->query('//article[contains(concat(" ", @class, " "), " project ")]') as $position => $card) { $image = $xpath->query('.//img', $card)->item(0); $links = $xpath->query('.//a', $card); $body = ''; foreach ($xpath->query('.//p', $card) as $paragraph) { $body .= $doc->saveHTML($paragraph); } $insert->execute([ trim($xpath->evaluate('string(.//h3)', $card)), trim($xpath->evaluate('string(.//span)', $card)), Html::sanitize($body), $image->getAttribute('src'), $image->getAttribute('alt'), $links->item(0)->getAttribute('href'), trim($links->item(0)->textContent), $links->item(1)?->getAttribute('href') ?? '', trim($links->item(1)?->textContent ?? ''), $position * 10, ]); } $pdo->prepare('INSERT INTO catalog (name, category, body, image, alt, url, label, position) VALUES (?, ?, ?, ?, ?, ?, ?, ?)') ->execute(['SHNU 学生软著服务', '校园服务', '
面向 SHNU 学生的软件著作权申请服务。
', '/assets/original/shnu-hero.webp', '', '/shnu-sc', '查看学生方案', 30]); $pdo->prepare("UPDATE sections SET body = ?, version = version + 1 WHERE page_slug = 'home' AND key = 'product' AND version = 0 AND body = ?") ->execute(['浏览来笙的建站工具、智能 DNS 和软件著作权服务。
查看产品与服务', $stockBody]); $choices = $pdo->query("SELECT page_slug, body FROM sections WHERE key = 'why' AND page_slug IN ('sc', 'shnu-sc')"); $updateChoice = $pdo->prepare("UPDATE sections SET body = ?, version = version + 1 WHERE page_slug = ? AND key = 'why'"); foreach ($choices->fetchAll() as $section) { $body = preg_replace('~(