Advertisement
Guest User

Confluence

a guest
Jan 18th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.74 KB | None | 0 0
  1. <html>
  2. <body>
  3. <?php
  4.  
  5. if(!$_POST){
  6. ?>
  7.  
  8. <form name="input" action="/confluence/create-file.php" method="POST">
  9.     Space key: <input type="text" name="space_key" value="TO" /><br />
  10.     Titel pagina: <input type="text" name="page_title" value="" /><br />
  11.     <input type="submit" value="Aanmaken" />
  12. </form>
  13. <?php    
  14.     die;
  15. }
  16.  
  17. $soapClient = new SoapClient(null, array(
  18.     "location" => "http://shopworks.atlassian.net/confluence/rpc/soap-axis/confluenceservice-v1?wsdl",
  19.     "uri" => "http://soap.rpc.confluence.atlassian.com",
  20.     "trace" => TRUE));
  21.  
  22. $soapClient = new SoapClient(
  23.     "http://shopworks.atlassian.net/confluence/rpc/soap-axis/confluenceservice-v2?wsdl"
  24.     ,array("trace" => 1, "exceptions" => 0)
  25. );      
  26. $token = $soapClient->login('username', 'password');
  27.  
  28. if(isset($_POST['space_key']) && isset($_POST['page_title']) && strlen($_POST['page_title'])>0 && strlen($_POST['space_key'])>0){
  29.     $name   = $_POST['page_title'];
  30.     $key    = $_POST['space_key'];
  31. }else{
  32.     echo 'Geen space key of pagina title opgegegeven <a href="/confluence/create-file.php">Terug</a>';
  33.     die;
  34. }
  35.  
  36.  
  37.  
  38. $page = $soapClient->getPage($token,$key,$name);
  39. $page2 = $soapClient->renderContent($token, $key, $page->id);
  40.  
  41. $attachments = $soapClient->getAttachments($token,$page->id);
  42.  
  43. foreach($attachments as $attachment){
  44.  
  45.     $file = file_get_contents((string)$attachment->url.'&os_username=username&os_password=password');
  46.     $dir = "/home/shopworks/www/wiki/download/attachments/".$page->id.'/';
  47.    
  48.     if(!is_dir($dir)){
  49.        mkdir($dir, 0777);
  50.        chmod($dir, 0777);
  51.     }
  52.    
  53.     file_put_contents($dir.$attachment->fileName, $file);
  54. }
  55.  
  56.  
  57. $style ='
  58.  
  59.  
  60. div#Content {
  61.     width: 1160px;
  62.     margin: 0px auto;
  63.     padding: 0px 20px 300px 20px !important;
  64.    
  65.     background-color: #fff;
  66.     border-left:    1px solid #efefef;
  67.     border-right:   1px solid #efefef;
  68. }
  69.  
  70. h1, h2, h3, h4 {
  71.         font:       normal 11px/30px Arial, sans-serif;
  72.         margin:     0px 0px 5px 0px;
  73. }
  74.  
  75. h1 {
  76.     color:      #b01f24;
  77.     font-size:  30px;
  78.    
  79. }
  80. h2 {
  81.     color:      #be3f43;
  82.     font-size:  25px;
  83.    
  84. }
  85. h3 {
  86.     color:      #e843494;
  87.     font-size:  20px;
  88.    
  89. }
  90. h4 {
  91.     color:      #feacaf4;
  92.     font-size:  15px;
  93.    
  94. }
  95. body, p, td, table, tr, .bodytext, .stepfield {
  96.     font: normal 12px/20px Arial, sans-serif;
  97. }
  98. a:link, a:visited, a:focus, a:hover, a:active, a.blogHeading {
  99.     color: #b01f24;
  100.     text-decoration:    none;
  101. }
  102. a:hover {
  103.     text-decoration:    underline;
  104. }
  105. h1, h2, h3, h4, h5, h6, .wiki-content h1, .wiki-content h2, .wiki-content h3, .wiki-content h4, .wiki-content h5, .wiki-content h6, .pagetitle, .steptitle, .substeptitle, .formtitle, table.confluenceTable td.confluenceTd.highlight, table.confluenceTable td.confluenceTd.highlight > p, table.confluenceTable th.confluenceTh, table.confluenceTable th.confluenceTh > p, table.admin th, .form-element-large, .form-element-small, #toolbar #format-dropdown .format-h1 a, #toolbar #format-dropdown .format-h2 a, #toolbar #format-dropdown .format-h3 a, #toolbar #format-dropdown .format-h4 a, #toolbar #format-dropdown .format-h5 a, #toolbar #format-dropdown .format-h6 a {
  106. color:      #be3f43;
  107. }
  108. div#holderFooterShopWorks {
  109. position: fixed;
  110. bottom: 0px;
  111.  
  112. width:  100%;  
  113.     color:              #fff;
  114.     /*background-color: rgba(167,31,36,0.9);*/
  115.    background-color: #a71f24;
  116.    opacity: 0.90; /* CSS3 standard */
  117.    filter:alpha(opacity=90); /* for internet explorer */
  118.    -moz-opacity:0.90; /* for older gecko browsers */
  119.     -khtml-opacity: 0.90; /* for older webkit browsers */
  120. }
  121. div#footerShopWorksContent {
  122.     width:  1160px;
  123.     margin: 0px auto;
  124.     padding:            20px;
  125.     overflow:       hidden;
  126. }
  127.     div#holderFooterShopWorks ul, div#holderFooterShopWorks ul li {
  128.         margin: 0px;
  129.         padding: 0px;
  130.     }
  131.     div#holderFooterShopWorks ul li {
  132.        float: left;
  133.         list-style: outside;
  134.         list-style: none;
  135.        line-height: 22px;
  136.     }
  137.     div#holderFooterShopWorks ul li ul li {
  138.         display: block;
  139.         width: 100%;
  140.     }
  141.     div#holderFooterShopWorks ul li a {
  142.         color: #fafafa; /*rgba(255,255,255,0.6);*/
  143.        opacity: 0.60; /* CSS3 standard */
  144.        filter:alpha(opacity=60); /* for internet explorer */
  145.        -moz-opacity:0.60; /* for older gecko browsers */
  146.         -khtml-opacity: 0.60; /* for older webkit browsers */
  147.     }
  148.     div#holderFooterShopWorks ul li.title {
  149.         color:          #fff;
  150.         font-size:      22px;
  151.         margin:         0px 0px 20px 0px;
  152.     }
  153.     div#holderFooterShopWorks ul li#contact {
  154.         float:right;
  155.        width: 140px;
  156.     }
  157. </style>
  158. <meta http-equiv="X-UA-Compatible" content="IE-edge,chrome=1" />
  159. ';
  160. $footer = '<div id="holderFooterShopWorks">
  161.     <div id="footerShopWorksContent">
  162.         <ul>
  163.             <li>
  164.                 <ul>
  165.                     <li class="title">ShopWorks</li>
  166.                                        <li><a href="http://www.shopworks.nl" title="ShopWorks">ShopWorks.nl</a></li>
  167.                                        <li><a href="http://twitter.com/shopworks_nl" title="Twitter">Twitter</a></li>
  168.                                        <li><a href="http://www.linkedin.com/company/shopworks_nl" title="Twitter">LinkedIn</a></li>                                      
  169.                                        
  170.                 </ul>
  171.             </li>
  172.             <li>
  173.                 <ul>
  174.                     <li class="title">ShopWorks Support</li>
  175.                     <li><a href="https://shopworksnl.zendesk.com" title="Zenddesk">Supportdesk</a></li>
  176.                                        <li><a href="https://shopworks.atlassian.net/" title="Zenddesk">Wiki (handleidingen)</a></li>                                        
  177.                                        
  178.                 </ul>
  179.             </li>                        
  180.             <li id="contact">
  181.                 <ul>
  182.                                    <li class="title">Contact</li>
  183.                                    <li>ShopWorks B.V.</li>
  184.                                    <li>Kanaalweg 29</li>
  185.                                    <li>3526 KM, Utrecht</li>
  186.                                    <li>T: +31(0)30-6023759</li>
  187.                                    <li>E: <a href="mailto:info@shopworks.nl">info@shopworks.nl</li>
  188.                 </ul>
  189.             </li>
  190.         </ul>
  191.     </div>
  192. </div></body>';
  193.  
  194. function niceName($name){
  195.     $name = str_replace(' ', '_', $name);
  196.     $name = strtolower($name);
  197.    
  198.     return $name;
  199. }
  200.  
  201. $str =  str_replace('</style>',$style, $page2);
  202. $str = str_replace('</body>',$footer, $str);
  203. $str = str_replace('<base href="https://shopworks.atlassian.net/wiki"/>','',$str);
  204. $str = str_replace('+','%20',$str);
  205. $str = str_replace('%3A',':',$str);
  206. $str = str_replace('thumbnails','attachments',$str);
  207.  
  208. $str = str_replace('<html>','<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', $str);
  209.  
  210. $newName = md5(time()).'-'.niceName($name).'.html';
  211.  
  212. file_put_contents($newName, $str);
  213. chmod($newName, 0777);
  214.  
  215. echo 'http://www.shopworks.nl/confluence/'.$newName;
  216. ?>
  217.  
  218. </body>
  219. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement