Prepend "http://" in front of urls that lack "://". Most urls tend to be websites and adding
http:// where it is missing fixes a bunch of urls in the database
This commit is contained in:
@@ -70,7 +70,9 @@ class Application {
|
|||||||
$this->sName = $oRow->appName;
|
$this->sName = $oRow->appName;
|
||||||
$this->sKeywords = $oRow->keywords;
|
$this->sKeywords = $oRow->keywords;
|
||||||
$this->sDescription = $oRow->description;
|
$this->sDescription = $oRow->description;
|
||||||
$this->sWebpage = $oRow->webPage;
|
//TODO: we should move the url to the appData table
|
||||||
|
// and return an id into the appData table here
|
||||||
|
$this->sWebpage = Url::normalize($oRow->webPage);
|
||||||
$this->sQueued = $oRow->queued;
|
$this->sQueued = $oRow->queued;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,27 +21,32 @@ class Url {
|
|||||||
/**
|
/**
|
||||||
* Constructor, fetches the url $iUrlId is given.
|
* Constructor, fetches the url $iUrlId is given.
|
||||||
*/
|
*/
|
||||||
function Url($iUrlId = null)
|
function Url($iUrlId = null, $oRow = null)
|
||||||
{
|
{
|
||||||
// we are working on an existing url
|
if(!$iUrlId && !$oRow)
|
||||||
if($iUrlId)
|
return;
|
||||||
|
|
||||||
|
if(!$oRow)
|
||||||
{
|
{
|
||||||
$sQuery = "SELECT appData.*
|
$sQuery = "SELECT appData.*
|
||||||
FROM appData
|
FROM appData
|
||||||
WHERE type = 'url'
|
WHERE type = 'url'
|
||||||
AND id = '?'";
|
AND id = '?'";
|
||||||
if($hResult = query_parameters($sQuery, $iUrlId))
|
$hResult = query_parameters($sQuery, $iUrlId);
|
||||||
{
|
$oRow = mysql_fetch_object($hResult);
|
||||||
$oRow = mysql_fetch_object($hResult);
|
}
|
||||||
$this->iUrlId = $iUrlId;
|
|
||||||
$this->sDescription = $oRow->description;
|
// we are working on an existing url
|
||||||
$this->iAppId = $oRow->appId;
|
if($oRow)
|
||||||
$this->iVersionId = $oRow->versionId;
|
{
|
||||||
$this->sUrl = $oRow->url;
|
$this->iUrlId = $iUrlId;
|
||||||
$this->bQueued = $oRow->queued;
|
$this->sDescription = $oRow->description;
|
||||||
$this->sSubmitTime = $oRow->submitTime;
|
$this->iAppId = $oRow->appId;
|
||||||
$this->iSubmitterId = $oRow->submitterId;
|
$this->iVersionId = $oRow->versionId;
|
||||||
}
|
$this->sUrl = Url::normalize($oRow->url);
|
||||||
|
$this->bQueued = $oRow->queued;
|
||||||
|
$this->sSubmitTime = $oRow->submitTime;
|
||||||
|
$this->iSubmitterId = $oRow->submitterId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,8 +428,7 @@ class Url {
|
|||||||
if($aValues["iVersionId"])
|
if($aValues["iVersionId"])
|
||||||
$sEmail = User::get_notify_email_address_list($aValues['iVersionId']);
|
$sEmail = User::get_notify_email_address_list($aValues['iVersionId']);
|
||||||
else
|
else
|
||||||
$sEmail = User::get_notify_email_address_list($aValues['iAppId'])
|
$sEmail = User::get_notify_email_address_list($aValues['iAppId']);
|
||||||
;
|
|
||||||
if($sWhatChanged && $sEmail)
|
if($sWhatChanged && $sEmail)
|
||||||
{
|
{
|
||||||
$oApp = new Application($aValues["iAppId"]);
|
$oApp = new Application($aValues["iAppId"]);
|
||||||
@@ -482,13 +486,33 @@ class Url {
|
|||||||
|
|
||||||
for($i = 0; $oRow = mysql_fetch_object($hResult); $i++)
|
for($i = 0; $oRow = mysql_fetch_object($hResult); $i++)
|
||||||
{
|
{
|
||||||
|
// create a url object
|
||||||
|
$oUrl = new Url(null, $oRow);
|
||||||
|
|
||||||
$sReturn .= html_tr(array(
|
$sReturn .= html_tr(array(
|
||||||
"<b>Link</b>",
|
"<b>Link</b>",
|
||||||
"<a href=\"$oRow->url\">$oRow->description</a>"),
|
"<a href=\"$oUrl->sUrl\">$oUrl->sDescription</a>"),
|
||||||
"color1");
|
"color1");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sReturn;
|
return $sReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if a url lacks "://" assume the url is an http one
|
||||||
|
// and prepend "http://"
|
||||||
|
function normalize($sTheUrl)
|
||||||
|
{
|
||||||
|
// if we already have "://" in the url
|
||||||
|
// we can leave the url alone
|
||||||
|
if(strpos($sTheUrl, "://") === false)
|
||||||
|
{
|
||||||
|
// assume this is a website and prepend "http://"
|
||||||
|
return "http://".$sTheUrl;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// leave the url alone
|
||||||
|
return $sTheUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user