Changeset 42829 for ipk


Ignore:
Timestamp:
09/25/18 22:05:22 (6 years ago)
Author:
karlo
Message:

fix callmon (html -> XML)

Location:
ipk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ipk/source.arm/tools_callmonitor/_path_/usr/local/share/titan/plugins/callmonitor1/fritzbox_msg_new.sh

    r40764 r42829  
    8181#detecting Dreambox-Type (DM7020 or DM7000 or DM500 or DM600PVR)
    8282 FRITZCACHE=/tmp/fritzbox.cache              #stores successfull reverse searches
    83  FRITZBUCH=/var/fritzbuch.tele
     83#FRITZBUCH=/var/fritzbuch.tele               #original
     84 FRITZBUCH=/mnt/swapextensions/fritzbuch.tele #TitanNit
    8485 TMPFILE=/tmp/fritzbox.tmp                   #stores page from wget command
    8586 TMPSTATUS=/tmp/fritzdream.status            #status der Dreambox (standby usw)
     
    201202};
    202203
    203 loadFritzBook49 () {
    204     echo "Version 49"
    205                 # Challenge abholen
    206                 echo "Challenge abholen start"
    207                 ChallengeXML=`wget -O - "http://$FRITZBOXIP/cgi-bin/webcm?getpage=../html/login_sid.xml" 2>/dev/null| grep Challenge`
    208                 Challenge=`echo $ChallengeXML | awk '{match($0,/>[^<>]+</); print substr($0,RSTART+1,RLENGTH-2)}'`
    209                 echo "Challenge abholen ende"
     204
     205rdom () { local IFS=\> ; read -d \< E C ;}
     206
     207loadXML(){
     208        #ID="$1"
     209        echo "Lese ID: $1"
     210        $CURL --data "sid=$SID&pbid=$1" http://$FRITZBOXIP:49000/phonebook.lua  > /tmp/curlhelp7.tmp
     211               
     212         while rdom; do
     213            if [[ $E = realName ]]; then
     214                name=$C
     215                #exit
     216            fi
     217            if [[ $E = number* ]]; then
     218                type=`echo "$E" | cut -d'"' -f2 | sed s/" "//g | sed s/"home"/"privat"/g | sed s/"work"/"geschaeftl."/g | sed s/"mobile"/"mobil"/g `
     219                nummer=$C
     220                tel=`echo $nummer | sed s/"+49"/"0"/g| sed s/" "//g`
     221                echo "$tel#$name->$type"  >> $FRITZBUCH
     222            fi
     223        done < /tmp/curlhelp7.tmp
     224};
     225
     226loadXMLsh4(){
     227        echo "Lese ID: $1"
     228        $CURL --data "sid=$SID&pbid=$1" http://$FRITZBOXIP:49000/phonebook.lua  > /tmp/curlhelp7.tmp
     229        while read line; do
     230                X=`echo $line | grep realName | wc -c`
     231                if [[ $X -gt 0 ]]; then
     232                        #E=`echo $line | cut -d'<' -f2 | cut -d'>' -f1`         
     233                        C=`echo $line | cut -d'>' -f2 | cut -d'<' -f1`
     234                        name=$C
     235                        #echo $name
     236                fi
     237               
     238                X=`echo $line | grep "number type" | wc -c`
     239                if [[ $X -gt 0 ]]; then
     240                        type=`echo $line| cut -d'"' -f2 | sed s/" "//g | sed s/"home"/"privat"/g | sed s/"work"/"geschaeftl."/g | sed s/"mobile"/"mobil"/g `
     241                        tel=`echo $line | cut -d'>' -f2 | cut -d'<' -f1`
     242                        echo "$tel#$name->$type"  >> $FRITZBUCH
     243                fi
     244                   
     245        done < /tmp/curlhelp7.tmp
     246};
     247
     248loadFritzBook70 () {
     249    echo "Version 70"
    210250               
    211                 Passwd="$FritzPass"
    212 
    213                 # login aufbauen und hashen
    214                 echo "login aufbauen und hashen start"
    215                 CPSTR="$Challenge-$Passwd"
    216                 MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/help; md5sum /tmp/help | awk '{print substr($0,1,32)}'`
    217                 RESPONSE="$Challenge-$MD5"
    218                 POSTDATA="login:command/response=$RESPONSE&getpage=../html/de/menus/menu2.html"
    219                 # login senden und SID herausfischen
    220                 SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/cgi-bin/webcm" 2>/dev/null| grep "name=\"sid\"" | head -n 1 | awk '{match($0,/value="[^"]+"/); print substr($0,RSTART+7,RLENGTH-8)}'`
    221                 echo "login aufbauen und hashen ende"
    222 
    223                 $CURL --data "telcfg:settings/Phonebook/Books/Select=0&getpage=../html/de/menus/menu2.html&var:pagename=fonbuch&sid=$SID&var:menu=fon&var:lang=de" http://$FRITZBOXIP/cgi-bin/webcm  | grep ">TrFon" | sed s/'<script type="text\/javascript">'// | sed s/';<\/script>'// | sed s/'('/'"'/ | sed s/')'/'"'/ > /tmp/curlhelp.tmp
    224                 while read line
    225                     do
    226                     art=`echo $line | cut -d'"' -f1`
    227                     if [ $art = "TrFonName" ]; then
    228                         name=`echo $line | cut -d'"' -f5`
    229                     elif [ $art = "TrFonNr" ]; then
    230                         nummer=`echo $line | cut -d'"' -f5`
    231                         echo "$nummer#$name->" >> $FRITZBUCH
    232                     fi
    233                 done < /tmp/curlhelp.tmp
    234                 rm /tmp/curlhelp.tmp
    235 
    236                 if [ ! -f $FRITZBUCH ]; then
    237                     #testen ob neues Telefonbuch
    238                     #$CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua > /tmp/test.curl
    239                     $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\">" | sed s/"<td class=\"tname\">"/"\nfritztele<"/ | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g > /tmp/curlhelp.tmp
    240                     while read line
    241                     do
    242                         nummer1="0"
    243                         nummer2="0"
    244                         nummer3="0"
    245                         pos1=14
    246                         pos2=0
    247                         pos3=0
    248                         art=`echo $line | cut -d'<' -f1`
    249                         if [ $art = "fritztele" ]; then
    250                             name=`echo $line | cut -d'<' -f2`
    251                             nummer1=`echo $line | cut -d'<' -f8`
    252                             help=`echo $line | cut -d'<' -f11`
    253                             if [ $help == "br" ]; then
    254                                 nummer2=`echo $line | cut -d'<' -f14`
    255                                 pos1=20
    256                                 pos2=22
    257                                 help=`echo $line | cut -d'<' -f17`
    258                                 if [ $help == "br" ]; then
    259                                     nummer3=`echo $line | cut -d'<' -f20`
    260                                     pos1=26
    261                                     pos2=28
    262                                     pos3=30
    263                                 fi
    264                             fi
    265                             if [ $nummer1 != "0" ]; then
    266                                 typ=`echo $line | cut -d'<' -f$pos1`
    267                                 echo "$nummer1#$name->$typ" >> $FRITZBUCH
    268                             fi
    269                             if [ $nummer2 != "0" ]; then
    270                                 typ=`echo $line | cut -d'<' -f$pos2`
    271                                 echo "$nummer2#$name->$typ" >> $FRITZBUCH
    272                             fi
    273                             if [ $nummer3 != "0" ]; then
    274                                 typ=`echo $line | cut -d'<' -f$pos3`
    275                                 echo "$nummer3#$name->$typ" >> $FRITZBUCH
    276                             fi
    277                         fi
    278                     done < /tmp/curlhelp.tmp
    279                     rm /tmp/curlhelp.tmp
    280                 fi
    281 };
    282 loadFritzBook50 () {
    283     echo "Version 50"
    284                
    285                 Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
    286                 Passwd="$FritzPass"
    287                 # login aufbauen und hashen
    288                 echo "login aufbauen und hashen start"
    289                 CPSTR="$Challenge-$Passwd"
    290                 MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
    291                 RESPONSE="$Challenge-$MD5"
    292 
    293                 POSTDATA="username=$FritzUser&response=$RESPONSE"
    294 
    295                 SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
    296 
    297                 echo "login aufbauen und hashen ende"
    298 
    299                 $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_select.lua  > /tmp/curlhelp3.tmp
    300 
    301                 BOOKID=`cat /tmp/curlhelp3.tmp | grep '<label for="uiBookid' | grep ritzcall | cut -d: -f2 | cut -d'"' -f1`
    302                 if [ -z "$BOOKID" ]; then
    303                     BOOKID=0
    304                 fi
    305 
    306                 $CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua  | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g  | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g  | sed s/"<<a href="//g | sed s/"<\/a<"//g | sed s/"+49"/"0"/g > /tmp/curlhelp3.tmp
    307 
    308                 while read line
    309                     do
    310                         nummer1="0"
    311                         nummer2="0"
    312                         nummer3="0"
    313                         nummer4="0"
    314                         pos1=11
    315                         pos2=0
    316                         pos3=0
    317                         art=`echo $line | cut -d'<' -f1`
    318                         if [ ! -z $art ] && [ $art = "fritztele" ]; then
    319                             name=`echo $line | cut -d'<' -f2 | sed s/"title="//g`
    320                             nummer1=`echo $line | cut -d'<' -f7 | sed s/" "//g`
    321                             help=`echo $line | cut -d'<' -f8 | cut -c 1-2`
    322                             if [ $help = "br" ]; then
    323                                 nummer2=`echo $line | cut -d'<' -f9 | sed s/" "//g`
    324                                 pos1=13
    325                                 pos2=15
    326                                 help=`echo $line | cut -d'<' -f10 | cut -c 1-2`
    327                                 if [ $help = "br" ]; then
    328                                     nummer3=`echo $line | cut -d'<' -f11 | sed s/" "//g`
    329                                     pos1=15
    330                                     pos2=17
    331                                     pos3=19
    332                                     help=`echo $line | cut -d'<' -f12 | cut -c 1-2`
    333                                     if [ $help = "br" ]; then
    334                                         nummer4=`echo $line | cut -d'<' -f13 | sed s/" "//g`
    335                                         pos1=17
    336                                         pos2=19
    337                                         pos3=21
    338                                         pos4=23
    339                                     fi
    340                                 fi
    341                             fi
    342                             if [ $nummer1 != "0" ]; then
    343                                 typ=`echo $line | cut -d'<' -f$pos1`
    344                                 echo "$nummer1#$name->$typ" >> $FRITZBUCH
    345                             fi
    346                             if [ $nummer2 != "0" ]; then
    347                                 typ=`echo $line | cut -d'<' -f$pos2`
    348                                 echo "$nummer2#$name->$typ" >> $FRITZBUCH
    349                             fi
    350                             if [ $nummer3 != "0" ]; then
    351                                 typ=`echo $line | cut -d'<' -f$pos3`
    352                                 echo "$nummer3#$name->$typ" >> $FRITZBUCH
    353                             fi
    354                             if [ $nummer4 != "0" ]; then
    355                                 typ=`echo $line | cut -d'<' -f$pos4`
    356                                 echo "$nummer4#$name->$typ" >> $FRITZBUCH
    357                             fi
    358                         fi
    359                     done < /tmp/curlhelp3.tmp
    360                     rm /tmp/curlhelp3.tmp
    361 };
    362 loadFritzBook60 () {
    363     echo "Version 60"
    364                
    365                 Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
    366                 Passwd="$FritzPass"
    367                 # login aufbauen und hashen
    368                 echo "login aufbauen und hashen start"
    369                 CPSTR="$Challenge-$Passwd"
    370                 MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
    371                 RESPONSE="$Challenge-$MD5"
    372 
    373                 POSTDATA="username=$FritzUser&response=$RESPONSE"
    374 
    375                 SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
    376 
    377                 echo "login aufbauen und hashen ende"
    378 
    379                 $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_select.lua  > /tmp/curlhelp6.tmp
    380 
    381                 BOOKID=`cat /tmp/curlhelp6.tmp | grep ' checked id="uiBookid' | cut -d: -f2 | cut -d'"' -f1`
    382                 if [ -z "$BOOKID" ]; then
    383                     BOOKID=0
    384                 else
    385                     echo "BookID: $BOOKID"
    386                 fi
     251        Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
     252        Passwd="$FritzPass"
     253        # login aufbauen und hashen
     254        echo "login aufbauen und hashen start"
     255        CPSTR="$Challenge-$Passwd"
     256        MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
     257        RESPONSE="$Challenge-$MD5"
     258
     259        POSTDATA="username=$FritzUser&response=$RESPONSE"
     260
     261        SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
     262
     263        echo "login aufbauen und hashen ende SID:$SID"
     264             
     265        BOOKID=-1       #Liste mit möglichen IDs
     266        $CURL --data "sid=$SID&pbid=$BOOKID" http://$FRITZBOXIP:49000/phonebook.lua | grep "id:"  > /tmp/curlhelp1.tmp
     267        #langsamere Routine nur bei sh4-Boxen verwenden
     268        sh4=`cat /proc/cpuinfo | grep "sh4" | wc -c`
    387269       
    388                 #$CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g  | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g  | sed s/"<<a href="//g | sed s/"<\/a<"//g > /tmp/curlhelp3.tmp
    389                 $CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g | sed s/">"/"<"/g | sed s/"<<"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g | sed s/"<a href="//g | sed s/"<\/a"//g | sed s/"+49"/"0"/g > /tmp/curlhelp6.tmp
    390            
    391                 while read line
    392                     do
    393                         nummer1="0"
    394                         nummer2="0"
    395                         nummer3="0"
    396                         nummer4="0"
    397                         nummer5="0"
    398                         nummer6="0"
    399                         pos1=10
    400                         pos2=0
    401                         pos3=0
    402                         art=`echo $line | cut -d'<' -f1`
    403                         if [ ! -z $art ] && [ $art = "fritztele" ]; then
    404                             name=`echo $line | cut -d'<' -f2 | sed s/"title="//g`
    405                             nummer1=`echo $line | cut -d'<' -f7 | sed s/" "//g`
    406                             help=`echo $line | cut -d'<' -f8`
    407                             if [ $help = "br" ]; then
    408                                 nummer2=`echo $line | cut -d'<' -f10 | sed s/" "//g`
    409                                 pos1=13
    410                                 pos2=15
    411                                 help=`echo $line | cut -d'<' -f11`
    412                                 if [ $help = "br" ]; then
    413                                     nummer3=`echo $line | cut -d'<' -f13 | sed s/" "//g`
    414                                     pos1=16
    415                                     pos2=18
    416                                     pos3=20
    417                                     help=`echo $line | cut -d'<' -f14`
    418                                     if [ $help = "br" ]; then
    419                                         nummer4=`echo $line | cut -d'<' -f16 | sed s/" "//g`
    420                                         pos1=19
    421                                         pos2=21
    422                                         pos3=23
    423                                         pos4=25
    424                                         help=`echo $line | cut -d'<' -f17`
    425                                         if [ $help = "br" ]; then
    426                                             nummer5=`echo $line | cut -d'<' -f19 | sed s/" "//g`
    427                                             pos1=22
    428                                             pos2=24
    429                                             pos3=26
    430                                             pos4=28
    431                                             pos5=30
    432                                             help=`echo $line | cut -d'<' -f20`
    433                                             if [ $help = "br" ]; then
    434                                                 nummer6=`echo $line | cut -d'<' -f22 | sed s/" "//g`
    435                                                 pos1=25
    436                                                 pos2=27
    437                                                 pos3=29
    438                                                 pos4=31
    439                                                 pos5=33
    440                                                 pos6=35
    441                                             fi
    442                                         fi
    443                                     fi
    444                                 fi
    445                             fi
    446                             if [ $nummer1 != "0" ]; then
    447                                 typ=`echo $line | cut -d'<' -f$pos1`
    448                                 echo "$nummer1#$name->$typ" >> $FRITZBUCH
    449                             fi
    450                             if [ $nummer2 != "0" ]; then
    451                                 typ=`echo $line | cut -d'<' -f$pos2`
    452                                 echo "$nummer2#$name->$typ" >> $FRITZBUCH
    453                             fi
    454                             if [ $nummer3 != "0" ]; then
    455                                 typ=`echo $line | cut -d'<' -f$pos3`
    456                                 echo "$nummer3#$name->$typ" >> $FRITZBUCH
    457                             fi
    458                             if [ $nummer4 != "0" ]; then
    459                                 typ=`echo $line | cut -d'<' -f$pos4`
    460                                 echo "$nummer4#$name->$typ" >> $FRITZBUCH
    461                             fi
    462                             if [ $nummer5 != "0" ]; then
    463                                 typ=`echo $line | cut -d'<' -f$pos3`
    464                                 echo "$nummer5#$name->$typ" >> $FRITZBUCH
    465                             fi
    466                             if [ $nummer6 != "0" ]; then
    467                                 typ=`echo $line | cut -d'<' -f$pos4`
    468                                 echo "$nummer6#$name->$typ" >> $FRITZBUCH
    469                             fi
    470                         fi
    471                     done < /tmp/curlhelp6.tmp
    472                     #rm /tmp/curlhelp6.tmp   
     270        while read line
     271                do
     272                        BOOKID=`echo $line | cut -d':' -f2 | sed s/" \, name"//g`
     273                        NAME=`echo $line | cut -d':' -f3`
     274                        echo "Lese $NAME BookID: $BOOKID"
     275                        if [ $sh4 -eq 0 ]; then
     276                                loadXML $BOOKID
     277                        else
     278                                loadXMLsh4 $BOOKID
     279                        fi
     280                done < /tmp/curlhelp1.tmp     
     281
     282       
    473283};
    474284
    475285loadFritzBook () {
    476286 if [ $usePhoneBook = "1" ]; then
    477         #rm $FRITZBUCH
     287        rm $FRITZBUCH
    478288        if [ ! -f $FRITZBUCH ]; then
    479289            echo "FritzBook new -> $FRITZBUCH"
    480290           
    481             loadFritzBook60
    482                    
    483             if [ `grep -c "/td#" $FRITZBUCH` != "0" ]; then
    484                 echo "Fehler gefunden! Teste nun v5"
    485                 rm $FRITZBUCH
    486             fi
     291            loadFritzBook70
    487292           
    488             if [ ! -f $FRITZBUCH ]; then
    489                     loadFritzBook50
    490             fi
    491             if [ ! -f $FRITZBUCH ]; then
    492                     loadFritzBook49
    493             fi
    494             if [ ! -f $FRITZBUCH ]; then
    495                 echo "Error loadFritzBook"
    496             fi
     293            rm /tmp/curlhelp1.tmp
     294            rm /tmp/curlhelp7.tmp
     295           
    497296        fi
    498297    fi 
  • ipk/source.mipsel/tools_callmonitor/_path_/usr/local/share/titan/plugins/callmonitor1/fritzbox_msg_new.sh

    r40764 r42829  
    8181#detecting Dreambox-Type (DM7020 or DM7000 or DM500 or DM600PVR)
    8282 FRITZCACHE=/tmp/fritzbox.cache              #stores successfull reverse searches
    83  FRITZBUCH=/var/fritzbuch.tele
     83#FRITZBUCH=/var/fritzbuch.tele               #original
     84 FRITZBUCH=/mnt/swapextensions/fritzbuch.tele #TitanNit
    8485 TMPFILE=/tmp/fritzbox.tmp                   #stores page from wget command
    8586 TMPSTATUS=/tmp/fritzdream.status            #status der Dreambox (standby usw)
     
    201202};
    202203
    203 loadFritzBook49 () {
    204     echo "Version 49"
    205                 # Challenge abholen
    206                 echo "Challenge abholen start"
    207                 ChallengeXML=`wget -O - "http://$FRITZBOXIP/cgi-bin/webcm?getpage=../html/login_sid.xml" 2>/dev/null| grep Challenge`
    208                 Challenge=`echo $ChallengeXML | awk '{match($0,/>[^<>]+</); print substr($0,RSTART+1,RLENGTH-2)}'`
    209                 echo "Challenge abholen ende"
     204
     205rdom () { local IFS=\> ; read -d \< E C ;}
     206
     207loadXML(){
     208        #ID="$1"
     209        echo "Lese ID: $1"
     210        $CURL --data "sid=$SID&pbid=$1" http://$FRITZBOXIP:49000/phonebook.lua  > /tmp/curlhelp7.tmp
     211               
     212         while rdom; do
     213            if [[ $E = realName ]]; then
     214                name=$C
     215                #exit
     216            fi
     217            if [[ $E = number* ]]; then
     218                type=`echo "$E" | cut -d'"' -f2 | sed s/" "//g | sed s/"home"/"privat"/g | sed s/"work"/"geschaeftl."/g | sed s/"mobile"/"mobil"/g `
     219                nummer=$C
     220                tel=`echo $nummer | sed s/"+49"/"0"/g| sed s/" "//g`
     221                echo "$tel#$name->$type"  >> $FRITZBUCH
     222            fi
     223        done < /tmp/curlhelp7.tmp
     224};
     225
     226loadXMLsh4(){
     227        echo "Lese ID: $1"
     228        $CURL --data "sid=$SID&pbid=$1" http://$FRITZBOXIP:49000/phonebook.lua  > /tmp/curlhelp7.tmp
     229        while read line; do
     230                X=`echo $line | grep realName | wc -c`
     231                if [[ $X -gt 0 ]]; then
     232                        #E=`echo $line | cut -d'<' -f2 | cut -d'>' -f1`         
     233                        C=`echo $line | cut -d'>' -f2 | cut -d'<' -f1`
     234                        name=$C
     235                        #echo $name
     236                fi
     237               
     238                X=`echo $line | grep "number type" | wc -c`
     239                if [[ $X -gt 0 ]]; then
     240                        type=`echo $line| cut -d'"' -f2 | sed s/" "//g | sed s/"home"/"privat"/g | sed s/"work"/"geschaeftl."/g | sed s/"mobile"/"mobil"/g `
     241                        tel=`echo $line | cut -d'>' -f2 | cut -d'<' -f1`
     242                        echo "$tel#$name->$type"  >> $FRITZBUCH
     243                fi
     244                   
     245        done < /tmp/curlhelp7.tmp
     246};
     247
     248loadFritzBook70 () {
     249    echo "Version 70"
    210250               
    211                 Passwd="$FritzPass"
    212 
    213                 # login aufbauen und hashen
    214                 echo "login aufbauen und hashen start"
    215                 CPSTR="$Challenge-$Passwd"
    216                 MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/help; md5sum /tmp/help | awk '{print substr($0,1,32)}'`
    217                 RESPONSE="$Challenge-$MD5"
    218                 POSTDATA="login:command/response=$RESPONSE&getpage=../html/de/menus/menu2.html"
    219                 # login senden und SID herausfischen
    220                 SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/cgi-bin/webcm" 2>/dev/null| grep "name=\"sid\"" | head -n 1 | awk '{match($0,/value="[^"]+"/); print substr($0,RSTART+7,RLENGTH-8)}'`
    221                 echo "login aufbauen und hashen ende"
    222 
    223                 $CURL --data "telcfg:settings/Phonebook/Books/Select=0&getpage=../html/de/menus/menu2.html&var:pagename=fonbuch&sid=$SID&var:menu=fon&var:lang=de" http://$FRITZBOXIP/cgi-bin/webcm  | grep ">TrFon" | sed s/'<script type="text\/javascript">'// | sed s/';<\/script>'// | sed s/'('/'"'/ | sed s/')'/'"'/ > /tmp/curlhelp.tmp
    224                 while read line
    225                     do
    226                     art=`echo $line | cut -d'"' -f1`
    227                     if [ $art = "TrFonName" ]; then
    228                         name=`echo $line | cut -d'"' -f5`
    229                     elif [ $art = "TrFonNr" ]; then
    230                         nummer=`echo $line | cut -d'"' -f5`
    231                         echo "$nummer#$name->" >> $FRITZBUCH
    232                     fi
    233                 done < /tmp/curlhelp.tmp
    234                 rm /tmp/curlhelp.tmp
    235 
    236                 if [ ! -f $FRITZBUCH ]; then
    237                     #testen ob neues Telefonbuch
    238                     #$CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua > /tmp/test.curl
    239                     $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\">" | sed s/"<td class=\"tname\">"/"\nfritztele<"/ | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g > /tmp/curlhelp.tmp
    240                     while read line
    241                     do
    242                         nummer1="0"
    243                         nummer2="0"
    244                         nummer3="0"
    245                         pos1=14
    246                         pos2=0
    247                         pos3=0
    248                         art=`echo $line | cut -d'<' -f1`
    249                         if [ $art = "fritztele" ]; then
    250                             name=`echo $line | cut -d'<' -f2`
    251                             nummer1=`echo $line | cut -d'<' -f8`
    252                             help=`echo $line | cut -d'<' -f11`
    253                             if [ $help == "br" ]; then
    254                                 nummer2=`echo $line | cut -d'<' -f14`
    255                                 pos1=20
    256                                 pos2=22
    257                                 help=`echo $line | cut -d'<' -f17`
    258                                 if [ $help == "br" ]; then
    259                                     nummer3=`echo $line | cut -d'<' -f20`
    260                                     pos1=26
    261                                     pos2=28
    262                                     pos3=30
    263                                 fi
    264                             fi
    265                             if [ $nummer1 != "0" ]; then
    266                                 typ=`echo $line | cut -d'<' -f$pos1`
    267                                 echo "$nummer1#$name->$typ" >> $FRITZBUCH
    268                             fi
    269                             if [ $nummer2 != "0" ]; then
    270                                 typ=`echo $line | cut -d'<' -f$pos2`
    271                                 echo "$nummer2#$name->$typ" >> $FRITZBUCH
    272                             fi
    273                             if [ $nummer3 != "0" ]; then
    274                                 typ=`echo $line | cut -d'<' -f$pos3`
    275                                 echo "$nummer3#$name->$typ" >> $FRITZBUCH
    276                             fi
    277                         fi
    278                     done < /tmp/curlhelp.tmp
    279                     rm /tmp/curlhelp.tmp
    280                 fi
    281 };
    282 loadFritzBook50 () {
    283     echo "Version 50"
    284                
    285                 Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
    286                 Passwd="$FritzPass"
    287                 # login aufbauen und hashen
    288                 echo "login aufbauen und hashen start"
    289                 CPSTR="$Challenge-$Passwd"
    290                 MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
    291                 RESPONSE="$Challenge-$MD5"
    292 
    293                 POSTDATA="username=$FritzUser&response=$RESPONSE"
    294 
    295                 SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
    296 
    297                 echo "login aufbauen und hashen ende"
    298 
    299                 $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_select.lua  > /tmp/curlhelp3.tmp
    300 
    301                 BOOKID=`cat /tmp/curlhelp3.tmp | grep '<label for="uiBookid' | grep ritzcall | cut -d: -f2 | cut -d'"' -f1`
    302                 if [ -z "$BOOKID" ]; then
    303                     BOOKID=0
    304                 fi
    305 
    306                 $CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua  | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g  | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g  | sed s/"<<a href="//g | sed s/"<\/a<"//g | sed s/"+49"/"0"/g > /tmp/curlhelp3.tmp
    307 
    308                 while read line
    309                     do
    310                         nummer1="0"
    311                         nummer2="0"
    312                         nummer3="0"
    313                         nummer4="0"
    314                         pos1=11
    315                         pos2=0
    316                         pos3=0
    317                         art=`echo $line | cut -d'<' -f1`
    318                         if [ ! -z $art ] && [ $art = "fritztele" ]; then
    319                             name=`echo $line | cut -d'<' -f2 | sed s/"title="//g`
    320                             nummer1=`echo $line | cut -d'<' -f7 | sed s/" "//g`
    321                             help=`echo $line | cut -d'<' -f8 | cut -c 1-2`
    322                             if [ $help = "br" ]; then
    323                                 nummer2=`echo $line | cut -d'<' -f9 | sed s/" "//g`
    324                                 pos1=13
    325                                 pos2=15
    326                                 help=`echo $line | cut -d'<' -f10 | cut -c 1-2`
    327                                 if [ $help = "br" ]; then
    328                                     nummer3=`echo $line | cut -d'<' -f11 | sed s/" "//g`
    329                                     pos1=15
    330                                     pos2=17
    331                                     pos3=19
    332                                     help=`echo $line | cut -d'<' -f12 | cut -c 1-2`
    333                                     if [ $help = "br" ]; then
    334                                         nummer4=`echo $line | cut -d'<' -f13 | sed s/" "//g`
    335                                         pos1=17
    336                                         pos2=19
    337                                         pos3=21
    338                                         pos4=23
    339                                     fi
    340                                 fi
    341                             fi
    342                             if [ $nummer1 != "0" ]; then
    343                                 typ=`echo $line | cut -d'<' -f$pos1`
    344                                 echo "$nummer1#$name->$typ" >> $FRITZBUCH
    345                             fi
    346                             if [ $nummer2 != "0" ]; then
    347                                 typ=`echo $line | cut -d'<' -f$pos2`
    348                                 echo "$nummer2#$name->$typ" >> $FRITZBUCH
    349                             fi
    350                             if [ $nummer3 != "0" ]; then
    351                                 typ=`echo $line | cut -d'<' -f$pos3`
    352                                 echo "$nummer3#$name->$typ" >> $FRITZBUCH
    353                             fi
    354                             if [ $nummer4 != "0" ]; then
    355                                 typ=`echo $line | cut -d'<' -f$pos4`
    356                                 echo "$nummer4#$name->$typ" >> $FRITZBUCH
    357                             fi
    358                         fi
    359                     done < /tmp/curlhelp3.tmp
    360                     rm /tmp/curlhelp3.tmp
    361 };
    362 loadFritzBook60 () {
    363     echo "Version 60"
    364                
    365                 Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
    366                 Passwd="$FritzPass"
    367                 # login aufbauen und hashen
    368                 echo "login aufbauen und hashen start"
    369                 CPSTR="$Challenge-$Passwd"
    370                 MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
    371                 RESPONSE="$Challenge-$MD5"
    372 
    373                 POSTDATA="username=$FritzUser&response=$RESPONSE"
    374 
    375                 SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
    376 
    377                 echo "login aufbauen und hashen ende"
    378 
    379                 $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_select.lua  > /tmp/curlhelp6.tmp
    380 
    381                 BOOKID=`cat /tmp/curlhelp6.tmp | grep ' checked id="uiBookid' | cut -d: -f2 | cut -d'"' -f1`
    382                 if [ -z "$BOOKID" ]; then
    383                     BOOKID=0
    384                 else
    385                     echo "BookID: $BOOKID"
    386                 fi
     251        Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
     252        Passwd="$FritzPass"
     253        # login aufbauen und hashen
     254        echo "login aufbauen und hashen start"
     255        CPSTR="$Challenge-$Passwd"
     256        MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
     257        RESPONSE="$Challenge-$MD5"
     258
     259        POSTDATA="username=$FritzUser&response=$RESPONSE"
     260
     261        SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
     262
     263        echo "login aufbauen und hashen ende SID:$SID"
     264             
     265        BOOKID=-1       #Liste mit möglichen IDs
     266        $CURL --data "sid=$SID&pbid=$BOOKID" http://$FRITZBOXIP:49000/phonebook.lua | grep "id:"  > /tmp/curlhelp1.tmp
     267        #langsamere Routine nur bei sh4-Boxen verwenden
     268        sh4=`cat /proc/cpuinfo | grep "sh4" | wc -c`
    387269       
    388                 #$CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g  | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g  | sed s/"<<a href="//g | sed s/"<\/a<"//g > /tmp/curlhelp3.tmp
    389                 $CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g | sed s/">"/"<"/g | sed s/"<<"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g | sed s/"<a href="//g | sed s/"<\/a"//g | sed s/"+49"/"0"/g > /tmp/curlhelp6.tmp
    390            
    391                 while read line
    392                     do
    393                         nummer1="0"
    394                         nummer2="0"
    395                         nummer3="0"
    396                         nummer4="0"
    397                         nummer5="0"
    398                         nummer6="0"
    399                         pos1=10
    400                         pos2=0
    401                         pos3=0
    402                         art=`echo $line | cut -d'<' -f1`
    403                         if [ ! -z $art ] && [ $art = "fritztele" ]; then
    404                             name=`echo $line | cut -d'<' -f2 | sed s/"title="//g`
    405                             nummer1=`echo $line | cut -d'<' -f7 | sed s/" "//g`
    406                             help=`echo $line | cut -d'<' -f8`
    407                             if [ $help = "br" ]; then
    408                                 nummer2=`echo $line | cut -d'<' -f10 | sed s/" "//g`
    409                                 pos1=13
    410                                 pos2=15
    411                                 help=`echo $line | cut -d'<' -f11`
    412                                 if [ $help = "br" ]; then
    413                                     nummer3=`echo $line | cut -d'<' -f13 | sed s/" "//g`
    414                                     pos1=16
    415                                     pos2=18
    416                                     pos3=20
    417                                     help=`echo $line | cut -d'<' -f14`
    418                                     if [ $help = "br" ]; then
    419                                         nummer4=`echo $line | cut -d'<' -f16 | sed s/" "//g`
    420                                         pos1=19
    421                                         pos2=21
    422                                         pos3=23
    423                                         pos4=25
    424                                         help=`echo $line | cut -d'<' -f17`
    425                                         if [ $help = "br" ]; then
    426                                             nummer5=`echo $line | cut -d'<' -f19 | sed s/" "//g`
    427                                             pos1=22
    428                                             pos2=24
    429                                             pos3=26
    430                                             pos4=28
    431                                             pos5=30
    432                                             help=`echo $line | cut -d'<' -f20`
    433                                             if [ $help = "br" ]; then
    434                                                 nummer6=`echo $line | cut -d'<' -f22 | sed s/" "//g`
    435                                                 pos1=25
    436                                                 pos2=27
    437                                                 pos3=29
    438                                                 pos4=31
    439                                                 pos5=33
    440                                                 pos6=35
    441                                             fi
    442                                         fi
    443                                     fi
    444                                 fi
    445                             fi
    446                             if [ $nummer1 != "0" ]; then
    447                                 typ=`echo $line | cut -d'<' -f$pos1`
    448                                 echo "$nummer1#$name->$typ" >> $FRITZBUCH
    449                             fi
    450                             if [ $nummer2 != "0" ]; then
    451                                 typ=`echo $line | cut -d'<' -f$pos2`
    452                                 echo "$nummer2#$name->$typ" >> $FRITZBUCH
    453                             fi
    454                             if [ $nummer3 != "0" ]; then
    455                                 typ=`echo $line | cut -d'<' -f$pos3`
    456                                 echo "$nummer3#$name->$typ" >> $FRITZBUCH
    457                             fi
    458                             if [ $nummer4 != "0" ]; then
    459                                 typ=`echo $line | cut -d'<' -f$pos4`
    460                                 echo "$nummer4#$name->$typ" >> $FRITZBUCH
    461                             fi
    462                             if [ $nummer5 != "0" ]; then
    463                                 typ=`echo $line | cut -d'<' -f$pos3`
    464                                 echo "$nummer5#$name->$typ" >> $FRITZBUCH
    465                             fi
    466                             if [ $nummer6 != "0" ]; then
    467                                 typ=`echo $line | cut -d'<' -f$pos4`
    468                                 echo "$nummer6#$name->$typ" >> $FRITZBUCH
    469                             fi
    470                         fi
    471                     done < /tmp/curlhelp6.tmp
    472                     #rm /tmp/curlhelp6.tmp   
     270        while read line
     271                do
     272                        BOOKID=`echo $line | cut -d':' -f2 | sed s/" \, name"//g`
     273                        NAME=`echo $line | cut -d':' -f3`
     274                        echo "Lese $NAME BookID: $BOOKID"
     275                        if [ $sh4 -eq 0 ]; then
     276                                loadXML $BOOKID
     277                        else
     278                                loadXMLsh4 $BOOKID
     279                        fi
     280                done < /tmp/curlhelp1.tmp     
     281
     282       
    473283};
    474284
    475285loadFritzBook () {
    476286 if [ $usePhoneBook = "1" ]; then
    477         #rm $FRITZBUCH
     287        rm $FRITZBUCH
    478288        if [ ! -f $FRITZBUCH ]; then
    479289            echo "FritzBook new -> $FRITZBUCH"
    480290           
    481             loadFritzBook60
    482                    
    483             if [ `grep -c "/td#" $FRITZBUCH` != "0" ]; then
    484                 echo "Fehler gefunden! Teste nun v5"
    485                 rm $FRITZBUCH
    486             fi
     291            loadFritzBook70
    487292           
    488             if [ ! -f $FRITZBUCH ]; then
    489                     loadFritzBook50
    490             fi
    491             if [ ! -f $FRITZBUCH ]; then
    492                     loadFritzBook49
    493             fi
    494             if [ ! -f $FRITZBUCH ]; then
    495                 echo "Error loadFritzBook"
    496             fi
     293            rm /tmp/curlhelp1.tmp
     294            rm /tmp/curlhelp7.tmp
     295           
    497296        fi
    498297    fi 
  • ipk/source.sh4/tools_callmonitor/_path_/usr/local/share/titan/plugins/callmonitor1/fritzbox_msg_new.sh

    r40764 r42829  
    8181#detecting Dreambox-Type (DM7020 or DM7000 or DM500 or DM600PVR)
    8282 FRITZCACHE=/tmp/fritzbox.cache              #stores successfull reverse searches
    83  FRITZBUCH=/var/fritzbuch.tele
     83#FRITZBUCH=/var/fritzbuch.tele               #original
     84 FRITZBUCH=/mnt/swapextensions/fritzbuch.tele #TitanNit
    8485 TMPFILE=/tmp/fritzbox.tmp                   #stores page from wget command
    8586 TMPSTATUS=/tmp/fritzdream.status            #status der Dreambox (standby usw)
     
    201202};
    202203
    203 loadFritzBook49 () {
    204     echo "Version 49"
    205                 # Challenge abholen
    206                 echo "Challenge abholen start"
    207                 ChallengeXML=`wget -O - "http://$FRITZBOXIP/cgi-bin/webcm?getpage=../html/login_sid.xml" 2>/dev/null| grep Challenge`
    208                 Challenge=`echo $ChallengeXML | awk '{match($0,/>[^<>]+</); print substr($0,RSTART+1,RLENGTH-2)}'`
    209                 echo "Challenge abholen ende"
     204
     205rdom () { local IFS=\> ; read -d \< E C ;}
     206
     207loadXML(){
     208        #ID="$1"
     209        echo "Lese ID: $1"
     210        $CURL --data "sid=$SID&pbid=$1" http://$FRITZBOXIP:49000/phonebook.lua  > /tmp/curlhelp7.tmp
     211               
     212         while rdom; do
     213            if [[ $E = realName ]]; then
     214                name=$C
     215                #exit
     216            fi
     217            if [[ $E = number* ]]; then
     218                type=`echo "$E" | cut -d'"' -f2 | sed s/" "//g | sed s/"home"/"privat"/g | sed s/"work"/"geschaeftl."/g | sed s/"mobile"/"mobil"/g `
     219                nummer=$C
     220                tel=`echo $nummer | sed s/"+49"/"0"/g| sed s/" "//g`
     221                echo "$tel#$name->$type"  >> $FRITZBUCH
     222            fi
     223        done < /tmp/curlhelp7.tmp
     224};
     225
     226loadXMLsh4(){
     227        echo "Lese ID: $1"
     228        $CURL --data "sid=$SID&pbid=$1" http://$FRITZBOXIP:49000/phonebook.lua  > /tmp/curlhelp7.tmp
     229        while read line; do
     230                X=`echo $line | grep realName | wc -c`
     231                if [[ $X -gt 0 ]]; then
     232                        #E=`echo $line | cut -d'<' -f2 | cut -d'>' -f1`         
     233                        C=`echo $line | cut -d'>' -f2 | cut -d'<' -f1`
     234                        name=$C
     235                        #echo $name
     236                fi
     237               
     238                X=`echo $line | grep "number type" | wc -c`
     239                if [[ $X -gt 0 ]]; then
     240                        type=`echo $line| cut -d'"' -f2 | sed s/" "//g | sed s/"home"/"privat"/g | sed s/"work"/"geschaeftl."/g | sed s/"mobile"/"mobil"/g `
     241                        tel=`echo $line | cut -d'>' -f2 | cut -d'<' -f1`
     242                        echo "$tel#$name->$type"  >> $FRITZBUCH
     243                fi
     244                   
     245        done < /tmp/curlhelp7.tmp
     246};
     247
     248loadFritzBook70 () {
     249    echo "Version 70"
    210250               
    211                 Passwd="$FritzPass"
    212 
    213                 # login aufbauen und hashen
    214                 echo "login aufbauen und hashen start"
    215                 CPSTR="$Challenge-$Passwd"
    216                 MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/help; md5sum /tmp/help | awk '{print substr($0,1,32)}'`
    217                 RESPONSE="$Challenge-$MD5"
    218                 POSTDATA="login:command/response=$RESPONSE&getpage=../html/de/menus/menu2.html"
    219                 # login senden und SID herausfischen
    220                 SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/cgi-bin/webcm" 2>/dev/null| grep "name=\"sid\"" | head -n 1 | awk '{match($0,/value="[^"]+"/); print substr($0,RSTART+7,RLENGTH-8)}'`
    221                 echo "login aufbauen und hashen ende"
    222 
    223                 $CURL --data "telcfg:settings/Phonebook/Books/Select=0&getpage=../html/de/menus/menu2.html&var:pagename=fonbuch&sid=$SID&var:menu=fon&var:lang=de" http://$FRITZBOXIP/cgi-bin/webcm  | grep ">TrFon" | sed s/'<script type="text\/javascript">'// | sed s/';<\/script>'// | sed s/'('/'"'/ | sed s/')'/'"'/ > /tmp/curlhelp.tmp
    224                 while read line
    225                     do
    226                     art=`echo $line | cut -d'"' -f1`
    227                     if [ $art = "TrFonName" ]; then
    228                         name=`echo $line | cut -d'"' -f5`
    229                     elif [ $art = "TrFonNr" ]; then
    230                         nummer=`echo $line | cut -d'"' -f5`
    231                         echo "$nummer#$name->" >> $FRITZBUCH
    232                     fi
    233                 done < /tmp/curlhelp.tmp
    234                 rm /tmp/curlhelp.tmp
    235 
    236                 if [ ! -f $FRITZBUCH ]; then
    237                     #testen ob neues Telefonbuch
    238                     #$CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua > /tmp/test.curl
    239                     $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\">" | sed s/"<td class=\"tname\">"/"\nfritztele<"/ | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g > /tmp/curlhelp.tmp
    240                     while read line
    241                     do
    242                         nummer1="0"
    243                         nummer2="0"
    244                         nummer3="0"
    245                         pos1=14
    246                         pos2=0
    247                         pos3=0
    248                         art=`echo $line | cut -d'<' -f1`
    249                         if [ $art = "fritztele" ]; then
    250                             name=`echo $line | cut -d'<' -f2`
    251                             nummer1=`echo $line | cut -d'<' -f8`
    252                             help=`echo $line | cut -d'<' -f11`
    253                             if [ $help == "br" ]; then
    254                                 nummer2=`echo $line | cut -d'<' -f14`
    255                                 pos1=20
    256                                 pos2=22
    257                                 help=`echo $line | cut -d'<' -f17`
    258                                 if [ $help == "br" ]; then
    259                                     nummer3=`echo $line | cut -d'<' -f20`
    260                                     pos1=26
    261                                     pos2=28
    262                                     pos3=30
    263                                 fi
    264                             fi
    265                             if [ $nummer1 != "0" ]; then
    266                                 typ=`echo $line | cut -d'<' -f$pos1`
    267                                 echo "$nummer1#$name->$typ" >> $FRITZBUCH
    268                             fi
    269                             if [ $nummer2 != "0" ]; then
    270                                 typ=`echo $line | cut -d'<' -f$pos2`
    271                                 echo "$nummer2#$name->$typ" >> $FRITZBUCH
    272                             fi
    273                             if [ $nummer3 != "0" ]; then
    274                                 typ=`echo $line | cut -d'<' -f$pos3`
    275                                 echo "$nummer3#$name->$typ" >> $FRITZBUCH
    276                             fi
    277                         fi
    278                     done < /tmp/curlhelp.tmp
    279                     rm /tmp/curlhelp.tmp
    280                 fi
    281 };
    282 loadFritzBook50 () {
    283     echo "Version 50"
    284                
    285                 Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
    286                 Passwd="$FritzPass"
    287                 # login aufbauen und hashen
    288                 echo "login aufbauen und hashen start"
    289                 CPSTR="$Challenge-$Passwd"
    290                 MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
    291                 RESPONSE="$Challenge-$MD5"
    292 
    293                 POSTDATA="username=$FritzUser&response=$RESPONSE"
    294 
    295                 SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
    296 
    297                 echo "login aufbauen und hashen ende"
    298 
    299                 $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_select.lua  > /tmp/curlhelp3.tmp
    300 
    301                 BOOKID=`cat /tmp/curlhelp3.tmp | grep '<label for="uiBookid' | grep ritzcall | cut -d: -f2 | cut -d'"' -f1`
    302                 if [ -z "$BOOKID" ]; then
    303                     BOOKID=0
    304                 fi
    305 
    306                 $CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua  | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g  | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g  | sed s/"<<a href="//g | sed s/"<\/a<"//g | sed s/"+49"/"0"/g > /tmp/curlhelp3.tmp
    307 
    308                 while read line
    309                     do
    310                         nummer1="0"
    311                         nummer2="0"
    312                         nummer3="0"
    313                         nummer4="0"
    314                         pos1=11
    315                         pos2=0
    316                         pos3=0
    317                         art=`echo $line | cut -d'<' -f1`
    318                         if [ ! -z $art ] && [ $art = "fritztele" ]; then
    319                             name=`echo $line | cut -d'<' -f2 | sed s/"title="//g`
    320                             nummer1=`echo $line | cut -d'<' -f7 | sed s/" "//g`
    321                             help=`echo $line | cut -d'<' -f8 | cut -c 1-2`
    322                             if [ $help = "br" ]; then
    323                                 nummer2=`echo $line | cut -d'<' -f9 | sed s/" "//g`
    324                                 pos1=13
    325                                 pos2=15
    326                                 help=`echo $line | cut -d'<' -f10 | cut -c 1-2`
    327                                 if [ $help = "br" ]; then
    328                                     nummer3=`echo $line | cut -d'<' -f11 | sed s/" "//g`
    329                                     pos1=15
    330                                     pos2=17
    331                                     pos3=19
    332                                     help=`echo $line | cut -d'<' -f12 | cut -c 1-2`
    333                                     if [ $help = "br" ]; then
    334                                         nummer4=`echo $line | cut -d'<' -f13 | sed s/" "//g`
    335                                         pos1=17
    336                                         pos2=19
    337                                         pos3=21
    338                                         pos4=23
    339                                     fi
    340                                 fi
    341                             fi
    342                             if [ $nummer1 != "0" ]; then
    343                                 typ=`echo $line | cut -d'<' -f$pos1`
    344                                 echo "$nummer1#$name->$typ" >> $FRITZBUCH
    345                             fi
    346                             if [ $nummer2 != "0" ]; then
    347                                 typ=`echo $line | cut -d'<' -f$pos2`
    348                                 echo "$nummer2#$name->$typ" >> $FRITZBUCH
    349                             fi
    350                             if [ $nummer3 != "0" ]; then
    351                                 typ=`echo $line | cut -d'<' -f$pos3`
    352                                 echo "$nummer3#$name->$typ" >> $FRITZBUCH
    353                             fi
    354                             if [ $nummer4 != "0" ]; then
    355                                 typ=`echo $line | cut -d'<' -f$pos4`
    356                                 echo "$nummer4#$name->$typ" >> $FRITZBUCH
    357                             fi
    358                         fi
    359                     done < /tmp/curlhelp3.tmp
    360                     rm /tmp/curlhelp3.tmp
    361 };
    362 loadFritzBook60 () {
    363     echo "Version 60"
    364                
    365                 Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
    366                 Passwd="$FritzPass"
    367                 # login aufbauen und hashen
    368                 echo "login aufbauen und hashen start"
    369                 CPSTR="$Challenge-$Passwd"
    370                 MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
    371                 RESPONSE="$Challenge-$MD5"
    372 
    373                 POSTDATA="username=$FritzUser&response=$RESPONSE"
    374 
    375                 SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
    376 
    377                 echo "login aufbauen und hashen ende"
    378 
    379                 $CURL --data "sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_select.lua  > /tmp/curlhelp6.tmp
    380 
    381                 BOOKID=`cat /tmp/curlhelp6.tmp | grep ' checked id="uiBookid' | cut -d: -f2 | cut -d'"' -f1`
    382                 if [ -z "$BOOKID" ]; then
    383                     BOOKID=0
    384                 else
    385                     echo "BookID: $BOOKID"
    386                 fi
     251        Challenge=`wget -O - "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null | grep Challenge | cut -d"<" -f6 | cut -d">" -f2`
     252        Passwd="$FritzPass"
     253        # login aufbauen und hashen
     254        echo "login aufbauen und hashen start"
     255        CPSTR="$Challenge-$Passwd"
     256        MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/helpx; md5sum /tmp/helpx | awk '{print substr($0,1,32)}'`
     257        RESPONSE="$Challenge-$MD5"
     258
     259        POSTDATA="username=$FritzUser&response=$RESPONSE"
     260
     261        SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/login_sid.lua" 2>/dev/null  | grep SID | cut -d"<" -f4 | cut -d">" -f2`
     262
     263        echo "login aufbauen und hashen ende SID:$SID"
     264             
     265        BOOKID=-1       #Liste mit möglichen IDs
     266        $CURL --data "sid=$SID&pbid=$BOOKID" http://$FRITZBOXIP:49000/phonebook.lua | grep "id:"  > /tmp/curlhelp1.tmp
     267        #langsamere Routine nur bei sh4-Boxen verwenden
     268        sh4=`cat /proc/cpuinfo | grep "sh4" | wc -c`
    387269       
    388                 #$CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g  | sed s/">"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g  | sed s/"<<a href="//g | sed s/"<\/a<"//g > /tmp/curlhelp3.tmp
    389                 $CURL --data "bookid=$BOOKID&sid=$SID" http://$FRITZBOXIP/fon_num/fonbook_list.lua | grep "<td class=\"tname\" title=" | sed s/'class="tname" '/"\nfritztele<"/g | sed s/">"/"<"/g | sed s/"<<"/"<"/g | sed s/"'"//g | sed s/'"'//g | sed s/"&amp;"/"+"/g | sed s/"<a href="//g | sed s/"<\/a"//g | sed s/"+49"/"0"/g > /tmp/curlhelp6.tmp
    390            
    391                 while read line
    392                     do
    393                         nummer1="0"
    394                         nummer2="0"
    395                         nummer3="0"
    396                         nummer4="0"
    397                         nummer5="0"
    398                         nummer6="0"
    399                         pos1=10
    400                         pos2=0
    401                         pos3=0
    402                         art=`echo $line | cut -d'<' -f1`
    403                         if [ ! -z $art ] && [ $art = "fritztele" ]; then
    404                             name=`echo $line | cut -d'<' -f2 | sed s/"title="//g`
    405                             nummer1=`echo $line | cut -d'<' -f7 | sed s/" "//g`
    406                             help=`echo $line | cut -d'<' -f8`
    407                             if [ $help = "br" ]; then
    408                                 nummer2=`echo $line | cut -d'<' -f10 | sed s/" "//g`
    409                                 pos1=13
    410                                 pos2=15
    411                                 help=`echo $line | cut -d'<' -f11`
    412                                 if [ $help = "br" ]; then
    413                                     nummer3=`echo $line | cut -d'<' -f13 | sed s/" "//g`
    414                                     pos1=16
    415                                     pos2=18
    416                                     pos3=20
    417                                     help=`echo $line | cut -d'<' -f14`
    418                                     if [ $help = "br" ]; then
    419                                         nummer4=`echo $line | cut -d'<' -f16 | sed s/" "//g`
    420                                         pos1=19
    421                                         pos2=21
    422                                         pos3=23
    423                                         pos4=25
    424                                         help=`echo $line | cut -d'<' -f17`
    425                                         if [ $help = "br" ]; then
    426                                             nummer5=`echo $line | cut -d'<' -f19 | sed s/" "//g`
    427                                             pos1=22
    428                                             pos2=24
    429                                             pos3=26
    430                                             pos4=28
    431                                             pos5=30
    432                                             help=`echo $line | cut -d'<' -f20`
    433                                             if [ $help = "br" ]; then
    434                                                 nummer6=`echo $line | cut -d'<' -f22 | sed s/" "//g`
    435                                                 pos1=25
    436                                                 pos2=27
    437                                                 pos3=29
    438                                                 pos4=31
    439                                                 pos5=33
    440                                                 pos6=35
    441                                             fi
    442                                         fi
    443                                     fi
    444                                 fi
    445                             fi
    446                             if [ $nummer1 != "0" ]; then
    447                                 typ=`echo $line | cut -d'<' -f$pos1`
    448                                 echo "$nummer1#$name->$typ" >> $FRITZBUCH
    449                             fi
    450                             if [ $nummer2 != "0" ]; then
    451                                 typ=`echo $line | cut -d'<' -f$pos2`
    452                                 echo "$nummer2#$name->$typ" >> $FRITZBUCH
    453                             fi
    454                             if [ $nummer3 != "0" ]; then
    455                                 typ=`echo $line | cut -d'<' -f$pos3`
    456                                 echo "$nummer3#$name->$typ" >> $FRITZBUCH
    457                             fi
    458                             if [ $nummer4 != "0" ]; then
    459                                 typ=`echo $line | cut -d'<' -f$pos4`
    460                                 echo "$nummer4#$name->$typ" >> $FRITZBUCH
    461                             fi
    462                             if [ $nummer5 != "0" ]; then
    463                                 typ=`echo $line | cut -d'<' -f$pos3`
    464                                 echo "$nummer5#$name->$typ" >> $FRITZBUCH
    465                             fi
    466                             if [ $nummer6 != "0" ]; then
    467                                 typ=`echo $line | cut -d'<' -f$pos4`
    468                                 echo "$nummer6#$name->$typ" >> $FRITZBUCH
    469                             fi
    470                         fi
    471                     done < /tmp/curlhelp6.tmp
    472                     #rm /tmp/curlhelp6.tmp   
     270        while read line
     271                do
     272                        BOOKID=`echo $line | cut -d':' -f2 | sed s/" \, name"//g`
     273                        NAME=`echo $line | cut -d':' -f3`
     274                        echo "Lese $NAME BookID: $BOOKID"
     275                        if [ $sh4 -eq 0 ]; then
     276                                loadXML $BOOKID
     277                        else
     278                                loadXMLsh4 $BOOKID
     279                        fi
     280                done < /tmp/curlhelp1.tmp     
     281
     282       
    473283};
    474284
    475285loadFritzBook () {
    476286 if [ $usePhoneBook = "1" ]; then
    477         #rm $FRITZBUCH
     287        rm $FRITZBUCH
    478288        if [ ! -f $FRITZBUCH ]; then
    479289            echo "FritzBook new -> $FRITZBUCH"
    480290           
    481             loadFritzBook60
    482                    
    483             if [ `grep -c "/td#" $FRITZBUCH` != "0" ]; then
    484                 echo "Fehler gefunden! Teste nun v5"
    485                 rm $FRITZBUCH
    486             fi
     291            loadFritzBook70
    487292           
    488             if [ ! -f $FRITZBUCH ]; then
    489                     loadFritzBook50
    490             fi
    491             if [ ! -f $FRITZBUCH ]; then
    492                     loadFritzBook49
    493             fi
    494             if [ ! -f $FRITZBUCH ]; then
    495                 echo "Error loadFritzBook"
    496             fi
     293            rm /tmp/curlhelp1.tmp
     294            rm /tmp/curlhelp7.tmp
     295           
    497296        fi
    498297    fi 
Note: See TracChangeset for help on using the changeset viewer.