Search Results

Search found 698 results on 28 pages for 'tola ch'.

Page 1/28 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Ch-ch-ch-changes...

    - by Lou Vega
    The last few months have been pretty crazy. Just before the MVP summit in February I was approached about changing to a different project with my (then current) employer, and right after the summit I was approached by another company. Eventually I went with the new company and a new role in the Information Assurance field. More to come on that as things progress. All that being said I've not been as active in the .NET community as I once was and I miss it - so I'm looking to dive back in especially as Windows Phone 7 draws nearer and nearer. Speaking of the community - many of you may not recognize me if you see me now :) I had told my son for the last couple years that I would cut my hair before he turned 5 (he always asked how come he didn't have long hair) and he turns 5 (time has flown!) on June 19th so May 30th I cut my long hair down pretty short and donated the hair to Locks of Love. As Chris said to me on Twitter, "pics or it didn't happen" - well fortunately my wife was there to document the whole thing so I'll get a picture or two posted here soon.

    Read the article

  • Uneditable file and Unreadable(for further processing) file( WHY? ) after processing it through C++

    - by mgj
    Hi...:) This might look to be a very long question to you I understand, but trust me on this its not long. I am not able to identify why after processing this text is not being able to be read and edited. I tried using the ord() function in python to check if the text contains any Unicode characters( non ascii characters) apart from the ascii ones.. I found quite a number of them. I have a strong feeling that this could be due to the original text itself( The INPUT ). Input-File: Just copy paste it into a file "acle5v1.txt" The objective of this code below is to check for upper case characters and to convert it to lower case and also to remove all punctuations so that these words are taken for further processing for word alignment #include<iostrea> #include<fstream> #include<ctype.h> #include<cstring> using namespace std; ifstream fin2("acle5v1.txt"); ofstream fin3("acle5v1_op.txt"); ofstream fin4("chkcharadded.txt"); ofstream fin5("chkcharntadded.txt"); ofstream fin6("chkprintchar.txt"); ofstream fin7("chknonasci.txt"); ofstream fin8("nonprinchar.txt"); int main() { char ch,ch1; fin2.seekg(0); fin3.seekp(0); int flag = 0; while(!fin2.eof()) { ch1=ch; fin2.get(ch); if (isprint(ch))// if the character is printable flag = 1; if(flag) { fin6<<"Printable character:\t"<<ch<<"\t"<<(int)ch<<endl; flag = 0; } else { fin8<<"Non printable character caught:\t"<<ch<<"\t"<<int(ch)<<endl; } if( isalnum(ch) || ch == '@' || ch == ' ' )// checks for alpha numeric characters { fin4<<"char added: "<<ch<<"\tits ascii value: "<<int(ch)<<endl; if(isupper(ch)) { //tolower(ch); fin3<<(char)tolower(ch); } else { fin3<<ch; } } else if( ( ch=='\t' || ch=='.' || ch==',' || ch=='#' || ch=='?' || ch=='!' || ch=='"' || ch != ';' || ch != ':') && ch1 != ' ' ) { fin3<<' '; } else if( (ch=='\t' || ch=='.' || ch==',' || ch=='#' || ch=='?' || ch=='!' || ch=='"' || ch != ';' || ch != ':') && ch1 == ' ' ) { //fin3<<" '; } else if( !(int(ch)>=0 && int(ch)<=127) ) { fin5<<"Char of ascii within range not added: "<<ch<<"\tits ascii value: "<<int(ch)<<endl; } else { fin7<<"Non ascii character caught(could be a -ve value also)\t"<<ch<<int(ch)<<endl; } } return 0; } I have a similar code as the above written in python which gives me an otput which is again not readable and not editable The code in python looks like this: #!/usr/bin/python # -*- coding: UTF-8 -*- import sys input_file=sys.argv[1] output_file=sys.argv[2] list1=[] f=open(input_file) for line in f: line=line.strip() #line=line.rstrip('.') line=line.replace('.','') line=line.replace(',','') line=line.replace('#','') line=line.replace('?','') line=line.replace('!','') line=line.replace('"','') line=line.replace('?','') line=line.replace('|','') line = line.lower() list1.append(line) f.close() f1=open(output_file,'w') f1.write(' '.join(list1)) f1.close() the file takes ip and op at runtime.. as: python punc_remover.py acle5v1.txt acle5v1_op.txt The output of this file is in "acle5v1_op.txt" now after processing this particular output file is needed for further processing. This particular file "aclee5v1_op.txt" is the UNREADABLE Aand UNEDITABLE File that I am not being able to use for further processing. I need this for Word alignment in NLP. I tried readin this output with the following program #include<iostream> #include<fstream> using namespace std; ifstream fin1("acle5v1_op.txt"); ofstream fout1("chckread_acle5v1_op.txt"); ofstream fout2("chcknotread_acle5v1_op.txt"); int main() { char ch; int flag = 0; long int r = 0; long int nr = 0; while(!(fin1)) { fin1.get(ch); if(ch) { flag = 1; } if(flag) { fout1<<ch; flag = 0; r++; } else { fout2<<"Char not been able to be read from source file\n"; nr++; } } cout<<"Number of characters able to be read: "<<r; cout<<endl<<"Number of characters not been able to be read: "<<nr; return 0; } which prints the character if its readable and if not it doesn't print them but I observed the output of both the file is blank thus I could draw a conclusion that this file "acle5v1_op.txt" is UNREADABLE AND UNEDITABLE. Could you please help me on how to deal with this problem.. To tell you a bit about the statistics wrt the original input file "acle5v1.txt" file it has around 3441 lines in it and around 3 million characters in it. Keeping in mind the number of characters in the file you editor might/might not be able to manage to open the file.. I was able to open the file in gedit of Fedora 10 which I am currently using .. This is just to notify you that opening with a particular editor was not actually an issue at least in my case... Can I use scripting languages like Python and Perl to deal with this problem if Yes how? could please be specific on that regard as I am a novice to Perl and Python. Or could you please tell me how do I solve this problem using C++ itself.. Thank you...:) I am really looking forward to some help or guidance on how to go about this problem....

    Read the article

  • Parsing a Directory of files - Check for a String

    - by i.h4d35
    This is my first post here so kindly pardon any mistakes that I have. I'm still learning to find my way around Stack Exchange. I am trying to write a Java program that tries to scan a Directory full of either .txt,.rtf or.doc files(and none other). The aim is to search all the files in the directory, and find out if a particular string exists in the file. If it does, it returns the string and the filename that it found the string in. The aim of this program is, it is a project for school wherein the program scans the personal folders of call center employees to check if they have stored any CC/DC nos and if yes, report the folder name - to reduce CC fraud. The search function was fairly straight forward and works when I individually specify the filename. However, the searching the directory and passing the files to the search function has me stumped. I've posted my code so far, if you guys could look thru it and give me some feedback/suggestions, I'd really appreciate it. Thanks in advance import java.io.*; import java.util.*; public class parse2{ void traverse(String directory) throws FileNotFoundException { File dir = new File(directory); if (dir.isDirectory()) { String[] children = dir.list(); for (int i=0; i<children.length; i++) { //System.out.println("\n" + children[i]); reader(children[i]); } } } void reader(String loc) throws FileNotFoundException { FileReader fr = new FileReader(loc); BufferedReader br = new BufferedReader(fr); Scanner sc = new Scanner(br); char[] chkArray; int chk=1; char ch; while(sc.hasNext()) { String chkStr = sc.next(); chkArray = chkStr.toCharArray(); if ((chkArray[0]=='4')&&(chkStr.length()>13)) { for(int i=0;i<chkArray.length;i++) { ch=chkArray[i]; if((ch=='0')||(ch=='1')||(ch=='2')||(ch=='3')||(ch=='4')||(ch=='5')||(ch=='6')||(ch=='7')||(ch=='8')||(ch=='9')) { chk=0; continue; } else { chk=1; break; } } if(chk==0) System.out.println("\n"+ chkStr); } else if((chkArray[0]=='5')&&(chkStr.length()>13)) { for(int i=0;i<chkArray.length;i++) { ch=chkArray[i]; if((ch=='0')||(ch=='1')||(ch=='2')||(ch=='3')||(ch=='4')||(ch=='5')||(ch=='6')||(ch=='7')||(ch=='8')||(ch=='9')) { chk=0; continue; } else { chk=1; break; } } if(chk==0) System.out.println("\n"+ chkStr); } else if((chkArray[0]=='6')&&(chkStr.length()>13)) { for(int i=0;i<chkArray.length;i++) { ch=chkArray[i]; if((ch=='0')||(ch=='1')||(ch=='2')||(ch=='3')||(ch=='4')||(ch=='5')||(ch=='6')||(ch=='7')||(ch=='8')||(ch=='9')) { chk=0; continue; } else { chk=1; break; } } if(chk==0) System.out.println("\n"+ chkStr); } } } public static void main(String args[]) throws FileNotFoundException { parse2 P = new parse2(); P.traverse("C:/Documents and Settings/h4d35/Desktop/javatest/chk"); } }

    Read the article

  • trying to grab data from a page after post via curl

    - by Ben
    i am trying to grab data from here : http://mediaforest.biz/mobile/nowplaying.aspx in the page you select a station and post it then you get new page with data. but i cant grab it, i get the same page again. i used this code: <?php header ('Content-type: text/html; charset=utf-8'); $url = "http://mediaforest.biz/mobile/nowplaying.aspx"; $referer = ""; // headers $header[] = "Host: ".parse_url($url, PHP_URL_HOST); $header[] = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"; $header[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; $header[] = "Accept-Language: he,en-us;q=0.7,en;q=0.3"; $header[] = "Accept-Encoding: gzip,deflate"; $header[] = "Accept-Charset: windows-1255,utf-8;q=0.7,*;q=0.7"; $header[] = "Keep-Alive: 115"; $header[] = "Connection: keep-alive"; $cookie="cookie.txt"; $fp=fopen($cookie,"w+"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_REFERER,$referer); curl_setopt($ch, CURLOPT_TIMEOUT, 900); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_HEADER,true); curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie); curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie); curl_setopt($ch, CURLOPT_VERBOSE, 0); $content=curl_exec($ch); echo $content; if(stristr($content,"__EVENTTARGET")){ $array1=explode('__EVENTTARGET" value="',$content); $content1=$array1[1]; $array2=explode('"> <input type="hidden" name="__EVENTARGUMENT"',$content1); $content2=$array2[0]; $EVENTTARGET=urlencode($content2); } if(stristr($content,"__EVENTARGUMENT")){ $array1=explode('__EVENTARGUMENT" value="',$content); $content1=$array1[1]; $array2=explode('"> <script language',$content1); $content2=$array2[0]; $EVENTARGUMENT=urlencode($content2); } if(stristr($content,"formNowPlaying")){ $array1=explode('method="post" action="',$content); $content1=$array1[1]; $array2=explode('"> <input type="hidden" name="__EVENTTARGET"',$content1); $content2=$array2[0]; $nexturl=$content2; } //echo $EVENTTARGET." ".$EVENTARGUMENT." ".$nexturl; $url = "http://mediaforest.biz/mobile/".$nexturl; $fields = "EVENTTARGET=".$EVENTTARGET."&__EVENTARGUMENT=".$EVENTARGUMENT."&MyChannels=0&ViewChannel_Button=Show"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_REFERER,$referer); curl_setopt($ch, CURLOPT_TIMEOUT, 900); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_HEADER,true); curl_setopt($ch, CURLOPT_COOKIEFILE,$cookie); curl_setopt($ch, CURLOPT_COOKIEJAR,$cookie); curl_setopt($ch, CURLOPT_VERBOSE, 1); $content_stage2=curl_exec($ch); echo $content_stage2; ?>

    Read the article

  • Trouble Percent-Encoding Spaces in Java

    - by behrk2
    Hi Everyone, I am using the URLUTF8Encoder.java class from W3C (www.w3.org/International/URLUTF8Encoder.java). Currently, it will encode any blank spaces ' ' into plus signs '+'. I am having difficulty modifying the code to percent-encode the blank space into '%20'. Unfortunately, I am not too familiar with hex. Can anyone help me out? I need to modify this snippet... else if (ch == ' ') { // space sbuf.append('+'); in the following code: final static String[] hex = { "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F", "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27", "%28", "%29", "%2A", "%2B", "%2C", "%2D", "%2E", "%2F", "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37", "%38", "%39", "%3A", "%3B", "%3C", "%3D", "%3E", "%3F", "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47", "%48", "%49", "%4A", "%4B", "%4C", "%4D", "%4E", "%4F", "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57", "%58", "%59", "%5A", "%5B", "%5C", "%5D", "%5E", "%5F", "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67", "%68", "%69", "%6A", "%6B", "%6C", "%6D", "%6E", "%6F", "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77", "%78", "%79", "%7A", "%7B", "%7C", "%7D", "%7E", "%7F", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B", "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F", "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9", "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3", "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD", "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7", "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1", "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB", "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5", "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF", "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF" }; public static String encode(String s) { StringBuffer sbuf = new StringBuffer(); int len = s.length(); for (int i = 0; i < len; i++) { int ch = s.charAt(i); if ('A' <= ch && ch <= 'Z') { // 'A'..'Z' sbuf.append((char) ch); } else if ('a' <= ch && ch <= 'z') { // 'a'..'z' sbuf.append((char) ch); } else if ('0' <= ch && ch <= '9') { // '0'..'9' sbuf.append((char) ch); } else if (ch == ' ') { // space sbuf.append('+'); } else if (ch == '-' || ch == '_' // unreserved || ch == '.' || ch == '!' || ch == '~' || ch == '*' || ch == '\'' || ch == '(' || ch == ')') { sbuf.append((char) ch); } else if (ch <= 0x007f) { // other ASCII sbuf.append(hex[ch]); } else if (ch <= 0x07FF) { // non-ASCII <= 0x7FF sbuf.append(hex[0xc0 | (ch >> 6)]); sbuf.append(hex[0x80 | (ch & 0x3F)]); } else { // 0x7FF < ch <= 0xFFFF sbuf.append(hex[0xe0 | (ch >> 12)]); sbuf.append(hex[0x80 | ((ch >> 6) & 0x3F)]); sbuf.append(hex[0x80 | (ch & 0x3F)]); } } return sbuf.toString(); } Thanks!

    Read the article

  • I'm writing a spellchecking program, how do I replace ch in a string?

    - by Ajay Hopkins
    What am I doing wrong/what can I do? import sys import string def remove(file): punctuation = string.punctuation for ch in file: if len(ch) > 1: print('error - ch is larger than 1 --| {0} |--'.format(ch)) if ch in punctuation: ch = ' ' return ch else: return ch ref = (open("ref.txt","r")) test_file = (open("test.txt", "r")) dictionary = ref.read().split() file = test_file.read().lower() file = remove(file) print(file) This is in Python 3.1.2

    Read the article

  • im writing a spellchecking program, how do i replace ch in a string..eg..

    - by Ajay Hopkins
    what am i doing wrong/what can i do?? import sys import string def remove(file): punctuation = string.punctuation for ch in file: if len(ch) > 1: print('error - ch is larger than 1 --| {0} |--'.format(ch)) if ch in punctuation: ch = ' ' return ch else: return ch ref = (open("ref.txt","r")) test_file = (open("test.txt", "r")) dictionary = ref.read().split() file = test_file.read().lower() file = remove(file) print(file) p.s, this is in Python 3.1.2

    Read the article

  • java inserting special characters with preparedstatement fails

    - by phill
    I am using an HTML form which sends <input type=hidden name=longdesc value='SMARTNET%^" 8X5XNBD'> this is done by the following javascript code: function masinsert(id) { var currentTime=new Date(); var button = document.getElementById("m"+id); button.onclick=""; button.value="Inserting"; var itemdescription = document.getElementById("itemdescription"+id).value; function handleHttpResponse() { if (http.readyState == 4) { button.value="Item Added"; } } var http = getHTTPObject(); // We create the HTTP Object var tempUrl = "\AInsert"; tempUrl += "itemdescription="+itemdescription+"&"+"itemshortdescription="+itemdescription.substring(0,37)+; alert(tempUrl); http.open("GET", tempUrl, true); http.onreadystatechange = handleHttpResponse; http.send(null); } to a java servlet. AInsert.java in the AInsert.java file, I do a String itemdescription = request.getParameter("longdesc"); which then sends the value to a preparedstatement to run an insert query. In the query, there are sometimes special characters which throw it off. For example, when I run the following insert into itemdescription (longdesc) values ('SMARTNET%^" 8X5XNBD') here is the actual snippet: PreparedStatement ps = conn.prepareStatement("INSERT INTO itemdescription (longdesc) values(?)"); ps.setString(1, itemdescription); ps.executeUpdate(); It will produce an error saying : Cannot insert the value NULL into column 'LongDesc', table 'App.dbo.itemdescription'; column does not allow nulls. Insert fails I have tried urlencode/urldecode String encodedString = URLEncoder.encode(longdesc, "UTF-8"); String decitemdescription = URLDecoder.decode(itemdescription, "UTF-8"); and i've also tried these functions //BEGIN URL Encoder final static String[] hex = { "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09", "%0a", "%0b", "%0c", "%0d", "%0e", "%0f", "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17", "%18", "%19", "%1a", "%1b", "%1c", "%1d", "%1e", "%1f", "%20", "%21", "%22", "%23", "%24", "%25", "%26", "%27", "%28", "%29", "%2a", "%2b", "%2c", "%2d", "%2e", "%2f", "%30", "%31", "%32", "%33", "%34", "%35", "%36", "%37", "%38", "%39", "%3a", "%3b", "%3c", "%3d", "%3e", "%3f", "%40", "%41", "%42", "%43", "%44", "%45", "%46", "%47", "%48", "%49", "%4a", "%4b", "%4c", "%4d", "%4e", "%4f", "%50", "%51", "%52", "%53", "%54", "%55", "%56", "%57", "%58", "%59", "%5a", "%5b", "%5c", "%5d", "%5e", "%5f", "%60", "%61", "%62", "%63", "%64", "%65", "%66", "%67", "%68", "%69", "%6a", "%6b", "%6c", "%6d", "%6e", "%6f", "%70", "%71", "%72", "%73", "%74", "%75", "%76", "%77", "%78", "%79", "%7a", "%7b", "%7c", "%7d", "%7e", "%7f", "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8a", "%8b", "%8c", "%8d", "%8e", "%8f", "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97", "%98", "%99", "%9a", "%9b", "%9c", "%9d", "%9e", "%9f", "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%a7", "%a8", "%a9", "%aa", "%ab", "%ac", "%ad", "%ae", "%af", "%b0", "%b1", "%b2", "%b3", "%b4", "%b5", "%b6", "%b7", "%b8", "%b9", "%ba", "%bb", "%bc", "%bd", "%be", "%bf", "%c0", "%c1", "%c2", "%c3", "%c4", "%c5", "%c6", "%c7", "%c8", "%c9", "%ca", "%cb", "%cc", "%cd", "%ce", "%cf", "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", "%d8", "%d9", "%da", "%db", "%dc", "%dd", "%de", "%df", "%e0", "%e1", "%e2", "%e3", "%e4", "%e5", "%e6", "%e7", "%e8", "%e9", "%ea", "%eb", "%ec", "%ed", "%ee", "%ef", "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", "%f8", "%f9", "%fa", "%fb", "%fc", "%fd", "%fe", "%ff" }; /** * Encode a string to the "x-www-form-urlencoded" form, enhanced * with the UTF-8-in-URL proposal. This is what happens: * * <ul> * <li><p>The ASCII characters 'a' through 'z', 'A' through 'Z', * and '0' through '9' remain the same. * * <li><p>The unreserved characters - _ . ! ~ * ' ( ) remain the same. * * <li><p>The space character ' ' is converted into a plus sign '+'. * * <li><p>All other ASCII characters are converted into the * 3-character string "%xy", where xy is * the two-digit hexadecimal representation of the character * code * * <li><p>All non-ASCII characters are encoded in two steps: first * to a sequence of 2 or 3 bytes, using the UTF-8 algorithm; * secondly each of these bytes is encoded as "%xx". * </ul> * * @param s The string to be encoded * @return The encoded string */ public static String encode(String s) { StringBuffer sbuf = new StringBuffer(); int len = s.length(); for (int i = 0; i < len; i++) { int ch = s.charAt(i); if ('A' <= ch && ch <= 'Z') { // 'A'..'Z' sbuf.append((char)ch); } else if ('a' <= ch && ch <= 'z') { // 'a'..'z' sbuf.append((char)ch); } else if ('0' <= ch && ch <= '9') { // '0'..'9' sbuf.append((char)ch); } else if (ch == ' ') { // space sbuf.append('+'); } else if (ch == '-' || ch == '_' // unreserved || ch == '.' || ch == '!' || ch == '~' || ch == '*' || ch == '\'' || ch == '(' || ch == ')') { sbuf.append((char)ch); } else if (ch <= 0x007f) { // other ASCII sbuf.append(hex[ch]); } else if (ch <= 0x07FF) { // non-ASCII <= 0x7FF sbuf.append(hex[0xc0 | (ch >> 6)]); sbuf.append(hex[0x80 | (ch & 0x3F)]); } else { // 0x7FF < ch <= 0xFFFF sbuf.append(hex[0xe0 | (ch >> 12)]); sbuf.append(hex[0x80 | ((ch >> 6) & 0x3F)]); sbuf.append(hex[0x80 | (ch & 0x3F)]); } } return sbuf.toString(); } //end encode and //decode url private static String unescape(String s) { StringBuffer sbuf = new StringBuffer () ; int l = s.length() ; int ch = -1 ; int b, sumb = 0; for (int i = 0, more = -1 ; i < l ; i++) { /* Get next byte b from URL segment s */ switch (ch = s.charAt(i)) { case '%': ch = s.charAt (++i) ; int hb = (Character.isDigit ((char) ch) ? ch - '0' : 10+Character.toLowerCase((char) ch) - 'a') & 0xF ; ch = s.charAt (++i) ; int lb = (Character.isDigit ((char) ch) ? ch - '0' : 10+Character.toLowerCase ((char) ch)-'a') & 0xF ; b = (hb << 4) | lb ; break ; case '+': b = ' ' ; break ; default: b = ch ; } /* Decode byte b as UTF-8, sumb collects incomplete chars */ if ((b & 0xc0) == 0x80) { // 10xxxxxx (continuation byte) sumb = (sumb << 6) | (b & 0x3f) ; // Add 6 bits to sumb if (--more == 0) sbuf.append((char) sumb) ; // Add char to sbuf } else if ((b & 0x80) == 0x00) { // 0xxxxxxx (yields 7 bits) sbuf.append((char) b) ; // Store in sbuf } else if ((b & 0xe0) == 0xc0) { // 110xxxxx (yields 5 bits) sumb = b & 0x1f; more = 1; // Expect 1 more byte } else if ((b & 0xf0) == 0xe0) { // 1110xxxx (yields 4 bits) sumb = b & 0x0f; more = 2; // Expect 2 more bytes } else if ((b & 0xf8) == 0xf0) { // 11110xxx (yields 3 bits) sumb = b & 0x07; more = 3; // Expect 3 more bytes } else if ((b & 0xfc) == 0xf8) { // 111110xx (yields 2 bits) sumb = b & 0x03; more = 4; // Expect 4 more bytes } else /*if ((b & 0xfe) == 0xfc)*/ { // 1111110x (yields 1 bit) sumb = b & 0x01; more = 5; // Expect 5 more bytes } /* We don't test if the UTF-8 encoding is well-formed */ } return sbuf.toString() ; } but the decoding doesn't change it back to the original special characters. Any ideas? thanks in advance UPDATE: I tried adding these two statements to grab the request String itemdescription = URLDecoder.decode(request.getParameter("itemdescription"), "UTF-8"); String itemshortdescription = URLDecoder.decode(request.getParameter("itemshortdescription"), "UTF-8"); System.out.println("processRequest | short descrip "); and this is failing as well if that helps. UPDATE2: I created an html form and did a direct insert with the encoded itemdescription such as and the insertion works correctly with the special charaters and everything. I guess there is something going on with my javascript submit. Any ideas on this?

    Read the article

  • After resolving and calling host via ipv6 with curl, next ipv4 request fails and vice versa

    - by Ranty
    I need to request the same host with different methods (using IPv4 and IPv6) from the same script. First request is always successful (no matter IPv4 or IPv6), but the second always fails with curl error 45 (Couldn't bind to IP). I'm using the following curl config: function v4_google() { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1'); curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/search?q=Moon'); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_INTERFACE, 'My IPv4 address'); $c = curl_exec($ch); $result = !curl_errno($ch) ? 'Success' : '<b>' . curl_error($ch) . '; #' . curl_errno($ch) . '</b>'; echo '<p>v4_google:<br>Response length: ' . mb_strlen($c) . '<br>Result: ' . $result . '</p>'; curl_close($ch); } function v6_google() { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1'); curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/search?q=Moon'); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); curl_setopt($ch, CURLOPT_INTERFACE, 'My IPv6 address'); $c = curl_exec($ch); $result = !curl_errno($ch) ? 'Success' : '<b>' . curl_error($ch) . '; #' . curl_errno($ch) . '</b>'; echo '<p>v6_google:<br>Response length: ' . mb_strlen($c) . '<br>Result: ' . $result . '</p>'; curl_close($ch); } v6_google(); v4_google(); So long story short, if I query v6_google(); first, then all consecutive calls of v4_google(); are failing with the curl error 45 (Couldn't bind to IP). And vice versa. As you can see, I separated code into different functions and added CURLOPT_FORBID_REUSE and CURLOPT_FRESH_CONNECT plus curl_close($ch), but it didn't help at all. It looks like curl is caching the resolving method of every host you request, and even if you specify another resolving method the next time you call that host, the cached one is used instead. I would appreciate any help with this issue.

    Read the article

  • Can a Site get a Virus from using Curl?

    - by Mark Tyler
    I have a script which uses simple php curl requests to get the contents from rss/atom feeds.... now my question is it possible that by using curl, is there a chance i might get a virus? Let's say I do a php curl request to a rss feed in feedburner (I know this site does not contain any viruses, but this is only an example) and let's say this site has a malicious virus of some kind. Is there a chance that I might inherit that virus too? If yes, what precautions can I do to make sure something like that never happens. This is the php code I am currently using to fetch the RSS $headers [] = 'Connection: Keep-Alive'; $headers [] = 'Content-type: application/x-www-form-urlencoded; charset=utf-8'; $headers [] = 'Accept-Encoding: application/xhtml+xml,application/xml,text/xml,text/html;q=0.9,*/*;q=0.8'; $ch = curl_init($url); //curl_setopt($ch, CURLOPT_USERAGENT,'Phenoix/0.1.3 (Feed Parser Beta; Beta ; Allow like Gecko) Build/20111112'); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1'); //curl_setopt($ch, CURLOPT_REFERER, "http://google.com/auto/clogger"); //curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate' ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers ); //curl_setopt($channel, CURLOPT_HEADER, 0); curl_setopt($ch, CURLINFO_HEADER_OUT, 1); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_FAILONERROR, 1); //allow cookie $cookie_file = "cookie1.txt"; curl_setopt($ch, CURLOPT_COOKIESESSION, true); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); $xml = curl_exec($ch); if(curl_error($ch)){ //$text .= "Error while updating. Please try again later"; return array(0, curl_error($ch)); } $info = curl_getinfo($ch); curl_close($ch);

    Read the article

  • php curl login problem

    - by user331329
    <?php // create a new CURL resource $file_path = '/mail'; define("COOKIE_FILE", "c:\cookie.txt"); $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "https://mail.gov.in/iwc/signin"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIESESSION, TRUE); session_write_close(); $strCookie = 'PHPSESSID=d095af0e30afc021dd3652734009' . $_COOKIE['PHPSESSID'] . '; path=/mail'; curl_setopt( $ch, CURLOPT_COOKIE, $strCookie ); curl_setopt ($ch, CURLOPT_COOKIEJAR, COOKIE_FILE); curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS,'fromLogin=true&domainName=nic.in&username=&password=&button=Sign%20In'); $url = curl_getinfo($ch); // grab URL and pass it to the browser $data = curl_exec($ch); echo $data."<pre>"; echo "<pre>"; print_r($url); // close CURL resource, and free up system resources curl_close($ch); ?> whats wrong with my code why i am not able to login directly in their mail

    Read the article

  • curl cookie not creating on success

    - by Bin
    Hi I'm using cUrl(PHP) to post a login request and store response in cookie file. In my second request I'm passing cookie in header and post data to verify it. Issue is that cookie file is not created in first succesful request results in failure for second request. Please suggest me where I'm doing wrong. $cookiefile="/var/www/html/dimdim/cook.txt"; $url_log="http://my.dimdim.com/api/auth/login"; $p_log='request={"account":"bin6k","password":"password","group":"all"}'; $url_ver="http://my.dimdim.com/api/auth/verify"; $p_ver='request={"account":"bin6k","password":"password","group":"all"}'; $ch = curl_init(); //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($ch, CURLOPT_URL,$url_log); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $p_log); ob_start(); // prevent any output $retval=curl_exec ($ch); // execute the curl command ob_end_clean(); // stop preventing output curl_close ($ch); //print_r($retval); unset($ch); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); curl_setopt($ch, CURLOPT_URL,$url_ver); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $p_log); $buf2 = curl_exec ($ch); curl_close ($ch); echo "".htmlentities($buf2);

    Read the article

  • Login in via curl then open that page logged in

    - by user207022
    I'm trying the following code to send post data to the login form, then reload that page in the browser as a logged in user. somehow it's not saving the cookie, and reusing it for the header() function, can the same thing as header be done by calling curl again after sending the login details? .. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , false ); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST , false ); curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']); //curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); curl_setopt($ch, CURLOPT_MAXREDIRS, 1); // Apply the XML to our curl call curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $data = curl_exec($ch); setcookie($cookie); header('location: ' . $url); die();

    Read the article

  • word wrap in tcpdf

    - by ChuckO
    I'm using tcpdf to creat a pdf version of the html table below. How do I word wrap the text in the cells? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <style type="text/css"> table.frm { width: 960px; Height:400px; margin-left: auto; margin-right: auto; border-width: 0px 0px 0px 0px; border-spacing: 0px; border-style: solid solid solid solid; border-color: gray gray gray gray; border-collapse: collapse; background-color: white; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 11px; } table.frm th { Width: 120px; border-width: 1px 1px 1px 1px; padding: 1px 1px 1px 1px; border-style: solid solid solid solid; border-collapse: collapse; border-color: gray gray gray gray; background-color: white; } table.frm td { width: 120px; height: 80px; vertical-align: top; border-width: 1px 1px 1px 1px; padding: 2px 2px 2px 2px; border-style: solid solid solid solid; border-collapse: collapse; border-color: gray gray gray gray; background-color: white; } </style> <title>Weekly Menu</title> </head> <body> <table class="frm"> <tr> <th align="center" colspan="8"><b>WEEKLY MENU</b></th> </tr> <tr> <th align="center" colspan="8"><b>Your Name Here</b></th> </tr> <tr> <th></th> <th>Monday</th> <th>Tuesday</th> <th>Wednesday</th> <th>Thursday</th> <th>Friday</th> <th>Saturday</th> <th>Sunday</th> </tr> <tr> <td><b>Breakfast</b></td> <td>Scrambled Eggs Black Coffee</td> <td>Vegetable Omelet Black Coffee</td> <td>2 slices Toast Black Coffee</td> <td>Cereal w/milk Black Coffee</td> <td>Orange Juice Black Coffee</td> <td>Cereal w/milk Black Coffee</td> <td>Pancakes w/syrup Black Coffee</td> </tr> <tr> <td><b>Lunch</b></td> <td>Tuna Salad Sandwich Diet Coke</td> <td>Greek Salad Black Coffee</td> <td></td> <td>Amer Cheese Sandwich Orange Juice</td> <td></td> <td></td> <td></td> </tr> <tr> <td><b>Dinner</b></td> <td>Burger Fried Onions Diet Coke</td> <td>Steak Fries Diet Sprite</td> <td></td> <td>Chicken Cutlet Baked Potato Peas</td> <td></td> <td></td> <td></td> </tr> <tr> <td><b>Snack</b></td> <td>Apple</td> <td>Orange</td> <td>Sm bag of chips</td> <td>Celery Sticks</td> <td></td> <td></td> <td></td> </tr> </table> </body> </html> This is the tcpdf code: $pdf = new TCPDF('Landscape', 'mm', '', true, 'UTF-8', false); $pdf->SetTitle('Weekly Menu'); $pdf->SetMargins(15, 7.5, 12.5); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->AddPage(); $pdf->setFormDefaultProp(array('lineWidth'=>0, 'borderStyle'=>'dot', 'fillColor'=>array(235, 235, 255), 'strokeColor'=>array(255,255,250))); $pdf->SetFont('times', 'BU', 12); $pdf->cell(250, 8, 'Weekly Menu', 0, 1, 'C'); $pdf->cell(250, 8, $yourname, 0, 1, 'C'); $pdf->SetFont('times', '', 10); $cw=35; $ch=25; $pdf->SetXY(15,50); $pdf->cell(25,5,'',1,0,'L'); $pdf->cell($cw,5,$day1,1,0,'C'); $pdf->cell($cw,5,$day2,1,0,'C'); $pdf->cell($cw,5,$day3,1,0,'C'); $pdf->cell($cw,5,$day4,1,0,'C'); $pdf->cell($cw,5,$day5,1,0,'C'); $pdf->cell($cw,5,$day6,1,0,'C'); $pdf->cell($cw,5,$day7,1,1,'C'); $pdf->cell(25,$ch,'Breakfast',1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[0]->breakfast,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[1]->breakfast,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[2]->breakfast,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[3]->breakfast,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[4]->breakfast,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[5]->breakfast,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[6]->breakfast,1,1,'L',0,0,false,'','T'); $pdf->cell(25,$ch,'Lunch',1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[0]->lunch,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[1]->lunch,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[2]->lunch,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[3]->lunch,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[4]->lunch,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[5]->lunch,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[6]->lunch,1,1,'L',0,0,false,'','T'); $pdf->cell(25,$ch,'Dinner',1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[0]->dinner,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[1]->dinner,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[2]->dinner,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[3]->dinner,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[4]->dinner,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[5]->dinner,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[6]->dinner,1,1,'L',0,0,false,'','T'); $pdf->cell(25,$ch,'Snack',1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[0]->snack,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[1]->snack,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[2]->snack,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[3]->snack,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[4]->snack,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[5]->snack,1,0,'L',0,0,false,'','T'); $pdf->cell($cw,$ch,$record[6]->snack,1,1,'L',0,0,false,'','T'); EOD;

    Read the article

  • Trying to scrape a page with php/curl, trouble with cookies, post vars, and hidden fields.

    - by Patrick
    Im trying to use CURL to scrape the results from the page http://adlab.msn.com/Online-Commercial-Intention/Default.aspx My understanding, is that i visit this page, it places cookie info and sets a few variables. I enter my query, select the query radio option, and click go. The problem, is that its not working the way that it does through the website as im trying to get it to using the code below. Ive tweaked several things, but im posting here in hopes someone can find what im missing. This is my code as it stands now: include("simple_html_dom.php"); $ckfile = tempnam ("/tmp", "CURLCOOKIE"); $query = $_GET['query']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://adlab.msn.com/Online-Commercial-Intention/default.aspx"); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"); $pagetext1 = curl_exec($ch); curl_exec($ch); $html2 = str_get_html($pagetext1); $viewstate = $html2->find('input[id=__VIEWSTATE]', 1)->plaintext; echo $query."<br>".$viewstate."<br>"; $params = array( '__EVENTTARGET' => "", '__EVENTARGUMENT' => "", '__LASTFOCUS' => "", '__VIEWSTATE' => "$viewstate", 'MyMaster%3ADemoPageContent%3AtxtQuery' => "$query", 'MyMaster%3ADemoPageContent%3Alan' => "QueryRadio", 'MyMaster%3ADemoPageContent%3AgoButton.x' => "17", 'MyMaster%3ADemoPageContent%3AgoButton.y' => "12", 'MyMaster%3ADemoPageContent%3AidQuery' => "$query", 'MyMaster%3AHiddenKeywordTextBox' => "", ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://adlab.msn.com/Online-Commercial-Intention/default.aspx'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_REFERER, 'http://adlab.msn.com/Online-Commercial-Intention/default.aspx'); curl_setopt($ch, CURLOPT_POSTFIELDS, '$params'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"); $pagetext = curl_exec($ch); curl_exec($ch); // echo $ckfile; $html = str_get_html($pagetext); $ret = $html->find('.intentionLabel', 1)->plaintext; echo $ret."<br><br><br>"; echo $pagetext;

    Read the article

  • warning: dict_ldap_lookup: Search error 1: Operations error

    - by drecute
    Please I need help with ldap search filter to use to retrieve the user email information from ldap. I'm running postfix_ldap of Ubuntu server 12.04. Everything seems to work fine, except getting the values returned from the search. Version 1 server_host = ldap://samba.example.com search_base = dc=company, dc=example, dc=com query_filter = mail=%s bind = no domain = example.com Version 2 server_host = ldap://samba.example.com search_base = dc=company, dc=example, dc=com query_filter = mail=%s bind_dn = cn=Users,dc=company,dc=example,dc=com domain = example.com mail logs Nov 26 11:13:26 mail postfix/smtpd[19662]: match_string: example.com ~? example.com Nov 26 11:13:26 mail postfix/smtpd[19662]: dict_ldap_lookup: No existing connection for LDAP source /etc/postfix/ldap-aliases.cf, reopening Nov 26 11:13:26 mail postfix/smtpd[19662]: dict_ldap_connect: Connecting to server ldap://samba.example.com Nov 26 11:13:26 mail postfix/smtpd[19662]: dict_ldap_connect: Actual Protocol version used is 3. Nov 26 11:13:26 mail postfix/smtpd[19662]: dict_ldap_connect: Binding to server ldap://samba.example.com with dn cn=Users,dc=company,dc=example,dc=com Nov 26 11:13:26 mail postfix/smtpd[19662]: warning: dict_ldap_connect: Unable to bind to server ldap://samba.example.com with dn cn=Users,dc=company,dc=example,dc=com: 49 (Invalid credentials) Nov 26 11:13:26 mail postfix/smtpd[19662]: warning: ldap:/etc/postfix/ldap-aliases.cf lookup error for "tola[email protected]" Nov 26 11:13:26 mail postfix/smtpd[19662]: maps_find: virtual_alias_maps: tola[email protected]: search aborted Nov 26 11:13:26 mail postfix/smtpd[19662]: mail_addr_find: tola[email protected] -> (try again) Nov 26 11:13:26 mail postfix/smtpd[19662]: NOQUEUE: reject: RCPT from col0-omc3-s2.col0.hotmail.com[65.55.34.140]: 451 4.3.0 <[email protected]>: Temporary lookup failure; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<col0-omc3-s2.col0.hotmail.com> Nov 26 11:13:26 mail postfix/smtpd[19662]: > col0-omc3-s2.col0.hotmail.com[65.55.34.140]: 451 4.3.0 <[email protected]>: Temporary lookup failure here's another log with successful search result but fialed to get the values of the result Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: Using existing connection for LDAP source /etc/postfix/ldap-aliases.cf Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: /etc/postfix/ldap-aliases.cf: Searching with filter [email protected] Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_get_values[1]: Search found 1 match(es) Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_get_values[1]: Leaving dict_ldap_get_values Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: Search returned nothing Nov 26 12:04:56 mail postfix/smtpd[20463]: maps_find: virtual_alias_maps: tola[email protected]: not found Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: In dict_ldap_lookup Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: /etc/postfix/ldap-aliases.cf: Skipping lookup of key 'tola.akintola': domain mismatch Nov 26 12:04:56 mail postfix/smtpd[20463]: maps_find: virtual_alias_maps: tola.akintola: not found Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: In dict_ldap_lookup Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: /etc/postfix/ldap-aliases.cf: Skipping lookup of key '@example.com': domain mismatch Nov 26 12:04:56 mail postfix/smtpd[20463]: maps_find: virtual_alias_maps: @example.com: not found Nov 26 12:04:56 mail postfix/smtpd[20463]: mail_addr_find: tola[email protected] -> (not found) My refined ldap-aliases.cf looks like this: server_host = ldap://samba.example.com server_port = 3268 search_base = dc=company, dc=example, dc=com query_filter = mail=%s result_attribute = uid bind_dn = cn=Administrator,cn=Users,dc=company,dc=example,dc=com bind_pw = pass domain = example.com So I'll like to know what ldap filter is appropriate to get this to work. Thanks for helping out.

    Read the article

  • Using Zend_HTTP_Client instead of CURL

    - by Vincent
    All, I want to use Zend_HTTP_CLient instead of CURL as there are issues with using curl on Solaris. I have the following curl code.. How will this code be written if I want to use Zend_HTTP_Client? $ch = curl_init(); $devnull = fopen('/tmp/cookie.txt', 'w'); curl_setopt($ch, CURLOPT_STDERR, $devnull); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $desturl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,800); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $retVal = curl_exec($ch); print_r(curl_error($ch)); curl_close($ch); if ($devnull) { fclose($devnull); } Thanks

    Read the article

  • CURL - https - solaris

    - by Vincent
    All, I am receiving the following error when I use PHP to curl to a https site. Both PHP and the https site are hosted on Solaris. This error seems to occur occassionally but frequently. error:80089077:lib(128):func(137):reason(119) This is the curl code I am using: $ch = curl_init(); $devnull = fopen('/tmp/cookie.txt', 'w'); curl_setopt($ch, CURLOPT_STDERR, $devnull); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $desturl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,800); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $retVal = curl_exec($ch); print_r(curl_error($ch)); curl_close($ch); if ($devnull) { fclose($devnull); } How can I fix this error? If not, is there an alternative to curl?

    Read the article

  • Which is more secure GET or POST sending parameters with cURL at PHP

    - by Steve
    I want to connect in a secure way with an API and I am using cURL to do it using HTTPS and SSL. Now, i was wondering what is better in terms of security, sending the data through GET or POST: $ch = curl_init("http://api.website.com/connect.php?user=xxx&pass=xxxx); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); $result = curl_exec($ch); curl_close($ch); Or $param['user'] = 'xxxx'; $param['pass'] = 'xxxx'; $ch = curl_init("http://api.website.com/connect.php); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $Parameters); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); $result = curl_exec($ch); curl_close($ch); I also realized that POST is much more slower retrieving the data.

    Read the article

  • Pointers inside a structure [on hold]

    - by user3402552
    I have the next program: #include<stdio.h> #include<stdlib.h> struct a { char *ch; char *str; }; int main() { struct a s1; char ptr[100]; int m, n; printf("\n Enter a string : "); gets(ptr); m = strlen(ptr); s1.ch = (char *)malloc(strlen(ptr) * sizeof(char)); if(s1.ch) { strcpy(s1.ch, ptr); } else { printf("\n Alocation failed!\n"); } printf("\n %s\n\n", s1.ch); while(*s1.ch) { printf(" %c", *(s1.ch)); s1.ch++; } printf("\n\n"); s1.ch = s1.ch - m; printf("\n\n\n %s \n\n", s1.ch); } Is this ok this program in this way ? I mean the pointers should not be initialized ? And if it is not ok, why compile it without errors?

    Read the article

  • Beginner question - Loop invariants (Specifically Ch.3 of "Accelerated C++")

    - by Owen
    Hi - as I said, a complete beginner question here. I'm currently working my way through "Accelerated C++" and just came across this in chapter 3: // invariant: // we have read count grades so far, and // sum is the sum of the first count grades while (cin >> x) { ++count; sum += x; } The authors follow this by explaining that the invariant needs special attention paid to it because when the input is read into the variable x, we will have read count+1 grades and thus the invariant will be untrue. Similarly, when we have incremented the counter, the variable sum will no longer be the sum of the last count grades (in case you hadn't guessed, it's the traditional program for calculating student marks). What I don't understand is why this matters. Surely for just about any other loop, a similar statement would be true? For example, here is the book's first while loop (the output is filled in later): // invariant: we have written r rows so far while (r != rows) { // write a row of output std::cout << std::endl; ++r; } Once we have written the appropriate row of output, surely the invariant is false until we have incremented r, just as in the other example? It's probably something really obvious, anyone could enlighten me as to what makes these two cases different, that'd be great - and thanks in advance for taking the time to answer such a complete novice question. Owen

    Read the article

  • PHP script works fine until I send a parameter from HTTPService in Flash Builder 4?

    - by ben
    I'm using a PHP script to read an RSS feed in my Flex 4 app. The script works when I put the url of the feed in the actual script, but I can't get it to work when I try to send the URL as a parameter from a HTTPService in Flex. Can anyone tell me what I'm doing wrong? Here is the HTTPService from Flex 4 that I'm using: <mx:HTTPService url="http://talk.6te.net/proxy.php" id="proxyService" method="POST" result="rssResult()" fault="rssFault()"> <mx:request> <url> http://feeds.feedburner.com/nah_right </url> </mx:request> </mx:HTTPService> This is the script that works: <?php $ch = curl_init(); $timeout = 30; $userAgent = $_SERVER['HTTP_USER_AGENT']; curl_setopt($ch, CURLOPT_URL, "http://feeds.feedburner.com/nah_right"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); $response = curl_exec($ch); if (curl_errno($ch)) { echo curl_error($ch); } else { curl_close($ch); echo $response; } ?> But this is what I actually want to use, but it doesn't work: <?php $ch = curl_init(); $timeout = 30; $userAgent = $_SERVER['HTTP_USER_AGENT']; curl_setopt($ch, CURLOPT_URL, $_REQUEST['url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); $response = curl_exec($ch); if (curl_errno($ch)) { echo curl_error($ch); } else { curl_close($ch); echo $response; } ?> Here is the request and response output of the HTTPService from the network monitor in Flash Builder 4 (using the PHP script that doesn't work): Request: POST /proxy.php HTTP/1.1 Host: talk.6te.net User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Content-type: application/x-www-form-urlencoded Content-length: 97 url=%0A%09%09%09%09%09http%3A%2F%2Ffeeds%2Efeedburner%2Ecom%2Fnah%5Fright%0A%20%20%20%20%09%09%09 Response: HTTP/1.1 200 OK Date: Mon, 10 May 2010 03:23:27 GMT Server: Apache X-Powered-By: PHP/5.2.13 Content-Length: 15 Content-Type: text/html <url> malformed I've tried putting the URL in " " in the HTTPService, but that didn't do anything. Any help would be greatly appreciated!

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >