forked from storm95/nishiAgarwal.in
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpFunctions.php
95 lines (79 loc) · 2.4 KB
/
phpFunctions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
function debugToConsole($dataTag, $data)
{
if(is_array($data) || is_object($data))
{
$data = json_encode($data);
}
echo("<script>console.log('PHP: ".$dataTag." : ".$data."');</script>");
}
function getPhotoHref($photoName)
{
global $onePhotoBlogPhp, $colName;
$retHref = $onePhotoBlogPhp.'?'.$colName.'='.$photoName;
//debugToConsole("getPhotoHref", $retHref);
return $retHref;
}
function getPhotoSrc($photoFileNameVal)
{
global $photoDir;
$retSrc = $photoDir.'/'.$photoFileNameVal;
//debugToConsole("getPhotoSrc", $retSrc);
return $retSrc;
}
function addOnePhoto($photoRow)
{
global $colName, $colDescription, $colPhotoFileName;
$retOnePhoto = '<div class="height-100 col-lg-4 col-md-4 col-sm-4 col-xs-4">
<div class="thumbnail">
<a href="'.getPhotoHref($photoRow[$colName]).'">
<div>
<img src="'.getPhotoSrc($photoRow[$colPhotoFileName]).'" class="thumbnail-img">
</div>
<div class="caption thumbnail-body" >
<div><h4><span>'.$photoRow[$colName].'</span></h4></div>
<div>
<p><span>'.$photoRow[$colDescription].'</span></p>
</div>
</div>
</a>
</div>
</div>';
return $retOnePhoto;
}
function addPhotoRow($photosArray, $startIdx, $noOfPhotosInRow)
{
$lastIdx = min(count($photosArray), $startIdx + $noOfPhotosInRow);
$retPhotoRow = '<div class="row thumbnail-div">';
for($i=$startIdx;$i<$lastIdx;++$i)
{
$retPhotoRow = $retPhotoRow.addOnePhoto($photosArray[$i]);
}
$retPhotoRow = $retPhotoRow.'</div>';
return $retPhotoRow;
}
function sendPwdVerifyCode($colEmailIdVal)
{
global $forgotChangePwdUrl, $sendPwdVerifyCode, $colPwdVerifyCode, $sendPwdVerifyCodeVal;
//send Mail
$colPwdVerifyCodeVal = generateRandomString();
$retAddPwdVerifyCode = addPwdVerifyCode($colPwdVerifyCodeVal, $colEmailIdVal);
$to = '[email protected]';
$subject = 'Password change';
$message = '<html> Please click <a href="'.$forgotChangePwdUrl.'?'.$sendPwdVerifyCode.'=2&'.$colPwdVerifyCode.'='.$colPwdVerifyCodeVal.'">this link</a> </html>';
$from = '[email protected]';
$retSendMail = sendMail($to, $subject, $message, $from);
if(!$retSendMail)
{//Mail couldnot be sent
return 3;
}
if($retAddPwdVerifyCode == 1)
{//PwdVerifyCode added to db
return 1;
}
else
{//Could not add PwdVerifyCode to db
return 2;
}
}
?>