1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @param $strcontact |
5
|
|
|
* @return string |
6
|
|
|
*/ |
7
|
|
|
function convertmycontacts($strcontact) |
8
|
|
|
{ |
9
|
|
|
// Ermitteln aller einzelnen Wörter von Kontakt aus Termin piCal |
10
|
|
|
// Umwandeln der einzelnen Namen in Link auf Benutzerkonto, wenn Name ein Mitgliedsname ist |
11
|
|
|
$strsearch = ' '; |
12
|
|
|
$strnew = ''; |
13
|
|
|
$strseperator = ''; |
|
|
|
|
14
|
|
|
|
15
|
|
|
$pos1 = 0; |
16
|
|
|
$pos2 = strpos($strcontact, $strsearch, $pos1); |
17
|
|
|
|
18
|
|
|
if ($pos2 === false) { |
19
|
|
|
//echo "<br>kein leerzeichen"; |
20
|
|
|
$struser = $strcontact; |
21
|
|
|
$struid = getuid($struser); |
22
|
|
View Code Duplication |
if ($struid == -1) { |
|
|
|
|
23
|
|
|
$strnew = $struser; |
24
|
|
|
} else { |
25
|
|
|
$strnew = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $struid . "' title='" . $struser . "'>" . $struser . '</a>'; |
26
|
|
|
} |
27
|
|
|
} else { |
28
|
|
|
//Leerzeichen vorhanden |
29
|
|
|
while ($pos2 !== false) { |
30
|
|
|
//alle wörter zwischen Leerzeichen ermitteln |
31
|
|
|
$struser = substr($strcontact, $pos1, $pos2 - $pos1); |
32
|
|
|
if (substr($struser, -1) === ',') { |
33
|
|
|
$struser = substr($struser, 0, strlen($struser) - 1); |
34
|
|
|
$strseperator = ', '; |
35
|
|
|
} else { |
36
|
|
|
$strseperator = ' '; |
37
|
|
|
} |
38
|
|
|
$struid = getuid($struser); |
39
|
|
|
if ($struid == -1) { |
40
|
|
|
$strnew = $strnew . $struser . $strseperator; |
41
|
|
|
} else { |
42
|
|
|
$strnew = $strnew . "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $struid . "' title='" . $struser . "'>" . $struser . '</a>' . $strseperator; |
43
|
|
|
} |
44
|
|
|
$pos1 = $pos2 + 1; |
45
|
|
|
$pos2 = strpos($strcontact, $strsearch, $pos1); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
if ($pos2 == 0) { |
49
|
|
|
//Rest ab letztem Leerzeichen einlesen |
50
|
|
|
$struser = substr($strcontact, $pos1); |
51
|
|
|
$struid = getuid($struser); |
52
|
|
View Code Duplication |
if ($struid == -1) { |
|
|
|
|
53
|
|
|
$strnew .= $struser; |
54
|
|
|
} else { |
55
|
|
|
$strnew = $strnew . "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $struid . "' title='" . $struser . "'>" . $struser . '</a>'; |
56
|
|
|
} |
57
|
|
|
} else { |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return $strnew; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param $UserName |
66
|
|
|
* @return int |
67
|
|
|
*/ |
68
|
|
|
function getuid($UserName) |
69
|
|
|
{ |
70
|
|
|
$rc = -1; |
71
|
|
|
$db = XoopsDatabaseFactory::getDatabaseConnection(); |
72
|
|
|
$sql = 'SELECT uid FROM ' . $db->prefix('users') . " WHERE uname = '" . $UserName . "' LIMIT 0,1"; |
73
|
|
|
|
74
|
|
|
$result = $db->query($sql); |
75
|
|
|
if ($result) { |
76
|
|
|
if ($db->getRowsNum($result) == 1) { |
77
|
|
|
$member = $GLOBALS['xoopsDB']->fetchObject($result); |
78
|
|
|
$userid = $member->uid; |
79
|
|
|
$rc = $userid; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return $rc; |
84
|
|
|
} |
85
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.