ultimix
sape_project_api.php
Go to the documentation of this file.
1 <?php
2 
3  /*
4  * This source code is a part of the Ultimix Project.
5  * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6  * it's own license wich could be found from the corresponding files or sources.
7  * This source code is provided "as is" without any warranties or garanties.
8  *
9  * Have a nice day!
10  *
11  * @url http://ultimix.sorceforge.net
12  *
13  * @author Alexey "gdever" Dodonov
14  */
15 
27 
38  var $SapeCommonApi = false;
39  var $SapeUtilities = false;
40  var $Security = false;
41 
56  function __construct()
57  {
58  try
59  {
60  $this->SapeCommonApi = get_package( 'sape::sape_common_api' , 'last' , __FILE__ );
61  $this->SapeUtilities = get_package( 'sape::sape_utilities' , 'last' , __FILE__ );
62  $this->Security = get_package( 'security' , 'last' , __FILE__ );
63  }
64  catch( Exception $e )
65  {
66  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
67  }
68  }
69 
88  function get_projects()
89  {
90  try
91  {
92  $Response = $this->SapeUtilities->call_method(
93  $this->SapeCommonApi->Client , 'sape.get_projects' , array() , 'Can\'t get projects'
94  );
95 
96  return( php_xmlrpc_decode( $Response->value() ) );
97  }
98  catch( Exception $e )
99  {
100  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
101  }
102  }
103 
130  function get_placements_new_prices( $ProjectId = 0 , $Days = 30 )
131  {
132  try
133  {
134  $ProjectId = $this->Security->get( $ProjectId , 'integer' );
135  $Days = $this->Security->get( $Days , 'integer' );
136 
137  $Parameters = array( new xmlrpcval( $ProjectId , 'int' ) , new xmlrpcval( $Days , 'string' ) );
138 
139  $Response = $this->SapeUtilities->call_method(
140  $this->SapeCommonApi->Client , 'sape.get_placements_new_prices' ,
141  $Parameters , 'Can\'t get placements'
142  );
143 
144  return( php_xmlrpc_decode( $Response->value() ) );
145  }
146  catch( Exception $e )
147  {
148  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
149  }
150  }
151 
170  function placements_delete( $LinkIds )
171  {
172  try
173  {
174  if( isset( $LinkIds[ 0 ] ) === false )
175  {
176  return( array() );
177  }
178 
179  $LinkIds = $this->Security->get( $LinkIds , 'integer' );
180 
181  $LinksToDelete = array();
182 
183  foreach( $LinkIds as $i => $id )
184  {
185  $LinksToDelete [] = new xmlrpcval( $id , 'string' );
186  }
187 
188  $Parameters = array( new xmlrpcval( $LinksToDelete , 'array' ) );
189 
190  $Response = $this->SapeUtilities->call_method(
191  $this->SapeCommonApi->Client , 'sape.placements_delete' , $Parameters , 'Can\'t delete links'
192  );
193 
194  return( php_xmlrpc_decode( $Response->value() ) );
195  }
196  catch( Exception $e )
197  {
198  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
199  }
200  }
201 
224  function get_urls( $ProjectId )
225  {
226  try
227  {
228  $ProjectId = $this->Security->get( $ProjectId , 'integer' );
229 
230  $Parameters = array( new xmlrpcval( $ProjectId , 'int' ) , new xmlrpcval( false , 'boolean' ) );
231 
232  $Response = $this->SapeUtilities->call_method(
233  $this->SapeCommonApi->Client , 'sape.get_urls' , $Parameters , 'Can\'t get URLs'
234  );
235 
236  return( php_xmlrpc_decode( $Response->value() ) );
237  }
238  catch( Exception $e )
239  {
240  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
241  }
242  }
243 
266  function get_url_links( $URLId )
267  {
268  try
269  {
270  $URLId = $this->Security->get( $URLId , 'integer' );
271 
272  $Parameters = array(
273  new xmlrpcval( $URLId , 'int' ) , new xmlrpcval( '' , 'string' ) ,
274  new xmlrpcval( '' , 'string' ) , new xmlrpcval( '' , 'string' ) , new xmlrpcval( 0 , 'int' )
275  );
276 
277  $Response = $this->SapeUtilities->call_method(
278  $this->SapeCommonApi->Client , 'sape.get_url_links' , $Parameters , 'Can\'t get links'
279  );
280 
281  return( php_xmlrpc_decode( $Response->value() ) );
282  }
283  catch( Exception $e )
284  {
285  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
286  }
287  }
288 
315  function url_add( $ProjectId , $URL , $Name )
316  {
317  try
318  {
319  $ProjectId = $this->Security->get( $ProjectId , 'integer' );
320 
321  $URL = $this->Security->get( $URL , 'string' );
322 
323  $Name = $this->Security->get( $Name , 'string' );
324 
325  $Parameters = array(
326  new xmlrpcval( $ProjectId , 'int' ) , new xmlrpcval( $URL , 'string' ) ,
327  new xmlrpcval( $Name , 'string' )
328  );
329 
330  $this->SapeUtilities->call_method(
331  $this->SapeCommonApi->Client , 'sape.url_add' , $Parameters , 'Can\'t add URL'
332  );
333  }
334  catch( Exception $e )
335  {
336  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
337  }
338  }
339 
362  function url_update( $URLId , $Params )
363  {
364  try
365  {
366  $URLId = $this->Security->get( $URLId , 'integer' );
367 
368  $Params = $this->Security->get( $Params , 'string' );
369 
370  $ParamsHash = array();
371 
372  foreach( $Params as $Key => $Value )
373  {
374  $ParamsHash[ $Key ] = new xmlrpcval( $Value , 'string' );
375  }
376 
377  $Parameters = array( new xmlrpcval( $URLId , 'int' ) , new xmlrpcval( $ParamsHash , 'array' ) );
378 
379  $Response = $this->SapeUtilities->call_method(
380  $this->SapeCommonApi->Client , 'sape.url_update' , $Parameters , 'Can\'t update URL'
381  );
382 
383  return( php_xmlrpc_decode( $Response->value() ) );
384  }
385  catch( Exception $e )
386  {
387  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
388  }
389  }
390 
409  function url_delete( $URLId )
410  {
411  try
412  {
413  $URLId = $this->Security->get( $URLId , 'integer' );
414 
415  $Parameters = array( new xmlrpcval( $URLId , 'int' ) );
416 
417  $this->SapeUtilities->call_method(
418  $this->SapeCommonApi->Client , 'sape.url_delete' , $Parameters , 'Can\'t delete URL'
419  );
420  }
421  catch( Exception $e )
422  {
423  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
424  }
425  }
426 
449  function get_url_anchors( $URLId )
450  {
451  try
452  {
453  $URLId = $this->Security->get( $URLId , 'integer' );
454 
455  $Parameters = array( new xmlrpcval( $URLId , 'int' ) );
456 
457  $Response = $this->SapeUtilities->call_method(
458  $this->SapeCommonApi->Client , 'sape.get_url_anchors' , $Parameters , 'Can\'t get url anchors'
459  );
460 
461  return( php_xmlrpc_decode( $Response->value() ) );
462  }
463  catch( Exception $e )
464  {
465  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
466  }
467  }
468 
491  function url_anchors_delete( $URLId , $AnchorIds )
492  {
493  try
494  {
495  $URLId = $this->Security->get( $URLId , 'integer' );
496 
497  $AnchorIds = $this->Security->get( $URLId , 'AnchorIds' );
498 
499  $Anchors = array();
500 
501  foreach( $AnchorIds as $i => $Anchor )
502  {
503  $Anchors [] = new xmlrpcval( $Anchor , 'int' );
504  }
505 
506  $Parameters = array( new xmlrpcval( $URLId , 'int' ) , new xmlrpcval( $Anchors , 'array' ) );
507 
508  $this->SapeUtilities->call_method(
509  $this->SapeCommonApi->Client , 'sape.url_anchors_delete' , $Parameters , 'Can\'t delete anchors'
510  );
511  }
512  catch( Exception $e )
513  {
514  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
515  }
516  }
517 
544  function url_set_autoseo( $URLId , $Auto = true , $RequireConfirm = false )
545  {
546  try
547  {
548  $URLId = $this->Security->get( $URLId , 'integer' );
549 
550  $Auto = $Auto ? true : false;
551 
552  $RequireConfirm = $RequireConfirm ? true : false;
553 
554  $Parameters = array(
555  new xmlrpcval( $URLId , 'int' ) , new xmlrpcval( $Auto , 'boolean' ) ,
556  new xmlrpcval( $RequireConfirm , 'boolean' )
557  );
558 
559  $Response = $this->SapeUtilities->call_method(
560  $this->SapeCommonApi->Client , 'sape.url_set_autoseo' , $Parameters , 'Can\'t set auto mode'
561  );
562 
563  return( php_xmlrpc_decode( $Response->value() ) );
564  }
565  catch( Exception $e )
566  {
567  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
568  }
569  }
570 
609  private function filter_auto_create_parameters( $FilterId , $URLId , $Quant , $Price , $DailyQuota )
610  {
611  try
612  {
613  $FilterId = $this->Security->get( $FilterId , 'integer' );
614  $URLId = $this->Security->get( $URLId , 'integer' );
615  $Quant = $this->Security->get( $Quant , 'integer' );
616  $Price = $this->Security->get( $Price , 'float' );
617  $DailyQuota = $this->Security->get( $DailyQuota , 'integer' );
618  $DailyQuota = $DailyQuota == 0 ? ( 255 <= $Quant ? 255 : $Quant ) : $DailyQuota;
619 
620  $Parameters = array(
621  new xmlrpcval( $FilterId , 'int' ) , new xmlrpcval( $URLId , 'int' ) ,
622  new xmlrpcval( $Quant , 'int' ) , new xmlrpcval( $Price , 'int' ) ,
623  new xmlrpcval( $DailyQuota , 'int' )
624  );
625  }
626  catch( Exception $e )
627  {
628  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
629  }
630  }
631 
666  function filter_auto_create( $FilterId , $URLId , $Quant , $Price , $DailyQuota = 0 )
667  {
668  try
669  {
670  $Parameters = $this->filter_auto_create_parameters(
671  $FilterId , $URLId , $Quant , $Price , $DailyQuota
672  );
673 
674  $this->SapeUtilities->call_method(
675  $this->SapeCommonApi->Client , 'sape.filter_auto_create' , $Parameters , 'Can\'t create auto filter'
676  );
677  }
678  catch( Exception $e )
679  {
680  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
681  }
682  }
683 
718  private function filter_auto_update_parameters( $FilterAutoId , $Quant , $Price , $DailyQuota )
719  {
720  try
721  {
722  $FilterAutoId = $this->Security->get( $FilterAutoId , 'integer' );
723  $Quant = $this->Security->get( $Quant , 'integer' );
724  $Price = $this->Security->get( $Price , 'float' );
725  $DailyQuota = $this->Security->get( $DailyQuota , 'integer' );
726  $DailyQuota = $DailyQuota == 0 ? ( 255 <= $Quant ? 255 : $Quant ) : $DailyQuota;
727 
728  $Parameters = array(
729  new xmlrpcval( $FilterAutoId , 'int' ) , new xmlrpcval( $Quant , 'int' ) ,
730  new xmlrpcval( $Price , 'int' ) , new xmlrpcval( $DailyQuota , 'int' )
731  );
732 
733  return( $Parameters );
734  }
735  catch( Exception $e )
736  {
737  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
738  }
739  }
740 
771  function filter_auto_update( $FilterAutoId , $Quant , $Price , $DailyQuota = 0 )
772  {
773  try
774  {
775  $Parameters = $this->filter_auto_update_parameters( $FilterAutoId , $Quant , $Price , $DailyQuota );
776 
777  $this->SapeUtilities->call_method(
778  $this->SapeCommonApi->Client , 'sape.filter_auto_update' , $Parameters , 'Can\'t update auto filter'
779  );
780  }
781  catch( Exception $e )
782  {
783  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
784  }
785  }
786 
805  function filter_auto_delete( $FilterAutoId , $Quant , $Price , $DailyQuota = 0 )
806  {
807  try
808  {
809  $FilterAutoId = $this->Security->get( $FilterAutoId , 'integer' );
810 
811  $Parameters = array( new xmlrpcval( $FilterAutoId , 'int' ) );
812 
813  $this->SapeUtilities->call_method(
814  $this->SapeCommonApi->Client , 'sape.filter_auto_delete' , $Parameters , 'Can\'t delete auto filter'
815  );
816  }
817  catch( Exception $e )
818  {
819  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
820  }
821  }
822 
841  function get_filters_auto( $URLId )
842  {
843  try
844  {
845  $URLId = $this->Security->get( $URLId , 'integer' );
846 
847  $Parameters = array( new xmlrpcval( $URLId , 'int' ) , new xmlrpcval( true , 'boolean' ) );
848 
849  $Response = $this->SapeUtilities->call_method(
850  $this->SapeCommonApi->Client , 'sape.get_filters_auto' , $Parameters , 'Can\'t get auto filters'
851  );
852 
853  return( php_xmlrpc_decode( $Response->value() ) );
854  }
855  catch( Exception $e )
856  {
857  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
858  }
859  }
860  }
861 
862 ?>