Add B2B form email saving

This commit is contained in:
Roman Pyrih
2025-03-07 12:38:32 +01:00
parent f2698d53d0
commit d4690a42af
9 changed files with 1768 additions and 1690 deletions

29
.vscode/settings.json vendored
View File

@@ -1,17 +1,14 @@
{ {
"liveSassCompile.settings.formats": [ "liveSassCompile.settings.formats": [
{ {
"format": "compressed", "format": "compressed",
"extensionName": ".css", "extensionName": ".css",
"savePath": "", "savePath": "~/../style-css/",
"savePathSegmentKeys": null, "savePathSegmentKeys": null,
"savePathReplaceSegmentsWith": null "savePathReplaceSegmentsWith": null
} }
], ],
"liveSassCompile.settings.generateMap": true, "liveSassCompile.settings.generateMap": true,
"liveSassCompile.settings.autoprefix": "defaults", "liveSassCompile.settings.autoprefix": "defaults",
"liveSassCompile.settings.watchOnLaunch": true, "liveSassCompile.settings.watchOnLaunch": true
"liveSassCompile.settings.includeItems": [ }
"/wp-content/themes/bridge-child/styles/*.scss"
]
}

View File

@@ -26,6 +26,31 @@ $mdb = new medoo( [
'charset' => 'utf8' 'charset' => 'utf8'
] ); ] );
function saveArticleUnlockData($email = '') {
$filePath = $_SERVER['DOCUMENT_ROOT'] . '/autoinstalator/wordpress6/b2b_users.csv';
$data = array(
'Email' => $email,
'Timestamp' => date('Y-m-d H:i:s')
);
if (!file_exists($filePath)) {
$header = array_keys($data);
$history = array($header);
} else {
$history = array_map('str_getcsv', file($filePath));
}
$history[] = $data;
$csvContent = fopen($filePath, 'w');
foreach ($history as $row) {
fputcsv($csvContent, $row);
}
fclose($csvContent);
}
if ( !$lang_id = \S::get_session( 'current-lang' ) ) if ( !$lang_id = \S::get_session( 'current-lang' ) )
{ {
$lang_id = \front\factory\Languages::default_language(); $lang_id = \front\factory\Languages::default_language();
@@ -117,12 +142,19 @@ if ( \S::get( 'a' ) == 'contrast' )
exit; exit;
} }
if ( \S::get( 'a' ) == 'article_unlock' ) if (\S::get('a') == 'article_unlock') {
{ $article_id = \S::get('article_id');
\front\controls\Articles::article_unlock( $email = \S::get('email');
\S::get( 'password' ),
\S::get( 'article_id' ) $success = \front\controls\Articles::article_unlock(
); \front\factory\Articles::article_password($article_id),
$article_id
);
if ($success) {
saveArticleUnlockData($email);
}
exit; exit;
} }

View File

@@ -70,7 +70,10 @@ class Articles
public static function article_unlock( $password, $article_id ) public static function article_unlock( $password, $article_id )
{ {
if ( $password == \front\factory\Articles::article_password( $article_id ) ) if ( $password == \front\factory\Articles::article_password( $article_id ) ){
\S::set_session( 'article-' . $article_id . '-' . $password, true ); \S::set_session( 'article-' . $article_id . '-' . $password, true );
return true;
}
return false;
} }
} }

0
b2b_users.csv Normal file
View File

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,7 @@ function saveContactData(
$invoiceNumber = '' $invoiceNumber = ''
) { ) {
$contactHistoryFile = $_SERVER['DOCUMENT_ROOT'] . '/autoinstalator/wordpress14/forms.csv'; $contactHistoryFile = $_SERVER['DOCUMENT_ROOT'] . '/autoinstalator/wordpress6/forms.csv';
$contactData = array( $contactData = array(
'Name' => $name, 'Name' => $name,

View File

@@ -0,0 +1,44 @@
<div class="article-password" id="article-password-<?= $this -> article['id'];?>">
<div class="row">
<div class="col-12">
<p><?= \S::lang( 'ten-artykul-jest-chroniony-podaj-haslo-aby-odblokowac-zawartosc-artykulu' );?></p>
<form metho="POST" id="form-<?= $this -> article['id'];?>">
<!-- <input type="password" name="password" id="password-<?= $this -> article['id'];?>" required="required"> -->
<input type="email" name="email" id="email-<?= $this -> article['id'];?>" required="required">
<input type="submit" class="btn btn-success" id="submit-<?= $this -> article['id'];?>" value="<?= \S::lang( 'odblokuj' );?>">
</form>
</div>
</div>
</div>
<script class="footer" type="text/javascript">
$( function()
{
$( 'body' ).on( click_event, '#submit-<?= $this -> article['id'];?>', function(e)
{
if ( $.trim( $( "#email-<?= $this -> article['id'];?>" ).val() ) !== '' )
{
e.preventDefault();
var email = $( '#email-<?= $this -> article['id'];?>' ).val();
$.ajax(
{
type: 'POST',
cache: false,
url: '/ajax.php',
data:
{
a: 'article_unlock',
email: email,
article_id: <?= $this -> article['id'];?>
},
success: function( data )
{
location.reload();
}
});
return false;
}
});
});
</script>