Skip to content

Instantly share code, notes, and snippets.

@proudcommerce
Created December 25, 2013 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save proudcommerce/8124404 to your computer and use it in GitHub Desktop.
Save proudcommerce/8124404 to your computer and use it in GitHub Desktop.
Script for saving old seo urls. Redirects old seo urls (e. g. from an other shop software after relaunch) to the new oxid shop seo urls.
<?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