בינה מלאכותית ChatGPT, איך אתם משתמשים בו בעבודה היומיומית?

  • הוסף לסימניות
  • #82
זה פשוט מדהים

אני -
how to create nonce table for protect my project​
הצ'אט -
A nonce (number used once) is a unique value that can be used to protect your project from certain types of attacks, such as cross-site request forgery (CSRF) attacks. Here's an example of how you can create a nonce table in a MySQL database:​
  1. Create a new table in your MySQL database to store nonces. You can call it "nonces" or something similar.​
  2. Add the following columns to the table:​
    • "nonce": a VARCHAR column to store the nonce value​
    • "expires": a TIMESTAMP column to store the expiration date and time of the nonce​
    • "user_id": an INT column to store the ID of the user associated with the nonce (if applicable)​
  3. Create a PHP function to generate and store a new nonce in the table. The function should do the following:​
    • Generate a new nonce value using a cryptographically secure random number generator​
    • Insert the nonce value, current timestamp, and user ID (if applicable) into the nonces table​
    • Return the nonce value​
  4. In your forms, links or any other point where you want to use nonce, include the nonce value as a hidden field or in query string.​
  5. When handling the form submission or link click, check the nonce value against the database to ensure that it is valid and has not expired. If the nonce is invalid or expired, reject the request.​
  6. Finally, you can also add a cron job or a scheduled task to regularly delete expired nonces from the database.​
It's important to note that using nonce alone may not be enough to protect your project from all types of attacks, it should be used in combination with other security measures such as input validation, and sanitization.​

אני -
give my the SQL query to create this table (at MySQL)

הצ'אט -
Here's an example of an SQL query that you can use to create a nonce table in a MySQL database:


SQL:
CREATE TABLE nonces (
nonce VARCHAR(255) NOT NULL PRIMARY KEY,
expires TIMESTAMP NOT NULL,
user_id INT(11) NOT NULL
);

This query creates a new table called "nonces" with three columns:

  • "nonce": a VARCHAR column with a maximum length of 255 characters and set as primary key.
  • "expires": a TIMESTAMP column to store the expiration date and time of the nonce
  • "user_id": an INT column to store the ID of the user associated with the nonce.
Please note that you may need to adjust the query to suit your specific requirements, such as the size of the nonce column if you require longer nonce strings.

It's also important to note that you need to have the proper permission to create tables and insert data on the
database you are using.

אני -
How do I use it to create a PHP code for a client-side AJAX query and server-side validation?

הצ'אט -
Here's an example of how you can use a nonce to protect a client-side AJAX query and perform server-side validation in PHP:

  1. On the client-side:
  • Create an AJAX request that sends a nonce value along with the data to be processed. You can generate the nonce value using a PHP function and include it as a hidden field in the form or as a query parameter in the AJAX request.
  • When the user submits the form or clicks on the link that triggers the AJAX request, the nonce value is sent to the server along with the other data.
  1. On the server-side:
  • When the server receives the AJAX request, it should check the nonce value against the database to ensure that it is valid and has not expired.
  • If the nonce is valid, the server can proceed to process the data and return a response to the client.
  • If the nonce is invalid or expired, the server should return an error and not process the data.
Here is an example of a PHP function that generates a new nonce:



PHP:
function generate_nonce() {
$nonce = bin2hex(random_bytes(32));
$expires = date("Y-m-d H:i:s", strtotime("+1 hour"));
$user_id = (isset($_SESSION['user_id'])) ? $_SESSION['user_id'] : null;

$query = "INSERT INTO nonces (nonce, expires, user_id) VALUES (?, ?, ?)";
$stmt = $pdo->prepare($query);
$stmt->execute([$nonce, $expires, $user_id]);
return $nonce;
}

You can use this function on your form or link to generate nonce and include it as a hidden field in form or as a query parameter in the AJAX request.

Then, in the server-side script that handles the form submission or link click, you can check the nonce value against the database using a query like this:



SQL:
$query = "SELECT * FROM nonces WHERE nonce = ? AND expires >= ?";
$stmt = $pdo->prepare($query);
$stmt->execute([$nonce, date('Y-m-d H:i:s')]);
$row = $stmt->fetch();

And check if the result is empty or not, if it's empty, the nonce is not valid, otherwise, the nonce is valid, you can proceed with the data and delete the nonce from the table.

It's important to note that this example is only a starting point and you should consider additional security measures to protect your application.
 
  • הוסף לסימניות
  • #83
זה שאפשר לשאול עוד שאלות אחרי התוצאה בלי לחפש מהתחלה זה גם יתרון.
חוץ מזה מקצר תהליכים בשוטף גם בדברים הכי פשוטים
הייתי צריכה לעשות data model, הכנסתי לו את רשימת השדות והסוגים כמו שקיבלתי, מפוסקים,
יצר לי קלאס ברגע בלי שאצטרך prop+tab+tab על כל שורה.
ובטח בנושאים חדשים מביא דוגמא שהייתי מגיעה לאותה תוצאה בד"כ אחרי כמה וכמה חיפושים ונסיונות.
 
  • הוסף לסימניות
  • #84
נתן לי הסבר מפורט כולל את הסיפריות וכל הקוד שצריך כדי לממש צ'אט בC# ואנגולר.
 
  • הוסף לסימניות
  • #85
מדהים! זרקתי לו מחלקה עם 140 שורות וצירפתי הנחיה לאפשר תכונה מסוימת
הוא זיהה את הפונקציה שאחראית לפעולה הזו ונתן חלופה מתאימה
 
  • הוסף לסימניות
  • #86
זה באמת מדהים, אבל פעמיים הוא לא ענה לי טוב,
פעם אחת על שאלה תאורטית, וכשכתבתי לו שהתשובה שגויה, הוא תיקן את עצמו,
ופעם אחת הייתי צריכה קטע קוד, העתקתי אותו והוא לא עבד...
(ולא שאלתי אותו כל כך הרבה בינתיים)
 
  • הוסף לסימניות
  • #87
עיקר התועלת שלו בחוויתי האישית:
1. התנסחות.
מציאת שמות מעולים למצגת לדזיין, לכלי חדש, כתיבת מייל שאמור להגיע לCS ואחרי זה ללקוח בצורה מהוקצעת. כתיבת קומיטים וטאסקים תיאוריים.
אם פעם הצטערתי שלא לקחתי קורס בהבעה בעל פה או בכתב, היום זה נעלם.

הוא עוזרי הנאמן בבניית דוגמאות קוד למאמרים..

כתיבת קו"ח לקולגות.
תנסו את זה. תכתבו את כל הדברים שאתם חזקים בהם, ותתתארו את החלקים שאמורים להיות בקו"ח.
תוצאה נחמדת ממש.

2. שמירה על קונטקסט. מתחילים בסיסי ועולים בשלבים עד לתוצאה הנכונה.
והוא איתי לאורך כל הדרך בלי הצורך לכתוב שוב ושוב את השאלה.

גם לי בנטפרי עובד רק דרך פיירפוקס.
בעבודה, זה לא מתאפשר בגלל ה VPN (זו בעיה ידועה, חפשו ברשת. הוא חוסם עקב בעיה שלו להגיע לזיהוי הנכון שלך)

אני משתמשת בכלי הבא (מקיף יותר? פחות צ'אטי?) כרגע בשוטף. אפשר לבחור שם עם איזה מודל רוצים לעבוד.
לפי ההסברים על המודלים השונים, הדיפולטי הוא הבחירה הטובה שלכם.
 
  • הוסף לסימניות
  • #88
יש פתרון לבעיה הזאת? קורה בכמה מחשבים
1674555957714.png
 
  • הוסף לסימניות
  • #91
  • הוסף לסימניות
  • #95
  • הוסף לסימניות
  • #97
זה לא חידוש של הבוט, כן?
הוא סתם עזר לכתוב את זה.
 
  • הוסף לסימניות
  • #98
זה לא חידוש של הבוט, כן?
הוא סתם עזר לכתוב את זה.
לא חשבתי אחרת...
רק הבאתי את זה בתור דוגמא עד איפה אפשר להגיע איתו.
 
  • הוסף לסימניות
  • #99
אין, מה לומר זה אחד הדברים.
צריך פשוט להגדיל ראש מה לבקש ממנו,
לדוג עשה לי טבלה של ארוחות צהרים לשבוע, שכוללות פחמימות ירקות חלבון
+רשימה למכולת כל יום

בנוגע למתכנתים, המשרה הבאה היא : דרוש מפתח GPT..
 

פרוגבוט

תוכן שיווקי
פרסומת

הצטרפות לניוזלטר

איזה כיף שהצטרפתם לניוזלטר שלנו!

מעכשיו, תהיו הראשונים לקבל את כל העדכונים, החדשות, ההפתעות בלעדיות, והתכנים הכי חמים שלנו בפרוג!

לוח מודעות

הפרק היומי

הפרק היומי! כל ערב פרק תהילים חדש. הצטרפו אלינו לקריאת תהילים משותפת!


תהילים פרק כה

אלְדָוִד אֵלֶיךָ יי נַפְשִׁי אֶשָּׂא:באֱלֹהַי בְּךָ בָטַחְתִּי אַל אֵבוֹשָׁה אַל יַעַלְצוּ אֹיְבַי לִי:גגַּם כָּל קוֶֹיךָ לֹא יֵבֹשׁוּ יֵבֹשׁוּ הַבּוֹגְדִים רֵיקָם:דדְּרָכֶיךָ יי הוֹדִיעֵנִי אֹרְחוֹתֶיךָ לַמְּדֵנִי:ההַדְרִיכֵנִי בַאֲמִתֶּךָ וְלַמְּדֵנִי כִּי אַתָּה אֱלֹהֵי יִשְׁעִי אוֹתְךָ קִוִּיתִי כָּל הַיּוֹם:וזְכֹר רַחֲמֶיךָ יי וַחֲסָדֶיךָ כִּי מֵעוֹלָם הֵמָּה:זחַטֹּאות נְעוּרַי וּפְשָׁעַי אַל תִּזְכֹּר כְּחַסְדְּךָ זְכָר לִי אַתָּה לְמַעַן טוּבְךָ יי:חטוֹב וְיָשָׁר יי עַל כֵּן יוֹרֶה חַטָּאִים בַּדָּרֶךְ:טיַדְרֵךְ עֲנָוִים בַּמִּשְׁפָּט וִילַמֵּד עֲנָוִים דַּרְכּוֹ:יכָּל אָרְחוֹת יי חֶסֶד וֶאֱמֶת לְנֹצְרֵי בְרִיתוֹ וְעֵדֹתָיו:יאלְמַעַן שִׁמְךָ יי וְסָלַחְתָּ לַעֲוֹנִי כִּי רַב הוּא:יבמִי זֶה הָאִישׁ יְרֵא יי יוֹרֶנּוּ בְּדֶרֶךְ יִבְחָר:יגנַפְשׁוֹ בְּטוֹב תָּלִין וְזַרְעוֹ יִירַשׁ אָרֶץ:ידסוֹד יי לִירֵאָיו וּבְרִיתוֹ לְהוֹדִיעָם:טועֵינַי תָּמִיד אֶל יי כִּי הוּא יוֹצִיא מֵרֶשֶׁת רַגְלָי:טזפְּנֵה אֵלַי וְחָנֵּנִי כִּי יָחִיד וְעָנִי אָנִי:יזצָרוֹת לְבָבִי הִרְחִיבוּ מִמְּצוּקוֹתַי הוֹצִיאֵנִי:יחרְאֵה עָנְיִי וַעֲמָלִי וְשָׂא לְכָל חַטֹּאותָי:יטרְאֵה אוֹיְבַי כִּי רָבּוּ וְשִׂנְאַת חָמָס שְׂנֵאוּנִי:כשָׁמְרָה נַפְשִׁי וְהַצִּילֵנִי אַל אֵבוֹשׁ כִּי חָסִיתִי בָךְ:כאתֹּם וָיֹשֶׁר יִצְּרוּנִי כִּי קִוִּיתִיךָ:כבפְּדֵה אֱלֹהִים אֶת יִשְׂרָאֵל מִכֹּל צָרוֹתָיו:
נקרא  2  פעמים
למעלה