Forked from proudcommerce/OXID eShop - Redirect old seo urls
Created
January 2, 2014 09:06
-
-
Save kermie/8216650 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* @copyright (c) Proud Sourcing GmbH | 2013 | |
* @link https://gist.github.com/proudcommerce | |
* @version 1.0.0 | |
**/ | |
class daten | |
{ | |
var $dbServer; // database host name | |
var $dbName; // database name | |
var $dbUser; // database user name | |
var $dbPassword; // database user password | |
function daten() | |
{ | |
require "config.inc.php"; | |
} | |
} | |
function newID() { | |
return substr(uniqid( "", true), 0, 3) . uniqid( "", true); | |
} | |
$config = new daten(); | |
$dbServer = $config->dbHost; | |
$dbName = $config->dbName; | |
$dbUser = $config->dbUser; | |
$dbPassword = $config->dbPwd; | |
$db = mysql_connect($dbServer, $dbUser, $dbPassword) or die(mysql_error()); | |
mysql_select_db($dbName, $db) or die(mysql_error()); | |
$sSQL = "SELECT oxid, nm_oldseourl FROM oxarticles WHERE nm_oldseourl != ''"; | |
$aRes = mysql_query($sSQL); | |
if(mysql_num_rows($aRes) > 0) | |
{ | |
echo "saving old article seo urls ...<br>"; | |
while($aData = mysql_fetch_array($aRes)) | |
{ | |
$sArticleId = $aData["oxid"]; | |
$sSeoUrl = substr($aData["nm_oldseourl"], 1); | |
$sSQL2 = "INSERT INTO oxseohistory (OXOBJECTID, OXSHOPID, OXIDENT) SELECT oxarticles.oxid, oxarticles.oxshopid, MD5(LOWER('$sSeoUrl')) from oxarticles where oxid = '$sArticleId'"; | |
echo $sSQL2."<br>"; | |
mysql_query($sSQL2); | |
} | |
} | |
$sSQL = "SELECT oxid, nm_oldseourl FROM oxcategories WHERE nm_oldseourl != ''"; | |
$aRes = mysql_query($sSQL); | |
if(mysql_num_rows($aRes) > 0) | |
{ | |
echo "<br>saving old category seo urls ...<br>"; | |
while($aData = mysql_fetch_array($aRes)) | |
{ | |
$sCategoryId = $aData["oxid"]; | |
$sSeoUrl = substr($aData["nm_oldseourl"], 1); | |
$sSQL2 = "INSERT INTO oxseohistory (OXOBJECTID, OXSHOPID, OXIDENT) SELECT oxcategories.oxid, oxcategories.oxshopid, MD5(LOWER('$sSeoUrl')) from oxcategories where oxid = '$sCategoryId'"; | |
echo $sSQL2."<br>"; | |
mysql_query($sSQL2); | |
} | |
} | |
mysql_close($db); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment