Thursday, February 7, 2013

PHPcoding (NOOB edition)

tonight.. i just playing with PHPcoding.

Start with login page but first i will create new folder in my server.

[dora@localhost public_html]$ mkdir project2
[dora@localhost public_html]$ ls
project1  project2  rnd  smf  test

[dora@localhost public_html]$ cd project2
[dora@localhost project2]$ nano -w index.php



done. then i do the "processing" [dora@localhost project2]$ nano -w login.php

[?php $username = $_REQUEST['username']; $password = $_REQUEST['password']; if ($username === 'Darlinx' && $password === 'Darlinx') echo "Password correct"; else echo "Password incorrect";

Form eXplaination :: [?php = is a tag to php form. in this process the form will received input. it will retrieve from global << [input name="username" $username $password = example of variable. echo = is for output. print as 'text' ** when u submit the first form (login) the data will be transfer to login.php now we need a comparison. I will set the input for "username" & "password" here. :)
ok. now i want to create "table" in my form. let say i hav $x number of rows & $y number of columns create new php file. [dora@localhost project2]$ nano -w table.php form eXplaination : ** this is what we call nested loop LOOP ROWS WHILE ROWS IS LESS THAN 3 PRINT ROW OPENING LOOP COLUMNS WHILE ROWS IS LESS THAN 4 PRINT COLUMN WITH ROW NUMBER AND COLUMN NUMBER LOOP END PRINT ROW CLOSING LOOP END
try to add border since. :X but.. that's how the loop working. i understand now. :)

Friday, January 4, 2013

CompiLer in NaNo EditoR .

Re-arrange my files in shell . Flashing back all the tutorial.

what i do .?

     [dora@localhost ~]$ ls
     BNC.docx  chrome-mac.zip  public_html  smf_2-0-2_install.tar.bz2

     [dora@localhost ~]$ cd public_html
     [dora@localhost public_html]$ ls
     project1  project1.tar.bz2  rnd  smf

     [dora@localhost public_html]$ cd ..

     [dora@localhost ~]$ ls
     BNC.docx  chrome-mac.zip  public_html  smf_2-0-2_install.tar.bz2
     [dora@localhost ~]$ rm -rf chrome-mac.zip
     [dora@localhost ~]$ ls
     BNC.docx  public_html  smf_2-0-2_install.tar.bz2

     [dora@localhost ~]$ cd public_html
     [dora@localhost public_html]$ ls
     project1  project1.tar.bz2  rnd  smf
     [dora@localhost public_html]$ rm -rf project1.tar.bz2
     [dora@localhost public_html]$ ls
     project1  rnd  smf

= deleting un-neccessary files.

i think i want to separate the code with compiler that i have save
in folder rnd. It's mixed. So i create one new folder for that.

     [dora@localhost public_html]$ mkdir test
     [dora@localhost public_html]$ ls
     project1  rnd  smf  test

     [dora@localhost public_html]$ cd rnd
     [dora@localhost rnd]$ ls
     a.asm  a.s          testcode.php   testcode2.php  testcode4.php  
     testcode6.php a.c    iframe.html  testcode1.php  testcode3.php  
     testcode5.php

it's so mixed.! :X

after test and error many cmd .. and googling -
i found this 

     [dora@localhost rnd]$ mv a.s a.c a.asm ../
     [dora@localhost rnd]$ ls
     iframe.html   testcode1.php  testcode3.php  testcode5.php
     testcode.php  testcode2.php  testcode4.php  testcode6.php

     [dora@localhost public_html]$ ls
     a.asm  a.c  a.s  project1  rnd  smf  test

now only i can use this ::

     [dora@localhost public_html]$ mv a.asm a.s a.c test/
     [dora@localhost public_html]$ ls
     project1  rnd  smf  test

     [dora@localhost public_html]$ cd test
     [dora@localhost test]$ ls
     a.asm  a.c  a.s

ok done.

try and error to use gcc. :X

** noted : it's (.s) for assembler. not (.asm)  :P

     [dora@localhost test]$ nano -w a.c

      

#include [stdio.h] main() { printf("Hello World!"); }

[dora@localhost test]$ gcc -o a a.c [dora@localhost test]$ ls -a . .. a a.asm a.c a.s [dora@localhost test]$ ./a Hello World![dora@localhost test]$ c is done . Im just trying using the same cmd for the assembly coding. In my last post.. i have do the assembly code in windows and i use "Visual Studio Express 2010" now i want to take the code and try to see how it will compile in nano. [dora@localhost test]$ nano -w a.s

TITLE Question6 assignment1 (main.asm) ; Description: ; This progam adds and subtracts 32-bit unsigned ; integers and stores the sum in a variable ; Revision date: INCLUDE Irvine32.inc main PROC mov eax,1 call DumpRegs ;1st value call DumpRegs ;2nd value mov ebx,0 ; initial setup mov edx,1 mov ecx,6 ; count L1: mov eax,ebx ; eax = ebx + edx add eax,edx call DumpRegs ; display eax mov ebx,edx mov edx,eax Loop L1 exit main ENDP END main

[dora@localhost test]$ gcc -o a a.s a.s: Assembler messages: a.s:1: Error: no such instruction: `title Question6 assignment1 (main.asm)' a.s:4: Error: no such instruction: `this progam adds and subtracts 32-bit unsigned' a.s:5: Error: no such instruction: `integers and stores the sum in a variable' a.s:6: Error: no such instruction: `revision date:' a.s:8: Error: no such instruction: `include Irvine32.inc' a.s:10: Error: no such instruction: `main PROC' a.s:11: Error: too many memory references for `mov' a.s:12: Error: junk at end of line, first unrecognized character is `1' a.s:13: Error: junk at end of line, first unrecognized character is `2' a.s:15: Error: too many memory references for `mov' a.s:15: Error: no such instruction: `initial setup' a.s:16: Error: too many memory references for `mov' a.s:17: Error: too many memory references for `mov' a.s:17: Error: no such instruction: `count' a.s:20: Error: too many memory references for `mov' a.s:21: Error: too many memory references for `add' a.s:22: Error: no such instruction: `display eax' a.s:23: Error: too many memory references for `mov' a.s:24: Error: too many memory references for `mov' a.s:27: Error: no such instruction: `exit' a.s:28: Error: no such instruction: `main ENDP' a.s:29: Error: no such instruction: `end main' [dora@localhost test]$ ouch .! stuck ...... dunno whut to do. i must change the coding.. i will googling for that. 09/01/2013 the new code.... [dora@localhost test]$ nano -w a.s

#TITLE Test #Description: #This progam adds and subtracts 32-bit unsigned #integers and stores the sum in a variable #Revision date: INCLUDE "Irvine32.inc" main: mov eax,1 call DumpRegs ;1st value call DumpRegs ;2nd value mov ebx,0 ; initial setup mov edx,1 mov ecx,6 ; count L1: mov eax,ebx ; eax = ebx + edx add eax,edx call DumpRegs ; display eax mov ebx,edx mov edx,eax Loop L1

I have modified a bit. now it look smooth in upper. I must replace the coding to more simple one. [dora@localhost test]$ gcc -o a a.s a.s: Assembler messages: a.s:10: Error: too many memory references for `mov' a.s:14: Error: too many memory references for `mov' a.s:17: Error: expecting operand after ','; got nothing a.s:18: Error: too many memory references for `add' a.s:19: Error: junk `eax' after expression a.s:20: Error: too many memory references for `mov' a.s:21: Error: too many memory references for `mov' [dora@localhost test]$

Wednesday, December 26, 2012

Assembly Language


i have changed my first PHPpage interface but it seem err not like 
what i want... it's look like so typical web. maybe im too new about 
this... have to learn and read more and more...

ok leave my PHP for a while ...i will explain in my next post bout 
that.. hehe

now. i want to do 3 task with assembly language.
this is a quite famaous questions to google for.. believe me. :P

no. im not doing this in my nano. im doing this coding using windows. 
(Microsoft c++ 2010 Express). im just try because i dont know wth of 
output i can get from the code. Still blur-ing.

6. Fibonacci Numbers

   Write a program that uses a loop to calculate the first seven values
   of the Fibonaccinumber sequence,described by the following formula:
   Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n - 1) +   Fib(n - 2). Place
   each value in the EAX register and display it with a call 
   DumpRegsstatement (see Section 3.2) inside the loop. 

TITLE Question6 assignment1  (main.asm)

; Description:
; This progam adds and subtracts 32-bit unsigned
; integers and stores the sum in a variable
; Revision date:

INCLUDE Irvine32.inc

main PROC
 mov   eax,1
 call DumpRegs ;1st value    
 call DumpRegs ;2nd value

 mov   ebx,0 ; initial setup
 mov   edx,1
    mov   ecx,6 ; count

L1:
 mov  eax,ebx ; eax = ebx + edx
 add  eax,edx
 call DumpRegs ; display eax
 mov  ebx,edx
 mov  edx,eax
    Loop L1

 exit
main ENDP
END main

This is the output that i get ::
noted :: this is the wrong answer. why .? because the question want the first seven values... but it show you 8 in that output. The answer should be like this. pic below. But the coding must change a bit, you cant start the number from = 0, but = 1 .
so the answer for this task is :: 110 1100 7. Arithmetic Expression Write a program that implements the following arithmetic expression: EAX = −val2 + 7 − val3 + val1 Use the following data deļ¬nitions: val1 SDWORD 8 val2 SDWORD -15 val3 SDWORD 20 In comments next to each instruction, write the hexadecimal value of EAX. Insert a call DumpRegsstatement at the end of the program.

TITLE Question7 assignment1  (main.asm)

; Description:
; This progam adds and subtracts 32-bit unsigned
; integers and stores the sum in a variable
; Revision date:

INCLUDE Irvine32.inc

.data
 val1  SDWORd 8
 val2  SDWORD -15
 val3  SDWORD 20
 finalVal SDWORD ?

.code
main PROC

 mov eax, val2 
 neg eax ; eax=-15
 add eax, 7; -val2 + 7

 mov ebx, val3
 add ebx, val1 ; val3+val1

 sub eax,ebx

 mov finalVal, eax 
 call DumpRegs  ; display the registers

exit

main ENDP
END main

This is the output that i get ::
** double checking := −val2 + 7 − val3 + val1 = 15 + 7 - 20 + 8 = 10 8. Copy a String Backwards Write a program using the LOOP instruction with indirect addressing that copies a string from source to target, reversing the character order in the process. Use the following variables: source BYTE "This is the source string",0 target BYTE SIZEOF source DUP('#') Insert the following statements immediately after the loop to display the hexadecimal contents of the target string: movesi,OFFSET target ; offset of variable mov ebx,1 ; byte format movecx,SIZEOF target ; counter callDumpMem If your program works correctly, it will display the following sequence of hexadecimal bytes: 67 6E 69 72 74 73 20 65 63 72 75 6F 73 20 65 68 74 20 73 69 20 73 69 68 54

TITLE Question8 assignment1  (main.asm)

; Description:
; This progam adds and subtracts 32-bit unsigned
; integers and stores the sum in a variable
; Revision date:

INCLUDE Irvine32.inc

.data
source BYTE " This is the source string", 0 
target BYTE SIZEOF source DUP('#') 

.code
main PROC

 mov esi, (OFFSET source) + (SIZEOF source) - 2
 mov edi, OFFSET target
 mov ecx, SIZEOF source

L1: mov al, [esi]
 mov [edi], al
 dec esi              ; pointer to source string
 inc edi              ; pointer to target string
 loop L1
 
 mov esi, OFFSET target     ; offset of variable
 mov ebx, 1   ; byte format
 mov ecx, SIZEOF target-1 ; counter
 call Dumpmem
 
 exit

main ENDP
END main

This is the output that i get ::
the different is... there is extra space in the output compare the answer that already give in the question. to solve this... ** mov esi, (OFFSET source) + (SIZEOF source) - 2 change that 2 to 1. ** mov esi, (OFFSET source) + (SIZEOF source) - (1) then u'll get the output exactly like shown above in the question. :)
done. (",)v . got 10 marks for this.

Tuesday, December 18, 2012

My FirSt PHP ProjeCt.


Because this is the first time i will create PHP interface and start 
doing my final PSM project, i have search the web for this and i found 
one. Here allocation for the web. With my ankel help, i start discover 
what's the instruction is all about. 

I will take the introduction from the web.

Whether you have a small or a huge website, you know how much hassle 
and time it takes to upgrade your web site pages. The upgrade process 
becomes even more irritating when you make a change that needs to be 
upgraded on every page of your website; a good example of such a change 
is adding a button to the header or changing the copy right information 
in the footer of your website.  

What u need to start is :: 

1. Requirement :
>> Server/Hosting capable of running php scripts.


2.The Tutorial :

Step 1
Create a folder on your server and name it "design".
Create another folder and name it "pages"

- i have create those folder in my public_html folder
     [dora@localhost ~]$ cd public_html
     [dora@localhost public_html]$ ls
     = design  pages  rnd  smf

- but we must set directory
  >> define folder to become DocumentRoot

     [dora@localhost public_html]$ pwd
     = /home/dora/public_html

     [dora@localhost public_html]$ mkdir project1
     [dora@localhost public_html]$ ls
     = design  pages  project1  rnd  smf

     [dora@localhost public_html]$ mv design  pages project1/
     [dora@localhost public_html]$ ls
     = project1  rnd  smf

     [dora@localhost public_html]$ cd project1
     [dora@localhost project1]$ ls
     = design  pages

- now, project1 is my DocumentRoot for the design. :)
  because the best way do not mess up DocumentRoot with other files.

Step 2
Now in the root directory create a file and give it the 'index.php'

** my DocumentRoot is 'project1' folder
   so i will put index.php inside 'project1'

     [dora@localhost project1]$ pwd
     = /home/dora/public_html/project1
     [dora@localhost project1]$ ls
     = design  index.php  pages

Step 3
In the "pages" directory, create a page and give it the name: 'main.html'

     [dora@localhost project1]$ cd pages
     [dora@localhost pages]$ nano -w main.html



     [dora@localhost pages]$ ls
     = main.html

     [dora@localhost pages]$ cd .. (cmd for return dir.)

Step 4
Add the following code to your 'index.php' file

     [dora@localhost project1]$ nano -w index.php



Step 5
Create the following files in the design folder:
'header.html', 'footer.html', 'right_column.html', 'left_column.html'

-> header.html
   [dora@localhost design]$ nano -w header.html



-> footer.html
   [dora@localhost design]$ nano -w footer.html



-> right_column.html
   [dora@localhost design]$ nano -w right_column.html



-> left_column.html
   [dora@localhost design]$ nano -w left_column.html



** and to add a little touch to my design, i've create a 'styles.css' 
   file in the design folder and add the following code:

-> styles.css
   [dora@localhost design]$ nano -w styles.css



** Now give it a test drive spin!

   http://server.www.project1

   noted :: i just follow the intructions from this web.

Actually it wont work. The tutorial is not complete. The main.html didnt call the css scripts. Now i have to edit main.html
   
   [dora@localhost pages]$ nano -w main.html
   


EXAMPLE OF PHP INTERFACE - from the tutorial.

addition :: system checking. su - [root@localhost ~]# find / -name httpd.conf = /etc/httpd/conf/httpd.conf [root@localhost ~]# cat /etc/httpd/conf/httpd.conf |grep text/css >> nano -w /etc/httpd/conf/httpd.conf find the empty line :: fill in => AddType text/css .css then save. [root@localhost ~]# apachectl configtest [root@localhost ~]# apachectl restart EDITING CSS THAT I DO.. :P http://server/www/project1/index.php/page=main.html
i will edit more later. hehe. i must read about HTML/CSS scripts more. done for now.

Monday, December 17, 2012

How To Start New ProjeCt.


Now i will playing with PHP coding and try to learn about PHP and the syntax. First i need a place to do my coding test. It's just like i will start a new project for this. :)
To make all the things ready,
- go to linux

- ssh dora@server
  [dora@localhost ~]$ ls
  >> BNC.docx  public_html  smf_2-0-2_install.tar.bz2

- cmd :: mkdir public_html/rnd ; cd public_html/rnd

- using nano.
  nano -w testcode.php
  ** insert the code inside.
  from [html] ...... [/html]

- save

Now i can view from my SAFARI .

>> http://server/www/rnd

Sunday, December 16, 2012

How To Backup My CentOS


I guess backup ur system is an important things to do. We always try and error. who know when we try and error it's goes to permanent error to ur system. So i highlight this in my new post. Because i want to remember doing this. hehe.
i will do this in my MAC . not in my centOS.

cmd ::

cd VirtualBox\ VMs/

   Aaliyahs-MacBook-Pro:VirtualBox VMs aaliyahdora$ 
   Aaliyahs-MacBook-Pro:VirtualBox VMs aaliyahdora$ ls
   >> CentOS6

/VirtualBox VMs$ tar cjf CentOS6-`date '+%d-%B-%Y'`.tar.bz2 CentOS6/
/VirtualBox VMs$ ls |grep bz2

** the dated will be auto in. ( i fill the cmd with dated when i 
   first try this .. :X )

   Aaliyahs-MacBook-Pro:VirtualBox VMs aaliyahdora$ ls
    >> CentOS6  CentOS6-24-November-2012.tar.bz2

   du -sh ( to check file size )

   Aaliyahs-MacBook-Pro:VirtualBox VMs aaliyahdora$ du -sh 
   CentOS6-24-November-2012.tar.bz2

   >> 328M CentOS6-24-November-2012.tar.bz2

   Aaliyahs-MacBook-Pro:VirtualBox VMs aaliyahdora$ du -sh CentOS6

   >> 1.1G CentOS6

psst : have free to try this.. :)

Friday, December 14, 2012

Create a Simple Machines Forum (SMF) - Part03


This is the interface of my SMF .



i mean first interface after done the installation.

Now, i will try to change the templates FORUM and set up my FORUM until it looks more cute like me. hehe.

1. i have search for SMF templates. googl-ing i mean.
2. then i download about 4-5 templates that im interest to my MAC.
3. i compress the files to tar.bz2 n upload the files to my server.

cmd ::
- open vbox

- open my MAC terminal. ** Aaliyahs-MacBook-Pro:~ aaliyahdora$ cd Downloads -> ls

- then i upload all the templates files to the server. ** Aaliyahs-MacBook-Pro:Downloads aaliyahdora$ scp green-ornamental. tar.bz2 dora@192.168.56.10:/home/dora/public_html/smf/Themes ** Aaliyahs-MacBook-Pro:Downloads aaliyahdora$ scp Boxit_2. tar.bz2 dora@192.168.56.10:/home/dora/public_html/smf/Themes ** Aaliyahs-MacBook-Pro:Downloads aaliyahdora$ scp Salava_1_0_x. tar.bz2 dora@192.168.56.10:/home/dora/public_html/smf/Themes ** Aaliyahs-MacBook-Pro:Downloads aaliyahdora$ scp extreme. tar.bz2 dora@192.168.56.10:/home/dora/public_html/smf/Themes ** Aaliyahs-MacBook-Pro:Downloads aaliyahdora$ scp dzinerstudio_urban. tar.bz2 dora@192.168.56.10:/home/dora/public_html/smf/Themes ** Aaliyahs-MacBook-Pro:Downloads aaliyahdora$ scp Dirt_3. tar.bz2 dora@192.168.56.10:/home/dora/public_html/smf/Themes ** Aaliyahs-MacBook-Pro:Downloads aaliyahdora$ scp WoW_2. tar.bz2 dora@192.168.56.10:/home/dora/public_html/smf/Themes ** Aaliyahs-MacBook-Pro:Downloads aaliyahdora$ scp Dirt_3_SMF2. tar.bz2 dora@192.168.56.10:/home/dora/public_html/smf/Themes

- extract the files in folder themes. - open SMF and import the file from server.



HOW TO USED SMF TEMPLATES.

let say i want to import extreme templates folder

- FROM A DIRECTORY FROM SERVER :/home/dora/public_html/Themes/extreme

- Copy of Default named : extreme

- click install

then you can choose to use which one templates you want in 
"OVERALL FORUM DEFAULT" & Reset it to everyone.
example of templates in my SMF.

for the first time doing this, i got a problem..

when i click to install the templates from the server, it's always
appear the link like this ::

****  [That theme directory doesn't exist, or doesn't contain a theme!]

for   [dora@localhost Boxit_2]$ pwd
      >> /home/dora/public_html/smf/Themes/Boxit_2

****  if i success installing the themes, templates that i download dont 
      hav the image and backgound.

noted :: this is because centOS6 got little problem with chmod/permission.

then i tried to chmod all my templates files.

cmd ::

try n error :

[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/Boxit_2/* 
chmod 777 /home/dora/public_html/smf/Themes/Boxit_2/*.*
[dora@localhost Themes]$ 

**** when i used this 2 cmd, i can see the Boxit_2 template name already
     in the list of template in my SMF but when i choose the template as
     default.. there's no background & image attach. it is just like a 
     plain html without css.

then i try this cmd :

[dora@localhost Themes]$ 
chmod -R 777 /home/dora/public_html/smf/Themes/Boxit_2/

**** when i reload the pages. it's well done. suddenly i got beautiful 
     templates in my SMF. Then i do the command to all the templates 
     folder in server.

[dora@localhost Themes]$
chmod 777 /home/dora/public_html/smf/Themes/Dirt_3_SMF2/* 
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/Dirt_3_SMF2/*.*
[dora@localhost Themes]$ 
chmod -R 777 /home/dora/public_html/smf/Themes/Dirt_3_SMF2/
[dora@localhost Themes]$ 
chmod 777/home/dora/public_html/smf/Themes/WoW_2/*
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/WoW_2/*
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/WoW_2/*.*
[dora@localhost Themes]$ 
chmod -R 777 /home/dora/public_html/smf/Themes/WoW_2/
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/Catalysm_2/*
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/Catalysm_2/*.*
[dora@localhost Themes]$ 
chmod -R 777 /home/dora/public_html/smf/Themes/Catalysm_2/
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/green-ornamental/*
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/green-ornamental/*.*
[dora@localhost Themes]$ 
chmod -R 777 /home/dora/public_html/smf/Themes/green-ornamental/
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/extreme/*
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/extreme/*.*
[dora@localhost Themes]$ 
chmod -R 777 /home/dora/public_html/smf/Themes/extreme/
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/Salava_1_0_x/*
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/Salava_1_0_x/*.*
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/Salava_1_0_x/*
[dora@localhost Themes]$ 
chmod -R 777 /home/dora/public_html/smf/Themes/Salava_1_0_x/
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/themes/Salava_1_0_x/*.*
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/dzinerstudio_urban/*
[dora@localhost Themes]$ 
chmod 777 /home/dora/public_html/smf/Themes/dzinerstudio_urban/*.*
[dora@localhost Themes]$ 
chmod -R 777 /home/dora/public_html/smf/Themes/dzinerstudio_urban/ 

**** it's done. :)
MY TEMPLATES EXAMPLE.








psst :: it's great. (".)v