الموقع العربي الاول للعبة Silkroad Online

الموقع العربي الاول للعبة Silkroad Online (https://silkroad4arab.com/vb/index.php)
-   قســم البــرامج العامــة (https://silkroad4arab.com/vb/forumdisplay.php?f=155)
-   -   اكواد برامج سى بلس بلس و سى شارب من برمجتى (https://silkroad4arab.com/vb/showthread.php?t=492004)

iMido 27-03-2013 02:25 AM

اكواد برامج سى بلس بلس و سى شارب من برمجتى
 
بسم الله الرحمن الرحيم

عاملين ايه يا رجاله :D

وحيات ديكى المنتدى وحشنى اوى و الاعضاء الرجاله الى علمونى حجات متتعدش برضو وحشونى :D

بعد غياب طويل قررت ارجع بمواضيع برمجه تانى بس مش فى بى دوت نت علشان باين عليكو مش بتحبوها و كمان بيقولو عليها لغه اطفال -_-

سى شارب و سى بلس بلس :D

اول سورس كود :-

ده حاجه كده علشان تفهم التعامل مع fstream الخاصه ب الملفات

++C

كود PHP:

#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;

int main(int argcchar *argv[])
{
    
string check;
    
string rline;
    
string toread;
    
cout<<"If you wanna read text press 'R' , wanna write press 'W'\n\n";
    
cin>>check;
    if (
check == "R" || "r")
    {
              
ifstream read ("ex.txt");
              if ( 
read.is_open())
              {
                   while ( 
read.good())
                   {
                         
getline (read rline);
                         
cout << endl << rline << endl << endl ;
                         }
                   }
              }
    

     if ( 
check =="W" || "w" )
    {
         
cout<<"\n\nWrite Text to save \n\n";
         
cin >> toread ;
         
ofstream write ;
         
write.open("ex.txt");
         
write << toread ;
         
cout << "\nSaved ..\n\n";
         }
        else 
        {
             
cout<< "Enter A Valid Value ..";
             }
    
    
    
system("PAUSE");
    return 
EXIT_SUCCESS;


البرنامج مكتوب على المترجم الجامد ++DEV C
* لو فى مشاكل فى تجربته على الفيجول او تربو سى مش هتخسر حاجه لو قلتلى :D *

تانى سورس كود :-

انتى فايرس بس حاجه خفيفه كده * يعنى مش عاوز حد يقولى انا عندى انتى فايرس هحتاج ده ليه ! .. ده تعلىمى يا حج لو تجارى مكنتش هتشوف السورس لو اتشقلبت :D :D *

كود PHP:

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using Microsoft.VisualBasic;
using System.Windows.Forms;
using Microsoft.CSharp;
using System.Threading;

namespace 
Softex_Mini_Antivirus
{
    public 
partial class Form1 Form
    
{
        public 
Form1()
        {
            
InitializeComponent();
        }
      
      
        private 
void timer1_Tick(object senderEventArgs e)
        {
            
button7.Enabled true;
            
button8.Enabled true;
            
lsf.Text textBox1.Text;
            
listBox3.Items.Add(lsf.Text);
            
progressBar1.Maximum Convert.ToInt32(listBox1.Items.Count);

            
totalfiles.Text Convert.ToString(listBox1.Items.Count);
         

            if (
progressBar1.Value != progressBar1.Maximum)
            {
                try
                {

                    
listBox1.SelectedIndex listBox1.SelectedIndex 1;
                    
textBox1.Text listBox1.SelectedItem.ToString();
                }
                catch (
Exception ex)
                {
                }

                try
                {

                    if (!
File.Exists(Application.StartupPath + @"/viruslist.txt"))
                    {
                        throw new 
Exception("There's no db file !");
                    }
                    
TextBox scanbox = new TextBox();
                    
string read File.ReadAllText(Application.StartupPath + @"/viruslist.txt");
                    
progressBar1.Increment(1);
                    
infecfiles.Text Convert.ToString(listBox2.Items.Count);
                    
scannedfiles.Text Convert.ToString(progressBar1.Value);
                    
scanbox.Text read;
                    
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                    
FileStream f = new FileStream(listBox1.SelectedItem.ToString(), FileMode.OpenFileAccess.ReadFileShare.Read8192);
                    
= new FileStream(listBox1.SelectedItem.ToString(), FileMode.OpenFileAccess.ReadFileShare.Read8192);

                    
md5.ComputeHash(f);
                    
Byte[] hash md5.Hash;
                    
StringBuilder buff = new StringBuilder();
                    foreach (
Byte hashByte in hash)
                    {
                        
buff.Append(String.Format("{0:X2}"hashByte));
                    }

                    if (
scanbox.Text.Contains(buff.ToString()))
                    {
                        
listBox2.Items.Add(listBox1.SelectedItem);

                    }
                }
                catch (
Exception ex)
                {
                }
            }
            else
            {
                
timer1.Enabled false;
                
MessageBox.Show("Finished Scanning Folder!");
                
tabControl1.SelectTab(3);
            }
            if (
listBox1.Items.Count == 0)
            {
                
MessageBox.Show("No Threats were detected, Scan Window will close!""Info"MessageBoxButtons.OKMessageBoxIcon.Information);
            }
        }

        private 
void timer2_Tick(object senderEventArgs e)
        {
            try
            {
                if (
listBox2.Items.Count != 0)
                {
                    
listBox2.SelectedIndex += 1;
                    
File.Delete(listBox1.SelectedItem.ToString());
                    
listBox2.Items.Remove(listBox2.SelectedItem.ToString());

                }
                else
                {
                    
timer1.Enabled false;
                    
timer2.Enabled false;
                    
MessageBox.Show("Threat Was Removed Successfully!""Info"MessageBoxButtons.OKMessageBoxIcon.Information);
                }
            }
            catch (
Exception ex)
            {

            }


        }


        private 
void fileSystemWatcher1_Changed(object senderFileSystemEventArgs e)
        {
            try
            {
                
lsf.Text e.FullPath;
                
listBox3.Items.Add(lsf.Text);
                
openFileDialog1.FileName "";

                
TextBox scanbox = new TextBox();
                
scanbox.Text File.ReadAllText(Application.StartupPath + @"/viruslist.txt").ToString();
                
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                
Byte[] hash md5.Hash;
                
StringBuilder buff = new StringBuilder();

                foreach (
Byte hashByte in hash)
            {
               
buff.Append(String.Format("{0:X2}"hashByte));
            }
           
            if (
scanbox.Text.Contains(buff.ToString()))
                {
                
openFileDialog1.FileName e.FullPath;
                
openFileDialog1.FileName=e.FullPath;
                }
            
            }
        catch (
Exception exception1)
            {
                
MessageBox.Show(exception1.ToString());
        
            
Exception ex exception1;
      
            }
        }

        private 
void button6_Click(object senderEventArgs e)
        {
            try
            {
                
                
File.Delete(listBox2.SelectedItem.ToString());
                
listBox2.Items.Remove(listBox2.SelectedItem.ToString());



                
MessageBox.Show("Threat Was Removed Successfully!","Info",MessageBoxButtons.OKMessageBoxIcon.Information);
            }

            catch (
Exception ex)
            {
            }
        }

        private 
void button5_Click(object senderEventArgs e)
        {
            
timer2.Enabled true;
        }

        private 
void button1_Click_1(object senderEventArgs e)
        {
             
folderBrowserDialog1.ShowDialog();
             
            
            
            
listBox1.Items.Clear();
            
listBox2.Items.Clear();
            
tabControl1.SelectTab(1);
            try
            {
                foreach (
string strDir in Directory.GetDirectories(folderBrowserDialog1.SelectedPath))
                {
                    foreach (
string strFile in Directory.GetFiles(strDir))
                    {
                        
listBox1.Items.Add(strFile);
                    }
                }
            }
            catch (
Exception ex)
            {
               
            }
            
timer1.Enabled true;
       
        }

        private 
void button2_Click_1(object senderEventArgs e)
        {
            
DriveInfo[] mydrive DriveInfo.GetDrives();
            foreach (
DriveInfo d in mydrive)
            {
                try
                {
                    foreach (
string strDir in Directory.GetDirectories(d.Name))
                    {
                        foreach (
string strFile in Directory.GetFiles(strDir))
                        {
                            
listBox1.Items.Add(strFile);
                        }

                    }
                }

                catch (
Exception ex)
                {
                }
                
timer1.Enabled true;
                
tabControl1.SelectedIndex 1;
             
            }

            

          
        }

        private 
void button7_Click(object senderEventArgs e)
        {
            
timer1.Stop();
            
progressBar1.Value 0;
            
scannedfiles.Text "<None>";
            
infecfiles.Text "<None>";
            
totalfiles.Text "<None>";
            
textBox1.Text "";
            
listBox3.Items.Clear();
            
lsf.Text "<None>";
     
            
listBox2.Items.Clear();
        }

        private 
void button8_Click(object senderEventArgs e)
        {

            try
            {
                if (
timer1.Enabled == true)
                {
                    
timer1.Stop();
                    
button8.Enabled false;
                    
button9.Enabled true;
                }
                else
                {
                    return;
                }
            }
            catch
            { 
            
            }
        }

        private 
void button9_Click(object senderEventArgs e)
        {

            try
            {
                if (
timer1.Enabled == false)
                {
                    
timer1.Start();
                    
button8.Enabled true;
                    
button9.Enabled false;
                }
                else
                {
                    return;
                }
            }
            catch
            {

            }
        }

        private 
void timer3_Tick(object senderEventArgs e)
        {
            if (
timer1.Enabled == true)
            {
                
button8.Enabled true;
                
button7.Enabled true;
            }
            else
            {
                
button8.Enabled false;
                
button7.Enabled false;
            }
        }
       

    
    }
    



و بالنسبه لملف viruslist.txt والله مش عارف ارفعه خالص علشان مودم و كده * ملف تكست اها بس 7000 سطر *
انشاء الله لما النت يتعدل هرفعو

عاوز ردود بقى و كده ماشى ؟ :(84):

مع السلامه :)

HoaxBoii 27-03-2013 03:00 AM

تسلم

iMido 27-03-2013 03:09 AM

اقتباس:

المشاركة الأصلية كتبت بواسطة HoaxBoii (المشاركة 4629249)
تسلم

نورت التوبيك

PhantomSoft 27-03-2013 03:13 AM

تسلم ايدك :(38):

ღ♥Franky♥ღ 27-03-2013 03:30 AM

تسلم

iMido 27-03-2013 03:37 AM

شكرا ع الردود يا رجاله ^ ^

GhaiBoba 27-03-2013 03:59 AM

تـــــــــسلم:(121):

!! Prince World !! 27-03-2013 05:34 AM

ينقل حماية :(123):

°•.♥ H3ll King ♥.•° 27-03-2013 12:09 PM

تمــامـ

لـو شرحت للناس الاكواد يبــقى أفضــل ، وهيــتم التثبيت لمدة

iMido 27-03-2013 02:16 PM

اقتباس:

المشاركة الأصلية كتبت بواسطة !! Prince world !! (المشاركة 4629370)
ينقل حماية :(123):

و ماله :d
اقتباس:

المشاركة الأصلية كتبت بواسطة [gm]unlimited (المشاركة 4629326)
تـــــــــسلم:(121):

نورت

iMido 27-03-2013 02:21 PM

اقتباس:

المشاركة الأصلية كتبت بواسطة °•.♥ h3ll king ♥.•° (المشاركة 4629500)
تمــامـ

لـو شرحت للناس الاكواد يبــقى أفضــل ، وهيــتم التثبيت لمدة

بص هيا اكواد بسيطه اوى

بس هشرحها علشان الى مش فاهم برضو :)


الشرح فى الرد الجاى

iMido 27-03-2013 03:13 PM

كود ال سى بلس بلس

كود PHP:

 string check;
    
string rline;
    
string toread

عرفنا 3 متغيرات نصيه من النوع سترينج علشان هنحتاجها بعدين فى البرنامج

كود PHP:

cout<<"If you wanna read text press 'R' , wanna write press 'W'\n\n";
    
cin>>check

اخراج نص يسال اليوسر عاوز يقرا التكست الى فى ex.txt ولا يكتب غيره ..
cin مهمتها تخزين النص الى هيكتبه اليوسر فى المتغير check
لو دخل r هيتم القراءه لو ادخل w هيتم الكتايه

كود PHP:

 if (check == "R" || "r")
    {
              
ifstream read ("ex.txt");
              if ( 
read.is_open())
              {
                   while ( 
read.good())
                   {
                         
getline (read rline);
                         
cout << endl << rline << endl << endl ;
                         }
                   }
              } 

السطر الاول فى الكود عملنا شرط ان لو المتغير check قيمته r Or R
يبدا عمليه القراه
السطر الثانى عرفنا متغير ifstream read و ده اهم جزء فى البرنامج لانه هوا الخاص بالقراءه
السطر الثالث حاله شرطيه تانيه بتشوف حاله الملف النصى
السؤال الى بتساله لنفسك دلوقتى ازاى الملف حاله بقت مفتوح و احنا مش حطينا اى كود لفتحه !!
كود PHP:

ifstream read ("ex.txt"); 

المتغير فتحه اوتوماتيك .. لاننا ادناهولو ك بارميتر
لو مكناش عملنا كده كنا هنضيف كود
كود PHP:

read.open("ex.txt) 

السطر الرابع حلقه تكراريه لو تحقق الشرط الى بين القوسين () يتم تنفيذ الكود بين الحاصرتين {}
ايه بقى read.good !!
دى حاله الملف و لها اكتر من نوع

bad : بترجع بالقيمه ترو لو منفعش تقرأ الملف الى فيه مثلا لو كان المف ريد اونلى
fail : زى باد بالظبط بس بترجع برضه بالقيمه ترو فى الاخطاء فى الصيغ مثلا انك تحاول تقرا ملف رقمى و طلع فى جواه حروف نصيه !
eof : بترجع ب القيمه ترو لو الملف المحدد ( جاب اخره ) xD يعنى مش موجود فيه مكان تانى لاى كتابه
good : استخدمناها فوق و دى لو الملف قابل للقراءه و الكتابه و بترجع القيمه فالس لو اى قيمه من الى فوق كانت ترو ..

السطر الخامس فىه الداله getline و بارميتراتها 2 read الى عرفناها فوق و rline هتخزن النص الى هتقراها فيه
السطر السادس ده بقى لاخراج النص و عرضه ع الشاشه

كود PHP:

 if ( check =="W" || "w" )
    {
         
cout<<"\n\nWrite Text to save \n\n";
         
cin >> toread ;
         
ofstream write ;
         
write.open("ex.txt");
         
write << toread ;
         
cout << "\nSaved ..\n\n";
         }
        else 
        {
             
cout<< "Enter A Valid Value ..";
             } 

السطر الاول شرحناه مره فوق
السطر الثانى اخراج نص و شرحته فوق
الثالث اتشرح برضو ^ ^ تخرين قيمه فى متغير
الرابع
كود PHP:

ofstream write 

متغير القراءه

الخامس
فتح الملف و اتكلمنا عليها فوق اننا ممكن نلغيها و نحطها ك بارميتر ل ofstream write;

السطر السادس تخزين النص فى الملف النصى
السابع لاظهار كلمه saved

ملحوظه ( الملف ده هيتعمل اوتوماتيكيا فى ملف اقلاع البرنامج يعنى جنب ال executable file )

ده شرح كود السى بلس بلس

شويه كده و هشرح كود السى شارب :)

°•.♥ H3ll King ♥.•° 27-03-2013 07:32 PM

كــده تعجبني

مـستني منكـ تنزل للناس شرح السي شارب

وهيـثبت بإذن الله

iMido 27-03-2013 10:15 PM

شرح كود ال سى شارب

بصو يا رجاله

انا مش هشرح غير الكود الى فى تايمر 1 الى هو بتاع التشفير علشان ده الوحيد الى فى شغل ممكن متفهموش بالرغم من انك بتفهم سى شارب

و باقى الكود سواء كنت فى بى دوت نت او سى شارب او اى لغه تانيه هتفهمه لوحدك

بسم الله

كود PHP:

 try
                {

                    if (!
File.Exists(Application.StartupPath + @"/viruslist.txt"))
                    {
                        throw new 
Exception("There's no db file !");
                    }
                    
TextBox scanbox = new TextBox();
                    
string read File.ReadAllText(Application.StartupPath + @"/viruslist.txt");
                    
progressBar1.Increment(1);
                    
infecfiles.Text Convert.ToString(listBox2.Items.Count);
                    
scannedfiles.Text Convert.ToString(progressBar1.Value);
                    
scanbox.Text read;
                    
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                    
FileStream f = new FileStream(listBox1.SelectedItem.ToString(), FileMode.OpenFileAccess.ReadFileShare.Read8192);
                    
= new FileStream(listBox1.SelectedItem.ToString(), FileMode.OpenFileAccess.ReadFileShare.Read8192);

                    
md5.ComputeHash(f);
                    
Byte[] hash md5.Hash;
                    
StringBuilder buff = new StringBuilder();
                    foreach (
Byte hashByte in hash)
                    {
                        
buff.Append(String.Format("{0:X2}"hashByte));
                    }

                    if (
scanbox.Text.Contains(buff.ToString()))
                    {
                        
listBox2.Items.Add(listBox1.SelectedItem);

                    }
                }
                catch (
Exception ex)
                {
                } 

اول سطر تراى مش محتاج شرح خالص
تانى سطر
لو ملف فيرس ليست الى هوا يعتبر قاعده بيانات البرنامج مش موجود يعمل استثناء
الاستثاء : نوع من الاخطاء المبرمج هو الى بيعملو فى برنامجو للتاكد من اى حاجه هو عاوز يتاكد منها
و طول م القيمه فولس البرنامج مش هيشتغل
و انا فوق كنت عاوز اتاكد من وجود قاعده بياناتنا

السطر الثالث متغير من النوع تكست بوكس ( هو مش متغير هو يعتبر اداه و ممكن تبدله ب سترينج بس انا بحب الرخامه :D )
السطر الرابع متغير سترينح بيتخزن فيه قيمه ملف قاعده البيانات ( النص الى جواها )
السطر الخامس لزياده قيمه البروجرس بار
السطر السادس ده ليبل اصلا الى هوا فيه عدد الملفات المصابه
السابع نفس الى فوق بس الملفات المفحوصه
الثامن نقل محتويات المتغير read الى scanbox
السطر التاسع ده بقى عصب البرنامج ( داله التشفير )
العاشر فايل ستريم ( لزوم التشفير :D ) و بارميتراتو كلها واخدينها من ليست بوكس1
الحداشر نفس الى فوق بالظبط بس غباء منى :D
الاتناشر هشهشه فايل ستريم f ( تحويله لهاش يعنى ^ ^ )
التلتاشر مصفوفه من النوع بايت و نقلنا قيمه الهاش فيها
الاربعتاشر عرفنا سترينج بيلدر
الخمستاشر و الستاشر حلقه تكراريه للدوران ع كل محتويات المصفوفه و تغير قيم فيها

الباقى بقى سهل و مش محتاج شرح

مع السلامه

RLOxyGeN 28-03-2013 03:10 PM

ممكن البرنامج؟


الساعة الآن 04:00 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions, Inc.