Advertisement
Guest User

ki

a guest
Sep 19th, 2017
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.70 KB | None | 0 0
  1. def doAction(user,kwik,action,design)
  2.    
  3.     postID = templateNumToPageID(design)
  4.  
  5.  
  6.  if user.present?
  7.      cpanelInfo = []
  8.  
  9.  Net::SSH.start('207.58.161.120', 'root', :password => "Nomorechip!!!23", :port => 8765) do |ssh|
  10.    
  11.      ssh.exec!("cd /home/#{user}/public_html && wp config get --format=json --allow-root") do
  12.                       |ch, stream, line|
  13.                       output = line
  14.                       if JSON.is_json?(output)
  15.                           #puts output
  16.                           begin
  17.                               out = JSON.generate(output)
  18.                               out = JSON.parse(output)  
  19.                               #puts out[3]['value']
  20.                               prefix = out[0]['value']
  21.                               dbName = out[3]['value']
  22.                               dbUser = out[4]['value']
  23.                               dbPass = out[5]['value']
  24.                              
  25.                               cpanelInfo << {'prefix' => prefix.to_s, 'dbName' => dbName.to_s, 'dbUser' => dbUser.to_s, 'dbPass' => dbPass.to_s}
  26.                               #puts cpanelInfo
  27.                           rescue JSON::ParserError => e  
  28.                               # do smth
  29.                               puts e
  30.                           end
  31.                       end
  32.                      
  33.                      
  34.                      
  35.  
  36.     end
  37.     #puts cpanelInfo
  38.     cpanelInfo.each do |c|
  39.        
  40.         postContent = '[vc_row][vc_column][vc_column_text]<img src="http://d2xcg9rrwac7gn.cloudfront.net/polished_pro/Kwik.png" alt="" /> <strong>can help make your purchase even easier.</strong>
  41.  
  42. [/vc_column_text][vc_column_text]You don’t have to let aa small budget keep you from being comfortable in your home.* Now that [brand] offers special financing options from Synchrony Bank, expand your purchasing power and convenience with:
  43. <ul>
  44.     <li>Convenient monthly payment options</li>
  45.     <li>Competitive interest rates</li>
  46.     <li>No prepayment penalties</li>
  47.     <li>A simple application process and fast credit decisions</li>
  48.     <li>Unsecured, generous revolving credit lines</li>
  49.     <li>Open credit line for future purchases</li>
  50. </ul>
  51. And unlike Visa®, MasterCard and other bank cards, KwikComfort Financing provides multiple promotional financial options, including:
  52. <ul>
  53.     <li>Deferred interest</li>
  54.     <li>No interest with equal monthly payments</li>
  55.     <li>Fixed payment with interest plans offering APRs and interest rates much lower than most bank card rates</li>
  56. </ul>
  57. [/vc_column_text][vc_column_text]
  58. <p style="font-size: 10px;">*Subject to credit approval. Minimum monthly payments required. See contractor for details.</p>
  59.  
  60. [/vc_column_text][vc_column_text]Applying online is quick, secure and private. To apply for a credit card, simply complete the <a id="textlink" href="https://etail.mysynchrony.com/eapply/eapply.action?mid='+kwik+'&pcgc=M900">online credit application</a>. You will be able to read the privacy policy and review the terms of this offer before submitting the online application.[/vc_column_text][vc_empty_space][vc_cta h2="Applying Online is quick, secure and private. " add_button="bottom" btn_title="Apply Here" btn_link="url:https%3A%2F%2Fetail.mysynchrony.com%2Feapply%2Feapply.action%3Fmid%3D'+kwik+'%26pcgc%3DM900|title:Apply%20Online|target:%20_blank" btn_add_icon="true"]To apply for a credit card, simply complete the online credit application. You will be able to read the privacy policy and review the terms of this offer before submitting the online application.[/vc_cta][/vc_column][/vc_row]'
  61.        
  62.         postContent = postContent.to_s
  63.        
  64.         dbName = c['dbName']
  65.         dbUser = c['dbUser']
  66.         dbPass = c['dbPass']
  67.         prefix = c['prefix']
  68.         puts prefix
  69.        
  70.         if prefix.include? '_'
  71.            
  72.         else
  73.             prefix = prefix + '_'
  74.         end
  75.         if action
  76.             #edit the page
  77.             ssh.exec!("mysql --host=localhost --user=#{dbUser} --password=#{dbPass} --database=#{dbName} -e \"UPDATE #{prefix}posts SET post_content='#{postContent}' WHERE id='#{postID}'\" ") do |ch, stream, line|
  78.                 puts line
  79.             end
  80.         else #draft the pg
  81.             ssh.exec!("mysql --host=localhost --user=#{dbUser} --password=#{dbPass} --database=#{dbName} -e \"UPDATE #{prefix}posts SET post_status='draft' WHERE id='#{postID}'\" ") do |ch, stream, line|
  82.                 puts line
  83.             end
  84.         end
  85.        
  86.         ssh.exec!("wp w3-total-cache flush all") do |ch, stream, line|
  87.             puts line
  88.         end
  89.        
  90.        
  91.        
  92.     end
  93.     #$ssh
  94.     #maybe also get kwik info before
  95.    
  96.    
  97.    
  98.   end
  99.  
  100.  end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement