php:使用php脚本替换图像src路径

时间:2019-04-29 11:27:42

标签: php mysql magento-1.9

我想创建php脚本来更新img src路径。

旧结果:

<a href="http://example.com" target="_blank"><img src="{{media url=''}}wysiwyg/images/img_07.jpg" border="1">

预期结果:

<a href="http://example.com" target="_blank"><img src="{{media url='wysiwyg/images/img_07.jpg'}}" border="1">

我使用以下代码:

<?php
$servername = "localhost";
$username = "root";
$password = "testing";
$dbname = "database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM table_nm WHERE attribute_id = 1";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        echo htmlentities($row["value"]) . "<br>"; //old result text display from here.
    }
} else {
    echo "0 results";
}
$conn->close();
?>

我需要改变以获得预期的结果吗?

1 个答案:

答案 0 :(得分:1)

您可以尝试此方法以获得预期的结果

std::string pubkey = "ecdsa-sha2-nistp256 AAAA...Kw= foo@bar";
std::string ecdsa = "ecdsa-sha2-nistp256 ";
size_t begin = pubkey.find(ecdsa);
size_t end = pubkey.find(" ", begin + ecdsa.size() );
pubkey = pubkey.substr(begin + ecdsa.size(), end - (begin + ecdsa.size()) ); //pubkey is now : AAAA...Kw=

EC_GROUP *ecgroup = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1);
EC_POINT *point = EC_POINT_new(ecgroup);
int res = EC_POINT_oct2point(ecgroup, point, (unsigned char *)pubkey.c_str(), pubkey.size(), NULL); //Return 0 here, but OK should be 1
eckey = EC_KEY_new();
res = EC_KEY_set_group(eckey, ecgroup);
res = EC_KEY_set_public_key(eckey, point);